commit 0b31ff9135aa840af701914c6b3fd62f2e6c082f Author: Accusys Date: Fri May 22 17:19:10 2026 +0800 ollama source for Momentry Core verification diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..02d796f --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +.vscode +ollama +app +macapp +dist +build +.env +.cache +test_data +.git + diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..10c2144 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,28 @@ +llama/**/*.cpp linguist-vendored +llama/**/*.hpp linguist-vendored +llama/**/*.h linguist-vendored +llama/**/*.c linguist-vendored +llama/**/*.cu linguist-vendored +llama/**/*.cuh linguist-vendored +llama/**/*.m linguist-vendored +llama/**/*.metal linguist-vendored + +ml/backend/**/*.c linguist-vendored +ml/backend/**/*.h linguist-vendored +ml/backend/**/*.cpp linguist-vendored +ml/backend/**/*.hpp linguist-vendored +ml/backend/**/*.cu linguist-vendored +ml/backend/**/*.cuh linguist-vendored +ml/backend/**/*.m linguist-vendored +ml/backend/**/*.metal linguist-vendored +ml/backend/**/*.comp linguist-vendored +ml/backend/**/*.glsl linguist-vendored +ml/backend/**/CMakeLists.txt linguist-vendored + +app/webview linguist-vendored + +llama/build-info.cpp linguist-generated +ml/backend/ggml/ggml/src/ggml-metal/ggml-metal-embed.s linguist-generated + +* text=auto +*.go text eol=lf diff --git a/.github/ISSUE_TEMPLATE/10_bug_report.yml b/.github/ISSUE_TEMPLATE/10_bug_report.yml new file mode 100644 index 0000000..2fa85ed --- /dev/null +++ b/.github/ISSUE_TEMPLATE/10_bug_report.yml @@ -0,0 +1,68 @@ +name: Bug report +labels: [bug] +description: Something isn't working right. +body: + - type: textarea + id: description + attributes: + label: What is the issue? + description: What happened? What did you expect to happen? + validations: + required: true + - type: textarea + id: logs + attributes: + label: Relevant log output + description: Please copy and paste any relevant log output. See [Troubleshooting Guide](https://github.com/ollama/ollama/blob/main/docs/troubleshooting.mdx#how-to-troubleshoot-issues) for details. + render: shell + validations: + required: false + - type: dropdown + id: os + attributes: + label: OS + description: Which operating system are you using? + multiple: true + options: + - Linux + - macOS + - Windows + - Docker + - WSL2 + validations: + required: false + - type: dropdown + id: gpu + attributes: + label: GPU + description: Which GPU are you using? + multiple: true + options: + - Nvidia + - AMD + - Intel + - Apple + - Other + validations: + required: false + - type: dropdown + id: cpu + attributes: + label: CPU + description: Which CPU are you using? + multiple: true + options: + - Intel + - AMD + - Apple + - Other + validations: + required: false + - type: input + id: version + attributes: + label: Ollama version + description: What version of Ollama are you using? (`ollama --version`) + placeholder: e.g., 0.1.32 + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/20_feature_request.md b/.github/ISSUE_TEMPLATE/20_feature_request.md new file mode 100644 index 0000000..e899721 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/20_feature_request.md @@ -0,0 +1,6 @@ +--- +name: Feature request +about: Request a new feature +labels: feature request +--- + diff --git a/.github/ISSUE_TEMPLATE/30_model_request.md b/.github/ISSUE_TEMPLATE/30_model_request.md new file mode 100644 index 0000000..c705a5f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/30_model_request.md @@ -0,0 +1,5 @@ +--- +name: Model request +about: Request support for a new model to be added to Ollama +labels: model request +--- \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..70d9aa3 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,8 @@ +blank_issues_enabled: true +contact_links: + - name: Help + url: https://discord.com/invite/ollama + about: Please join our Discord server for help using Ollama + - name: Troubleshooting + url: https://github.com/ollama/ollama/blob/main/docs/faq.md#faq + about: See the FAQ for common issues and solutions diff --git a/.github/workflows/latest.yaml b/.github/workflows/latest.yaml new file mode 100644 index 0000000..4d47dd3 --- /dev/null +++ b/.github/workflows/latest.yaml @@ -0,0 +1,24 @@ +name: latest + +on: + release: + types: [released] + +jobs: + update-latest: + environment: release + runs-on: linux + steps: + - uses: actions/checkout@v4 + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ vars.DOCKER_USER }} + password: ${{ secrets.DOCKER_ACCESS_TOKEN }} + - name: Tag images as latest + env: + PUSH: "1" + shell: bash + run: | + export "VERSION=${GITHUB_REF_NAME#v}" + ./scripts/tag_latest.sh diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..fe3658f --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,708 @@ +name: release + +on: + push: + tags: + - 'v*' + +env: + CGO_CFLAGS: '-O3' + CGO_CXXFLAGS: '-O3' + +jobs: + setup-environment: + runs-on: ubuntu-latest + environment: release + outputs: + GOFLAGS: ${{ steps.goflags.outputs.GOFLAGS }} + VERSION: ${{ steps.goflags.outputs.VERSION }} + vendorsha: ${{ steps.changes.outputs.vendorsha }} + steps: + - uses: actions/checkout@v4 + - name: Set environment + id: goflags + run: | + echo GOFLAGS="'-ldflags=-w -s \"-X=github.com/ollama/ollama/version.Version=${GITHUB_REF_NAME#v}\" \"-X=github.com/ollama/ollama/server.mode=release\"'" | tee -a $GITHUB_OUTPUT + echo VERSION="${GITHUB_REF_NAME#v}" | tee -a $GITHUB_OUTPUT + echo vendorsha=$(make -f Makefile.sync print-base) | tee -a $GITHUB_OUTPUT + + darwin-build: + runs-on: macos-26-xlarge + environment: release + needs: setup-environment + env: + GOFLAGS: ${{ needs.setup-environment.outputs.GOFLAGS }} + VERSION: ${{ needs.setup-environment.outputs.VERSION }} + APPLE_IDENTITY: ${{ secrets.APPLE_IDENTITY }} + APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }} + APPLE_TEAM_ID: ${{ vars.APPLE_TEAM_ID }} + APPLE_ID: ${{ vars.APPLE_ID }} + MACOS_SIGNING_KEY: ${{ secrets.MACOS_SIGNING_KEY }} + MACOS_SIGNING_KEY_PASSWORD: ${{ secrets.MACOS_SIGNING_KEY_PASSWORD }} + CGO_CFLAGS: '-mmacosx-version-min=14.0 -O3' + CGO_CXXFLAGS: '-mmacosx-version-min=14.0 -O3' + CGO_LDFLAGS: '-mmacosx-version-min=14.0 -O3' + steps: + - uses: actions/checkout@v4 + - run: | + echo $MACOS_SIGNING_KEY | base64 --decode > certificate.p12 + security create-keychain -p password build.keychain + security default-keychain -s build.keychain + security unlock-keychain -p password build.keychain + security import certificate.p12 -k build.keychain -P $MACOS_SIGNING_KEY_PASSWORD -T /usr/bin/codesign + security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k password build.keychain + security set-keychain-settings -lut 3600 build.keychain + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache-dependency-path: | + go.sum + Makefile.sync + - run: | + ./scripts/build_darwin.sh + - name: Log build results + run: | + ls -l dist/ + - uses: actions/upload-artifact@v4 + with: + name: bundles-darwin + path: | + dist/*.tgz + dist/*.tar.zst + dist/*.zip + dist/*.dmg + + windows-depends: + strategy: + matrix: + os: [windows] + arch: [amd64] + preset: ['CPU'] + include: + - os: windows + arch: amd64 + preset: 'CUDA 12' + install: https://developer.download.nvidia.com/compute/cuda/12.8.0/local_installers/cuda_12.8.0_571.96_windows.exe + cuda-components: + - '"cudart"' + - '"nvcc"' + - '"cublas"' + - '"cublas_dev"' + cuda-version: '12.8' + flags: '' + - os: windows + arch: amd64 + preset: 'CUDA 13' + install: https://developer.download.nvidia.com/compute/cuda/13.0.0/local_installers/cuda_13.0.0_windows.exe + cuda-components: + - '"cudart"' + - '"nvcc"' + - '"cublas"' + - '"cublas_dev"' + - '"crt"' + - '"nvvm"' + - '"nvptxcompiler"' + cuda-version: '13.0' + flags: '' + - os: windows + arch: amd64 + preset: 'ROCm 6' + install: https://download.amd.com/developer/eula/rocm-hub/AMD-Software-PRO-Edition-24.Q4-WinSvr2022-For-HIP.exe + rocm-version: '6.2' + flags: '-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_FLAGS="-parallel-jobs=4 -Wno-ignored-attributes -Wno-deprecated-pragma" -DCMAKE_CXX_FLAGS="-parallel-jobs=4 -Wno-ignored-attributes -Wno-deprecated-pragma"' + runner_dir: 'rocm' + - os: windows + arch: amd64 + preset: Vulkan + install: https://sdk.lunarg.com/sdk/download/1.4.321.1/windows/vulkansdk-windows-X64-1.4.321.1.exe + flags: '' + runner_dir: 'vulkan' + - os: windows + arch: amd64 + preset: 'MLX CUDA 13' + install: https://developer.download.nvidia.com/compute/cuda/13.0.0/local_installers/cuda_13.0.0_windows.exe + cudnn-install: https://developer.download.nvidia.com/compute/cudnn/redist/cudnn/windows-x86_64/cudnn-windows-x86_64-9.18.1.3_cuda13-archive.zip + cuda-components: + - '"cudart"' + - '"nvcc"' + - '"cublas"' + - '"cublas_dev"' + - '"cufft"' + - '"cufft_dev"' + - '"nvrtc"' + - '"nvrtc_dev"' + - '"crt"' + - '"nvvm"' + - '"nvptxcompiler"' + cuda-version: '13.0' + flags: '' + runs-on: ${{ matrix.arch == 'arm64' && format('{0}-{1}', matrix.os, matrix.arch) || matrix.os }} + environment: release + env: + GOFLAGS: ${{ needs.setup-environment.outputs.GOFLAGS }} + steps: + # Increase pagefile to handle momentary spikes in RAM from NVCC compiles + - if: startsWith(matrix.preset, 'MLX ') + name: Increase pagefile to 200 GB + uses: al-cheb/configure-pagefile-action@v1.5 + with: + minimum-size: 16GB + maximum-size: 200GB + disk-root: "D:" + - name: Install system dependencies + run: | + choco install -y --no-progress ccache ninja + if (Get-Command ccache -ErrorAction SilentlyContinue) { + ccache -o cache_dir=${{ github.workspace }}\.ccache + } + - if: startsWith(matrix.preset, 'CUDA ') || startsWith(matrix.preset, 'ROCm ') || startsWith(matrix.preset, 'Vulkan') || startsWith(matrix.preset, 'MLX ') + id: cache-install + uses: actions/cache/restore@v4 + with: + path: | + C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA + C:\Program Files\AMD\ROCm + C:\VulkanSDK + C:\Program Files\NVIDIA\CUDNN + key: ${{ matrix.install }}-${{ matrix.cudnn-install }} + - if: startsWith(matrix.preset, 'CUDA ') || startsWith(matrix.preset, 'MLX ') + name: Install CUDA ${{ matrix.cuda-version }} + run: | + $ErrorActionPreference = "Stop" + if ("${{ steps.cache-install.outputs.cache-hit }}" -ne 'true') { + Invoke-WebRequest -Uri "${{ matrix.install }}" -OutFile "install.exe" + $subpackages = @(${{ join(matrix.cuda-components, ', ') }}) | Foreach-Object {"${_}_${{ matrix.cuda-version }}"} + Start-Process -FilePath .\install.exe -ArgumentList (@("-s") + $subpackages) -NoNewWindow -Wait + } + + $cudaPath = (Resolve-Path "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\*").path + echo "$cudaPath\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + - if: startsWith(matrix.preset, 'ROCm') + name: Install ROCm ${{ matrix.rocm-version }} + run: | + $ErrorActionPreference = "Stop" + if ("${{ steps.cache-install.outputs.cache-hit }}" -ne 'true') { + Invoke-WebRequest -Uri "${{ matrix.install }}" -OutFile "install.exe" + Start-Process -FilePath .\install.exe -ArgumentList '-install' -NoNewWindow -Wait + } + + $hipPath = (Resolve-Path "C:\Program Files\AMD\ROCm\*").path + echo "$hipPath\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + echo "CC=$hipPath\bin\clang.exe" | Out-File -FilePath $env:GITHUB_ENV -Append + echo "CXX=$hipPath\bin\clang++.exe" | Out-File -FilePath $env:GITHUB_ENV -Append + echo "HIPCXX=$hipPath\bin\clang++.exe" | Out-File -FilePath $env:GITHUB_ENV -Append + echo "HIP_PLATFORM=amd" | Out-File -FilePath $env:GITHUB_ENV -Append + echo "CMAKE_PREFIX_PATH=$hipPath" | Out-File -FilePath $env:GITHUB_ENV -Append + - if: matrix.preset == 'Vulkan' + name: Install Vulkan ${{ matrix.rocm-version }} + run: | + $ErrorActionPreference = "Stop" + if ("${{ steps.cache-install.outputs.cache-hit }}" -ne 'true') { + Invoke-WebRequest -Uri "${{ matrix.install }}" -OutFile "install.exe" + Start-Process -FilePath .\install.exe -ArgumentList "-c","--am","--al","in" -NoNewWindow -Wait + } + + $vulkanPath = (Resolve-Path "C:\VulkanSDK\*").path + echo "$vulkanPath\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + echo "VULKAN_SDK=$vulkanPath" >> $env:GITHUB_ENV + - if: matrix.preset == 'CPU' + run: | + echo "CC=clang.exe" | Out-File -FilePath $env:GITHUB_ENV -Append + echo "CXX=clang++.exe" | Out-File -FilePath $env:GITHUB_ENV -Append + - if: startsWith(matrix.preset, 'MLX ') + name: Install cuDNN for MLX + run: | + $ErrorActionPreference = "Stop" + $cudnnRoot = "C:\Program Files\NVIDIA\CUDNN" + if ("${{ steps.cache-install.outputs.cache-hit }}" -ne 'true') { + Invoke-WebRequest -Uri "${{ matrix.cudnn-install }}" -OutFile "cudnn.zip" + Expand-Archive -Path cudnn.zip -DestinationPath cudnn-extracted + $cudnnDir = (Get-ChildItem -Path cudnn-extracted -Directory)[0].FullName + New-Item -ItemType Directory -Force -Path $cudnnRoot + Copy-Item -Path "$cudnnDir\*" -Destination "$cudnnRoot\" -Recurse + } + + echo "CUDNN_ROOT_DIR=$cudnnRoot" | Out-File -FilePath $env:GITHUB_ENV -Append + echo "CUDNN_INCLUDE_PATH=$cudnnRoot\include" | Out-File -FilePath $env:GITHUB_ENV -Append + echo "CUDNN_LIBRARY_PATH=$cudnnRoot\lib\x64" | Out-File -FilePath $env:GITHUB_ENV -Append + echo "$cudnnRoot\bin\x64" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + - if: ${{ !cancelled() && steps.cache-install.outputs.cache-hit != 'true' }} + uses: actions/cache/save@v4 + with: + path: | + C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA + C:\Program Files\AMD\ROCm + C:\VulkanSDK + C:\Program Files\NVIDIA\CUDNN + key: ${{ matrix.install }}-${{ matrix.cudnn-install }} + - uses: actions/checkout@v4 + - uses: actions/cache@v4 + with: + path: ${{ github.workspace }}\.ccache + key: ccache-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.preset }}-${{ needs.setup-environment.outputs.vendorsha }} + - name: Build target "${{ matrix.preset }}" + run: | + Import-Module 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\Microsoft.VisualStudio.DevShell.dll' + Enter-VsDevShell -VsInstallPath 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise' -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -no_logo' + cmake --preset "${{ matrix.preset }}" ${{ matrix.flags }} --install-prefix "$((pwd).Path)\dist\${{ matrix.os }}-${{ matrix.arch }}" + cmake --build --preset "${{ matrix.preset }}" -- -l $([Environment]::ProcessorCount) + cmake --install build --component "${{ startsWith(matrix.preset, 'MLX ') && 'MLX' || startsWith(matrix.preset, 'CUDA ') && 'CUDA' || startsWith(matrix.preset, 'ROCm ') && 'HIP' || startsWith(matrix.preset, 'Vulkan') && 'Vulkan' || 'CPU' }}" --strip + if ('${{ matrix.preset }}'.StartsWith('MLX ')) { cmake --install build --component MLX_VENDOR } + Remove-Item -Path dist\lib\ollama\rocm\rocblas\library\*gfx906* -ErrorAction SilentlyContinue + env: + CMAKE_GENERATOR: Ninja + - name: Log build results + run: | + gci -path .\dist -Recurse -File | ForEach-Object { get-filehash -path $_.FullName -Algorithm SHA256 } | format-list + - uses: actions/upload-artifact@v4 + with: + name: depends-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.preset }} + path: dist\* + + windows-build: + strategy: + matrix: + os: [windows] + arch: [amd64, arm64] + include: + - os: windows + arch: amd64 + llvmarch: x86_64 + - os: windows + arch: arm64 + llvmarch: aarch64 + runs-on: ${{ matrix.arch == 'arm64' && format('{0}-{1}', matrix.os, matrix.arch) || matrix.os }} + environment: release + needs: [setup-environment] + env: + GOFLAGS: ${{ needs.setup-environment.outputs.GOFLAGS }} + VERSION: ${{ needs.setup-environment.outputs.VERSION }} + steps: + - name: Install ARM64 system dependencies + if: matrix.arch == 'arm64' + run: | + $ErrorActionPreference = "Stop" + Set-ExecutionPolicy Bypass -Scope Process -Force + [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072 + iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) + echo "C:\ProgramData\chocolatey\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + + Invoke-WebRequest -Uri https://aka.ms/vs/17/release/vc_redist.arm64.exe -OutFile "${{ runner.temp }}\vc_redist.arm64.exe" + Start-Process -FilePath "${{ runner.temp }}\vc_redist.arm64.exe" -ArgumentList @("/install", "/quiet", "/norestart") -NoNewWindow -Wait + + choco install -y --no-progress git gzip + echo "C:\Program Files\Git\cmd" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + - name: Install clang and gcc-compat + run: | + $ErrorActionPreference = "Stop" + Set-ExecutionPolicy Bypass -Scope Process -Force + Invoke-WebRequest -Uri "https://github.com/mstorsjo/llvm-mingw/releases/download/20240619/llvm-mingw-20240619-ucrt-${{ matrix.llvmarch }}.zip" -OutFile "${{ runner.temp }}\llvm-mingw-ucrt.zip" + Expand-Archive -Path ${{ runner.temp }}\llvm-mingw-ucrt.zip -DestinationPath "C:\Program Files\" + $installPath=(Resolve-Path -Path "C:\Program Files\llvm-mingw-*-ucrt*").path + echo "$installPath\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache-dependency-path: | + go.sum + Makefile.sync + - name: Verify gcc is actually clang + run: | + $ErrorActionPreference='Continue' + $version=& gcc -v 2>&1 + $version=$version -join "`n" + echo "gcc is $version" + if ($version -notmatch 'clang') { + echo "ERROR: GCC must be clang for proper utf16 handling" + exit 1 + } + $ErrorActionPreference='Stop' + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "20" + - run: | + ./scripts/build_windows ollama app + - name: Log build results + run: | + gci -path .\dist -Recurse -File | ForEach-Object { get-filehash -path $_.FullName -Algorithm SHA256 } | format-list + - uses: actions/upload-artifact@v4 + with: + name: build-${{ matrix.os }}-${{ matrix.arch }} + path: | + dist\* + + windows-app: + runs-on: windows + environment: release + needs: [windows-build, windows-depends] + env: + GOFLAGS: ${{ needs.setup-environment.outputs.GOFLAGS }} + VERSION: ${{ needs.setup-environment.outputs.VERSION }} + KEY_CONTAINER: ${{ vars.KEY_CONTAINER }} + steps: + - uses: actions/checkout@v4 + - uses: google-github-actions/auth@v2 + with: + project_id: ollama + credentials_json: ${{ secrets.GOOGLE_SIGNING_CREDENTIALS }} + - run: | + $ErrorActionPreference = "Stop" + Invoke-WebRequest -Uri "https://go.microsoft.com/fwlink/p/?LinkId=323507" -OutFile "${{ runner.temp }}\sdksetup.exe" + Start-Process "${{ runner.temp }}\sdksetup.exe" -ArgumentList @("/q") -NoNewWindow -Wait + + Invoke-WebRequest -Uri "https://github.com/GoogleCloudPlatform/kms-integrations/releases/download/cng-v1.0/kmscng-1.0-windows-amd64.zip" -OutFile "${{ runner.temp }}\plugin.zip" + Expand-Archive -Path "${{ runner.temp }}\plugin.zip" -DestinationPath "${{ runner.temp }}\plugin\" + & "${{ runner.temp }}\plugin\*\kmscng.msi" /quiet + + echo "${{ vars.OLLAMA_CERT }}" >ollama_inc.crt + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache-dependency-path: | + go.sum + Makefile.sync + - uses: actions/download-artifact@v4 + with: + pattern: depends-windows* + path: dist + merge-multiple: true + - uses: actions/download-artifact@v4 + with: + pattern: build-windows* + path: dist + merge-multiple: true + - name: Log dist contents after download + run: | + gci -path .\dist -recurse + - run: | + ./scripts/build_windows.ps1 deps sign installer zip + - name: Log contents after build + run: | + gci -path .\dist -Recurse -File | ForEach-Object { get-filehash -path $_.FullName -Algorithm SHA256 } | format-list + - uses: actions/upload-artifact@v4 + with: + name: bundles-windows + path: | + dist/*.zip + dist/*.ps1 + dist/OllamaSetup.exe + + # Pre-build each Dockerfile stage on its own runner in parallel and push the + # resulting layers to a per-stage registry cache. The downstream + # docker-build-push job then assembles cache-hit-only. + linux-depends: + strategy: + matrix: + include: + - arch: amd64 + target: cpu + - arch: amd64 + target: cuda-12 + - arch: amd64 + target: cuda-13 + - arch: amd64 + target: mlx + - arch: amd64 + target: rocm-7 + - arch: amd64 + target: vulkan + - arch: arm64 + target: cpu + - arch: arm64 + target: cuda-12 + - arch: arm64 + target: cuda-13 + - arch: arm64 + target: jetpack-5 + - arch: arm64 + target: jetpack-6 + runs-on: ${{ matrix.arch == 'arm64' && 'linux-arm64' || 'linux' }} + environment: release + needs: setup-environment + env: + GOFLAGS: ${{ needs.setup-environment.outputs.GOFLAGS }} + steps: + - uses: actions/checkout@v4 + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 + with: + username: ${{ vars.DOCKER_USER }} + password: ${{ secrets.DOCKER_ACCESS_TOKEN }} + # Increase swap to handle momentary spikes in RAM from NVCC compiles + - if: matrix.target == 'mlx' + name: Increase Linux swap to 200 GB + shell: bash + run: | + set -e + SWAP_PATH=/swapfile-mlx + SWAP_SIZE_GB=200 + if [ -f "$SWAP_PATH" ]; then + sudo swapoff "$SWAP_PATH" 2>/dev/null || true + sudo rm -f "$SWAP_PATH" + fi + if ! sudo fallocate -l ${SWAP_SIZE_GB}G "$SWAP_PATH" 2>/dev/null; then + echo "fallocate unsupported, falling back to dd" + sudo dd if=/dev/zero of="$SWAP_PATH" bs=1M count=$((SWAP_SIZE_GB * 1024)) + fi + sudo chmod 600 "$SWAP_PATH" + sudo mkswap "$SWAP_PATH" + sudo swapon "$SWAP_PATH" + swapon --show + free -h + - uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/${{ matrix.arch }} + target: ${{ matrix.target }} + provenance: false + sbom: false + build-args: | + CGO_CFLAGS=${{ env.CGO_CFLAGS }} + CGO_CXXFLAGS=${{ env.CGO_CXXFLAGS }} + GOFLAGS=${{ env.GOFLAGS }} + APT_MIRROR=http://azure.archive.ubuntu.com/ubuntu + OLLAMA_MLX_BUILD_JOBS=16 + OLLAMA_MLX_NVCC_THREADS=6 + cache-from: | + type=registry,ref=ollama/release:cache-${{ matrix.arch }}-${{ matrix.target }} + type=registry,ref=${{ vars.DOCKER_REPO }}:latest + cache-to: type=registry,ref=ollama/release:cache-${{ matrix.arch }}-${{ matrix.target }},mode=max + + # Build each Docker variant (OS, arch, and flavor) separately. Using QEMU is unreliable and slower. + # Heavy stages were pre-built by linux-depends; this job is cache-hit-only for those layers + # and just assembles, runs the Go build, and pushes the final image. + docker-build-push: + strategy: + matrix: + include: + - os: linux + arch: arm64 + build-args: | + CGO_CFLAGS + CGO_CXXFLAGS + GOFLAGS + APT_MIRROR=http://azure.archive.ubuntu.com/ubuntu + OLLAMA_MLX_BUILD_JOBS=16 + OLLAMA_MLX_NVCC_THREADS=6 + cache-from: | + type=registry,ref=${{ vars.DOCKER_REPO }}:latest + type=registry,ref=ollama/release:cache-arm64-cpu + type=registry,ref=ollama/release:cache-arm64-cuda-12 + type=registry,ref=ollama/release:cache-arm64-cuda-13 + type=registry,ref=ollama/release:cache-arm64-jetpack-5 + type=registry,ref=ollama/release:cache-arm64-jetpack-6 + - os: linux + arch: amd64 + build-args: | + CGO_CFLAGS + CGO_CXXFLAGS + GOFLAGS + APT_MIRROR=http://azure.archive.ubuntu.com/ubuntu + OLLAMA_MLX_BUILD_JOBS=16 + OLLAMA_MLX_NVCC_THREADS=6 + cache-from: | + type=registry,ref=${{ vars.DOCKER_REPO }}:latest + type=registry,ref=ollama/release:cache-amd64-cpu + type=registry,ref=ollama/release:cache-amd64-cuda-12 + type=registry,ref=ollama/release:cache-amd64-cuda-13 + type=registry,ref=ollama/release:cache-amd64-mlx + type=registry,ref=ollama/release:cache-amd64-vulkan + - os: linux + arch: amd64 + suffix: '-rocm' + build-args: | + CGO_CFLAGS + CGO_CXXFLAGS + GOFLAGS + FLAVOR=rocm + APT_MIRROR=http://azure.archive.ubuntu.com/ubuntu + OLLAMA_MLX_BUILD_JOBS=16 + OLLAMA_MLX_NVCC_THREADS=6 + cache-from: | + type=registry,ref=${{ vars.DOCKER_REPO }}:latest + type=registry,ref=ollama/release:cache-amd64-cpu + type=registry,ref=ollama/release:cache-amd64-rocm-7 + runs-on: ${{ matrix.arch == 'arm64' && format('{0}-{1}', matrix.os, matrix.arch) || matrix.os }} + environment: release + needs: [setup-environment, linux-depends] + env: + GOFLAGS: ${{ needs.setup-environment.outputs.GOFLAGS }} + steps: + - uses: actions/checkout@v4 + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 + with: + username: ${{ vars.DOCKER_USER }} + password: ${{ secrets.DOCKER_ACCESS_TOKEN }} + - id: build-push + uses: docker/build-push-action@v6 + with: + context: . + platforms: ${{ matrix.os }}/${{ matrix.arch }} + provenance: false + sbom: false + build-args: ${{ matrix.build-args }} + outputs: type=image,name=${{ vars.DOCKER_REPO }},push-by-digest=true,name-canonical=true,push=true + cache-from: ${{ matrix.cache-from }} + cache-to: type=inline + - run: | + mkdir -p ${{ matrix.os }}-${{ matrix.arch }} + echo "${{ steps.build-push.outputs.digest }}" >${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.suffix }}.txt + working-directory: ${{ runner.temp }} + - uses: actions/upload-artifact@v4 + with: + name: digest-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.suffix }} + path: | + ${{ runner.temp }}/${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.suffix }}.txt + # Re-run buildx with --target archive against buildkit's local cache to + # extract the release directory layout. All upstream stages were just + # built above, so this is a cache-hit-only pass that just writes files. + - uses: docker/build-push-action@v6 + with: + context: . + platforms: ${{ matrix.os }}/${{ matrix.arch }} + target: archive + provenance: false + sbom: false + build-args: ${{ matrix.build-args }} + outputs: type=local,dest=dist/${{ matrix.os }}-${{ matrix.arch }} + cache-from: ${{ matrix.cache-from }} + - name: Deduplicate CUDA libraries + run: | + ./scripts/deduplicate_cuda_libs.sh dist/${{ matrix.os }}-${{ matrix.arch }} + - run: | + for COMPONENT in bin/* lib/ollama/*; do + case "$COMPONENT" in + bin/ollama*) echo $COMPONENT >>ollama-${{ matrix.os }}-${{ matrix.arch }}.tar.in ;; + lib/ollama/*.so*) echo $COMPONENT >>ollama-${{ matrix.os }}-${{ matrix.arch }}.tar.in ;; + lib/ollama/cuda_v*) echo $COMPONENT >>ollama-${{ matrix.os }}-${{ matrix.arch }}.tar.in ;; + lib/ollama/vulkan*) echo $COMPONENT >>ollama-${{ matrix.os }}-${{ matrix.arch }}.tar.in ;; + lib/ollama/mlx*) echo $COMPONENT >>ollama-${{ matrix.os }}-${{ matrix.arch }}-mlx.tar.in ;; + lib/ollama/include*) echo $COMPONENT >>ollama-${{ matrix.os }}-${{ matrix.arch }}.tar.in ;; + lib/ollama/cuda_jetpack5) echo $COMPONENT >>ollama-${{ matrix.os }}-${{ matrix.arch }}-jetpack5.tar.in ;; + lib/ollama/cuda_jetpack6) echo $COMPONENT >>ollama-${{ matrix.os }}-${{ matrix.arch }}-jetpack6.tar.in ;; + lib/ollama/rocm) echo $COMPONENT >>ollama-${{ matrix.os }}-${{ matrix.arch }}-rocm.tar.in ;; + esac + done + working-directory: dist/${{ matrix.os }}-${{ matrix.arch }} + # rocm builds cpu + rocm libs for the container image, which + # creates a CPU-only amd64 tarball that would collide with the full + # bundle when the release job merges artifacts. + - if: matrix.suffix == '-rocm' + run: rm -f dist/${{ matrix.os }}-${{ matrix.arch }}/ollama-${{ matrix.os }}-${{ matrix.arch }}.tar.in + - run: | + echo "Manifests" + for ARCHIVE in dist/${{ matrix.os }}-${{ matrix.arch }}/*.tar.in ; do + echo $ARCHIVE + cat $ARCHIVE + done + - run: | + for ARCHIVE in dist/${{ matrix.os }}-${{ matrix.arch }}/*.tar.in; do + tar c -C dist/${{ matrix.os }}-${{ matrix.arch }} -T $ARCHIVE --owner 0 --group 0 | zstd -19 -T0 >$(basename ${ARCHIVE//.*/}.tar.zst) & + done + wait + - uses: actions/upload-artifact@v4 + with: + name: bundles-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.suffix }} + path: | + *.tar.zst + + # Merge Docker images for the same flavor into a single multi-arch manifest + docker-merge-push: + strategy: + matrix: + suffix: ['', '-rocm'] + runs-on: linux + environment: release + needs: [docker-build-push] + steps: + - uses: docker/login-action@v3 + with: + username: ${{ vars.DOCKER_USER }} + password: ${{ secrets.DOCKER_ACCESS_TOKEN }} + - id: metadata + uses: docker/metadata-action@v4 + with: + flavor: | + latest=false + suffix=${{ matrix.suffix }} + images: | + ${{ vars.DOCKER_REPO }} + tags: | + type=ref,enable=true,priority=600,prefix=pr-,event=pr + type=semver,pattern={{version}} + - uses: actions/download-artifact@v4 + with: + pattern: digest-* + path: ${{ runner.temp }} + merge-multiple: true + - run: | + docker buildx imagetools create $(echo '${{ steps.metadata.outputs.json }}' | jq -cr '.tags | map("-t", .) | join(" ")') $(cat *-${{ matrix.suffix }}.txt | xargs printf '${{ vars.DOCKER_REPO }}@%s ') + docker buildx imagetools inspect ${{ vars.DOCKER_REPO }}:${{ steps.metadata.outputs.version }} + working-directory: ${{ runner.temp }} + + # Final release process + release: + runs-on: ubuntu-latest + environment: release + needs: [darwin-build, windows-app, docker-build-push] + permissions: + contents: write + env: + GH_TOKEN: ${{ github.token }} + steps: + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + with: + pattern: bundles-* + path: dist + merge-multiple: true + - name: Log dist contents + run: | + ls -l dist/ + - name: Copy install scripts to dist + run: | + cp scripts/install.sh dist/install.sh + - name: Generate checksum file + run: find . -type f -not -name 'sha256sum.txt' | xargs sha256sum | tee sha256sum.txt + working-directory: dist + - name: Create or update Release for tag + run: | + RELEASE_VERSION="$(echo ${GITHUB_REF_NAME} | cut -f1 -d-)" + echo "Looking for existing release for ${RELEASE_VERSION}" + OLD_TAG=$(gh release ls --json name,tagName | jq -r ".[] | select(.name == \"${RELEASE_VERSION}\") | .tagName") + if [ -n "$OLD_TAG" ]; then + echo "Updating release ${RELEASE_VERSION} to point to new tag ${GITHUB_REF_NAME}" + gh release edit ${OLD_TAG} --tag ${GITHUB_REF_NAME} + else + echo "Creating new release ${RELEASE_VERSION} pointing to tag ${GITHUB_REF_NAME}" + gh release create ${GITHUB_REF_NAME} \ + --title ${RELEASE_VERSION} \ + --draft \ + --generate-notes \ + --prerelease + fi + - name: Upload release artifacts + run: | + pids=() + for payload in dist/*.txt dist/*.zip dist/*.tgz dist/*.tar.zst dist/*.exe dist/*.dmg dist/*.ps1 dist/*.sh ; do + echo "Uploading $payload" + gh release upload ${GITHUB_REF_NAME} $payload --clobber & + pids+=($!) + sleep 1 + done + echo "Waiting for uploads to complete" + failed=0 + for pid in "${pids[@]}"; do + if ! wait $pid; then + echo "::error::Upload failed (pid $pid)" + failed=1 + fi + done + if [ $failed -ne 0 ]; then + echo "One or more uploads failed" + exit 1 + fi + echo "done" diff --git a/.github/workflows/test-install.yaml b/.github/workflows/test-install.yaml new file mode 100644 index 0000000..cecc1c3 --- /dev/null +++ b/.github/workflows/test-install.yaml @@ -0,0 +1,22 @@ +name: test-install + +on: + pull_request: + paths: + - 'scripts/install.sh' + - '.github/workflows/test-install.yaml' + +jobs: + test: + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - name: Run install script + run: sh ./scripts/install.sh + env: + OLLAMA_NO_START: 1 # do not start app + - name: Verify ollama is available + run: ollama --version diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..4ae6856 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,305 @@ +name: test + +concurrency: + # For PRs, later CI runs preempt previous ones. e.g. a force push on a PR + # cancels running CI jobs and starts all new ones. + # + # For non-PR pushes, concurrency.group needs to be unique for every distinct + # CI run we want to have happen. Use run_id, which in practice means all + # non-PR CI runs will be allowed to run without preempting each other. + group: ${{ github.workflow }}-$${{ github.pull_request.number || github.run_id }} + cancel-in-progress: true + +on: + pull_request: + paths: + - '**/*' + - '!docs/**' + - '!README.md' + +jobs: + changes: + runs-on: ubuntu-latest + outputs: + changed: ${{ steps.changes.outputs.changed }} + app_changed: ${{ steps.changes.outputs.app_changed }} + vendorsha: ${{ steps.changes.outputs.vendorsha }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - id: changes + run: | + changed() { + local BASE=${{ github.event.pull_request.base.sha }} + local HEAD=${{ github.event.pull_request.head.sha }} + local MERGE_BASE=$(git merge-base $BASE $HEAD) + git diff-tree -r --no-commit-id --name-only "$MERGE_BASE" "$HEAD" \ + | xargs python3 -c "import sys; from pathlib import Path; print(any(Path(x).match(glob) for x in sys.argv[1:] for glob in '$*'.split(' ')))" + } + + echo changed=$(changed 'llama/llama.cpp/**/*' 'ml/backend/ggml/ggml/**/*' '.github/**/*') | tee -a $GITHUB_OUTPUT + echo app_changed=$(changed 'app/**' 'app/**/*') | tee -a $GITHUB_OUTPUT + echo vendorsha=$(make -f Makefile.sync print-base) | tee -a $GITHUB_OUTPUT + + linux: + needs: [changes] + if: needs.changes.outputs.changed == 'True' + strategy: + matrix: + include: + - preset: CPU + - preset: CUDA + container: nvidia/cuda:13.0.0-devel-ubuntu22.04 + flags: '-DCMAKE_CUDA_ARCHITECTURES=87' + - preset: ROCm + container: rocm/dev-ubuntu-22.04:7.2.1 + extra-packages: rocm-libs + flags: '-DAMDGPU_TARGETS=gfx1010 -DCMAKE_PREFIX_PATH=/opt/rocm' + - preset: Vulkan + container: ubuntu:22.04 + extra-packages: > + mesa-vulkan-drivers vulkan-tools + libvulkan1 libvulkan-dev + vulkan-sdk cmake ccache g++ make + - preset: 'MLX CUDA 13' + container: nvidia/cuda:13.0.0-devel-ubuntu22.04 + extra-packages: libcudnn9-dev-cuda-13 libopenblas-dev liblapack-dev liblapacke-dev git curl + flags: '-DCMAKE_CUDA_ARCHITECTURES=87 -DMLX_CUDA_ARCHITECTURES=80-virtual -DBLAS_INCLUDE_DIRS=/usr/include/x86_64-linux-gnu -DLAPACK_INCLUDE_DIRS=/usr/include/x86_64-linux-gnu' + install-go: true + runs-on: linux + container: ${{ matrix.container }} + steps: + - uses: actions/checkout@v4 + - run: | + [ -n "${{ matrix.container }}" ] || sudo=sudo + $sudo apt-get update + # Add LunarG Vulkan SDK apt repo for Ubuntu 22.04 + if [ "${{ matrix.preset }}" = "Vulkan" ]; then + $sudo apt-get install -y --no-install-recommends wget gnupg ca-certificates software-properties-common + wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | $sudo gpg --dearmor -o /usr/share/keyrings/lunarg-archive-keyring.gpg + # Use signed-by to bind the repo to the installed keyring to avoid NO_PUBKEY + echo "deb [signed-by=/usr/share/keyrings/lunarg-archive-keyring.gpg] https://packages.lunarg.com/vulkan/1.4.313 jammy main" | $sudo tee /etc/apt/sources.list.d/lunarg-vulkan-1.4.313-jammy.list > /dev/null + $sudo apt-get update + fi + $sudo apt-get install -y cmake ccache ${{ matrix.extra-packages }} + # MLX requires CMake 3.25+, install from official releases + if [ "${{ matrix.preset }}" = "MLX CUDA 13" ]; then + curl -fsSL https://github.com/Kitware/CMake/releases/download/v3.31.2/cmake-3.31.2-linux-$(uname -m).tar.gz | $sudo tar xz -C /usr/local --strip-components 1 + fi + # Export VULKAN_SDK if provided by LunarG package (defensive) + if [ -d "/usr/lib/x86_64-linux-gnu/vulkan" ] && [ "${{ matrix.preset }}" = "Vulkan" ]; then + echo "VULKAN_SDK=/usr" >> $GITHUB_ENV + fi + env: + DEBIAN_FRONTEND: noninteractive + - if: matrix.install-go + name: Install Go + run: | + GO_VERSION=$(awk '/^go / { print $2 }' go.mod) + curl -fsSL "https://golang.org/dl/go${GO_VERSION}.linux-$(dpkg --print-architecture).tar.gz" | tar xz -C /usr/local + echo "/usr/local/go/bin" >> $GITHUB_PATH + - uses: actions/cache@v4 + with: + path: /github/home/.cache/ccache + key: ccache-${{ runner.os }}-${{ runner.arch }}-${{ matrix.preset }}-${{ needs.changes.outputs.vendorsha }} + - run: | + cmake --preset "${{ matrix.preset }}" ${{ matrix.flags }} + cmake --build --preset "${{ matrix.preset }}" -- -l $(nproc) + + windows: + needs: [changes] + if: needs.changes.outputs.changed == 'True' + strategy: + matrix: + include: + - preset: CPU + - preset: CUDA + install: https://developer.download.nvidia.com/compute/cuda/13.0.0/local_installers/cuda_13.0.0_windows.exe + flags: '-DCMAKE_CUDA_ARCHITECTURES=80' + cuda-components: + - '"cudart"' + - '"nvcc"' + - '"cublas"' + - '"cublas_dev"' + - '"crt"' + - '"nvvm"' + - '"nvptxcompiler"' + cuda-version: '13.0' + - preset: ROCm + install: https://download.amd.com/developer/eula/rocm-hub/AMD-Software-PRO-Edition-24.Q4-WinSvr2022-For-HIP.exe + flags: '-DAMDGPU_TARGETS=gfx1010 -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_FLAGS="-parallel-jobs=4 -Wno-ignored-attributes -Wno-deprecated-pragma" -DCMAKE_CXX_FLAGS="-parallel-jobs=4 -Wno-ignored-attributes -Wno-deprecated-pragma"' + - preset: Vulkan + install: https://sdk.lunarg.com/sdk/download/1.4.321.1/windows/vulkansdk-windows-X64-1.4.321.1.exe + - preset: 'MLX CUDA 13' + install: https://developer.download.nvidia.com/compute/cuda/13.0.0/local_installers/cuda_13.0.0_windows.exe + cudnn-install: https://developer.download.nvidia.com/compute/cudnn/redist/cudnn/windows-x86_64/cudnn-windows-x86_64-9.18.1.3_cuda13-archive.zip + flags: '-DCMAKE_CUDA_ARCHITECTURES=80 -DMLX_CUDA_ARCHITECTURES=80-virtual' + cuda-components: + - '"cudart"' + - '"nvcc"' + - '"cublas"' + - '"cublas_dev"' + - '"cufft"' + - '"cufft_dev"' + - '"nvrtc"' + - '"nvrtc_dev"' + - '"crt"' + - '"nvvm"' + - '"nvptxcompiler"' + cuda-version: '13.0' + runs-on: windows + steps: + - run: | + choco install -y --no-progress ccache ninja + if (Get-Command ccache -ErrorAction SilentlyContinue) { + ccache -o cache_dir=${{ github.workspace }}\.ccache + } + - if: matrix.preset == 'CUDA' || matrix.preset == 'ROCm' || matrix.preset == 'Vulkan' || matrix.preset == 'MLX CUDA 13' + id: cache-install + uses: actions/cache/restore@v4 + with: + path: | + C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA + C:\Program Files\AMD\ROCm + C:\VulkanSDK + C:\Program Files\NVIDIA\CUDNN + key: ${{ matrix.install }}-${{ matrix.cudnn-install }} + - if: matrix.preset == 'CUDA' || matrix.preset == 'MLX CUDA 13' + name: Install CUDA ${{ matrix.cuda-version }} + run: | + $ErrorActionPreference = "Stop" + if ("${{ steps.cache-install.outputs.cache-hit }}" -ne 'true') { + Invoke-WebRequest -Uri "${{ matrix.install }}" -OutFile "install.exe" + $subpackages = @(${{ join(matrix.cuda-components, ', ') }}) | Foreach-Object {"${_}_${{ matrix.cuda-version }}"} + Start-Process -FilePath .\install.exe -ArgumentList (@("-s") + $subpackages) -NoNewWindow -Wait + } + + $cudaPath = (Resolve-Path "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\*").path + echo "$cudaPath\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + - if: matrix.preset == 'ROCm' + name: Install ROCm ${{ matrix.rocm-version }} + run: | + $ErrorActionPreference = "Stop" + if ("${{ steps.cache-install.outputs.cache-hit }}" -ne 'true') { + Invoke-WebRequest -Uri "${{ matrix.install }}" -OutFile "install.exe" + Start-Process -FilePath .\install.exe -ArgumentList '-install' -NoNewWindow -Wait + } + + $hipPath = (Resolve-Path "C:\Program Files\AMD\ROCm\*").path + echo "$hipPath\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + echo "CC=$hipPath\bin\clang.exe" | Out-File -FilePath $env:GITHUB_ENV -Append + echo "CXX=$hipPath\bin\clang++.exe" | Out-File -FilePath $env:GITHUB_ENV -Append + echo "HIPCXX=$hipPath\bin\clang++.exe" | Out-File -FilePath $env:GITHUB_ENV -Append + echo "HIP_PLATFORM=amd" | Out-File -FilePath $env:GITHUB_ENV -Append + echo "CMAKE_PREFIX_PATH=$hipPath" | Out-File -FilePath $env:GITHUB_ENV -Append + - if: matrix.preset == 'Vulkan' + name: Install Vulkan ${{ matrix.rocm-version }} + run: | + $ErrorActionPreference = "Stop" + if ("${{ steps.cache-install.outputs.cache-hit }}" -ne 'true') { + Invoke-WebRequest -Uri "${{ matrix.install }}" -OutFile "install.exe" + Start-Process -FilePath .\install.exe -ArgumentList "-c","--am","--al","in" -NoNewWindow -Wait + } + + $vulkanPath = (Resolve-Path "C:\VulkanSDK\*").path + echo "$vulkanPath\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + echo "VULKAN_SDK=$vulkanPath" >> $env:GITHUB_ENV + - if: matrix.preset == 'MLX CUDA 13' + name: Install cuDNN for MLX + run: | + $ErrorActionPreference = "Stop" + $cudnnRoot = "C:\Program Files\NVIDIA\CUDNN" + if ("${{ steps.cache-install.outputs.cache-hit }}" -ne 'true') { + Invoke-WebRequest -Uri "${{ matrix.cudnn-install }}" -OutFile "cudnn.zip" + Expand-Archive -Path cudnn.zip -DestinationPath cudnn-extracted + $cudnnDir = (Get-ChildItem -Path cudnn-extracted -Directory)[0].FullName + New-Item -ItemType Directory -Force -Path $cudnnRoot + Copy-Item -Path "$cudnnDir\*" -Destination "$cudnnRoot\" -Recurse + } + + echo "CUDNN_ROOT_DIR=$cudnnRoot" | Out-File -FilePath $env:GITHUB_ENV -Append + echo "CUDNN_INCLUDE_PATH=$cudnnRoot\include" | Out-File -FilePath $env:GITHUB_ENV -Append + echo "CUDNN_LIBRARY_PATH=$cudnnRoot\lib\x64" | Out-File -FilePath $env:GITHUB_ENV -Append + echo "$cudnnRoot\bin\x64" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + - if: ${{ !cancelled() && steps.cache-install.outputs.cache-hit != 'true' }} + uses: actions/cache/save@v4 + with: + path: | + C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA + C:\Program Files\AMD\ROCm + C:\VulkanSDK + C:\Program Files\NVIDIA\CUDNN + key: ${{ matrix.install }}-${{ matrix.cudnn-install }} + - uses: actions/checkout@v4 + - uses: actions/cache@v4 + with: + path: ${{ github.workspace }}\.ccache + key: ccache-${{ runner.os }}-${{ runner.arch }}-${{ matrix.preset }}-${{ needs.changes.outputs.vendorsha }} + - run: | + Import-Module 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\Microsoft.VisualStudio.DevShell.dll' + Enter-VsDevShell -VsInstallPath 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise' -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -no_logo' + cmake --preset "${{ matrix.preset }}" ${{ matrix.flags }} + cmake --build --preset "${{ matrix.preset }}" -- -l $([Environment]::ProcessorCount) + env: + CMAKE_GENERATOR: Ninja + + go_mod_tidy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: check that 'go mod tidy' is clean + run: go mod tidy --diff || (echo "Please run 'go mod tidy'." && exit 1) + + test: + needs: [changes] + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} + env: + CGO_ENABLED: '1' + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + cache-dependency-path: | + go.sum + Makefile.sync + - uses: actions/setup-node@v4 + with: + node-version: '20' + - name: Install UI dependencies + working-directory: ./app/ui/app + run: npm ci + - name: Install tscriptify + run: | + go install github.com/tkrajina/typescriptify-golang-structs/tscriptify@latest + - name: Run UI tests + if: ${{ startsWith(matrix.os, 'ubuntu') }} + working-directory: ./app/ui/app + run: npm test + - name: Run go generate + run: go generate ./... + + - name: go test + if: always() + run: go test -count=1 -benchtime=1x ./... + + - name: go test app with live updater tag + if: ${{ needs.changes.outputs.app_changed == 'True' && contains(fromJSON('["macos-latest","windows-latest"]'), matrix.os) }} + run: go test -count=1 -tags updater_live ./app/... + + - uses: golangci/golangci-lint-action@v9 + with: + only-new-issues: true + + patches: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Verify patches apply cleanly and do not change files + run: | + make -f Makefile.sync clean checkout apply-patches sync + git diff --compact-summary --exit-code diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4e0b897 --- /dev/null +++ b/.gitignore @@ -0,0 +1,18 @@ +.DS_Store +.vscode +.env +.venv +.swp +dist +build +.cache +.gocache +*.exe +.idea +test_data +*.crt +__debug_bin* +llama/build +llama/vendor +/ollama +integration/testdata/models/ diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 0000000..5a42541 --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,51 @@ +version: "2" +linters: + enable: + - asasalint + - bidichk + - bodyclose + - containedctx + - gocheckcompilerdirectives + - intrange + - makezero + - misspell + - nilerr + - nolintlint + - nosprintfhostport + - unconvert + - usetesting + - wastedassign + - whitespace + disable: + - errcheck + - usestdlibvars + settings: + govet: + disable: + - unusedresult + staticcheck: + checks: + - all + - -QF* # disable quick fix suggestions + - -SA1019 + - -ST1000 # package comment format + - -ST1003 # underscores in package names + - -ST1005 # error strings should not be capitalized + - -ST1012 # error var naming (ErrFoo) + - -ST1016 # receiver name consistency + - -ST1020 # comment on exported function format + - -ST1021 # comment on exported type format + - -ST1022 # comment on exported var format + - -ST1023 # omit type from declaration +severity: + default: error + rules: + - linters: + - gofmt + - goimports + - intrange + severity: info +formatters: + enable: + - gofmt + - gofumpt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..f402d23 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,377 @@ +cmake_minimum_required(VERSION 3.21) + +project(Ollama C CXX) + +# Handle cross-compilation on macOS: when CMAKE_OSX_ARCHITECTURES is set to a +# single architecture different from the host, override CMAKE_SYSTEM_PROCESSOR +# to match. This is necessary because CMAKE_SYSTEM_PROCESSOR defaults to the +# host architecture, but downstream projects (like MLX) use it to detect the +# target architecture. +if(CMAKE_OSX_ARCHITECTURES AND NOT CMAKE_OSX_ARCHITECTURES MATCHES ";") + # Single architecture specified + if(CMAKE_OSX_ARCHITECTURES STREQUAL "x86_64" AND NOT CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + message(STATUS "Cross-compiling for x86_64: overriding CMAKE_SYSTEM_PROCESSOR from ${CMAKE_SYSTEM_PROCESSOR} to x86_64") + set(CMAKE_SYSTEM_PROCESSOR "x86_64") + elseif(CMAKE_OSX_ARCHITECTURES STREQUAL "arm64" AND NOT CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64") + message(STATUS "Cross-compiling for arm64: overriding CMAKE_SYSTEM_PROCESSOR from ${CMAKE_SYSTEM_PROCESSOR} to arm64") + set(CMAKE_SYSTEM_PROCESSOR "arm64") + endif() +endif() + +include(CheckLanguage) +include(GNUInstallDirs) + +find_package(Threads REQUIRED) + +set(CMAKE_BUILD_TYPE Release) +set(BUILD_SHARED_LIBS ON) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS ON) # Recent versions of MLX Requires gnu++17 extensions to compile properly + +set(GGML_BUILD ON) +set(GGML_SHARED ON) +set(GGML_CCACHE ON) +set(GGML_BACKEND_DL ON) +set(GGML_BACKEND_SHARED ON) +set(GGML_SCHED_MAX_COPIES 4) + +set(GGML_LLAMAFILE ON) +set(GGML_CUDA_PEER_MAX_BATCH_SIZE 128) +set(GGML_CUDA_GRAPHS ON) +set(GGML_CUDA_FA ON) +set(GGML_CUDA_COMPRESSION_MODE default) + +if((CMAKE_OSX_ARCHITECTURES AND NOT CMAKE_OSX_ARCHITECTURES MATCHES "arm64") + OR (NOT CMAKE_OSX_ARCHITECTURES AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "arm|aarch64|ARM64|ARMv[0-9]+")) + set(GGML_CPU_ALL_VARIANTS ON) +endif() + +if(APPLE) + set(CMAKE_BUILD_RPATH "@loader_path") + set(CMAKE_INSTALL_RPATH "@loader_path") + set(CMAKE_BUILD_WITH_INSTALL_RPATH ON) +endif() + +set(OLLAMA_BUILD_DIR ${CMAKE_BINARY_DIR}/lib/ollama) +set(OLLAMA_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib/ollama/${OLLAMA_RUNNER_DIR}) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OLLAMA_BUILD_DIR}) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${OLLAMA_BUILD_DIR}) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${OLLAMA_BUILD_DIR}) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OLLAMA_BUILD_DIR}) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${OLLAMA_BUILD_DIR}) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${OLLAMA_BUILD_DIR}) + +# Store ggml include paths for use with target_include_directories later. +# We avoid global include_directories() to prevent polluting the include path +# for other projects like MLX (whose openblas dependency has its own common.h). +set(GGML_INCLUDE_DIRS + ${CMAKE_CURRENT_SOURCE_DIR}/ml/backend/ggml/ggml/src + ${CMAKE_CURRENT_SOURCE_DIR}/ml/backend/ggml/ggml/src/include + ${CMAKE_CURRENT_SOURCE_DIR}/ml/backend/ggml/ggml/src/ggml-cpu + ${CMAKE_CURRENT_SOURCE_DIR}/ml/backend/ggml/ggml/src/ggml-cpu/amx +) + +add_compile_definitions(NDEBUG GGML_VERSION=0x0 GGML_COMMIT=0x0) + +# Define GGML version variables for shared library SOVERSION +# These are required by ggml/src/CMakeLists.txt for proper library versioning +set(GGML_VERSION_MAJOR 0) +set(GGML_VERSION_MINOR 0) +set(GGML_VERSION_PATCH 0) +set(GGML_VERSION "${GGML_VERSION_MAJOR}.${GGML_VERSION_MINOR}.${GGML_VERSION_PATCH}") + +set(GGML_CPU ON) +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/ml/backend/ggml/ggml/src) +set_property(TARGET ggml PROPERTY EXCLUDE_FROM_ALL TRUE) + +get_target_property(CPU_VARIANTS ggml-cpu MANUALLY_ADDED_DEPENDENCIES) +if(NOT CPU_VARIANTS) + set(CPU_VARIANTS "ggml-cpu") +endif() + +# Apply ggml include directories to ggml targets only (not globally) +target_include_directories(ggml-base PRIVATE ${GGML_INCLUDE_DIRS}) +foreach(variant ${CPU_VARIANTS}) + if(TARGET ${variant}) + target_include_directories(${variant} PRIVATE ${GGML_INCLUDE_DIRS}) + endif() +endforeach() + +install(TARGETS ggml-base ${CPU_VARIANTS} + RUNTIME_DEPENDENCIES + PRE_EXCLUDE_REGEXES ".*" + RUNTIME DESTINATION ${OLLAMA_INSTALL_DIR} COMPONENT CPU + LIBRARY DESTINATION ${OLLAMA_INSTALL_DIR} COMPONENT CPU + FRAMEWORK DESTINATION ${OLLAMA_INSTALL_DIR} COMPONENT CPU +) + +check_language(CUDA) +if(CMAKE_CUDA_COMPILER) + if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24" AND NOT CMAKE_CUDA_ARCHITECTURES) + set(CMAKE_CUDA_ARCHITECTURES "native") + endif() + + find_package(CUDAToolkit) + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/ml/backend/ggml/ggml/src/ggml-cuda) + target_include_directories(ggml-cuda PRIVATE ${GGML_INCLUDE_DIRS}) + install(TARGETS ggml-cuda + RUNTIME_DEPENDENCIES + DIRECTORIES ${CUDAToolkit_BIN_DIR} ${CUDAToolkit_BIN_DIR}/x64 ${CUDAToolkit_LIBRARY_DIR} + PRE_INCLUDE_REGEXES cublas cublasLt cudart + PRE_EXCLUDE_REGEXES ".*" + RUNTIME DESTINATION ${OLLAMA_INSTALL_DIR} COMPONENT CUDA + LIBRARY DESTINATION ${OLLAMA_INSTALL_DIR} COMPONENT CUDA + ) +endif() + +set(WINDOWS_AMDGPU_TARGETS_EXCLUDE_REGEX "^gfx(908|90a|1200|1201):xnack[+-]$" + CACHE STRING + "Regular expression describing AMDGPU_TARGETS not supported on Windows. Override to force building these targets. Default \"^gfx(908|90a|1200|1201):xnack[+-]$\"." +) + +check_language(HIP) +if(CMAKE_HIP_COMPILER) + set(HIP_PLATFORM "amd") + + if(NOT AMDGPU_TARGETS) + find_package(hip REQUIRED) + list(FILTER AMDGPU_TARGETS INCLUDE REGEX "^gfx(94[012]|101[02]|1030|110[012]|120[01])$") + endif() + + if(WIN32 AND WINDOWS_AMDGPU_TARGETS_EXCLUDE_REGEX) + list(FILTER AMDGPU_TARGETS EXCLUDE REGEX ${WINDOWS_AMDGPU_TARGETS_EXCLUDE_REGEX}) + endif() + + if(AMDGPU_TARGETS) + find_package(hip REQUIRED) + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/ml/backend/ggml/ggml/src/ggml-hip) + target_include_directories(ggml-hip PRIVATE ${GGML_INCLUDE_DIRS}) + + if (WIN32) + target_compile_definitions(ggml-hip PRIVATE GGML_CUDA_NO_PEER_COPY) + endif() + + target_compile_definitions(ggml-hip PRIVATE GGML_HIP_NO_VMM) + + install(TARGETS ggml-hip + RUNTIME_DEPENDENCY_SET rocm + RUNTIME DESTINATION ${OLLAMA_INSTALL_DIR} COMPONENT HIP + LIBRARY DESTINATION ${OLLAMA_INSTALL_DIR} COMPONENT HIP + ) + install(RUNTIME_DEPENDENCY_SET rocm + DIRECTORIES ${HIP_BIN_INSTALL_DIR} ${HIP_LIB_INSTALL_DIR} + PRE_INCLUDE_REGEXES hipblas rocblas amdhip64 rocsolver amd_comgr hsa-runtime64 rocsparse tinfo rocprofiler-register roctx64 rocroller drm drm_amdgpu numa elf + PRE_EXCLUDE_REGEXES ".*" + POST_EXCLUDE_REGEXES "system32" + RUNTIME DESTINATION ${OLLAMA_INSTALL_DIR} COMPONENT HIP + LIBRARY DESTINATION ${OLLAMA_INSTALL_DIR} COMPONENT HIP + ) + + foreach(HIP_LIB_BIN_INSTALL_DIR IN ITEMS ${HIP_BIN_INSTALL_DIR} ${HIP_LIB_INSTALL_DIR}) + if(EXISTS ${HIP_LIB_BIN_INSTALL_DIR}/rocblas) + install(DIRECTORY ${HIP_LIB_BIN_INSTALL_DIR}/rocblas DESTINATION ${OLLAMA_INSTALL_DIR} COMPONENT HIP) + break() + endif() + endforeach() + endif() +endif() + +if(NOT APPLE) + find_package(Vulkan) + if(Vulkan_FOUND) + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/ml/backend/ggml/ggml/src/ggml-vulkan) + target_include_directories(ggml-vulkan PRIVATE ${GGML_INCLUDE_DIRS}) + install(TARGETS ggml-vulkan + RUNTIME_DEPENDENCIES + PRE_INCLUDE_REGEXES vulkan + PRE_EXCLUDE_REGEXES ".*" + RUNTIME DESTINATION ${OLLAMA_INSTALL_DIR} COMPONENT Vulkan + LIBRARY DESTINATION ${OLLAMA_INSTALL_DIR} COMPONENT Vulkan + ) + endif() +endif() + +option(MLX_ENGINE "Enable MLX backend" OFF) +if(MLX_ENGINE) + message(STATUS "Setting up MLX (this takes a while...)") + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/x/imagegen/mlx) + + # Find CUDA toolkit if MLX is built with CUDA support + find_package(CUDAToolkit) + + # Build list of directories for runtime dependency resolution + set(MLX_RUNTIME_DIRS ${CUDAToolkit_BIN_DIR} ${CUDAToolkit_BIN_DIR}/x64 ${CUDAToolkit_LIBRARY_DIR}) + # Add cuDNN bin paths for DLLs (Windows MLX CUDA builds) + # CUDNN_ROOT_DIR is the standard CMake variable for cuDNN location + if(DEFINED ENV{CUDNN_ROOT_DIR}) + # cuDNN 9.x has versioned subdirectories under bin/ (e.g., bin/13.0/) + file(GLOB CUDNN_BIN_SUBDIRS "$ENV{CUDNN_ROOT_DIR}/bin/*") + list(APPEND MLX_RUNTIME_DIRS ${CUDNN_BIN_SUBDIRS}) + endif() + # Add build output directory and MLX dependency build directories + list(APPEND MLX_RUNTIME_DIRS ${OLLAMA_BUILD_DIR}) + # OpenBLAS DLL location (pre-built zip extracts into openblas-src/bin/) + list(APPEND MLX_RUNTIME_DIRS ${CMAKE_BINARY_DIR}/_deps/openblas-src/bin) + # NCCL: on Linux, if real NCCL is found, cmake bundles libnccl.so via the + # regex below. If NCCL is not found, MLX links a static stub (OBJECT lib) + # so there is no runtime dependency. This path covers the stub build dir + # for windows so we include the DLL in our dependencies. + list(APPEND MLX_RUNTIME_DIRS ${CMAKE_BINARY_DIR}/_deps/mlx-build/mlx/distributed/nccl/nccl_stub-prefix/src/nccl_stub-build/Release) + + # Base regexes for runtime dependencies (cross-platform) + set(MLX_INCLUDE_REGEXES cublas cublasLt cudart cufft nvrtc nvrtc-builtins cudnn nccl openblas gfortran) + # On Windows, also include dl.dll (dlfcn-win32 POSIX emulation layer) + if(WIN32) + list(APPEND MLX_INCLUDE_REGEXES "^dl\\.dll$") + endif() + + # Split mlx/mlxc libraries from runtime deps to avoid stripping deps + install(TARGETS mlx mlxc + RUNTIME_DEPENDENCY_SET mlx_runtime_deps + RUNTIME DESTINATION ${OLLAMA_INSTALL_DIR} COMPONENT MLX + LIBRARY DESTINATION ${OLLAMA_INSTALL_DIR} COMPONENT MLX + FRAMEWORK DESTINATION ${OLLAMA_INSTALL_DIR} COMPONENT MLX + ) + install(RUNTIME_DEPENDENCY_SET mlx_runtime_deps + DIRECTORIES ${MLX_RUNTIME_DIRS} + PRE_INCLUDE_REGEXES ${MLX_INCLUDE_REGEXES} + PRE_EXCLUDE_REGEXES ".*" + RUNTIME DESTINATION ${OLLAMA_INSTALL_DIR} COMPONENT MLX_VENDOR + LIBRARY DESTINATION ${OLLAMA_INSTALL_DIR} COMPONENT MLX_VENDOR + ) + + if(TARGET jaccl) + install(TARGETS jaccl + RUNTIME DESTINATION ${OLLAMA_INSTALL_DIR} COMPONENT MLX + LIBRARY DESTINATION ${OLLAMA_INSTALL_DIR} COMPONENT MLX + FRAMEWORK DESTINATION ${OLLAMA_INSTALL_DIR} COMPONENT MLX + ) + endif() + + # Install the Metal library for macOS arm64 (must be colocated with the binary) + # Metal backend is only built for arm64, not x86_64 + if(APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64") + install(FILES ${CMAKE_BINARY_DIR}/_deps/mlx-build/mlx/backend/metal/kernels/mlx.metallib + DESTINATION ${OLLAMA_INSTALL_DIR} + COMPONENT MLX) + endif() + + # Install headers for NVRTC JIT compilation at runtime. + # MLX's own install rules use the default component so they get skipped by + # --component MLX. Headers are installed alongside libmlx in OLLAMA_INSTALL_DIR. + # + # Layout: + # ${OLLAMA_INSTALL_DIR}/include/cccl/{cuda,nv}/ — CCCL headers + # ${OLLAMA_INSTALL_DIR}/include/*.h — CUDA toolkit headers + # + # MLX's jit_module.cpp resolves CCCL via + # current_binary_dir()[.parent_path()] / "include" / "cccl" + # On Linux, MLX's jit_module.cpp resolves CCCL via + # current_binary_dir().parent_path() / "include" / "cccl", so we create a + # symlink from lib/ollama/include -> ${OLLAMA_RUNNER_DIR}/include + # This will need refinement if we add multiple CUDA versions for MLX in the future. + # CUDA runtime headers are found via CUDA_PATH env var (set by mlxrunner). + if(EXISTS ${CMAKE_BINARY_DIR}/_deps/cccl-src/include/cuda) + install(DIRECTORY ${CMAKE_BINARY_DIR}/_deps/cccl-src/include/cuda + DESTINATION ${OLLAMA_INSTALL_DIR}/include/cccl + COMPONENT MLX) + install(DIRECTORY ${CMAKE_BINARY_DIR}/_deps/cccl-src/include/nv + DESTINATION ${OLLAMA_INSTALL_DIR}/include/cccl + COMPONENT MLX) + if(NOT WIN32 AND NOT APPLE) + install(CODE " + set(_link \"${CMAKE_INSTALL_PREFIX}/lib/ollama/include\") + set(_target \"${OLLAMA_RUNNER_DIR}/include\") + if(NOT EXISTS \${_link}) + execute_process(COMMAND \${CMAKE_COMMAND} -E create_symlink \${_target} \${_link}) + endif() + " COMPONENT MLX) + endif() + endif() + + # Install minimal CUDA toolkit headers needed by MLX JIT kernels. + # These are the transitive closure of includes from mlx/backend/cuda/device/*.cuh. + # The Go mlxrunner sets CUDA_PATH to OLLAMA_INSTALL_DIR so MLX finds them at + # $CUDA_PATH/include/*.h via NVRTC --include-path. + if(CUDAToolkit_FOUND) + # CUDAToolkit_INCLUDE_DIRS may be a semicolon-separated list + # (e.g. ".../include;.../include/cccl"). Find the entry that + # contains the CUDA runtime headers we need. + set(_cuda_inc "") + foreach(_dir ${CUDAToolkit_INCLUDE_DIRS}) + if(EXISTS "${_dir}/cuda_runtime_api.h") + set(_cuda_inc "${_dir}") + break() + endif() + endforeach() + if(NOT _cuda_inc) + message(WARNING "Could not find cuda_runtime_api.h in CUDAToolkit_INCLUDE_DIRS: ${CUDAToolkit_INCLUDE_DIRS}") + else() + set(_dst "${OLLAMA_INSTALL_DIR}/include") + set(_MLX_JIT_CUDA_HEADERS + builtin_types.h + cooperative_groups.h + cuda_bf16.h + cuda_bf16.hpp + cuda_device_runtime_api.h + cuda_fp16.h + cuda_fp16.hpp + cuda_fp8.h + cuda_fp8.hpp + cuda_runtime_api.h + device_types.h + driver_types.h + math_constants.h + surface_types.h + texture_types.h + vector_functions.h + vector_functions.hpp + vector_types.h + ) + foreach(_hdr ${_MLX_JIT_CUDA_HEADERS}) + install(FILES "${_cuda_inc}/${_hdr}" + DESTINATION ${_dst} + COMPONENT MLX) + endforeach() + # Subdirectory headers + install(DIRECTORY "${_cuda_inc}/cooperative_groups" + DESTINATION ${_dst} + COMPONENT MLX + FILES_MATCHING PATTERN "*.h") + install(FILES "${_cuda_inc}/crt/host_defines.h" + DESTINATION "${_dst}/crt" + COMPONENT MLX) + endif() + endif() + + # On Windows, explicitly install dl.dll (dlfcn-win32 POSIX dlopen emulation) + # RUNTIME_DEPENDENCIES auto-excludes it via POST_EXCLUDE_FILES_STRICT because + # dlfcn-win32 is a known CMake target with its own install rules (which install + # to the wrong destination). We must install it explicitly here. + if(WIN32) + install(FILES ${OLLAMA_BUILD_DIR}/dl.dll + DESTINATION ${OLLAMA_INSTALL_DIR} + COMPONENT MLX) + endif() + + # Manually install CUDA runtime libraries that MLX loads via dlopen + # (not detected by RUNTIME_DEPENDENCIES since they aren't link-time deps) + if(CUDAToolkit_FOUND) + file(GLOB MLX_CUDA_LIBS + "${CUDAToolkit_LIBRARY_DIR}/libcudart.so*" + "${CUDAToolkit_LIBRARY_DIR}/libcublas.so*" + "${CUDAToolkit_LIBRARY_DIR}/libcublasLt.so*" + "${CUDAToolkit_LIBRARY_DIR}/libnvrtc.so*" + "${CUDAToolkit_LIBRARY_DIR}/libnvrtc-builtins.so*" + "${CUDAToolkit_LIBRARY_DIR}/libcufft.so*" + "${CUDAToolkit_LIBRARY_DIR}/libcudnn.so*") + if(MLX_CUDA_LIBS) + install(FILES ${MLX_CUDA_LIBS} + DESTINATION ${OLLAMA_INSTALL_DIR} + COMPONENT MLX_VENDOR) + endif() + endif() +endif() diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..fd647e4 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,197 @@ +{ + "version": 3, + "configurePresets": [ + { + "name": "Default", + "binaryDir": "${sourceDir}/build", + "installDir": "${sourceDir}/dist", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", + "CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded" + } + }, + { + "name": "CPU", + "inherits": [ "Default" ] + }, + { + "name": "CUDA", + "inherits": [ "Default" ] + }, + { + "name": "CUDA 11", + "inherits": [ "CUDA" ], + "cacheVariables": { + "CMAKE_CUDA_ARCHITECTURES": "50-virtual;60-virtual;61-virtual;70-virtual;75-virtual;80-virtual;86-virtual;87-virtual;89-virtual;90-virtual", + "CMAKE_CUDA_FLAGS": "-Wno-deprecated-gpu-targets -t 2", + "OLLAMA_RUNNER_DIR": "cuda_v11" + } + }, + { + "name": "CUDA 12", + "inherits": [ "CUDA" ], + "cacheVariables": { + "CMAKE_CUDA_ARCHITECTURES": "50;52;60;61;70;75;80;86;89;90;90a;120", + "CMAKE_CUDA_FLAGS": "-Wno-deprecated-gpu-targets -t 2", + "OLLAMA_RUNNER_DIR": "cuda_v12" + } + }, + { + "name": "CUDA 13", + "inherits": [ "CUDA" ], + "cacheVariables": { + "CMAKE_CUDA_ARCHITECTURES": "75-virtual;80-virtual;86-virtual;87-virtual;89-virtual;90-virtual;90a-virtual;100-virtual;103-virtual;110-virtual;120-virtual;121-virtual", + "CMAKE_CUDA_FLAGS": "-t 2", + "OLLAMA_RUNNER_DIR": "cuda_v13" + } + }, + { + "name": "JetPack 5", + "inherits": [ "CUDA" ], + "cacheVariables": { + "CMAKE_CUDA_ARCHITECTURES": "72;87", + "OLLAMA_RUNNER_DIR": "cuda_jetpack5" + } + }, + { + "name": "JetPack 6", + "inherits": [ "CUDA" ], + "cacheVariables": { + "CMAKE_CUDA_ARCHITECTURES": "87", + "OLLAMA_RUNNER_DIR": "cuda_jetpack6" + } + }, + { + "name": "ROCm", + "inherits": [ "Default" ], + "cacheVariables": { + "CMAKE_HIP_PLATFORM": "amd" + } + }, + { + "name": "ROCm 6", + "inherits": [ "ROCm" ], + "cacheVariables": { + "CMAKE_HIP_FLAGS": "-parallel-jobs=4", + "AMDGPU_TARGETS": "gfx940;gfx941;gfx942;gfx1010;gfx1012;gfx1030;gfx1100;gfx1101;gfx1102;gfx1151;gfx1200;gfx1201;gfx908:xnack-;gfx90a:xnack+;gfx90a:xnack-", + "OLLAMA_RUNNER_DIR": "rocm" + } + }, + { + "name": "ROCm 7", + "inherits": [ "ROCm" ], + "cacheVariables": { + "CMAKE_HIP_FLAGS": "-parallel-jobs=4", + "AMDGPU_TARGETS": "gfx942;gfx950;gfx1010;gfx1012;gfx1030;gfx1100;gfx1101;gfx1102;gfx1103;gfx1150;gfx1151;gfx1200;gfx1201;gfx908:xnack-;gfx90a:xnack+;gfx90a:xnack-", + "OLLAMA_RUNNER_DIR": "rocm" + } + }, + { + "name": "Vulkan", + "inherits": [ "Default" ], + "cacheVariables": { + "OLLAMA_RUNNER_DIR": "vulkan" + } + }, + { + "name": "MLX", + "inherits": [ "Default" ], + "cacheVariables": { + "MLX_ENGINE": "ON", + "OLLAMA_RUNNER_DIR": "mlx" + } + }, + { + "name": "MLX CUDA 12", + "inherits": [ "MLX", "CUDA 12" ], + "cacheVariables": { + "OLLAMA_RUNNER_DIR": "mlx_cuda_v12" + } + }, + { + "name": "MLX CUDA 13", + "inherits": [ "MLX", "CUDA 13" ], + "cacheVariables": { + "MLX_CUDA_ARCHITECTURES": "75-virtual;80-virtual;86-virtual;89-virtual;90-virtual;90a-virtual;100-virtual;103-virtual;110-virtual;120-virtual;121-virtual", + "OLLAMA_RUNNER_DIR": "mlx_cuda_v13" + } + } + ], + "buildPresets": [ + { + "name": "Default", + "configurePreset": "Default", + "configuration": "Release" + }, + { + "name": "CPU", + "configurePreset": "Default", + "targets": [ "ggml-cpu" ] + }, + { + "name": "CUDA", + "configurePreset": "CUDA", + "targets": [ "ggml-cuda" ] + }, + { + "name": "CUDA 11", + "inherits": [ "CUDA" ], + "configurePreset": "CUDA 11" + }, + { + "name": "CUDA 12", + "inherits": [ "CUDA" ], + "configurePreset": "CUDA 12" + }, + { + "name": "CUDA 13", + "inherits": [ "CUDA" ], + "configurePreset": "CUDA 13" + }, + { + "name": "JetPack 5", + "inherits": [ "CUDA" ], + "configurePreset": "JetPack 5" + }, + { + "name": "JetPack 6", + "inherits": [ "CUDA" ], + "configurePreset": "JetPack 6" + }, + { + "name": "ROCm", + "configurePreset": "ROCm", + "targets": [ "ggml-hip" ] + }, + { + "name": "ROCm 6", + "inherits": [ "ROCm" ], + "configurePreset": "ROCm 6" + }, + { + "name": "ROCm 7", + "inherits": [ "ROCm" ], + "configurePreset": "ROCm 7" + }, + { + "name": "Vulkan", + "targets": [ "ggml-vulkan" ], + "configurePreset": "Vulkan" + }, + { + "name": "MLX", + "targets": [ "mlx", "mlxc" ], + "configurePreset": "MLX" + }, + { + "name": "MLX CUDA 12", + "targets": [ "mlx", "mlxc" ], + "configurePreset": "MLX CUDA 12" + }, + { + "name": "MLX CUDA 13", + "targets": [ "mlx", "mlxc" ], + "configurePreset": "MLX CUDA 13" + } + ] +} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..8d51cc1 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,88 @@ +# Contributing to Ollama + +Thank you for your interest in contributing to Ollama! Here are a few guidelines to help get you started. + +## Set up + +See the [development documentation](./docs/development.md) for instructions on how to build and run Ollama locally. + +### Ideal issues + +* [Bugs](https://github.com/ollama/ollama/issues?q=is%3Aissue+is%3Aopen+label%3Abug): issues where Ollama stops working or where it results in an unexpected error. +* [Performance](https://github.com/ollama/ollama/issues?q=is%3Aissue+is%3Aopen+label%3Aperformance): issues to make Ollama faster at model inference, downloading or uploading. +* [Security](https://github.com/ollama/ollama/blob/main/SECURITY.md): issues that could lead to a security vulnerability. As mentioned in [SECURITY.md](https://github.com/ollama/ollama/blob/main/SECURITY.md), please do not disclose security vulnerabilities publicly. + +### Issues that are harder to review + +* New features: new features (e.g. API fields, environment variables) add surface area to Ollama and make it harder to maintain in the long run as they cannot be removed without potentially breaking users in the future. +* Refactoring: large code improvements are important, but can be harder or take longer to review and merge. +* Documentation: small updates to fill in or correct missing documentation are helpful, however large documentation additions can be hard to maintain over time. + +### Issues that may not be accepted + +* Changes that break backwards compatibility in Ollama's API (including the OpenAI-compatible API) +* Changes that add significant friction to the user experience +* Changes that create a large future maintenance burden for maintainers and contributors + +## Proposing a (non-trivial) change + +> By "non-trivial", we mean a change that is not a bug fix or small +> documentation update. If you are unsure, please ask us on our [Discord +> server](https://discord.gg/ollama). + +Before opening a non-trivial Pull Request, please open an issue to discuss the change and +get feedback from the maintainers. This helps us understand the context of the +change and how it fits into Ollama's roadmap and prevents us from duplicating +work or you from spending time on a change that we may not be able to accept. + +Tips for proposals: + +* Explain the problem you are trying to solve, not what you are trying to do. +* Explain why the change is important. +* Explain how the change will be used. +* Explain how the change will be tested. + +Additionally, for bonus points: Provide draft documentation you would expect to +see if the changes were accepted. + +## Pull requests + +**Commit messages** + +The title should look like: + + : + +The package is the most affected Go package. If the change does not affect Go +code, then use the directory name instead. Changes to a single well-known +file in the root directory may use the file name. + +The short description should start with a lowercase letter and be a +continuation of the sentence: + + "This changes Ollama to..." + +Examples: + + llm/backend/mlx: support the llama architecture + CONTRIBUTING: provide clarity on good commit messages, and bad + +Bad Examples: + + feat: add more emoji + fix: was not using famous web framework + chore: generify code + +**Tests** + +Please include tests. Strive to test behavior, not implementation. + +**New dependencies** + +Dependencies should be added sparingly. If you are adding a new dependency, +please explain why it is necessary and what other ways you attempted that +did not work without it. + +## Need help? + +If you need help with anything, feel free to reach out to us on our [Discord server](https://discord.gg/ollama). diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..461c858 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,235 @@ +# vim: filetype=dockerfile + +ARG FLAVOR=${TARGETARCH} + +ARG ROCMVERSION=7.2.1 +ARG JETPACK5VERSION=r35.4.1 +ARG JETPACK6VERSION=r36.4.0 +ARG CMAKEVERSION=3.31.2 +ARG NINJAVERSION=1.12.1 +ARG VULKANVERSION=1.4.321.1 + +# Default empty stages for local MLX source overrides. +# Override with: docker build --build-context local-mlx=../mlx --build-context local-mlx-c=../mlx-c +FROM scratch AS local-mlx +FROM scratch AS local-mlx-c + +FROM --platform=linux/amd64 rocm/dev-almalinux-8:${ROCMVERSION}-complete AS base-amd64 +RUN dnf install -y yum-utils ccache gcc-toolset-11-gcc gcc-toolset-11-gcc-c++ gcc-toolset-11-binutils \ + && yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo +ENV PATH=/opt/rh/gcc-toolset-11/root/usr/bin:$PATH + +FROM --platform=linux/arm64 almalinux:8 AS base-arm64 +# install epel-release for ccache +RUN yum install -y yum-utils epel-release \ + && dnf install -y clang ccache git \ + && yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/sbsa/cuda-rhel8.repo +ENV CC=clang CXX=clang++ + +FROM base-${TARGETARCH} AS base +ARG CMAKEVERSION +ARG NINJAVERSION +RUN curl -fsSL https://github.com/Kitware/CMake/releases/download/v${CMAKEVERSION}/cmake-${CMAKEVERSION}-linux-$(uname -m).tar.gz | tar xz -C /usr/local --strip-components 1 +RUN dnf install -y unzip \ + && curl -fsSL -o /tmp/ninja.zip https://github.com/ninja-build/ninja/releases/download/v${NINJAVERSION}/ninja-linux$([ "$(uname -m)" = "aarch64" ] && echo "-aarch64").zip \ + && unzip /tmp/ninja.zip -d /usr/local/bin \ + && rm /tmp/ninja.zip +ENV CMAKE_GENERATOR=Ninja +ENV LDFLAGS=-s + +FROM base AS cpu +RUN dnf install -y gcc-toolset-11-gcc gcc-toolset-11-gcc-c++ +ENV PATH=/opt/rh/gcc-toolset-11/root/usr/bin:$PATH +COPY CMakeLists.txt CMakePresets.json . +COPY ml/backend/ggml/ggml ml/backend/ggml/ggml +RUN --mount=type=cache,target=/root/.ccache \ + cmake --preset 'CPU' \ + && cmake --build --preset 'CPU' -- -l $(nproc) \ + && cmake --install build --component CPU --strip + +FROM base AS cuda-11 +ARG CUDA11VERSION=11.8 +RUN dnf install -y cuda-toolkit-${CUDA11VERSION//./-} +ENV PATH=/usr/local/cuda-11/bin:$PATH +COPY CMakeLists.txt CMakePresets.json . +COPY ml/backend/ggml/ggml ml/backend/ggml/ggml +RUN --mount=type=cache,target=/root/.ccache \ + cmake --preset 'CUDA 11' \ + && cmake --build --preset 'CUDA 11' -- -l $(nproc) \ + && cmake --install build --component CUDA --strip + +FROM base AS cuda-12 +ARG CUDA12VERSION=12.8 +RUN dnf install -y cuda-toolkit-${CUDA12VERSION//./-} +ENV PATH=/usr/local/cuda-12/bin:$PATH +COPY CMakeLists.txt CMakePresets.json . +COPY ml/backend/ggml/ggml ml/backend/ggml/ggml +RUN --mount=type=cache,target=/root/.ccache \ + cmake --preset 'CUDA 12' \ + && cmake --build --preset 'CUDA 12' -- -l $(nproc) \ + && cmake --install build --component CUDA --strip + + +FROM base AS cuda-13 +ARG CUDA13VERSION=13.0 +RUN dnf install -y cuda-toolkit-${CUDA13VERSION//./-} +ENV PATH=/usr/local/cuda-13/bin:$PATH +COPY CMakeLists.txt CMakePresets.json . +COPY ml/backend/ggml/ggml ml/backend/ggml/ggml +RUN --mount=type=cache,target=/root/.ccache \ + cmake --preset 'CUDA 13' \ + && cmake --build --preset 'CUDA 13' -- -l $(nproc) \ + && cmake --install build --component CUDA --strip + + +FROM base AS rocm-7 +ENV PATH=/opt/rocm/hcc/bin:/opt/rocm/hip/bin:/opt/rocm/bin:/opt/rocm/hcc/bin:$PATH +COPY CMakeLists.txt CMakePresets.json . +COPY ml/backend/ggml/ggml ml/backend/ggml/ggml +RUN --mount=type=cache,target=/root/.ccache \ + cmake --preset 'ROCm 7' \ + && cmake --build --preset 'ROCm 7' -- -l $(nproc) \ + && cmake --install build --component HIP --strip +RUN rm -f dist/lib/ollama/rocm/rocblas/library/*gfx90[06]* + +FROM --platform=linux/arm64 nvcr.io/nvidia/l4t-jetpack:${JETPACK5VERSION} AS jetpack-5 +ARG CMAKEVERSION +ARG NINJAVERSION +RUN apt-get update && apt-get install -y curl ccache unzip \ + && curl -fsSL https://github.com/Kitware/CMake/releases/download/v${CMAKEVERSION}/cmake-${CMAKEVERSION}-linux-$(uname -m).tar.gz | tar xz -C /usr/local --strip-components 1 \ + && curl -fsSL -o /tmp/ninja.zip https://github.com/ninja-build/ninja/releases/download/v${NINJAVERSION}/ninja-linux-aarch64.zip \ + && unzip /tmp/ninja.zip -d /usr/local/bin \ + && rm /tmp/ninja.zip +ENV CMAKE_GENERATOR=Ninja +COPY CMakeLists.txt CMakePresets.json . +COPY ml/backend/ggml/ggml ml/backend/ggml/ggml +RUN --mount=type=cache,target=/root/.ccache \ + cmake --preset 'JetPack 5' \ + && cmake --build --preset 'JetPack 5' -- -l $(nproc) \ + && cmake --install build --component CUDA --strip + +FROM --platform=linux/arm64 nvcr.io/nvidia/l4t-jetpack:${JETPACK6VERSION} AS jetpack-6 +ARG CMAKEVERSION +ARG NINJAVERSION +RUN apt-get update && apt-get install -y curl ccache unzip \ + && curl -fsSL https://github.com/Kitware/CMake/releases/download/v${CMAKEVERSION}/cmake-${CMAKEVERSION}-linux-$(uname -m).tar.gz | tar xz -C /usr/local --strip-components 1 \ + && curl -fsSL -o /tmp/ninja.zip https://github.com/ninja-build/ninja/releases/download/v${NINJAVERSION}/ninja-linux-aarch64.zip \ + && unzip /tmp/ninja.zip -d /usr/local/bin \ + && rm /tmp/ninja.zip +ENV CMAKE_GENERATOR=Ninja +COPY CMakeLists.txt CMakePresets.json . +COPY ml/backend/ggml/ggml ml/backend/ggml/ggml +RUN --mount=type=cache,target=/root/.ccache \ + cmake --preset 'JetPack 6' \ + && cmake --build --preset 'JetPack 6' -- -l $(nproc) \ + && cmake --install build --component CUDA --strip + +FROM base AS vulkan +ARG VULKANVERSION +RUN ln -s /usr/bin/python3 /usr/bin/python \ + && wget https://sdk.lunarg.com/sdk/download/${VULKANVERSION}/linux/vulkansdk-linux-x86_64-${VULKANVERSION}.tar.xz -O /tmp/vulkansdk.tar.xz \ + && tar xvf /tmp/vulkansdk.tar.xz -C /tmp \ + && /tmp/${VULKANVERSION}/vulkansdk -j 8 vulkan-headers \ + && /tmp/${VULKANVERSION}/vulkansdk -j 8 shaderc \ + && cp -r /tmp/${VULKANVERSION}/x86_64/include/* /usr/local/include/ \ + && cp -r /tmp/${VULKANVERSION}/x86_64/lib/* /usr/local/lib \ + && cp -r /tmp/${VULKANVERSION}/x86_64/bin/* /usr/local/bin/ \ + && rm -rf /tmp/${VULKANVERSION} /tmp/vulkansdk.tar.xz +COPY CMakeLists.txt CMakePresets.json . +COPY ml/backend/ggml/ggml ml/backend/ggml/ggml +RUN --mount=type=cache,target=/root/.ccache \ + cmake --preset 'Vulkan' \ + && cmake --build --preset 'Vulkan' -- -l $(nproc) \ + && cmake --install build --component Vulkan --strip + +FROM base AS mlx +ARG CUDA13VERSION=13.0 +# OLLAMA_MLX_BUILD_JOBS empty -> ninja gates by load average (-l $(nproc)) +ARG OLLAMA_MLX_BUILD_JOBS= +ARG OLLAMA_MLX_NVCC_THREADS=2 +RUN dnf install -y cuda-toolkit-${CUDA13VERSION//./-} \ + && dnf install -y openblas-devel lapack-devel \ + && dnf install -y libcudnn9-cuda-13 libcudnn9-devel-cuda-13 \ + && dnf install -y libnccl libnccl-devel +ENV PATH=/usr/local/cuda-13/bin:$PATH +ENV BLAS_INCLUDE_DIRS=/usr/include/openblas +ENV LAPACK_INCLUDE_DIRS=/usr/include/openblas +ENV CGO_LDFLAGS="-L/usr/local/cuda-13/lib64 -L/usr/local/cuda-13/targets/x86_64-linux/lib/stubs" +WORKDIR /go/src/github.com/ollama/ollama +COPY CMakeLists.txt CMakePresets.json . +COPY ml/backend/ggml/ggml ml/backend/ggml/ggml +COPY x/imagegen/mlx x/imagegen/mlx +COPY go.mod go.sum . +COPY MLX_VERSION MLX_C_VERSION . +RUN curl -fsSL https://golang.org/dl/go$(awk '/^go/ { print $2 }' go.mod).linux-$(case $(uname -m) in x86_64) echo amd64 ;; aarch64) echo arm64 ;; esac).tar.gz | tar xz -C /usr/local +ENV PATH=/usr/local/go/bin:$PATH +RUN go mod download +RUN --mount=type=cache,target=/root/.ccache \ + --mount=type=bind,from=local-mlx,target=/tmp/local-mlx \ + --mount=type=bind,from=local-mlx-c,target=/tmp/local-mlx-c \ + if [ -f /tmp/local-mlx/CMakeLists.txt ]; then \ + export OLLAMA_MLX_SOURCE=/tmp/local-mlx; \ + fi \ + && if [ -f /tmp/local-mlx-c/CMakeLists.txt ]; then \ + export OLLAMA_MLX_C_SOURCE=/tmp/local-mlx-c; \ + fi \ + && cmake --preset 'MLX CUDA 13' -DBLAS_INCLUDE_DIRS=/usr/include/openblas -DLAPACK_INCLUDE_DIRS=/usr/include/openblas -DCMAKE_CUDA_FLAGS="-t ${OLLAMA_MLX_NVCC_THREADS}" \ + && cmake --build --preset 'MLX CUDA 13' -- -l $(nproc) ${OLLAMA_MLX_BUILD_JOBS:+-j ${OLLAMA_MLX_BUILD_JOBS}} \ + && cmake --install build --component MLX --strip \ + && cmake --install build --component MLX_VENDOR + +FROM base AS build +WORKDIR /go/src/github.com/ollama/ollama +COPY go.mod go.sum . +RUN curl -fsSL https://golang.org/dl/go$(awk '/^go/ { print $2 }' go.mod).linux-$(case $(uname -m) in x86_64) echo amd64 ;; aarch64) echo arm64 ;; esac).tar.gz | tar xz -C /usr/local +ENV PATH=/usr/local/go/bin:$PATH +RUN go mod download +COPY . . +ARG GOFLAGS="'-ldflags=-w -s'" +ENV CGO_ENABLED=1 +ARG CGO_CFLAGS +ARG CGO_CXXFLAGS +ENV CGO_CFLAGS="${CGO_CFLAGS}" +ENV CGO_CXXFLAGS="${CGO_CXXFLAGS}" +RUN --mount=type=cache,target=/root/.cache/go-build \ + go build -trimpath -buildmode=pie -o /bin/ollama . + +FROM --platform=linux/amd64 scratch AS amd64 +# COPY --from=cuda-11 dist/lib/ollama/ /lib/ollama/ +COPY --from=cuda-12 dist/lib/ollama /lib/ollama/ +COPY --from=cuda-13 dist/lib/ollama /lib/ollama/ +COPY --from=vulkan dist/lib/ollama /lib/ollama/ +COPY --from=mlx /go/src/github.com/ollama/ollama/dist/lib/ollama /lib/ollama/ + +FROM --platform=linux/arm64 scratch AS arm64 +# COPY --from=cuda-11 dist/lib/ollama/ /lib/ollama/ +COPY --from=cuda-12 dist/lib/ollama /lib/ollama/ +COPY --from=cuda-13 dist/lib/ollama/ /lib/ollama/ +COPY --from=jetpack-5 dist/lib/ollama/ /lib/ollama/ +COPY --from=jetpack-6 dist/lib/ollama/ /lib/ollama/ + +FROM scratch AS rocm +COPY --from=rocm-7 dist/lib/ollama /lib/ollama + +FROM ${FLAVOR} AS archive +COPY --from=cpu dist/lib/ollama /lib/ollama +COPY --from=build /bin/ollama /bin/ollama + +FROM ubuntu:24.04 +ARG APT_MIRROR=http://archive.ubuntu.com/ubuntu +RUN sed -i "s|http://archive.ubuntu.com/ubuntu|$APT_MIRROR|g" /etc/apt/sources.list.d/ubuntu.sources \ + && apt-get update \ + && apt-get install -y ca-certificates libvulkan1 libopenblas0 \ + && sed -i "s|$APT_MIRROR|http://archive.ubuntu.com/ubuntu|g" /etc/apt/sources.list.d/ubuntu.sources \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* +COPY --from=archive /bin /usr/bin +ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +COPY --from=archive /lib/ollama /usr/lib/ollama +ENV LD_LIBRARY_PATH=/usr/local/nvidia/lib:/usr/local/nvidia/lib64 +ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility +ENV NVIDIA_VISIBLE_DEVICES=all +ENV OLLAMA_HOST=0.0.0.0:11434 +EXPOSE 11434 +ENTRYPOINT ["/bin/ollama"] +CMD ["serve"] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8e3dc97 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Ollama + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/MLX_C_VERSION b/MLX_C_VERSION new file mode 100644 index 0000000..b351137 --- /dev/null +++ b/MLX_C_VERSION @@ -0,0 +1 @@ +fba4470b89073180056c9ea46c443051375f7399 diff --git a/MLX_VERSION b/MLX_VERSION new file mode 100644 index 0000000..02237b6 --- /dev/null +++ b/MLX_VERSION @@ -0,0 +1 @@ +e8ebdebeeb655feaa85a51f6b24ece5b6d5518d1 diff --git a/Makefile.sync b/Makefile.sync new file mode 100644 index 0000000..c1c24f2 --- /dev/null +++ b/Makefile.sync @@ -0,0 +1,76 @@ +UPSTREAM=https://github.com/ggml-org/llama.cpp.git +WORKDIR=llama/vendor +FETCH_HEAD=ec98e2002 + +.PHONY: help +help: + @echo "Available targets:" + @echo " sync Sync with upstream repositories" + @echo " checkout Checkout upstream repository" + @echo " apply-patches Apply patches to local repository" + @echo " format-patches Format patches from local repository" + @echo " clean Clean local repository" + @echo + @echo "Example:" + @echo " make -f $(lastword $(MAKEFILE_LIST)) clean apply-patches sync" + +.PHONY: sync +sync: llama/build-info.cpp ml/backend/ggml/ggml/src/ggml-metal/ggml-metal-embed.metal + +llama/build-info.cpp: llama/build-info.cpp.in llama/llama.cpp + sed -e 's|@FETCH_HEAD@|$(FETCH_HEAD)|' <$< >$@ + +ml/backend/ggml/ggml/src/ggml-metal/ggml-metal-embed.metal: ml/backend/ggml/ggml + go generate ./$(@D) + +.PHONY: llama/llama.cpp +llama/llama.cpp: llama/vendor + rsync -arvzc --delete -f "include LICENSE" -f "merge $@/.rsync-filter" $(addprefix $<,/LICENSE /) $@ + +.PHONY: ml/backend/ggml/ggml +ml/backend/ggml/ggml: llama/vendor + rsync -arvzc --delete -f "include LICENSE" -f "merge $@/.rsync-filter" $(addprefix $<,/LICENSE /ggml/) $@ + +PATCHES=$(wildcard llama/patches/*.patch) +PATCHED=$(join $(dir $(PATCHES)), $(addsuffix ed, $(addprefix ., $(notdir $(PATCHES))))) + +.PHONY: apply-patches +.NOTPARALLEL: +apply-patches: $(PATCHED) + +llama/patches/.%.patched: llama/patches/%.patch + @if git -c user.name=nobody -c 'user.email=<>' -C $(WORKDIR) am -3 $(realpath $<); then \ + touch $@; \ + else \ + echo "Patch failed. Resolve any conflicts then continue."; \ + echo "1. Run 'git -C $(WORKDIR) am --continue'"; \ + echo "2. Run 'make -f $(lastword $(MAKEFILE_LIST)) format-patches'"; \ + echo "3. Run 'make -f $(lastword $(MAKEFILE_LIST)) clean apply-patches'"; \ + exit 1; \ + fi + +.PHONY: checkout +checkout: $(WORKDIR) + git -C $(WORKDIR) fetch + git -C $(WORKDIR) checkout -f $(FETCH_HEAD) + +$(WORKDIR): + git clone $(UPSTREAM) $(WORKDIR) + +.PHONY: format-patches +format-patches: llama/patches + git -C $(WORKDIR) format-patch \ + --no-signature \ + --no-numbered \ + --zero-commit \ + -o $(realpath $<) \ + $(FETCH_HEAD) + +.PHONY: clean +clean: checkout + @git -C $(WORKDIR) am --abort || true + $(RM) llama/patches/.*.patched + +.PHONY: print-base +print-base: + @echo $(FETCH_HEAD) \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..0fc1e8c --- /dev/null +++ b/README.md @@ -0,0 +1,356 @@ +

+ + ollama + +

+ +# Ollama + +Start building with open models. + +## Download + +### macOS + +```shell +curl -fsSL https://ollama.com/install.sh | sh +``` + +or [download manually](https://ollama.com/download/Ollama.dmg) + +### Windows + +```shell +irm https://ollama.com/install.ps1 | iex +``` + +or [download manually](https://ollama.com/download/OllamaSetup.exe) + +### Linux + +```shell +curl -fsSL https://ollama.com/install.sh | sh +``` + +[Manual install instructions](https://docs.ollama.com/linux#manual-install) + +### Docker + +The official [Ollama Docker image](https://hub.docker.com/r/ollama/ollama) `ollama/ollama` is available on Docker Hub. + +### Libraries + +- [ollama-python](https://github.com/ollama/ollama-python) +- [ollama-js](https://github.com/ollama/ollama-js) + +### Community + +- [Discord](https://discord.gg/ollama) +- [𝕏 (Twitter)](https://x.com/ollama) +- [Reddit](https://reddit.com/r/ollama) + +## Get started + +``` +ollama +``` + +You'll be prompted to run a model or connect Ollama to your existing agents or applications such as `Claude Code`, `OpenClaw`, `OpenCode` , `Codex`, `Copilot`, and more. + +### Coding + +To launch a specific integration: + +``` +ollama launch claude +``` + +Supported integrations include [Claude Code](https://docs.ollama.com/integrations/claude-code), [Codex](https://docs.ollama.com/integrations/codex), [Copilot CLI](https://docs.ollama.com/integrations/copilot-cli), [Droid](https://docs.ollama.com/integrations/droid), and [OpenCode](https://docs.ollama.com/integrations/opencode). + +### AI assistant + +Use [OpenClaw](https://docs.ollama.com/integrations/openclaw) to turn Ollama into a personal AI assistant across WhatsApp, Telegram, Slack, Discord, and more: + +``` +ollama launch openclaw +``` + +### Chat with a model + +Run and chat with [Gemma 3](https://ollama.com/library/gemma3): + +``` +ollama run gemma3 +``` + +See [ollama.com/library](https://ollama.com/library) for the full list. + +See the [quickstart guide](https://docs.ollama.com/quickstart) for more details. + +## REST API + +Ollama has a REST API for running and managing models. + +``` +curl http://localhost:11434/api/chat -d '{ + "model": "gemma3", + "messages": [{ + "role": "user", + "content": "Why is the sky blue?" + }], + "stream": false +}' +``` + +See the [API documentation](https://docs.ollama.com/api) for all endpoints. + +### Python + +``` +pip install ollama +``` + +```python +from ollama import chat + +response = chat(model='gemma3', messages=[ + { + 'role': 'user', + 'content': 'Why is the sky blue?', + }, +]) +print(response.message.content) +``` + +### JavaScript + +``` +npm i ollama +``` + +```javascript +import ollama from "ollama"; + +const response = await ollama.chat({ + model: "gemma3", + messages: [{ role: "user", content: "Why is the sky blue?" }], +}); +console.log(response.message.content); +``` + +## Supported backends + +- [llama.cpp](https://github.com/ggml-org/llama.cpp) project founded by Georgi Gerganov. + +## Documentation + +- [CLI reference](https://docs.ollama.com/cli) +- [REST API reference](https://docs.ollama.com/api) +- [Importing models](https://docs.ollama.com/import) +- [Modelfile reference](https://docs.ollama.com/modelfile) +- [Building from source](https://github.com/ollama/ollama/blob/main/docs/development.md) + +## Community Integrations + +> Want to add your project? Open a pull request. + +### Chat Interfaces + +#### Web + +- [Open WebUI](https://github.com/open-webui/open-webui) - Extensible, self-hosted AI interface +- [Onyx](https://github.com/onyx-dot-app/onyx) - Connected AI workspace +- [LibreChat](https://github.com/danny-avila/LibreChat) - Enhanced ChatGPT clone with multi-provider support +- [Lobe Chat](https://github.com/lobehub/lobe-chat) - Modern chat framework with plugin ecosystem ([docs](https://lobehub.com/docs/self-hosting/examples/ollama)) +- [NextChat](https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web) - Cross-platform ChatGPT UI ([docs](https://docs.nextchat.dev/models/ollama)) +- [Perplexica](https://github.com/ItzCrazyKns/Perplexica) - AI-powered search engine, open-source Perplexity alternative +- [big-AGI](https://github.com/enricoros/big-AGI) - AI suite for professionals +- [Lollms WebUI](https://github.com/ParisNeo/lollms-webui) - Multi-model web interface +- [ChatOllama](https://github.com/sugarforever/chat-ollama) - Chatbot with knowledge bases +- [Bionic GPT](https://github.com/bionic-gpt/bionic-gpt) - On-premise AI platform +- [Chatbot UI](https://github.com/ivanfioravanti/chatbot-ollama) - ChatGPT-style web interface +- [Hollama](https://github.com/fmaclen/hollama) - Minimal web interface +- [Chatbox](https://github.com/Bin-Huang/Chatbox) - Desktop and web AI client +- [chat](https://github.com/swuecho/chat) - Chat web app for teams +- [Ollama RAG Chatbot](https://github.com/datvodinh/rag-chatbot.git) - Chat with multiple PDFs using RAG +- [Tkinter-based client](https://github.com/chyok/ollama-gui) - Python desktop client + +#### Desktop + +- [Dify.AI](https://github.com/langgenius/dify) - LLM app development platform +- [AnythingLLM](https://github.com/Mintplex-Labs/anything-llm) - All-in-one AI app for Mac, Windows, and Linux +- [Maid](https://github.com/Mobile-Artificial-Intelligence/maid) - Cross-platform mobile and desktop client +- [Witsy](https://github.com/nbonamy/witsy) - AI desktop app for Mac, Windows, and Linux +- [Cherry Studio](https://github.com/kangfenmao/cherry-studio) - Multi-provider desktop client +- [Ollama App](https://github.com/JHubi1/ollama-app) - Multi-platform client for desktop and mobile +- [PyGPT](https://github.com/szczyglis-dev/py-gpt) - AI desktop assistant for Linux, Windows, and Mac +- [Alpaca](https://github.com/Jeffser/Alpaca) - GTK4 client for Linux and macOS +- [SwiftChat](https://github.com/aws-samples/swift-chat) - Cross-platform including iOS, Android, and Apple Vision Pro +- [Enchanted](https://github.com/AugustDev/enchanted) - Native macOS and iOS client +- [RWKV-Runner](https://github.com/josStorer/RWKV-Runner) - Multi-model desktop runner +- [Ollama Grid Search](https://github.com/dezoito/ollama-grid-search) - Evaluate and compare models +- [macai](https://github.com/Renset/macai) - macOS client for Ollama and ChatGPT +- [AI Studio](https://github.com/MindWorkAI/AI-Studio) - Multi-provider desktop IDE +- [Reins](https://github.com/ibrahimcetin/reins) - Parameter tuning and reasoning model support +- [ConfiChat](https://github.com/1runeberg/confichat) - Privacy-focused with optional encryption +- [LLocal.in](https://github.com/kartikm7/llocal) - Electron desktop client +- [MindMac](https://mindmac.app) - AI chat client for Mac +- [Msty](https://msty.app) - Multi-model desktop client +- [BoltAI for Mac](https://boltai.com) - AI chat client for Mac +- [IntelliBar](https://intellibar.app/) - AI-powered assistant for macOS +- [Kerlig AI](https://www.kerlig.com/) - AI writing assistant for macOS +- [Hillnote](https://hillnote.com) - Markdown-first AI workspace +- [Perfect Memory AI](https://www.perfectmemory.ai/) - Productivity AI personalized by screen and meeting history + +#### Mobile + +- [Ollama Android Chat](https://github.com/sunshine0523/OllamaServer) - One-click Ollama on Android + +> SwiftChat, Enchanted, Maid, Ollama App, Reins, and ConfiChat listed above also support mobile platforms. + +### Code Editors & Development + +- [Cline](https://github.com/cline/cline) - VS Code extension for multi-file/whole-repo coding +- [Continue](https://github.com/continuedev/continue) - Open-source AI code assistant for any IDE +- [Void](https://github.com/voideditor/void) - Open source AI code editor, Cursor alternative +- [Copilot for Obsidian](https://github.com/logancyang/obsidian-copilot) - AI assistant for Obsidian +- [twinny](https://github.com/rjmacarthy/twinny) - Copilot and Copilot chat alternative +- [gptel Emacs client](https://github.com/karthink/gptel) - LLM client for Emacs +- [Ollama Copilot](https://github.com/bernardo-bruning/ollama-copilot) - Use Ollama as GitHub Copilot +- [Obsidian Local GPT](https://github.com/pfrankov/obsidian-local-gpt) - Local AI for Obsidian +- [Ellama Emacs client](https://github.com/s-kostyaev/ellama) - LLM tool for Emacs +- [orbiton](https://github.com/xyproto/orbiton) - Config-free text editor with Ollama tab completion +- [AI ST Completion](https://github.com/yaroslavyaroslav/OpenAI-sublime-text) - Sublime Text 4 AI assistant +- [VT Code](https://github.com/vinhnx/vtcode) - Rust-based terminal coding agent with Tree-sitter +- [QodeAssist](https://github.com/Palm1r/QodeAssist) - AI coding assistant for Qt Creator +- [AI Toolkit for VS Code](https://aka.ms/ai-tooklit/ollama-docs) - Microsoft-official VS Code extension +- [Open Interpreter](https://docs.openinterpreter.com/language-model-setup/local-models/ollama) - Natural language interface for computers + +### Libraries & SDKs + +- [LiteLLM](https://github.com/BerriAI/litellm) - Unified API for 100+ LLM providers +- [Semantic Kernel](https://github.com/microsoft/semantic-kernel/tree/main/python/semantic_kernel/connectors/ai/ollama) - Microsoft AI orchestration SDK +- [LangChain4j](https://github.com/langchain4j/langchain4j) - Java LangChain ([example](https://github.com/langchain4j/langchain4j-examples/tree/main/ollama-examples/src/main/java)) +- [LangChainGo](https://github.com/tmc/langchaingo/) - Go LangChain ([example](https://github.com/tmc/langchaingo/tree/main/examples/ollama-completion-example)) +- [Spring AI](https://github.com/spring-projects/spring-ai) - Spring framework AI support ([docs](https://docs.spring.io/spring-ai/reference/api/chat/ollama-chat.html)) +- [LangChain](https://python.langchain.com/docs/integrations/chat/ollama/) and [LangChain.js](https://js.langchain.com/docs/integrations/chat/ollama/) with [example](https://js.langchain.com/docs/tutorials/local_rag/) +- [Ollama for Ruby](https://github.com/crmne/ruby_llm) - Ruby LLM library +- [any-llm](https://github.com/mozilla-ai/any-llm) - Unified LLM interface by Mozilla +- [OllamaSharp for .NET](https://github.com/awaescher/OllamaSharp) - .NET SDK +- [LangChainRust](https://github.com/Abraxas-365/langchain-rust) - Rust LangChain ([example](https://github.com/Abraxas-365/langchain-rust/blob/main/examples/llm_ollama.rs)) +- [Agents-Flex for Java](https://github.com/agents-flex/agents-flex) - Java agent framework ([example](https://github.com/agents-flex/agents-flex/tree/main/agents-flex-llm/agents-flex-llm-ollama/src/test/java/com/agentsflex/llm/ollama)) +- [Elixir LangChain](https://github.com/brainlid/langchain) - Elixir LangChain +- [Ollama-rs for Rust](https://github.com/pepperoni21/ollama-rs) - Rust SDK +- [LangChain for .NET](https://github.com/tryAGI/LangChain) - .NET LangChain ([example](https://github.com/tryAGI/LangChain/blob/main/examples/LangChain.Samples.OpenAI/Program.cs)) +- [chromem-go](https://github.com/philippgille/chromem-go) - Go vector database with Ollama embeddings ([example](https://github.com/philippgille/chromem-go/tree/v0.5.0/examples/rag-wikipedia-ollama)) +- [LangChainDart](https://github.com/davidmigloz/langchain_dart) - Dart LangChain +- [LlmTornado](https://github.com/lofcz/llmtornado) - Unified C# interface for multiple inference APIs +- [Ollama4j for Java](https://github.com/ollama4j/ollama4j) - Java SDK +- [Ollama for Laravel](https://github.com/cloudstudio/ollama-laravel) - Laravel integration +- [Ollama for Swift](https://github.com/mattt/ollama-swift) - Swift SDK +- [LlamaIndex](https://docs.llamaindex.ai/en/stable/examples/llm/ollama/) and [LlamaIndexTS](https://ts.llamaindex.ai/modules/llms/available_llms/ollama) - Data framework for LLM apps +- [Haystack](https://github.com/deepset-ai/haystack-integrations/blob/main/integrations/ollama.md) - AI pipeline framework +- [Firebase Genkit](https://firebase.google.com/docs/genkit/plugins/ollama) - Google AI framework +- [Ollama-hpp for C++](https://github.com/jmont-dev/ollama-hpp) - C++ SDK +- [PromptingTools.jl](https://github.com/svilupp/PromptingTools.jl) - Julia LLM toolkit ([example](https://svilupp.github.io/PromptingTools.jl/dev/examples/working_with_ollama)) +- [Ollama for R - rollama](https://github.com/JBGruber/rollama) - R SDK +- [Portkey](https://portkey.ai/docs/welcome/integration-guides/ollama) - AI gateway +- [Testcontainers](https://testcontainers.com/modules/ollama/) - Container-based testing +- [LLPhant](https://github.com/theodo-group/LLPhant?tab=readme-ov-file#ollama) - PHP AI framework + +### Frameworks & Agents + +- [AutoGPT](https://github.com/Significant-Gravitas/AutoGPT/blob/master/docs/content/platform/ollama.md) - Autonomous AI agent platform +- [crewAI](https://github.com/crewAIInc/crewAI) - Multi-agent orchestration framework +- [Strands Agents](https://github.com/strands-agents/sdk-python) - Model-driven agent building by AWS +- [Cheshire Cat](https://github.com/cheshire-cat-ai/core) - AI assistant framework +- [any-agent](https://github.com/mozilla-ai/any-agent) - Unified agent framework interface by Mozilla +- [Stakpak](https://github.com/stakpak/agent) - Open source DevOps agent +- [Hexabot](https://github.com/hexastack/hexabot) - Conversational AI builder +- [Neuro SAN](https://github.com/cognizant-ai-lab/neuro-san-studio) - Multi-agent orchestration ([docs](https://github.com/cognizant-ai-lab/neuro-san-studio/blob/main/docs/user_guide.md#ollama)) + +### RAG & Knowledge Bases + +- [RAGFlow](https://github.com/infiniflow/ragflow) - RAG engine based on deep document understanding +- [R2R](https://github.com/SciPhi-AI/R2R) - Open-source RAG engine +- [MaxKB](https://github.com/1Panel-dev/MaxKB/) - Ready-to-use RAG chatbot +- [Minima](https://github.com/dmayboroda/minima) - On-premises or fully local RAG +- [Chipper](https://github.com/TilmanGriesel/chipper) - AI interface with Haystack RAG +- [ARGO](https://github.com/xark-argo/argo) - RAG and deep research on Mac/Windows/Linux +- [Archyve](https://github.com/nickthecook/archyve) - RAG-enabling document library +- [Casibase](https://casibase.org) - AI knowledge base with RAG and SSO +- [BrainSoup](https://www.nurgo-software.com/products/brainsoup) - Native client with RAG and multi-agent automation + +### Bots & Messaging + +- [LangBot](https://github.com/RockChinQ/LangBot) - Multi-platform messaging bots with agents and RAG +- [AstrBot](https://github.com/Soulter/AstrBot/) - Multi-platform chatbot with RAG and plugins +- [Discord-Ollama Chat Bot](https://github.com/kevinthedang/discord-ollama) - TypeScript Discord bot +- [Ollama Telegram Bot](https://github.com/ruecat/ollama-telegram) - Telegram bot +- [LLM Telegram Bot](https://github.com/innightwolfsleep/llm_telegram_bot) - Telegram bot for roleplay + +### Terminal & CLI + +- [aichat](https://github.com/sigoden/aichat) - All-in-one LLM CLI with Shell Assistant, RAG, and AI tools +- [oterm](https://github.com/ggozad/oterm) - Terminal client for Ollama +- [gollama](https://github.com/sammcj/gollama) - Go-based model manager for Ollama +- [tlm](https://github.com/yusufcanb/tlm) - Local shell copilot +- [tenere](https://github.com/pythops/tenere) - TUI for LLMs +- [ParLlama](https://github.com/paulrobello/parllama) - TUI for Ollama +- [llm-ollama](https://github.com/taketwo/llm-ollama) - Plugin for [Datasette's LLM CLI](https://llm.datasette.io/en/stable/) +- [ShellOracle](https://github.com/djcopley/ShellOracle) - Shell command suggestions +- [LLM-X](https://github.com/mrdjohnson/llm-x) - Progressive web app for LLMs +- [cmdh](https://github.com/pgibler/cmdh) - Natural language to shell commands +- [VT](https://github.com/vinhnx/vt.ai) - Minimal multimodal AI chat app + +### Productivity & Apps + +- [AppFlowy](https://github.com/AppFlowy-IO/AppFlowy) - AI collaborative workspace, self-hostable Notion alternative +- [Screenpipe](https://github.com/mediar-ai/screenpipe) - 24/7 screen and mic recording with AI-powered search +- [Vibe](https://github.com/thewh1teagle/vibe) - Transcribe and analyze meetings +- [Page Assist](https://github.com/n4ze3m/page-assist) - Chrome extension for AI-powered browsing +- [NativeMind](https://github.com/NativeMindBrowser/NativeMindExtension) - Private, on-device browser AI assistant +- [Ollama Fortress](https://github.com/ParisNeo/ollama_proxy_server) - Security proxy for Ollama +- [1Panel](https://github.com/1Panel-dev/1Panel/) - Web-based Linux server management +- [Writeopia](https://github.com/Writeopia/Writeopia) - Text editor with Ollama integration +- [QA-Pilot](https://github.com/reid41/QA-Pilot) - GitHub code repository understanding +- [Raycast extension](https://github.com/MassimilianoPasquini97/raycast_ollama) - Ollama in Raycast +- [Painting Droid](https://github.com/mateuszmigas/painting-droid) - Painting app with AI integrations +- [Serene Pub](https://github.com/doolijb/serene-pub) - AI roleplaying app +- [Mayan EDMS](https://gitlab.com/mayan-edms/mayan-edms) - Document management with Ollama workflows +- [TagSpaces](https://www.tagspaces.org) - File management with [AI tagging](https://docs.tagspaces.org/ai/) + +### Observability & Monitoring + +- [Opik](https://www.comet.com/docs/opik/cookbook/ollama) - Debug, evaluate, and monitor LLM applications +- [OpenLIT](https://github.com/openlit/openlit) - OpenTelemetry-native monitoring for Ollama and GPUs +- [Lunary](https://lunary.ai/docs/integrations/ollama) - LLM observability with analytics and PII masking +- [Langfuse](https://langfuse.com/docs/integrations/ollama) - Open source LLM observability +- [HoneyHive](https://docs.honeyhive.ai/integrations/ollama) - AI observability and evaluation for agents +- [MLflow Tracing](https://mlflow.org/docs/latest/llms/tracing/index.html#automatic-tracing) - Open source LLM observability + +### Database & Embeddings + +- [pgai](https://github.com/timescale/pgai) - PostgreSQL as a vector database ([guide](https://github.com/timescale/pgai/blob/main/docs/vectorizer-quick-start.md)) +- [MindsDB](https://github.com/mindsdb/mindsdb/blob/staging/mindsdb/integrations/handlers/ollama_handler/README.md) - Connect Ollama with 200+ data platforms +- [chromem-go](https://github.com/philippgille/chromem-go/blob/v0.5.0/embed_ollama.go) - Embeddable vector database for Go ([example](https://github.com/philippgille/chromem-go/tree/v0.5.0/examples/rag-wikipedia-ollama)) +- [Kangaroo](https://github.com/dbkangaroo/kangaroo) - AI-powered SQL client + +### Infrastructure & Deployment + +#### Cloud + +- [Google Cloud](https://cloud.google.com/run/docs/tutorials/gpu-gemma2-with-ollama) +- [Fly.io](https://fly.io/docs/python/do-more/add-ollama/) +- [Koyeb](https://www.koyeb.com/deploy/ollama) +- [Harbor](https://github.com/av/harbor) - Containerized LLM toolkit with Ollama as default backend + +#### Package Managers + +- [Pacman](https://archlinux.org/packages/extra/x86_64/ollama/) +- [Homebrew](https://formulae.brew.sh/formula/ollama) +- [Nix package](https://search.nixos.org/packages?show=ollama&from=0&size=50&sort=relevance&type=packages&query=ollama) +- [Helm Chart](https://artifacthub.io/packages/helm/ollama-helm/ollama) +- [Gentoo](https://github.com/gentoo/guru/tree/master/app-misc/ollama) +- [Flox](https://flox.dev/blog/ollama-part-one) +- [Guix channel](https://codeberg.org/tusharhero/ollama-guix) diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..43fe310 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,25 @@ +# Security + +The Ollama maintainer team takes security seriously and will actively work to resolve security issues. + +## Reporting a vulnerability + +If you discover a security vulnerability, please do not open a public issue. Instead, please report it by emailing hello@ollama.com. We ask that you give us sufficient time to investigate and address the vulnerability before disclosing it publicly. + +Please include the following details in your report: +- A description of the vulnerability +- Steps to reproduce the issue +- Your assessment of the potential impact +- Any possible mitigations + +## Security best practices + +While the maintainer team does its best to secure Ollama, users are encouraged to implement their own security best practices, such as: + +- Regularly updating to the latest version of Ollama +- Securing access to hosted instances of Ollama +- Monitoring systems for unusual activity + +## Contact + +For any other questions or concerns related to security, please contact us at hello@ollama.com diff --git a/anthropic/anthropic.go b/anthropic/anthropic.go new file mode 100755 index 0000000..46394cd --- /dev/null +++ b/anthropic/anthropic.go @@ -0,0 +1,1267 @@ +package anthropic + +import ( + "bytes" + "context" + "crypto/rand" + "encoding/base64" + "encoding/json" + "errors" + "fmt" + "io" + "log/slog" + "net/http" + "net/url" + "strconv" + "strings" + "time" + + "github.com/ollama/ollama/api" + "github.com/ollama/ollama/auth" + internalcloud "github.com/ollama/ollama/internal/cloud" + "github.com/ollama/ollama/logutil" +) + +// Error types matching Anthropic API +type Error struct { + Type string `json:"type"` + Message string `json:"message"` +} + +type ErrorResponse struct { + Type string `json:"type"` // always "error" + Error Error `json:"error"` + RequestID string `json:"request_id,omitempty"` +} + +// NewError creates a new ErrorResponse with the appropriate error type based on HTTP status code +func NewError(code int, message string) ErrorResponse { + var etype string + switch code { + case http.StatusBadRequest: + etype = "invalid_request_error" + case http.StatusUnauthorized: + etype = "authentication_error" + case http.StatusForbidden: + etype = "permission_error" + case http.StatusNotFound: + etype = "not_found_error" + case http.StatusTooManyRequests: + etype = "rate_limit_error" + case http.StatusServiceUnavailable, 529: + etype = "overloaded_error" + default: + etype = "api_error" + } + + return ErrorResponse{ + Type: "error", + Error: Error{Type: etype, Message: message}, + RequestID: generateID("req"), + } +} + +// Request types + +// MessagesRequest represents an Anthropic Messages API request +type MessagesRequest struct { + Model string `json:"model"` + MaxTokens int `json:"max_tokens"` + Messages []MessageParam `json:"messages"` + System any `json:"system,omitempty"` // string or []map[string]any (JSON-decoded ContentBlock) + Stream bool `json:"stream,omitempty"` + Temperature *float64 `json:"temperature,omitempty"` + TopP *float64 `json:"top_p,omitempty"` + TopK *int `json:"top_k,omitempty"` + StopSequences []string `json:"stop_sequences,omitempty"` + Tools []Tool `json:"tools,omitempty"` + ToolChoice *ToolChoice `json:"tool_choice,omitempty"` + Thinking *ThinkingConfig `json:"thinking,omitempty"` + Metadata *Metadata `json:"metadata,omitempty"` + OutputConfig *OutputConfig `json:"output_config,omitempty"` +} + +type OutputConfig struct { + Effort string `json:"effort,omitempty"` +} + +// MessageParam represents a message in the request +type MessageParam struct { + Role string `json:"role"` // "user" or "assistant" + Content []ContentBlock `json:"content"` // always []ContentBlock; plain strings are normalized on unmarshal +} + +func (m *MessageParam) UnmarshalJSON(data []byte) error { + var raw struct { + Role string `json:"role"` + Content json.RawMessage `json:"content"` + } + if err := json.Unmarshal(data, &raw); err != nil { + return err + } + m.Role = raw.Role + + var s string + if err := json.Unmarshal(raw.Content, &s); err == nil { + m.Content = []ContentBlock{{Type: "text", Text: &s}} + return nil + } + + return json.Unmarshal(raw.Content, &m.Content) +} + +// ContentBlock represents a content block in a message. +// Text and Thinking use pointers so they serialize as the field being present (even if empty) +// only when set, which is required for SDK streaming accumulation. +type ContentBlock struct { + Type string `json:"type"` // text, image, tool_use, tool_result, thinking, server_tool_use, web_search_tool_result + + // For text blocks - pointer so field only appears when set (SDK requires it for accumulation) + Text *string `json:"text,omitempty"` + + // For text blocks with citations + Citations []Citation `json:"citations,omitempty"` + + // For image blocks + Source *ImageSource `json:"source,omitempty"` + + // For tool_use and server_tool_use blocks + ID string `json:"id,omitempty"` + Name string `json:"name,omitempty"` + Input api.ToolCallFunctionArguments `json:"input,omitzero"` + + // For tool_result and web_search_tool_result blocks + ToolUseID string `json:"tool_use_id,omitempty"` + Content any `json:"content,omitempty"` // string, []ContentBlock, []WebSearchResult, or WebSearchToolResultError + IsError bool `json:"is_error,omitempty"` + + // For thinking blocks - pointer so field only appears when set (SDK requires it for accumulation) + Thinking *string `json:"thinking,omitempty"` + Signature string `json:"signature,omitempty"` +} + +// Citation represents a citation in a text block +type Citation struct { + Type string `json:"type"` // "web_search_result_location" + URL string `json:"url"` + Title string `json:"title"` + EncryptedIndex string `json:"encrypted_index,omitempty"` + CitedText string `json:"cited_text,omitempty"` +} + +// WebSearchResult represents a single web search result +type WebSearchResult struct { + Type string `json:"type"` // "web_search_result" + URL string `json:"url"` + Title string `json:"title"` + EncryptedContent string `json:"encrypted_content,omitempty"` + PageAge string `json:"page_age,omitempty"` +} + +// WebSearchToolResultError represents an error from web search +type WebSearchToolResultError struct { + Type string `json:"type"` // "web_search_tool_result_error" + ErrorCode string `json:"error_code"` +} + +// ImageSource represents the source of an image +type ImageSource struct { + Type string `json:"type"` // "base64" + MediaType string `json:"media_type,omitempty"` + Data string `json:"data,omitempty"` + URL string `json:"url,omitempty"` +} + +// Tool represents a tool definition +type Tool struct { + Type string `json:"type,omitempty"` // "custom" for user-defined tools, or "web_search_20250305" for web search + Name string `json:"name"` + Description string `json:"description,omitempty"` + InputSchema json.RawMessage `json:"input_schema,omitempty"` + + // Web search specific fields + MaxUses int `json:"max_uses,omitempty"` +} + +// ToolChoice controls how the model uses tools +type ToolChoice struct { + Type string `json:"type"` // "auto", "any", "tool", "none" + Name string `json:"name,omitempty"` + DisableParallelToolUse bool `json:"disable_parallel_tool_use,omitempty"` +} + +// ThinkingConfig controls extended thinking +type ThinkingConfig struct { + Type string `json:"type"` // "enabled" or "disabled" + BudgetTokens int `json:"budget_tokens,omitempty"` +} + +// Metadata for the request +type Metadata struct { + UserID string `json:"user_id,omitempty"` +} + +// Response types + +// MessagesResponse represents an Anthropic Messages API response +type MessagesResponse struct { + ID string `json:"id"` + Type string `json:"type"` // "message" + Role string `json:"role"` // "assistant" + Model string `json:"model"` + Content []ContentBlock `json:"content"` + StopReason string `json:"stop_reason,omitempty"` + StopSequence string `json:"stop_sequence,omitempty"` + Usage Usage `json:"usage"` +} + +// Usage contains token usage information +type Usage struct { + InputTokens int `json:"input_tokens"` + OutputTokens int `json:"output_tokens"` +} + +// Streaming event types + +// MessageStartEvent is sent at the start of streaming +type MessageStartEvent struct { + Type string `json:"type"` // "message_start" + Message MessagesResponse `json:"message"` +} + +// ContentBlockStartEvent signals the start of a content block +type ContentBlockStartEvent struct { + Type string `json:"type"` // "content_block_start" + Index int `json:"index"` + ContentBlock ContentBlock `json:"content_block"` +} + +// ContentBlockDeltaEvent contains incremental content updates +type ContentBlockDeltaEvent struct { + Type string `json:"type"` // "content_block_delta" + Index int `json:"index"` + Delta Delta `json:"delta"` +} + +// Delta represents an incremental update +type Delta struct { + Type string `json:"type"` // "text_delta", "input_json_delta", "thinking_delta", "signature_delta" + Text string `json:"text,omitempty"` + PartialJSON string `json:"partial_json,omitempty"` + Thinking string `json:"thinking,omitempty"` + Signature string `json:"signature,omitempty"` +} + +// ContentBlockStopEvent signals the end of a content block +type ContentBlockStopEvent struct { + Type string `json:"type"` // "content_block_stop" + Index int `json:"index"` +} + +// MessageDeltaEvent contains updates to the message +type MessageDeltaEvent struct { + Type string `json:"type"` // "message_delta" + Delta MessageDelta `json:"delta"` + Usage DeltaUsage `json:"usage"` +} + +// MessageDelta contains stop information +type MessageDelta struct { + StopReason string `json:"stop_reason,omitempty"` + StopSequence string `json:"stop_sequence,omitempty"` +} + +// DeltaUsage contains cumulative token usage +type DeltaUsage struct { + InputTokens int `json:"input_tokens"` + OutputTokens int `json:"output_tokens"` +} + +// MessageStopEvent signals the end of the message +type MessageStopEvent struct { + Type string `json:"type"` // "message_stop" +} + +// PingEvent is a keepalive event +type PingEvent struct { + Type string `json:"type"` // "ping" +} + +// StreamErrorEvent is an error during streaming +type StreamErrorEvent struct { + Type string `json:"type"` // "error" + Error Error `json:"error"` +} + +// FromMessagesRequest converts an Anthropic MessagesRequest to an Ollama api.ChatRequest +func FromMessagesRequest(r MessagesRequest) (*api.ChatRequest, error) { + logutil.Trace("anthropic: converting request", "req", TraceMessagesRequest(r)) + + var messages []api.Message + + if r.System != nil { + switch sys := r.System.(type) { + case string: + if sys != "" { + messages = append(messages, api.Message{Role: "system", Content: sys}) + } + case []any: + // System can be an array of content blocks + var content strings.Builder + for _, block := range sys { + if blockMap, ok := block.(map[string]any); ok { + if blockMap["type"] == "text" { + if text, ok := blockMap["text"].(string); ok { + content.WriteString(text) + } + } + } + } + if content.Len() > 0 { + messages = append(messages, api.Message{Role: "system", Content: content.String()}) + } + } + } + + for i, msg := range r.Messages { + converted, err := convertMessage(msg) + if err != nil { + logutil.Trace("anthropic: message conversion failed", "index", i, "role", msg.Role, "err", err) + return nil, err + } + messages = append(messages, converted...) + } + + options := make(map[string]any) + + options["num_predict"] = r.MaxTokens + + if r.Temperature != nil { + options["temperature"] = *r.Temperature + } + + if r.TopP != nil { + options["top_p"] = *r.TopP + } + + if r.TopK != nil { + options["top_k"] = *r.TopK + } + + if len(r.StopSequences) > 0 { + options["stop"] = r.StopSequences + } + + var tools api.Tools + hasBuiltinWebSearch := false + for _, t := range r.Tools { + if strings.HasPrefix(t.Type, "web_search") { + hasBuiltinWebSearch = true + break + } + } + + for _, t := range r.Tools { + // Anthropic built-in web_search maps to Ollama function name "web_search". + // If a user-defined tool also uses that name in the same request, drop the + // user-defined one to avoid ambiguous tool-call routing. + if hasBuiltinWebSearch && !strings.HasPrefix(t.Type, "web_search") && t.Name == "web_search" { + logutil.Trace("anthropic: dropping colliding custom web_search tool", "tool", TraceTool(t)) + continue + } + + tool, _, err := convertTool(t) + if err != nil { + return nil, err + } + tools = append(tools, tool) + } + + var think *api.ThinkValue + normalizedEffort := "" + if r.OutputConfig != nil { + normalizedEffort = strings.ToLower(strings.TrimSpace(r.OutputConfig.Effort)) + if normalizedEffort == "xhigh" { + normalizedEffort = "high" + } + } + + if r.Thinking != nil && r.Thinking.Type == "enabled" { + think = &api.ThinkValue{Value: true} + } + if r.Thinking != nil && r.Thinking.Type == "disabled" { + think = &api.ThinkValue{Value: false} + } + if think == nil && r.OutputConfig != nil { + switch normalizedEffort { + case "high", "medium", "low", "max": + think = &api.ThinkValue{Value: normalizedEffort} + } + } + + stream := r.Stream + convertedRequest := &api.ChatRequest{ + Model: r.Model, + Messages: messages, + Options: options, + Stream: &stream, + Tools: tools, + Think: think, + } + logutil.Trace("anthropic: converted request", "req", TraceChatRequest(convertedRequest)) + + return convertedRequest, nil +} + +// convertMessage converts an Anthropic MessageParam to Ollama api.Message(s) +func convertMessage(msg MessageParam) ([]api.Message, error) { + var messages []api.Message + role := strings.ToLower(msg.Role) + + var textContent strings.Builder + var images []api.ImageData + var toolCalls []api.ToolCall + var thinking string + var toolResults []api.Message + textBlocks := 0 + imageBlocks := 0 + toolUseBlocks := 0 + toolResultBlocks := 0 + serverToolUseBlocks := 0 + webSearchToolResultBlocks := 0 + thinkingBlocks := 0 + unknownBlocks := 0 + + for _, block := range msg.Content { + switch block.Type { + case "text": + textBlocks++ + if block.Text != nil { + textContent.WriteString(*block.Text) + } + + case "image": + imageBlocks++ + if block.Source == nil { + logutil.Trace("anthropic: invalid image source", "role", role) + return nil, errors.New("invalid image source") + } + + decoded, err := resolveImageSource(block.Source) + if err != nil { + logutil.Trace("anthropic: unsupported image source", "role", role, "source_type", block.Source.Type, "error", err) + return nil, err + } + images = append(images, decoded) + + case "tool_use": + toolUseBlocks++ + if block.ID == "" { + logutil.Trace("anthropic: tool_use block missing id", "role", role) + return nil, errors.New("tool_use block missing required 'id' field") + } + if block.Name == "" { + logutil.Trace("anthropic: tool_use block missing name", "role", role) + return nil, errors.New("tool_use block missing required 'name' field") + } + toolCalls = append(toolCalls, api.ToolCall{ + ID: block.ID, + Function: api.ToolCallFunction{ + Name: block.Name, + Arguments: block.Input, + }, + }) + + case "tool_result": + toolResultBlocks++ + resultContent, resultImages, err := convertToolResultContent(block.Content) + if err != nil { + logutil.Trace("anthropic: invalid tool_result content", "role", role, "error", err) + return nil, err + } + + toolResults = append(toolResults, api.Message{ + Role: "tool", + Content: resultContent, + Images: resultImages, + ToolCallID: block.ToolUseID, + }) + + case "thinking": + thinkingBlocks++ + if block.Thinking != nil { + thinking = *block.Thinking + } + + case "server_tool_use": + serverToolUseBlocks++ + toolCalls = append(toolCalls, api.ToolCall{ + ID: block.ID, + Function: api.ToolCallFunction{ + Name: block.Name, + Arguments: block.Input, + }, + }) + + case "web_search_tool_result": + webSearchToolResultBlocks++ + toolResults = append(toolResults, api.Message{ + Role: "tool", + Content: formatWebSearchToolResultContent(block.Content), + ToolCallID: block.ToolUseID, + }) + default: + unknownBlocks++ + } + } + + if role == "user" && len(toolResults) > 0 { + messages = append(messages, toolResults...) + } + + if textContent.Len() > 0 || len(images) > 0 || len(toolCalls) > 0 || thinking != "" { + m := api.Message{ + Role: role, + Content: textContent.String(), + Images: images, + ToolCalls: toolCalls, + Thinking: thinking, + } + messages = append(messages, m) + } + + // Add tool results as separate messages. + if role != "user" || len(toolResults) == 0 { + messages = append(messages, toolResults...) + } + logutil.Trace("anthropic: converted block message", + "role", role, + "blocks", len(msg.Content), + "text", textBlocks, + "image", imageBlocks, + "tool_use", toolUseBlocks, + "tool_result", toolResultBlocks, + "server_tool_use", serverToolUseBlocks, + "web_search_result", webSearchToolResultBlocks, + "thinking", thinkingBlocks, + "unknown", unknownBlocks, + "messages", TraceAPIMessages(messages), + ) + + return messages, nil +} + +func formatWebSearchToolResultContent(content any) string { + switch c := content.(type) { + case string: + return c + case []WebSearchResult: + var resultContent strings.Builder + for _, item := range c { + if item.Type != "web_search_result" { + continue + } + fmt.Fprintf(&resultContent, "- %s: %s\n", item.Title, item.URL) + } + return resultContent.String() + case []any: + var resultContent strings.Builder + for _, item := range c { + itemMap, ok := item.(map[string]any) + if !ok { + continue + } + switch itemMap["type"] { + case "web_search_result": + title, _ := itemMap["title"].(string) + url, _ := itemMap["url"].(string) + fmt.Fprintf(&resultContent, "- %s: %s\n", title, url) + case "web_search_tool_result_error": + errorCode, _ := itemMap["error_code"].(string) + if errorCode == "" { + return "web_search_tool_result_error" + } + return "web_search_tool_result_error: " + errorCode + } + } + return resultContent.String() + case map[string]any: + if c["type"] == "web_search_tool_result_error" { + errorCode, _ := c["error_code"].(string) + if errorCode == "" { + return "web_search_tool_result_error" + } + return "web_search_tool_result_error: " + errorCode + } + data, err := json.Marshal(c) + if err != nil { + return "" + } + return string(data) + case WebSearchToolResultError: + if c.ErrorCode == "" { + return "web_search_tool_result_error" + } + return "web_search_tool_result_error: " + c.ErrorCode + default: + data, err := json.Marshal(c) + if err != nil { + return "" + } + return string(data) + } +} + +// convertTool converts an Anthropic Tool to an Ollama api.Tool, returning true if it's a server tool +func convertTool(t Tool) (api.Tool, bool, error) { + if strings.HasPrefix(t.Type, "web_search") { + props := api.NewToolPropertiesMap() + props.Set("query", api.ToolProperty{ + Type: api.PropertyType{"string"}, + Description: "The search query to look up on the web", + }) + return api.Tool{ + Type: "function", + Function: api.ToolFunction{ + Name: "web_search", + Description: "Search the web for current information. Use this to find up-to-date information about any topic.", + Parameters: api.ToolFunctionParameters{ + Type: "object", + Required: []string{"query"}, + Properties: props, + }, + }, + }, true, nil + } + + var params api.ToolFunctionParameters + if len(t.InputSchema) > 0 { + if err := json.Unmarshal(t.InputSchema, ¶ms); err != nil { + logutil.Trace("anthropic: invalid tool schema", "tool", t.Name, "err", err) + return api.Tool{}, false, fmt.Errorf("invalid input_schema for tool %q: %w", t.Name, err) + } + } + + return api.Tool{ + Type: "function", + Function: api.ToolFunction{ + Name: t.Name, + Description: t.Description, + Parameters: params, + }, + }, false, nil +} + +// ToMessagesResponse converts an Ollama api.ChatResponse to an Anthropic MessagesResponse +func ToMessagesResponse(id string, r api.ChatResponse) MessagesResponse { + var content []ContentBlock + + if r.Message.Thinking != "" { + content = append(content, ContentBlock{ + Type: "thinking", + Thinking: ptr(r.Message.Thinking), + }) + } + + if r.Message.Content != "" { + content = append(content, ContentBlock{ + Type: "text", + Text: ptr(r.Message.Content), + }) + } + + for _, tc := range r.Message.ToolCalls { + content = append(content, ContentBlock{ + Type: "tool_use", + ID: tc.ID, + Name: tc.Function.Name, + Input: tc.Function.Arguments, + }) + } + + stopReason := mapStopReason(r.DoneReason, len(r.Message.ToolCalls) > 0) + + return MessagesResponse{ + ID: id, + Type: "message", + Role: "assistant", + Model: r.Model, + Content: content, + StopReason: stopReason, + Usage: Usage{ + InputTokens: r.Metrics.PromptEvalCount, + OutputTokens: r.Metrics.EvalCount, + }, + } +} + +// mapStopReason converts Ollama done_reason to Anthropic stop_reason +func mapStopReason(reason string, hasToolCalls bool) string { + if hasToolCalls { + return "tool_use" + } + + switch reason { + case "stop": + return "end_turn" + case "length": + return "max_tokens" + default: + if reason != "" { + return "stop_sequence" + } + return "" + } +} + +// StreamConverter manages state for converting Ollama streaming responses to Anthropic format +type StreamConverter struct { + ID string + Model string + firstWrite bool + contentIndex int + inputTokens int + outputTokens int + estimatedInputTokens int // Estimated tokens from request (used when actual metrics are 0) + thinkingStarted bool + thinkingDone bool + textStarted bool + toolCallsSent map[string]bool +} + +func NewStreamConverter(id, model string, estimatedInputTokens int) *StreamConverter { + return &StreamConverter{ + ID: id, + Model: model, + firstWrite: true, + estimatedInputTokens: estimatedInputTokens, + toolCallsSent: make(map[string]bool), + } +} + +// StreamEvent represents a streaming event to be sent to the client +type StreamEvent struct { + Event string + Data any +} + +// Process converts an Ollama ChatResponse to Anthropic streaming events +func (c *StreamConverter) Process(r api.ChatResponse) []StreamEvent { + var events []StreamEvent + + if c.firstWrite { + c.firstWrite = false + // Use actual metrics if available, otherwise use estimate + c.inputTokens = r.Metrics.PromptEvalCount + if c.inputTokens == 0 && c.estimatedInputTokens > 0 { + c.inputTokens = c.estimatedInputTokens + } + + events = append(events, StreamEvent{ + Event: "message_start", + Data: MessageStartEvent{ + Type: "message_start", + Message: MessagesResponse{ + ID: c.ID, + Type: "message", + Role: "assistant", + Model: c.Model, + Content: []ContentBlock{}, + Usage: Usage{ + InputTokens: c.inputTokens, + OutputTokens: 0, + }, + }, + }, + }) + } + + if r.Message.Thinking != "" && !c.thinkingDone { + if !c.thinkingStarted { + c.thinkingStarted = true + events = append(events, StreamEvent{ + Event: "content_block_start", + Data: ContentBlockStartEvent{ + Type: "content_block_start", + Index: c.contentIndex, + ContentBlock: ContentBlock{ + Type: "thinking", + Thinking: ptr(""), + }, + }, + }) + } + + events = append(events, StreamEvent{ + Event: "content_block_delta", + Data: ContentBlockDeltaEvent{ + Type: "content_block_delta", + Index: c.contentIndex, + Delta: Delta{ + Type: "thinking_delta", + Thinking: r.Message.Thinking, + }, + }, + }) + } + + if r.Message.Content != "" { + if c.thinkingStarted && !c.thinkingDone { + c.thinkingDone = true + events = append(events, StreamEvent{ + Event: "content_block_stop", + Data: ContentBlockStopEvent{ + Type: "content_block_stop", + Index: c.contentIndex, + }, + }) + c.contentIndex++ + } + + if !c.textStarted { + c.textStarted = true + events = append(events, StreamEvent{ + Event: "content_block_start", + Data: ContentBlockStartEvent{ + Type: "content_block_start", + Index: c.contentIndex, + ContentBlock: ContentBlock{ + Type: "text", + Text: ptr(""), + }, + }, + }) + } + + events = append(events, StreamEvent{ + Event: "content_block_delta", + Data: ContentBlockDeltaEvent{ + Type: "content_block_delta", + Index: c.contentIndex, + Delta: Delta{ + Type: "text_delta", + Text: r.Message.Content, + }, + }, + }) + } + + for _, tc := range r.Message.ToolCalls { + if c.toolCallsSent[tc.ID] { + continue + } + + // Close thinking block if still open (thinking → tool_use without text in between) + if c.thinkingStarted && !c.thinkingDone { + c.thinkingDone = true + events = append(events, StreamEvent{ + Event: "content_block_stop", + Data: ContentBlockStopEvent{ + Type: "content_block_stop", + Index: c.contentIndex, + }, + }) + c.contentIndex++ + } + + if c.textStarted { + events = append(events, StreamEvent{ + Event: "content_block_stop", + Data: ContentBlockStopEvent{ + Type: "content_block_stop", + Index: c.contentIndex, + }, + }) + c.contentIndex++ + c.textStarted = false + } + + argsJSON, err := json.Marshal(tc.Function.Arguments) + if err != nil { + slog.Error("failed to marshal tool arguments", "error", err, "tool_id", tc.ID) + continue + } + events = append(events, StreamEvent{ + Event: "content_block_start", + Data: ContentBlockStartEvent{ + Type: "content_block_start", + Index: c.contentIndex, + ContentBlock: ContentBlock{ + Type: "tool_use", + ID: tc.ID, + Name: tc.Function.Name, + Input: api.NewToolCallFunctionArguments(), + }, + }, + }) + + events = append(events, StreamEvent{ + Event: "content_block_delta", + Data: ContentBlockDeltaEvent{ + Type: "content_block_delta", + Index: c.contentIndex, + Delta: Delta{ + Type: "input_json_delta", + PartialJSON: string(argsJSON), + }, + }, + }) + + events = append(events, StreamEvent{ + Event: "content_block_stop", + Data: ContentBlockStopEvent{ + Type: "content_block_stop", + Index: c.contentIndex, + }, + }) + + c.toolCallsSent[tc.ID] = true + c.contentIndex++ + } + + if r.Done { + if c.textStarted { + events = append(events, StreamEvent{ + Event: "content_block_stop", + Data: ContentBlockStopEvent{ + Type: "content_block_stop", + Index: c.contentIndex, + }, + }) + } else if c.thinkingStarted && !c.thinkingDone { + events = append(events, StreamEvent{ + Event: "content_block_stop", + Data: ContentBlockStopEvent{ + Type: "content_block_stop", + Index: c.contentIndex, + }, + }) + } + + c.inputTokens = r.Metrics.PromptEvalCount + c.outputTokens = r.Metrics.EvalCount + stopReason := mapStopReason(r.DoneReason, len(c.toolCallsSent) > 0) + + events = append(events, StreamEvent{ + Event: "message_delta", + Data: MessageDeltaEvent{ + Type: "message_delta", + Delta: MessageDelta{ + StopReason: stopReason, + }, + Usage: DeltaUsage{ + InputTokens: c.inputTokens, + OutputTokens: c.outputTokens, + }, + }, + }) + + events = append(events, StreamEvent{ + Event: "message_stop", + Data: MessageStopEvent{ + Type: "message_stop", + }, + }) + } + + return events +} + +// generateID generates a unique ID with the given prefix using crypto/rand +func generateID(prefix string) string { + b := make([]byte, 12) + if _, err := rand.Read(b); err != nil { + // Fallback to time-based ID if crypto/rand fails + return fmt.Sprintf("%s_%d", prefix, time.Now().UnixNano()) + } + return fmt.Sprintf("%s_%x", prefix, b) +} + +// GenerateMessageID generates a unique message ID +func GenerateMessageID() string { + return generateID("msg") +} + +func resolveImageSource(source *ImageSource) (api.ImageData, error) { + if source.Type != "base64" { + return nil, fmt.Errorf("invalid image source type: %s. Only base64 images are supported.", source.Type) + } + + decoded, err := base64.StdEncoding.DecodeString(source.Data) + if err != nil { + return nil, fmt.Errorf("invalid base64 image data: %w", err) + } + + return decoded, nil +} + +func convertToolResultContent(content any) (string, []api.ImageData, error) { + switch c := content.(type) { + case nil: + return "", nil, nil + case string: + return c, nil, nil + case []any: + var text strings.Builder + var images []api.ImageData + + for _, cb := range c { + cbMap, ok := cb.(map[string]any) + if !ok { + continue + } + + switch cbMap["type"] { + case "text": + if t, ok := cbMap["text"].(string); ok { + text.WriteString(t) + } + case "image": + rawSource, ok := cbMap["source"].(map[string]any) + if !ok { + return "", nil, errors.New("invalid tool_result image source") + } + + var source ImageSource + if rawType, ok := rawSource["type"].(string); ok { + source.Type = rawType + } + if rawMediaType, ok := rawSource["media_type"].(string); ok { + source.MediaType = rawMediaType + } + if rawData, ok := rawSource["data"].(string); ok { + source.Data = rawData + } + + img, err := resolveImageSource(&source) + if err != nil { + return "", nil, err + } + images = append(images, img) + } + } + + return text.String(), images, nil + default: + return "", nil, nil + } +} + +// ptr returns a pointer to the given string value +func ptr(s string) *string { + return &s +} + +// CountTokensRequest represents an Anthropic count_tokens request +type CountTokensRequest struct { + Model string `json:"model"` + Messages []MessageParam `json:"messages"` + System any `json:"system,omitempty"` + Tools []Tool `json:"tools,omitempty"` + Thinking *ThinkingConfig `json:"thinking,omitempty"` +} + +// EstimateInputTokens estimates input tokens from a MessagesRequest (reuses CountTokensRequest logic) +func EstimateInputTokens(req MessagesRequest) int { + return estimateTokens(CountTokensRequest{ + Model: req.Model, + Messages: req.Messages, + System: req.System, + Tools: req.Tools, + Thinking: req.Thinking, + }) +} + +// CountTokensResponse represents an Anthropic count_tokens response +type CountTokensResponse struct { + InputTokens int `json:"input_tokens"` +} + +// estimateTokens returns a rough estimate of tokens (len/4). +// TODO: Replace with actual tokenization via Tokenize API for accuracy. +// Current len/4 heuristic is a rough approximation (~4 chars/token average). +func estimateTokens(req CountTokensRequest) int { + var totalLen int + + // Count system prompt + totalLen += countAnyContent(req.System) + + for _, msg := range req.Messages { + // Count role (always present) + totalLen += len(msg.Role) + // Count content + totalLen += countAnyContent(msg.Content) + } + + for _, tool := range req.Tools { + totalLen += len(tool.Name) + len(tool.Description) + len(tool.InputSchema) + } + + // Return len/4 as rough token estimate, minimum 1 if there's any content + tokens := totalLen / 4 + if tokens == 0 && (len(req.Messages) > 0 || req.System != nil) { + tokens = 1 + } + return tokens +} + +func countAnyContent(content any) int { + if content == nil { + return 0 + } + + switch c := content.(type) { + case string: + return len(c) + case []ContentBlock: + total := 0 + for _, block := range c { + total += countContentBlock(block) + } + return total + case []any: + total := 0 + for _, item := range c { + data, err := json.Marshal(item) + if err != nil { + continue + } + var block ContentBlock + if err := json.Unmarshal(data, &block); err == nil { + total += countContentBlock(block) + } + } + return total + default: + if data, err := json.Marshal(content); err == nil { + return len(data) + } + return 0 + } +} + +func countContentBlock(block ContentBlock) int { + total := 0 + if block.Text != nil { + total += len(*block.Text) + } + if block.Thinking != nil { + total += len(*block.Thinking) + } + if block.Type == "tool_use" || block.Type == "tool_result" { + if data, err := json.Marshal(block); err == nil { + total += len(data) + } + } + return total +} + +// OllamaWebSearchRequest represents a request to the Ollama web search API +type OllamaWebSearchRequest struct { + Query string `json:"query"` + MaxResults int `json:"max_results,omitempty"` +} + +// OllamaWebSearchResult represents a single search result from Ollama API +type OllamaWebSearchResult struct { + Title string `json:"title"` + URL string `json:"url"` + Content string `json:"content"` +} + +// OllamaWebSearchResponse represents the response from the Ollama web search API +type OllamaWebSearchResponse struct { + Results []OllamaWebSearchResult `json:"results"` +} + +var WebSearchEndpoint = "https://ollama.com/api/web_search" + +func WebSearch(ctx context.Context, query string, maxResults int) (*OllamaWebSearchResponse, error) { + if internalcloud.Disabled() { + logutil.TraceContext(ctx, "anthropic: web search blocked", "reason", "cloud_disabled") + return nil, errors.New(internalcloud.DisabledError("web search is unavailable")) + } + + if maxResults <= 0 { + maxResults = 5 + } + if maxResults > 10 { + maxResults = 10 + } + + reqBody := OllamaWebSearchRequest{ + Query: query, + MaxResults: maxResults, + } + + body, err := json.Marshal(reqBody) + if err != nil { + return nil, fmt.Errorf("failed to marshal web search request: %w", err) + } + + searchURL, err := url.Parse(WebSearchEndpoint) + if err != nil { + return nil, fmt.Errorf("failed to parse web search URL: %w", err) + } + logutil.TraceContext(ctx, "anthropic: web search request", + "query", TraceTruncateString(query), + "max_results", maxResults, + "url", searchURL.String(), + ) + + q := searchURL.Query() + q.Set("ts", strconv.FormatInt(time.Now().Unix(), 10)) + searchURL.RawQuery = q.Encode() + + signature := "" + if strings.EqualFold(searchURL.Hostname(), "ollama.com") { + challenge := fmt.Sprintf("%s,%s", http.MethodPost, searchURL.RequestURI()) + signature, err = auth.Sign(ctx, []byte(challenge)) + if err != nil { + return nil, fmt.Errorf("failed to sign web search request: %w", err) + } + } + logutil.TraceContext(ctx, "anthropic: web search auth", "signed", signature != "") + + req, err := http.NewRequestWithContext(ctx, "POST", searchURL.String(), bytes.NewReader(body)) + if err != nil { + return nil, fmt.Errorf("failed to create web search request: %w", err) + } + + req.Header.Set("Content-Type", "application/json") + if signature != "" { + req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", signature)) + } + + resp, err := http.DefaultClient.Do(req) + if err != nil { + return nil, fmt.Errorf("web search request failed: %w", err) + } + defer resp.Body.Close() + logutil.TraceContext(ctx, "anthropic: web search response", "status", resp.StatusCode) + + if resp.StatusCode != http.StatusOK { + respBody, _ := io.ReadAll(resp.Body) + return nil, fmt.Errorf("web search returned status %d: %s", resp.StatusCode, string(respBody)) + } + + var searchResp OllamaWebSearchResponse + if err := json.NewDecoder(resp.Body).Decode(&searchResp); err != nil { + return nil, fmt.Errorf("failed to decode web search response: %w", err) + } + logutil.TraceContext(ctx, "anthropic: web search results", "count", len(searchResp.Results)) + + return &searchResp, nil +} + +func ConvertOllamaToAnthropicResults(ollamaResults *OllamaWebSearchResponse) []WebSearchResult { + var results []WebSearchResult + for _, r := range ollamaResults.Results { + results = append(results, WebSearchResult{ + Type: "web_search_result", + URL: r.URL, + Title: r.Title, + }) + } + return results +} diff --git a/anthropic/anthropic_test.go b/anthropic/anthropic_test.go new file mode 100755 index 0000000..27f9b9a --- /dev/null +++ b/anthropic/anthropic_test.go @@ -0,0 +1,1907 @@ +package anthropic + +import ( + "encoding/base64" + "encoding/json" + "strings" + "testing" + + "github.com/google/go-cmp/cmp" + + "github.com/ollama/ollama/api" +) + +const ( + testImage = `iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=` +) + +// textContent is a convenience for constructing []ContentBlock with a single text block in tests. +func textContent(s string) []ContentBlock { + return []ContentBlock{{Type: "text", Text: &s}} +} + +// makeArgs creates ToolCallFunctionArguments from key-value pairs (convenience function for tests) +func makeArgs(kvs ...any) api.ToolCallFunctionArguments { + args := api.NewToolCallFunctionArguments() + for i := 0; i < len(kvs)-1; i += 2 { + args.Set(kvs[i].(string), kvs[i+1]) + } + return args +} + +func TestFromMessagesRequest_Basic(t *testing.T) { + req := MessagesRequest{ + Model: "test-model", + MaxTokens: 1024, + Messages: []MessageParam{ + {Role: "user", Content: textContent("Hello")}, + }, + } + + result, err := FromMessagesRequest(req) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + if result.Model != "test-model" { + t.Errorf("expected model 'test-model', got %q", result.Model) + } + + if len(result.Messages) != 1 { + t.Fatalf("expected 1 message, got %d", len(result.Messages)) + } + + if result.Messages[0].Role != "user" || result.Messages[0].Content != "Hello" { + t.Errorf("unexpected message: %+v", result.Messages[0]) + } + + if numPredict, ok := result.Options["num_predict"].(int); !ok || numPredict != 1024 { + t.Errorf("expected num_predict 1024, got %v", result.Options["num_predict"]) + } +} + +func TestFromMessagesRequest_WithSystemPrompt(t *testing.T) { + req := MessagesRequest{ + Model: "test-model", + MaxTokens: 1024, + System: "You are a helpful assistant.", + Messages: []MessageParam{ + {Role: "user", Content: textContent("Hello")}, + }, + } + + result, err := FromMessagesRequest(req) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + if len(result.Messages) != 2 { + t.Fatalf("expected 2 messages, got %d", len(result.Messages)) + } + + if result.Messages[0].Role != "system" || result.Messages[0].Content != "You are a helpful assistant." { + t.Errorf("unexpected system message: %+v", result.Messages[0]) + } +} + +func TestFromMessagesRequest_WithSystemPromptArray(t *testing.T) { + req := MessagesRequest{ + Model: "test-model", + MaxTokens: 1024, + System: []any{ + map[string]any{"type": "text", "text": "You are helpful."}, + map[string]any{"type": "text", "text": " Be concise."}, + }, + Messages: []MessageParam{ + {Role: "user", Content: textContent("Hello")}, + }, + } + + result, err := FromMessagesRequest(req) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + if len(result.Messages) != 2 { + t.Fatalf("expected 2 messages, got %d", len(result.Messages)) + } + + if result.Messages[0].Content != "You are helpful. Be concise." { + t.Errorf("unexpected system message content: %q", result.Messages[0].Content) + } +} + +func TestFromMessagesRequest_WithOptions(t *testing.T) { + temp := 0.7 + topP := 0.9 + topK := 40 + req := MessagesRequest{ + Model: "test-model", + MaxTokens: 2048, + Messages: []MessageParam{{Role: "user", Content: textContent("Hello")}}, + Temperature: &temp, + TopP: &topP, + TopK: &topK, + StopSequences: []string{"\n", "END"}, + } + + result, err := FromMessagesRequest(req) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + if result.Options["temperature"] != 0.7 { + t.Errorf("expected temperature 0.7, got %v", result.Options["temperature"]) + } + if result.Options["top_p"] != 0.9 { + t.Errorf("expected top_p 0.9, got %v", result.Options["top_p"]) + } + if result.Options["top_k"] != 40 { + t.Errorf("expected top_k 40, got %v", result.Options["top_k"]) + } + if diff := cmp.Diff([]string{"\n", "END"}, result.Options["stop"]); diff != "" { + t.Errorf("stop sequences mismatch: %s", diff) + } +} + +func TestFromMessagesRequest_WithImage(t *testing.T) { + imgData, _ := base64.StdEncoding.DecodeString(testImage) + + req := MessagesRequest{ + Model: "test-model", + MaxTokens: 1024, + Messages: []MessageParam{ + { + Role: "user", + Content: []ContentBlock{ + {Type: "text", Text: ptr("What's in this image?")}, + { + Type: "image", + Source: &ImageSource{ + Type: "base64", + MediaType: "image/png", + Data: testImage, + }, + }, + }, + }, + }, + } + + result, err := FromMessagesRequest(req) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + if len(result.Messages) != 1 { + t.Fatalf("expected 1 message, got %d", len(result.Messages)) + } + + if result.Messages[0].Content != "What's in this image?" { + t.Errorf("expected content 'What's in this image?', got %q", result.Messages[0].Content) + } + + if len(result.Messages[0].Images) != 1 { + t.Fatalf("expected 1 image, got %d", len(result.Messages[0].Images)) + } + + if string(result.Messages[0].Images[0]) != string(imgData) { + t.Error("image data mismatch") + } +} + +func TestFromMessagesRequest_WithToolUse(t *testing.T) { + req := MessagesRequest{ + Model: "test-model", + MaxTokens: 1024, + Messages: []MessageParam{ + {Role: "user", Content: textContent("What's the weather in Paris?")}, + { + Role: "assistant", + Content: []ContentBlock{ + { + Type: "tool_use", + ID: "call_123", + Name: "get_weather", + Input: makeArgs("location", "Paris"), + }, + }, + }, + }, + } + + result, err := FromMessagesRequest(req) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + if len(result.Messages) != 2 { + t.Fatalf("expected 2 messages, got %d", len(result.Messages)) + } + + if len(result.Messages[1].ToolCalls) != 1 { + t.Fatalf("expected 1 tool call, got %d", len(result.Messages[1].ToolCalls)) + } + + tc := result.Messages[1].ToolCalls[0] + if tc.ID != "call_123" { + t.Errorf("expected tool call ID 'call_123', got %q", tc.ID) + } + if tc.Function.Name != "get_weather" { + t.Errorf("expected tool name 'get_weather', got %q", tc.Function.Name) + } +} + +func TestFromMessagesRequest_WithToolResult(t *testing.T) { + req := MessagesRequest{ + Model: "test-model", + MaxTokens: 1024, + Messages: []MessageParam{ + { + Role: "user", + Content: []ContentBlock{ + { + Type: "tool_result", + ToolUseID: "call_123", + Content: "The weather in Paris is sunny, 22°C", + }, + }, + }, + }, + } + + result, err := FromMessagesRequest(req) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + if len(result.Messages) != 1 { + t.Fatalf("expected 1 message, got %d", len(result.Messages)) + } + + msg := result.Messages[0] + if msg.Role != "tool" { + t.Errorf("expected role 'tool', got %q", msg.Role) + } + if msg.ToolCallID != "call_123" { + t.Errorf("expected tool_call_id 'call_123', got %q", msg.ToolCallID) + } + if msg.Content != "The weather in Paris is sunny, 22°C" { + t.Errorf("unexpected content: %q", msg.Content) + } +} + +func TestFromMessagesRequest_WithToolResultImage(t *testing.T) { + imgData, _ := base64.StdEncoding.DecodeString(testImage) + + req := MessagesRequest{ + Model: "test-model", + MaxTokens: 1024, + Messages: []MessageParam{ + { + Role: "user", + Content: []ContentBlock{ + { + Type: "tool_result", + ToolUseID: "call_img", + Content: []any{ + map[string]any{"type": "text", "text": "Attached image"}, + map[string]any{ + "type": "image", + "source": map[string]any{ + "type": "base64", + "media_type": "image/png", + "data": testImage, + }, + }, + }, + }, + }, + }, + }, + } + + result, err := FromMessagesRequest(req) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + if len(result.Messages) != 1 { + t.Fatalf("expected 1 message, got %d", len(result.Messages)) + } + + msg := result.Messages[0] + if msg.Role != "tool" { + t.Errorf("expected role 'tool', got %q", msg.Role) + } + if msg.ToolCallID != "call_img" { + t.Errorf("expected tool_call_id 'call_img', got %q", msg.ToolCallID) + } + if msg.Content != "Attached image" { + t.Errorf("unexpected content: %q", msg.Content) + } + if len(msg.Images) != 1 { + t.Fatalf("expected 1 image, got %d", len(msg.Images)) + } + if string(msg.Images[0]) != string(imgData) { + t.Error("image data mismatch") + } +} + +func TestFromMessagesRequest_WithToolResultFollowedByUserText(t *testing.T) { + req := MessagesRequest{ + Model: "test-model", + MaxTokens: 1024, + Messages: []MessageParam{ + { + Role: "assistant", + Content: []ContentBlock{ + { + Type: "tool_use", + ID: "call_read", + Name: "Read", + Input: makeArgs("file_path", "/Users/hoyyeva/Desktop/aaa.png"), + }, + }, + }, + { + Role: "user", + Content: []ContentBlock{ + { + Type: "tool_result", + ToolUseID: "call_read", + Content: "Read image (311.5KB)", + }, + { + Type: "text", + Text: ptr("Please describe it."), + }, + }, + }, + }, + } + + result, err := FromMessagesRequest(req) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + if len(result.Messages) != 3 { + t.Fatalf("expected 3 messages, got %d", len(result.Messages)) + } + + if result.Messages[1].Role != "tool" { + t.Fatalf("expected second message to be tool, got %q", result.Messages[1].Role) + } + if result.Messages[1].ToolCallID != "call_read" { + t.Fatalf("expected tool_call_id 'call_read', got %q", result.Messages[1].ToolCallID) + } + if result.Messages[2].Role != "user" { + t.Fatalf("expected third message to be user, got %q", result.Messages[2].Role) + } + if result.Messages[2].Content != "Please describe it." { + t.Fatalf("unexpected user content: %q", result.Messages[2].Content) + } +} + +func TestFromMessagesRequest_WithOutputConfigEffort(t *testing.T) { + req := MessagesRequest{ + Model: "gemma4", + MaxTokens: 32000, + Messages: []MessageParam{ + { + Role: "user", + Content: textContent("Describe the image."), + }, + }, + OutputConfig: &OutputConfig{ + Effort: "high", + }, + } + + result, err := FromMessagesRequest(req) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + if result.Think == nil { + t.Fatal("expected think to be set from output_config.effort") + } + + if got := result.Think.String(); got != "high" { + t.Fatalf("expected think level 'high', got %q", got) + } +} + +func TestFromMessagesRequest_WithOutputConfigEffortXHighMapsToHigh(t *testing.T) { + req := MessagesRequest{ + Model: "gemma4", + MaxTokens: 32000, + Messages: []MessageParam{ + { + Role: "user", + Content: textContent("Describe the image."), + }, + }, + OutputConfig: &OutputConfig{ + Effort: "xhigh", + }, + } + + result, err := FromMessagesRequest(req) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + if result.Think == nil { + t.Fatal("expected think to be set from output_config.effort") + } + + if got := result.Think.String(); got != "high" { + t.Fatalf("expected think level 'high' for xhigh effort, got %q", got) + } +} + +func TestFromMessagesRequest_ThinkingDisabledOverridesOutputConfigEffort(t *testing.T) { + req := MessagesRequest{ + Model: "gemma4", + MaxTokens: 32000, + Messages: []MessageParam{ + { + Role: "user", + Content: textContent("Describe the image."), + }, + }, + Thinking: &ThinkingConfig{ + Type: "disabled", + }, + OutputConfig: &OutputConfig{ + Effort: "high", + }, + } + + result, err := FromMessagesRequest(req) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + if result.Think == nil { + t.Fatal("expected think to be set") + } + + if got := result.Think.Value; got != false { + t.Fatalf("expected think=false when thinking is disabled, got %v", got) + } +} + +func TestFromMessagesRequest_ThinkingAdaptiveUsesOutputConfigEffort(t *testing.T) { + req := MessagesRequest{ + Model: "gemma4", + MaxTokens: 32000, + Messages: []MessageParam{ + { + Role: "user", + Content: textContent("Describe the image."), + }, + }, + Thinking: &ThinkingConfig{ + Type: "adaptive", + }, + OutputConfig: &OutputConfig{ + Effort: "high", + }, + } + + result, err := FromMessagesRequest(req) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + if result.Think == nil { + t.Fatal("expected think to be set from output_config.effort") + } + + if got := result.Think.String(); got != "high" { + t.Fatalf("expected think level 'high' for adaptive thinking, got %q", got) + } +} + +func TestFromMessagesRequest_WithTools(t *testing.T) { + req := MessagesRequest{ + Model: "test-model", + MaxTokens: 1024, + Messages: []MessageParam{{Role: "user", Content: textContent("Hello")}}, + Tools: []Tool{ + { + Name: "get_weather", + Description: "Get current weather", + InputSchema: json.RawMessage(`{"type":"object","properties":{"location":{"type":"string"}},"required":["location"]}`), + }, + }, + } + + result, err := FromMessagesRequest(req) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + if len(result.Tools) != 1 { + t.Fatalf("expected 1 tool, got %d", len(result.Tools)) + } + + tool := result.Tools[0] + if tool.Type != "function" { + t.Errorf("expected type 'function', got %q", tool.Type) + } + if tool.Function.Name != "get_weather" { + t.Errorf("expected name 'get_weather', got %q", tool.Function.Name) + } + if tool.Function.Description != "Get current weather" { + t.Errorf("expected description 'Get current weather', got %q", tool.Function.Description) + } +} + +func TestFromMessagesRequest_DropsCustomWebSearchWhenBuiltinPresent(t *testing.T) { + req := MessagesRequest{ + Model: "test-model", + MaxTokens: 1024, + Messages: []MessageParam{{Role: "user", Content: textContent("Hello")}}, + Tools: []Tool{ + { + Type: "web_search_20250305", + Name: "web_search", + }, + { + Type: "custom", + Name: "web_search", + Description: "User-defined web search that should be dropped", + InputSchema: json.RawMessage(`{"type":"invalid"}`), + }, + { + Type: "custom", + Name: "get_weather", + Description: "Get current weather", + InputSchema: json.RawMessage(`{"type":"object","properties":{"location":{"type":"string"}},"required":["location"]}`), + }, + }, + } + + result, err := FromMessagesRequest(req) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + if len(result.Tools) != 2 { + t.Fatalf("expected 2 tools after dropping custom web_search, got %d", len(result.Tools)) + } + if result.Tools[0].Function.Name != "web_search" { + t.Fatalf("expected first tool to be built-in web_search, got %q", result.Tools[0].Function.Name) + } + if result.Tools[1].Function.Name != "get_weather" { + t.Fatalf("expected second tool to be get_weather, got %q", result.Tools[1].Function.Name) + } +} + +func TestFromMessagesRequest_KeepsCustomWebSearchWhenBuiltinAbsent(t *testing.T) { + req := MessagesRequest{ + Model: "test-model", + MaxTokens: 1024, + Messages: []MessageParam{{Role: "user", Content: textContent("Hello")}}, + Tools: []Tool{ + { + Type: "custom", + Name: "web_search", + Description: "User-defined web search", + InputSchema: json.RawMessage(`{"type":"object","properties":{"query":{"type":"string"}},"required":["query"]}`), + }, + }, + } + + result, err := FromMessagesRequest(req) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + if len(result.Tools) != 1 { + t.Fatalf("expected 1 custom tool, got %d", len(result.Tools)) + } + if result.Tools[0].Function.Name != "web_search" { + t.Fatalf("expected custom tool name web_search, got %q", result.Tools[0].Function.Name) + } + if result.Tools[0].Function.Description != "User-defined web search" { + t.Fatalf("expected custom description preserved, got %q", result.Tools[0].Function.Description) + } +} + +func TestFromMessagesRequest_WithThinking(t *testing.T) { + req := MessagesRequest{ + Model: "test-model", + MaxTokens: 1024, + Messages: []MessageParam{{Role: "user", Content: textContent("Hello")}}, + Thinking: &ThinkingConfig{Type: "enabled", BudgetTokens: 1000}, + } + + result, err := FromMessagesRequest(req) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + if result.Think == nil { + t.Fatal("expected Think to be set") + } + if v, ok := result.Think.Value.(bool); !ok || !v { + t.Errorf("expected Think.Value to be true, got %v", result.Think.Value) + } +} + +func TestFromMessagesRequest_ThinkingOnlyBlock(t *testing.T) { + req := MessagesRequest{ + Model: "test-model", + MaxTokens: 1024, + Messages: []MessageParam{ + {Role: "user", Content: textContent("Hello")}, + { + Role: "assistant", + Content: []ContentBlock{ + { + Type: "thinking", + Thinking: ptr("Let me think about this..."), + }, + }, + }, + }, + } + + result, err := FromMessagesRequest(req) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + if len(result.Messages) != 2 { + t.Fatalf("expected 2 messages, got %d", len(result.Messages)) + } + + assistantMsg := result.Messages[1] + if assistantMsg.Thinking != "Let me think about this..." { + t.Errorf("expected thinking content, got %q", assistantMsg.Thinking) + } +} + +func TestFromMessagesRequest_ToolUseMissingID(t *testing.T) { + req := MessagesRequest{ + Model: "test-model", + MaxTokens: 1024, + Messages: []MessageParam{ + { + Role: "assistant", + Content: []ContentBlock{ + { + Type: "tool_use", + Name: "get_weather", + }, + }, + }, + }, + } + + _, err := FromMessagesRequest(req) + if err == nil { + t.Fatal("expected error for missing tool_use id") + } + if err.Error() != "tool_use block missing required 'id' field" { + t.Errorf("unexpected error message: %v", err) + } +} + +func TestFromMessagesRequest_ToolUseMissingName(t *testing.T) { + req := MessagesRequest{ + Model: "test-model", + MaxTokens: 1024, + Messages: []MessageParam{ + { + Role: "assistant", + Content: []ContentBlock{ + { + Type: "tool_use", + ID: "call_123", + }, + }, + }, + }, + } + + _, err := FromMessagesRequest(req) + if err == nil { + t.Fatal("expected error for missing tool_use name") + } + if err.Error() != "tool_use block missing required 'name' field" { + t.Errorf("unexpected error message: %v", err) + } +} + +func TestFromMessagesRequest_InvalidToolSchema(t *testing.T) { + req := MessagesRequest{ + Model: "test-model", + MaxTokens: 1024, + Messages: []MessageParam{{Role: "user", Content: textContent("Hello")}}, + Tools: []Tool{ + { + Name: "bad_tool", + InputSchema: json.RawMessage(`{invalid json`), + }, + }, + } + + _, err := FromMessagesRequest(req) + if err == nil { + t.Fatal("expected error for invalid tool schema") + } +} + +func TestToMessagesResponse_Basic(t *testing.T) { + resp := api.ChatResponse{ + Model: "test-model", + Message: api.Message{ + Role: "assistant", + Content: "Hello there!", + }, + Done: true, + DoneReason: "stop", + Metrics: api.Metrics{ + PromptEvalCount: 10, + EvalCount: 5, + }, + } + + result := ToMessagesResponse("msg_123", resp) + + if result.ID != "msg_123" { + t.Errorf("expected ID 'msg_123', got %q", result.ID) + } + if result.Type != "message" { + t.Errorf("expected type 'message', got %q", result.Type) + } + if result.Role != "assistant" { + t.Errorf("expected role 'assistant', got %q", result.Role) + } + if len(result.Content) != 1 { + t.Fatalf("expected 1 content block, got %d", len(result.Content)) + } + if result.Content[0].Type != "text" || result.Content[0].Text == nil || *result.Content[0].Text != "Hello there!" { + t.Errorf("unexpected content: %+v", result.Content[0]) + } + if result.StopReason != "end_turn" { + t.Errorf("expected stop_reason 'end_turn', got %q", result.StopReason) + } + if result.Usage.InputTokens != 10 || result.Usage.OutputTokens != 5 { + t.Errorf("unexpected usage: %+v", result.Usage) + } +} + +func TestToMessagesResponse_WithToolCalls(t *testing.T) { + resp := api.ChatResponse{ + Model: "test-model", + Message: api.Message{ + Role: "assistant", + ToolCalls: []api.ToolCall{ + { + ID: "call_123", + Function: api.ToolCallFunction{ + Name: "get_weather", + Arguments: makeArgs("location", "Paris"), + }, + }, + }, + }, + Done: true, + DoneReason: "stop", + } + + result := ToMessagesResponse("msg_123", resp) + + if len(result.Content) != 1 { + t.Fatalf("expected 1 content block, got %d", len(result.Content)) + } + if result.Content[0].Type != "tool_use" { + t.Errorf("expected type 'tool_use', got %q", result.Content[0].Type) + } + if result.Content[0].ID != "call_123" { + t.Errorf("expected ID 'call_123', got %q", result.Content[0].ID) + } + if result.Content[0].Name != "get_weather" { + t.Errorf("expected name 'get_weather', got %q", result.Content[0].Name) + } + if result.StopReason != "tool_use" { + t.Errorf("expected stop_reason 'tool_use', got %q", result.StopReason) + } +} + +func TestToMessagesResponse_WithThinking(t *testing.T) { + resp := api.ChatResponse{ + Model: "test-model", + Message: api.Message{ + Role: "assistant", + Content: "The answer is 42.", + Thinking: "Let me think about this...", + }, + Done: true, + DoneReason: "stop", + } + + result := ToMessagesResponse("msg_123", resp) + + if len(result.Content) != 2 { + t.Fatalf("expected 2 content blocks, got %d", len(result.Content)) + } + if result.Content[0].Type != "thinking" { + t.Errorf("expected first block type 'thinking', got %q", result.Content[0].Type) + } + if result.Content[0].Thinking == nil || *result.Content[0].Thinking != "Let me think about this..." { + t.Errorf("unexpected thinking content: %v", result.Content[0].Thinking) + } + if result.Content[1].Type != "text" { + t.Errorf("expected second block type 'text', got %q", result.Content[1].Type) + } +} + +func TestMapStopReason(t *testing.T) { + tests := []struct { + reason string + hasToolCalls bool + want string + }{ + {"stop", false, "end_turn"}, + {"length", false, "max_tokens"}, + {"stop", true, "tool_use"}, + {"other", false, "stop_sequence"}, + {"", false, ""}, + } + + for _, tt := range tests { + got := mapStopReason(tt.reason, tt.hasToolCalls) + if got != tt.want { + t.Errorf("mapStopReason(%q, %v) = %q, want %q", tt.reason, tt.hasToolCalls, got, tt.want) + } + } +} + +func TestNewError(t *testing.T) { + tests := []struct { + code int + want string + }{ + {400, "invalid_request_error"}, + {401, "authentication_error"}, + {403, "permission_error"}, + {404, "not_found_error"}, + {429, "rate_limit_error"}, + {500, "api_error"}, + {503, "overloaded_error"}, + {529, "overloaded_error"}, + } + + for _, tt := range tests { + result := NewError(tt.code, "test message") + if result.Type != "error" { + t.Errorf("NewError(%d) type = %q, want 'error'", tt.code, result.Type) + } + if result.Error.Type != tt.want { + t.Errorf("NewError(%d) error.type = %q, want %q", tt.code, result.Error.Type, tt.want) + } + if result.Error.Message != "test message" { + t.Errorf("NewError(%d) message = %q, want 'test message'", tt.code, result.Error.Message) + } + if result.RequestID == "" { + t.Errorf("NewError(%d) request_id should not be empty", tt.code) + } + } +} + +func TestGenerateMessageID(t *testing.T) { + id1 := GenerateMessageID() + id2 := GenerateMessageID() + + if id1 == "" { + t.Error("GenerateMessageID returned empty string") + } + if id1 == id2 { + t.Error("GenerateMessageID returned duplicate IDs") + } + if len(id1) < 10 { + t.Errorf("GenerateMessageID returned short ID: %q", id1) + } + if id1[:4] != "msg_" { + t.Errorf("GenerateMessageID should start with 'msg_', got %q", id1[:4]) + } +} + +func TestStreamConverter_Basic(t *testing.T) { + conv := NewStreamConverter("msg_123", "test-model", 0) + + // First chunk + resp1 := api.ChatResponse{ + Model: "test-model", + Message: api.Message{ + Role: "assistant", + Content: "Hello", + }, + Metrics: api.Metrics{PromptEvalCount: 10}, + } + + events1 := conv.Process(resp1) + if len(events1) < 3 { + t.Fatalf("expected at least 3 events for first chunk, got %d", len(events1)) + } + + // Should have message_start, content_block_start, content_block_delta + if events1[0].Event != "message_start" { + t.Errorf("expected first event 'message_start', got %q", events1[0].Event) + } + if events1[1].Event != "content_block_start" { + t.Errorf("expected second event 'content_block_start', got %q", events1[1].Event) + } + if events1[2].Event != "content_block_delta" { + t.Errorf("expected third event 'content_block_delta', got %q", events1[2].Event) + } + + // Final chunk + resp2 := api.ChatResponse{ + Model: "test-model", + Message: api.Message{ + Role: "assistant", + Content: " world!", + }, + Done: true, + DoneReason: "stop", + Metrics: api.Metrics{PromptEvalCount: 10, EvalCount: 5}, + } + + events2 := conv.Process(resp2) + + // Should have content_block_delta, content_block_stop, message_delta, message_stop + hasStop := false + for _, e := range events2 { + if e.Event == "message_delta" { + if data, ok := e.Data.(MessageDeltaEvent); ok { + if data.Type != "message_delta" { + t.Errorf("unexpected data type: %+v", data) + } + + if data.Delta.StopReason != "end_turn" { + t.Errorf("unexpected stop reason: %+v", data.Delta.StopReason) + } + + if data.Usage.InputTokens != 10 || data.Usage.OutputTokens != 5 { + t.Errorf("unexpected usage: %+v", data.Usage) + } + } else { + t.Errorf("unexpected data: %+v", e.Data) + } + } + + if e.Event == "message_stop" { + hasStop = true + } + } + if !hasStop { + t.Error("expected message_stop event in final chunk") + } +} + +func TestStreamConverter_WithToolCalls(t *testing.T) { + conv := NewStreamConverter("msg_123", "test-model", 0) + + resp := api.ChatResponse{ + Model: "test-model", + Message: api.Message{ + Role: "assistant", + ToolCalls: []api.ToolCall{ + { + ID: "call_123", + Function: api.ToolCallFunction{ + Name: "get_weather", + Arguments: makeArgs("location", "Paris"), + }, + }, + }, + }, + Done: true, + DoneReason: "stop", + Metrics: api.Metrics{PromptEvalCount: 10, EvalCount: 5}, + } + + events := conv.Process(resp) + + hasToolStart := false + hasToolDelta := false + for _, e := range events { + if e.Event == "content_block_start" { + if start, ok := e.Data.(ContentBlockStartEvent); ok { + if start.ContentBlock.Type == "tool_use" { + hasToolStart = true + } + } + } + if e.Event == "content_block_delta" { + if delta, ok := e.Data.(ContentBlockDeltaEvent); ok { + if delta.Delta.Type == "input_json_delta" { + hasToolDelta = true + } + } + } + } + + if !hasToolStart { + t.Error("expected tool_use content_block_start event") + } + if !hasToolDelta { + t.Error("expected input_json_delta event") + } +} + +// TestStreamConverter_ThinkingDirectlyFollowedByToolCall verifies that when a +// model emits a thinking block followed directly by a tool_use block (with no +// text block in between), the streaming converter correctly closes the thinking +// block and increments the content index before opening the tool_use block. +// Previously, the converter reused contentIndex=0 for the tool_use block, +// which caused "Content block not found" errors in clients. See #14816. +func TestStreamConverter_ThinkingDirectlyFollowedByToolCall(t *testing.T) { + conv := NewStreamConverter("msg_123", "test-model", 0) + + // First chunk: thinking content (no text) + resp1 := api.ChatResponse{ + Model: "test-model", + Message: api.Message{ + Role: "assistant", + Thinking: "I should call the tool.", + }, + } + events1 := conv.Process(resp1) + + // Should have: message_start, content_block_start(thinking), content_block_delta(thinking) + if len(events1) < 3 { + t.Fatalf("expected at least 3 events for thinking chunk, got %d", len(events1)) + } + if events1[0].Event != "message_start" { + t.Errorf("expected first event 'message_start', got %q", events1[0].Event) + } + thinkingStart, ok := events1[1].Data.(ContentBlockStartEvent) + if !ok || thinkingStart.ContentBlock.Type != "thinking" { + t.Errorf("expected content_block_start(thinking) as second event, got %+v", events1[1]) + } + if thinkingStart.Index != 0 { + t.Errorf("expected thinking block at index 0, got %d", thinkingStart.Index) + } + + // Second chunk: tool call (no text between thinking and tool) + resp2 := api.ChatResponse{ + Model: "test-model", + Message: api.Message{ + Role: "assistant", + ToolCalls: []api.ToolCall{ + { + ID: "call_abc", + Function: api.ToolCallFunction{ + Name: "ask_user", + Arguments: makeArgs("question", "cats or dogs?"), + }, + }, + }, + }, + Done: true, + DoneReason: "stop", + Metrics: api.Metrics{PromptEvalCount: 10, EvalCount: 5}, + } + events2 := conv.Process(resp2) + + // Expect: content_block_stop(index=0), content_block_start(tool_use, index=1), + // content_block_delta(input_json_delta, index=1), content_block_stop(index=1), + // message_delta, message_stop + var thinkingStop, toolStart, toolDelta, toolStop *StreamEvent + for i := range events2 { + e := &events2[i] + switch e.Event { + case "content_block_stop": + if stop, ok := e.Data.(ContentBlockStopEvent); ok { + if stop.Index == 0 && thinkingStop == nil { + thinkingStop = e + } else if stop.Index == 1 { + toolStop = e + } + } + case "content_block_start": + if start, ok := e.Data.(ContentBlockStartEvent); ok && start.ContentBlock.Type == "tool_use" { + toolStart = e + } + case "content_block_delta": + if delta, ok := e.Data.(ContentBlockDeltaEvent); ok && delta.Delta.Type == "input_json_delta" { + toolDelta = e + } + } + } + + if thinkingStop == nil { + t.Error("expected content_block_stop for thinking block (index 0)") + } + if toolStart == nil { + t.Fatal("expected content_block_start for tool_use block") + } + if start, ok := toolStart.Data.(ContentBlockStartEvent); !ok || start.Index != 1 { + t.Errorf("expected tool_use block at index 1, got %+v", toolStart.Data) + } + if toolDelta == nil { + t.Fatal("expected input_json_delta event for tool call") + } + if delta, ok := toolDelta.Data.(ContentBlockDeltaEvent); !ok || delta.Index != 1 { + t.Errorf("expected tool delta at index 1, got %+v", toolDelta.Data) + } + if toolStop == nil { + t.Error("expected content_block_stop for tool_use block (index 1)") + } +} + +func TestStreamConverter_ToolCallWithUnmarshalableArgs(t *testing.T) { + // Test that unmarshalable arguments (like channels) are handled gracefully + // and don't cause a panic or corrupt stream + conv := NewStreamConverter("msg_123", "test-model", 0) + + // Create a channel which cannot be JSON marshaled + unmarshalable := make(chan int) + badArgs := api.NewToolCallFunctionArguments() + badArgs.Set("channel", unmarshalable) + + resp := api.ChatResponse{ + Model: "test-model", + Message: api.Message{ + Role: "assistant", + ToolCalls: []api.ToolCall{ + { + ID: "call_bad", + Function: api.ToolCallFunction{ + Name: "bad_function", + Arguments: badArgs, + }, + }, + }, + }, + Done: true, + DoneReason: "stop", + } + + // Should not panic and should skip the unmarshalable tool call + events := conv.Process(resp) + + // Verify no tool_use block was started (since marshal failed before block start) + hasToolStart := false + for _, e := range events { + if e.Event == "content_block_start" { + if start, ok := e.Data.(ContentBlockStartEvent); ok { + if start.ContentBlock.Type == "tool_use" { + hasToolStart = true + } + } + } + } + + if hasToolStart { + t.Error("expected no tool_use block when arguments cannot be marshaled") + } +} + +func TestStreamConverter_MultipleToolCallsWithMixedValidity(t *testing.T) { + // Test that valid tool calls still work when mixed with invalid ones + conv := NewStreamConverter("msg_123", "test-model", 0) + + unmarshalable := make(chan int) + badArgs := api.NewToolCallFunctionArguments() + badArgs.Set("channel", unmarshalable) + + resp := api.ChatResponse{ + Model: "test-model", + Message: api.Message{ + Role: "assistant", + ToolCalls: []api.ToolCall{ + { + ID: "call_good", + Function: api.ToolCallFunction{ + Name: "good_function", + Arguments: makeArgs("location", "Paris"), + }, + }, + { + ID: "call_bad", + Function: api.ToolCallFunction{ + Name: "bad_function", + Arguments: badArgs, + }, + }, + }, + }, + Done: true, + DoneReason: "stop", + } + + events := conv.Process(resp) + + // Count tool_use blocks - should only have 1 (the valid one) + toolStartCount := 0 + toolDeltaCount := 0 + for _, e := range events { + if e.Event == "content_block_start" { + if start, ok := e.Data.(ContentBlockStartEvent); ok { + if start.ContentBlock.Type == "tool_use" { + toolStartCount++ + if start.ContentBlock.Name != "good_function" { + t.Errorf("expected tool name 'good_function', got %q", start.ContentBlock.Name) + } + } + } + } + if e.Event == "content_block_delta" { + if delta, ok := e.Data.(ContentBlockDeltaEvent); ok { + if delta.Delta.Type == "input_json_delta" { + toolDeltaCount++ + } + } + } + } + + if toolStartCount != 1 { + t.Errorf("expected 1 tool_use block, got %d", toolStartCount) + } + if toolDeltaCount != 1 { + t.Errorf("expected 1 input_json_delta, got %d", toolDeltaCount) + } +} + +func TestContentBlockJSON_EmptyFieldsPresent(t *testing.T) { + tests := []struct { + name string + block ContentBlock + wantKeys []string + }{ + { + name: "text block includes empty text field", + block: ContentBlock{ + Type: "text", + Text: ptr(""), + }, + wantKeys: []string{"type", "text"}, + }, + { + name: "thinking block includes empty thinking field", + block: ContentBlock{ + Type: "thinking", + Thinking: ptr(""), + }, + wantKeys: []string{"type", "thinking"}, + }, + { + name: "text block with content", + block: ContentBlock{ + Type: "text", + Text: ptr("hello"), + }, + wantKeys: []string{"type", "text"}, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + data, err := json.Marshal(tt.block) + if err != nil { + t.Fatalf("failed to marshal: %v", err) + } + + var result map[string]any + if err := json.Unmarshal(data, &result); err != nil { + t.Fatalf("failed to unmarshal: %v", err) + } + + for _, key := range tt.wantKeys { + if _, ok := result[key]; !ok { + t.Errorf("expected key %q to be present in JSON output, got: %s", key, string(data)) + } + } + }) + } +} + +func TestContentBlockJSON_NonToolBlocksDoNotIncludeInput(t *testing.T) { + tests := []struct { + name string + block ContentBlock + }{ + { + name: "text block", + block: ContentBlock{ + Type: "text", + Text: ptr("hello"), + }, + }, + { + name: "thinking block", + block: ContentBlock{ + Type: "thinking", + Thinking: ptr("let me think"), + }, + }, + { + name: "image block", + block: ContentBlock{ + Type: "image", + Source: &ImageSource{ + Type: "base64", + MediaType: "image/png", + Data: testImage, + }, + }, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + data, err := json.Marshal(tt.block) + if err != nil { + t.Fatalf("failed to marshal: %v", err) + } + + var result map[string]any + if err := json.Unmarshal(data, &result); err != nil { + t.Fatalf("failed to unmarshal: %v", err) + } + + if _, ok := result["input"]; ok { + t.Fatalf("unexpected input field in non-tool block JSON: %s", string(data)) + } + }) + } +} + +func TestStreamConverter_ContentBlockStartIncludesEmptyFields(t *testing.T) { + t.Run("text block start includes empty text", func(t *testing.T) { + conv := NewStreamConverter("msg_123", "test-model", 0) + + resp := api.ChatResponse{ + Model: "test-model", + Message: api.Message{Role: "assistant", Content: "hello"}, + } + + events := conv.Process(resp) + + var foundTextStart bool + for _, e := range events { + if e.Event == "content_block_start" { + if start, ok := e.Data.(ContentBlockStartEvent); ok { + if start.ContentBlock.Type == "text" { + foundTextStart = true + // Marshal and verify the text field is present + data, _ := json.Marshal(start) + var result map[string]any + if err := json.Unmarshal(data, &result); err != nil { + t.Fatalf("failed to unmarshal content_block_start JSON: %v", err) + } + cb := result["content_block"].(map[string]any) + if _, ok := cb["text"]; !ok { + t.Error("content_block_start for text should include 'text' field") + } + } + } + } + } + + if !foundTextStart { + t.Error("expected text content_block_start event") + } + }) + + t.Run("thinking block start includes empty thinking", func(t *testing.T) { + conv := NewStreamConverter("msg_123", "test-model", 0) + + resp := api.ChatResponse{ + Model: "test-model", + Message: api.Message{Role: "assistant", Thinking: "let me think..."}, + } + + events := conv.Process(resp) + + var foundThinkingStart bool + for _, e := range events { + if e.Event == "content_block_start" { + if start, ok := e.Data.(ContentBlockStartEvent); ok { + if start.ContentBlock.Type == "thinking" { + foundThinkingStart = true + data, _ := json.Marshal(start) + var result map[string]any + json.Unmarshal(data, &result) + cb := result["content_block"].(map[string]any) + if _, ok := cb["thinking"]; !ok { + t.Error("content_block_start for thinking should include 'thinking' field") + } + } + } + } + } + + if !foundThinkingStart { + t.Error("expected thinking content_block_start event") + } + }) + + t.Run("tool_use block start includes empty input object", func(t *testing.T) { + conv := NewStreamConverter("msg_123", "test-model", 0) + + resp := api.ChatResponse{ + Model: "test-model", + Message: api.Message{ + Role: "assistant", + ToolCalls: []api.ToolCall{ + { + ID: "call_123", + Function: api.ToolCallFunction{ + Name: "get_weather", + Arguments: makeArgs("location", "Paris"), + }, + }, + }, + }, + } + + events := conv.Process(resp) + + var foundToolStart bool + for _, e := range events { + if e.Event == "content_block_start" { + if start, ok := e.Data.(ContentBlockStartEvent); ok { + if start.ContentBlock.Type == "tool_use" { + foundToolStart = true + if start.ContentBlock.Input.Len() != 0 { + t.Errorf("expected empty input object, got len=%d", start.ContentBlock.Input.Len()) + } + + data, _ := json.Marshal(start) + var result map[string]any + json.Unmarshal(data, &result) + cb := result["content_block"].(map[string]any) + input, ok := cb["input"] + if !ok { + t.Error("content_block_start for tool_use should include 'input' field") + continue + } + inputMap, ok := input.(map[string]any) + if !ok { + t.Errorf("input field should be an object, got %T", input) + continue + } + if len(inputMap) != 0 { + t.Errorf("expected empty input object in content_block_start, got %v", inputMap) + } + } + } + } + } + + if !foundToolStart { + t.Error("expected tool_use content_block_start event") + } + }) +} + +func TestEstimateTokens_SimpleMessage(t *testing.T) { + req := CountTokensRequest{ + Model: "test-model", + Messages: []MessageParam{ + {Role: "user", Content: textContent("Hello, world!")}, + }, + } + + tokens := estimateTokens(req) + + // "user" (4) + "Hello, world!" (13) = 17 chars / 4 = 4 tokens + if tokens < 1 { + t.Errorf("expected at least 1 token, got %d", tokens) + } + // Sanity check: shouldn't be wildly off + if tokens > 10 { + t.Errorf("expected fewer than 10 tokens for short message, got %d", tokens) + } +} + +func TestEstimateTokens_WithSystemPrompt(t *testing.T) { + req := CountTokensRequest{ + Model: "test-model", + System: "You are a helpful assistant.", + Messages: []MessageParam{ + {Role: "user", Content: textContent("Hello")}, + }, + } + + tokens := estimateTokens(req) + + // System prompt adds to count + if tokens < 5 { + t.Errorf("expected at least 5 tokens with system prompt, got %d", tokens) + } +} + +func TestEstimateTokens_WithTools(t *testing.T) { + req := CountTokensRequest{ + Model: "test-model", + Messages: []MessageParam{ + {Role: "user", Content: textContent("What's the weather?")}, + }, + Tools: []Tool{ + { + Name: "get_weather", + Description: "Get the current weather for a location", + InputSchema: json.RawMessage(`{"type":"object","properties":{"location":{"type":"string"}}}`), + }, + }, + } + + tokens := estimateTokens(req) + + // Tools add significant content + if tokens < 10 { + t.Errorf("expected at least 10 tokens with tools, got %d", tokens) + } +} + +func TestEstimateTokens_WithThinking(t *testing.T) { + req := CountTokensRequest{ + Model: "test-model", + Messages: []MessageParam{ + {Role: "user", Content: textContent("Hello")}, + { + Role: "assistant", + Content: []ContentBlock{ + { + Type: "thinking", + Thinking: ptr("Let me think about this carefully..."), + }, + { + Type: "text", + Text: ptr("Here is my response."), + }, + }, + }, + }, + } + + tokens := estimateTokens(req) + + // Thinking content should be counted + if tokens < 10 { + t.Errorf("expected at least 10 tokens with thinking content, got %d", tokens) + } +} + +func TestEstimateTokens_EmptyContent(t *testing.T) { + req := CountTokensRequest{ + Model: "test-model", + Messages: []MessageParam{}, + } + + tokens := estimateTokens(req) + + if tokens != 0 { + t.Errorf("expected 0 tokens for empty content, got %d", tokens) + } +} + +// Web Search Tests + +func TestConvertTool_WebSearch(t *testing.T) { + tool := Tool{ + Type: "web_search_20250305", + Name: "web_search", + MaxUses: 5, + } + + result, isServerTool, err := convertTool(tool) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + if !isServerTool { + t.Error("expected isServerTool to be true for web_search tool") + } + + if result.Type != "function" { + t.Errorf("expected type 'function', got %q", result.Type) + } + + if result.Function.Name != "web_search" { + t.Errorf("expected name 'web_search', got %q", result.Function.Name) + } + + if result.Function.Description == "" { + t.Error("expected non-empty description for web_search tool") + } + + // Check that query parameter is defined + if result.Function.Parameters.Properties == nil { + t.Fatal("expected properties to be defined") + } + + queryProp, ok := result.Function.Parameters.Properties.Get("query") + if !ok { + t.Error("expected 'query' property to be defined") + } + + if len(queryProp.Type) == 0 || queryProp.Type[0] != "string" { + t.Errorf("expected query type to be 'string', got %v", queryProp.Type) + } +} + +func TestConvertTool_RegularTool(t *testing.T) { + tool := Tool{ + Type: "custom", + Name: "get_weather", + Description: "Get the weather", + InputSchema: json.RawMessage(`{"type":"object","properties":{"location":{"type":"string"}}}`), + } + + result, isServerTool, err := convertTool(tool) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + if isServerTool { + t.Error("expected isServerTool to be false for regular tool") + } + + if result.Function.Name != "get_weather" { + t.Errorf("expected name 'get_weather', got %q", result.Function.Name) + } +} + +func TestConvertMessage_ServerToolUse(t *testing.T) { + msg := MessageParam{ + Role: "assistant", + Content: []ContentBlock{ + { + Type: "server_tool_use", + ID: "srvtoolu_123", + Name: "web_search", + Input: makeArgs("query", "test query"), + }, + }, + } + + messages, err := convertMessage(msg) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + if len(messages) != 1 { + t.Fatalf("expected 1 message, got %d", len(messages)) + } + + if len(messages[0].ToolCalls) != 1 { + t.Fatalf("expected 1 tool call, got %d", len(messages[0].ToolCalls)) + } + + tc := messages[0].ToolCalls[0] + if tc.ID != "srvtoolu_123" { + t.Errorf("expected tool call ID 'srvtoolu_123', got %q", tc.ID) + } + + if tc.Function.Name != "web_search" { + t.Errorf("expected tool name 'web_search', got %q", tc.Function.Name) + } +} + +func TestConvertMessage_WebSearchToolResult(t *testing.T) { + msg := MessageParam{ + Role: "user", + Content: []ContentBlock{ + { + Type: "web_search_tool_result", + ToolUseID: "srvtoolu_123", + Content: []any{ + map[string]any{ + "type": "web_search_result", + "title": "Test Result", + "url": "https://example.com", + }, + }, + }, + }, + } + + messages, err := convertMessage(msg) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + // Should have a tool result message + if len(messages) != 1 { + t.Fatalf("expected 1 message, got %d", len(messages)) + } + + if messages[0].Role != "tool" { + t.Errorf("expected role 'tool', got %q", messages[0].Role) + } + + if messages[0].ToolCallID != "srvtoolu_123" { + t.Errorf("expected tool_call_id 'srvtoolu_123', got %q", messages[0].ToolCallID) + } + + if messages[0].Content == "" { + t.Error("expected non-empty content from web search results") + } +} + +func TestConvertMessage_WebSearchToolResultEmptyStillCreatesToolMessage(t *testing.T) { + msg := MessageParam{ + Role: "user", + Content: []ContentBlock{ + { + Type: "web_search_tool_result", + ToolUseID: "srvtoolu_empty", + Content: []any{}, + }, + }, + } + + messages, err := convertMessage(msg) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + if len(messages) != 1 { + t.Fatalf("expected 1 message, got %d", len(messages)) + } + if messages[0].Role != "tool" { + t.Fatalf("expected role tool, got %q", messages[0].Role) + } + if messages[0].ToolCallID != "srvtoolu_empty" { + t.Fatalf("expected tool_call_id srvtoolu_empty, got %q", messages[0].ToolCallID) + } + if messages[0].Content != "" { + t.Fatalf("expected empty content for empty web search results, got %q", messages[0].Content) + } +} + +func TestConvertMessage_WebSearchToolResultErrorStillCreatesToolMessage(t *testing.T) { + msg := MessageParam{ + Role: "user", + Content: []ContentBlock{ + { + Type: "web_search_tool_result", + ToolUseID: "srvtoolu_error", + Content: map[string]any{ + "type": "web_search_tool_result_error", + "error_code": "max_uses_exceeded", + }, + }, + }, + } + + messages, err := convertMessage(msg) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + + if len(messages) != 1 { + t.Fatalf("expected 1 message, got %d", len(messages)) + } + if messages[0].Role != "tool" { + t.Fatalf("expected role tool, got %q", messages[0].Role) + } + if messages[0].ToolCallID != "srvtoolu_error" { + t.Fatalf("expected tool_call_id srvtoolu_error, got %q", messages[0].ToolCallID) + } + if !strings.Contains(messages[0].Content, "max_uses_exceeded") { + t.Fatalf("expected error code in converted tool content, got %q", messages[0].Content) + } +} + +func TestConvertOllamaToAnthropicResults(t *testing.T) { + ollamaResp := &OllamaWebSearchResponse{ + Results: []OllamaWebSearchResult{ + { + Title: "Test Title", + URL: "https://example.com", + Content: "Test content", + }, + { + Title: "Another Result", + URL: "https://example.org", + Content: "More content", + }, + }, + } + + results := ConvertOllamaToAnthropicResults(ollamaResp) + + if len(results) != 2 { + t.Fatalf("expected 2 results, got %d", len(results)) + } + + if results[0].Type != "web_search_result" { + t.Errorf("expected type 'web_search_result', got %q", results[0].Type) + } + + if results[0].Title != "Test Title" { + t.Errorf("expected title 'Test Title', got %q", results[0].Title) + } + + if results[0].URL != "https://example.com" { + t.Errorf("expected URL 'https://example.com', got %q", results[0].URL) + } +} + +func TestWebSearchTypes(t *testing.T) { + // Test that WebSearchResult serializes correctly + result := WebSearchResult{ + Type: "web_search_result", + URL: "https://example.com", + Title: "Test", + EncryptedContent: "abc123", + PageAge: "2025-01-01", + } + + data, err := json.Marshal(result) + if err != nil { + t.Fatalf("failed to marshal WebSearchResult: %v", err) + } + + var unmarshaled WebSearchResult + if err := json.Unmarshal(data, &unmarshaled); err != nil { + t.Fatalf("failed to unmarshal WebSearchResult: %v", err) + } + + if unmarshaled.Type != result.Type { + t.Errorf("type mismatch: expected %q, got %q", result.Type, unmarshaled.Type) + } + + // Test WebSearchToolResultError + errResult := WebSearchToolResultError{ + Type: "web_search_tool_result_error", + ErrorCode: "max_uses_exceeded", + } + + data, err = json.Marshal(errResult) + if err != nil { + t.Fatalf("failed to marshal WebSearchToolResultError: %v", err) + } + + var unmarshaledErr WebSearchToolResultError + if err := json.Unmarshal(data, &unmarshaledErr); err != nil { + t.Fatalf("failed to unmarshal WebSearchToolResultError: %v", err) + } + + if unmarshaledErr.ErrorCode != "max_uses_exceeded" { + t.Errorf("error_code mismatch: expected 'max_uses_exceeded', got %q", unmarshaledErr.ErrorCode) + } +} + +func TestCitation(t *testing.T) { + citation := Citation{ + Type: "web_search_result_location", + URL: "https://example.com", + Title: "Example", + EncryptedIndex: "enc123", + CitedText: "Some cited text...", + } + + data, err := json.Marshal(citation) + if err != nil { + t.Fatalf("failed to marshal Citation: %v", err) + } + + var unmarshaled Citation + if err := json.Unmarshal(data, &unmarshaled); err != nil { + t.Fatalf("failed to unmarshal Citation: %v", err) + } + + if unmarshaled.Type != "web_search_result_location" { + t.Errorf("type mismatch: expected 'web_search_result_location', got %q", unmarshaled.Type) + } + + if unmarshaled.CitedText != "Some cited text..." { + t.Errorf("cited_text mismatch: expected 'Some cited text...', got %q", unmarshaled.CitedText) + } +} diff --git a/anthropic/trace.go b/anthropic/trace.go new file mode 100644 index 0000000..65dc8db --- /dev/null +++ b/anthropic/trace.go @@ -0,0 +1,352 @@ +package anthropic + +import ( + "encoding/json" + "fmt" + "sort" + + "github.com/ollama/ollama/api" +) + +// Trace truncation limits. +const ( + TraceMaxStringRunes = 240 + TraceMaxSliceItems = 8 + TraceMaxMapEntries = 16 + TraceMaxDepth = 4 +) + +// TraceTruncateString shortens s to TraceMaxStringRunes, appending a count of +// omitted characters when truncated. +func TraceTruncateString(s string) string { + if len(s) == 0 { + return s + } + runes := []rune(s) + if len(runes) <= TraceMaxStringRunes { + return s + } + return fmt.Sprintf("%s...(+%d chars)", string(runes[:TraceMaxStringRunes]), len(runes)-TraceMaxStringRunes) +} + +// TraceJSON round-trips v through JSON and returns a compacted representation. +func TraceJSON(v any) any { + if v == nil { + return nil + } + data, err := json.Marshal(v) + if err != nil { + return map[string]any{"marshal_error": err.Error(), "type": fmt.Sprintf("%T", v)} + } + var out any + if err := json.Unmarshal(data, &out); err != nil { + return TraceTruncateString(string(data)) + } + return TraceCompactValue(out, 0) +} + +// TraceCompactValue recursively truncates strings, slices, and maps for trace +// output. depth tracks recursion to enforce TraceMaxDepth. +func TraceCompactValue(v any, depth int) any { + if v == nil { + return nil + } + if depth >= TraceMaxDepth { + switch t := v.(type) { + case string: + return TraceTruncateString(t) + case []any: + return fmt.Sprintf("", len(t)) + case map[string]any: + return fmt.Sprintf("", len(t)) + default: + return fmt.Sprintf("<%T>", v) + } + } + switch t := v.(type) { + case string: + return TraceTruncateString(t) + case []any: + limit := min(len(t), TraceMaxSliceItems) + out := make([]any, 0, limit+1) + for i := range limit { + out = append(out, TraceCompactValue(t[i], depth+1)) + } + if len(t) > limit { + out = append(out, fmt.Sprintf("... +%d more items", len(t)-limit)) + } + return out + case map[string]any: + keys := make([]string, 0, len(t)) + for k := range t { + keys = append(keys, k) + } + sort.Strings(keys) + limit := min(len(keys), TraceMaxMapEntries) + out := make(map[string]any, limit+1) + for i := range limit { + out[keys[i]] = TraceCompactValue(t[keys[i]], depth+1) + } + if len(keys) > limit { + out["__truncated_keys"] = len(keys) - limit + } + return out + default: + return t + } +} + +// --------------------------------------------------------------------------- +// Anthropic request/response tracing +// --------------------------------------------------------------------------- + +// TraceMessagesRequest returns a compact trace representation of a MessagesRequest. +func TraceMessagesRequest(r MessagesRequest) map[string]any { + return map[string]any{ + "model": r.Model, + "max_tokens": r.MaxTokens, + "messages": traceMessageParams(r.Messages), + "system": traceAnthropicContent(r.System), + "stream": r.Stream, + "tools": traceTools(r.Tools), + "tool_choice": TraceJSON(r.ToolChoice), + "thinking": TraceJSON(r.Thinking), + "stop_sequences": r.StopSequences, + "temperature": ptrVal(r.Temperature), + "top_p": ptrVal(r.TopP), + "top_k": ptrVal(r.TopK), + } +} + +// TraceMessagesResponse returns a compact trace representation of a MessagesResponse. +func TraceMessagesResponse(r MessagesResponse) map[string]any { + return map[string]any{ + "id": r.ID, + "model": r.Model, + "content": TraceJSON(r.Content), + "stop_reason": r.StopReason, + "usage": r.Usage, + } +} + +func traceMessageParams(msgs []MessageParam) []map[string]any { + out := make([]map[string]any, 0, len(msgs)) + for _, m := range msgs { + out = append(out, map[string]any{ + "role": m.Role, + "content": traceAnthropicContent(m.Content), + }) + } + return out +} + +func traceAnthropicContent(content any) any { + switch c := content.(type) { + case nil: + return nil + case string: + return TraceTruncateString(c) + case []any: + blocks := make([]any, 0, len(c)) + for _, block := range c { + blockMap, ok := block.(map[string]any) + if !ok { + blocks = append(blocks, TraceCompactValue(block, 0)) + continue + } + blocks = append(blocks, traceAnthropicBlock(blockMap)) + } + return blocks + default: + return TraceJSON(c) + } +} + +func traceAnthropicBlock(block map[string]any) map[string]any { + blockType, _ := block["type"].(string) + out := map[string]any{"type": blockType} + switch blockType { + case "text": + if text, ok := block["text"].(string); ok { + out["text"] = TraceTruncateString(text) + } else { + out["text"] = TraceCompactValue(block["text"], 0) + } + case "thinking": + if thinking, ok := block["thinking"].(string); ok { + out["thinking"] = TraceTruncateString(thinking) + } else { + out["thinking"] = TraceCompactValue(block["thinking"], 0) + } + case "tool_use", "server_tool_use": + out["id"] = block["id"] + out["name"] = block["name"] + out["input"] = TraceCompactValue(block["input"], 0) + case "tool_result", "web_search_tool_result": + out["tool_use_id"] = block["tool_use_id"] + out["content"] = TraceCompactValue(block["content"], 0) + case "image": + if source, ok := block["source"].(map[string]any); ok { + out["source"] = map[string]any{ + "type": source["type"], + "media_type": source["media_type"], + "url": source["url"], + "data_len": len(fmt.Sprint(source["data"])), + } + } + default: + out["block"] = TraceCompactValue(block, 0) + } + return out +} + +func traceTools(tools []Tool) []map[string]any { + out := make([]map[string]any, 0, len(tools)) + for _, t := range tools { + out = append(out, TraceTool(t)) + } + return out +} + +// TraceTool returns a compact trace representation of an Anthropic Tool. +func TraceTool(t Tool) map[string]any { + return map[string]any{ + "type": t.Type, + "name": t.Name, + "description": TraceTruncateString(t.Description), + "input_schema": TraceJSON(t.InputSchema), + "max_uses": t.MaxUses, + } +} + +// ContentBlockTypes returns the type strings from content (when it's []any blocks). +func ContentBlockTypes(content any) []string { + blocks, ok := content.([]any) + if !ok { + return nil + } + types := make([]string, 0, len(blocks)) + for _, block := range blocks { + blockMap, ok := block.(map[string]any) + if !ok { + types = append(types, fmt.Sprintf("%T", block)) + continue + } + t, _ := blockMap["type"].(string) + types = append(types, t) + } + return types +} + +func ptrVal[T any](v *T) any { + if v == nil { + return nil + } + return *v +} + +// --------------------------------------------------------------------------- +// Ollama api.* tracing (shared between anthropic and middleware packages) +// --------------------------------------------------------------------------- + +// TraceChatRequest returns a compact trace representation of an Ollama ChatRequest. +func TraceChatRequest(req *api.ChatRequest) map[string]any { + if req == nil { + return nil + } + stream := false + if req.Stream != nil { + stream = *req.Stream + } + return map[string]any{ + "model": req.Model, + "messages": TraceAPIMessages(req.Messages), + "tools": TraceAPITools(req.Tools), + "stream": stream, + "options": req.Options, + "think": TraceJSON(req.Think), + } +} + +// TraceChatResponse returns a compact trace representation of an Ollama ChatResponse. +func TraceChatResponse(resp api.ChatResponse) map[string]any { + return map[string]any{ + "model": resp.Model, + "done": resp.Done, + "done_reason": resp.DoneReason, + "message": TraceAPIMessage(resp.Message), + "metrics": TraceJSON(resp.Metrics), + } +} + +// TraceAPIMessages returns compact trace representations for a slice of api.Message. +func TraceAPIMessages(msgs []api.Message) []map[string]any { + out := make([]map[string]any, 0, len(msgs)) + for _, m := range msgs { + out = append(out, TraceAPIMessage(m)) + } + return out +} + +// TraceAPIMessage returns a compact trace representation of a single api.Message. +func TraceAPIMessage(m api.Message) map[string]any { + return map[string]any{ + "role": m.Role, + "content": TraceTruncateString(m.Content), + "thinking": TraceTruncateString(m.Thinking), + "images": traceImageSizes(m.Images), + "tool_calls": traceToolCalls(m.ToolCalls), + "tool_name": m.ToolName, + "tool_call_id": m.ToolCallID, + } +} + +func traceImageSizes(images []api.ImageData) []int { + if len(images) == 0 { + return nil + } + sizes := make([]int, 0, len(images)) + for _, img := range images { + sizes = append(sizes, len(img)) + } + return sizes +} + +// TraceAPITools returns compact trace representations for a slice of api.Tool. +func TraceAPITools(tools api.Tools) []map[string]any { + out := make([]map[string]any, 0, len(tools)) + for _, t := range tools { + out = append(out, TraceAPITool(t)) + } + return out +} + +// TraceAPITool returns a compact trace representation of a single api.Tool. +func TraceAPITool(t api.Tool) map[string]any { + return map[string]any{ + "type": t.Type, + "name": t.Function.Name, + "description": TraceTruncateString(t.Function.Description), + "parameters": TraceJSON(t.Function.Parameters), + } +} + +// TraceToolCall returns a compact trace representation of an api.ToolCall. +func TraceToolCall(tc api.ToolCall) map[string]any { + return map[string]any{ + "id": tc.ID, + "name": tc.Function.Name, + "args": TraceJSON(tc.Function.Arguments), + } +} + +func traceToolCalls(tcs []api.ToolCall) []map[string]any { + if len(tcs) == 0 { + return nil + } + out := make([]map[string]any, 0, len(tcs)) + for _, tc := range tcs { + out = append(out, TraceToolCall(tc)) + } + return out +} diff --git a/api/client.go b/api/client.go new file mode 100644 index 0000000..7ef8aba --- /dev/null +++ b/api/client.go @@ -0,0 +1,488 @@ +// Package api implements the client-side API for code wishing to interact +// with the ollama service. The methods of the [Client] type correspond to +// the ollama REST API as described in [the API documentation]. +// The ollama command-line client itself uses this package to interact with +// the backend service. +// +// # Examples +// +// Several examples of using this package are available [in the GitHub +// repository]. +// +// [the API documentation]: https://github.com/ollama/ollama/blob/main/docs/api.md +// [in the GitHub repository]: https://github.com/ollama/ollama/tree/main/api/examples +package api + +import ( + "bufio" + "bytes" + "context" + "encoding/json" + "errors" + "fmt" + "io" + "net/http" + "net/url" + "runtime" + "strconv" + "time" + + "github.com/ollama/ollama/auth" + "github.com/ollama/ollama/envconfig" + "github.com/ollama/ollama/format" + "github.com/ollama/ollama/version" +) + +// Client encapsulates client state for interacting with the ollama +// service. Use [ClientFromEnvironment] to create new Clients. +type Client struct { + base *url.URL + http *http.Client +} + +func checkError(resp *http.Response, body []byte) error { + if resp.StatusCode < http.StatusBadRequest { + return nil + } + + if resp.StatusCode == http.StatusUnauthorized { + authError := AuthorizationError{StatusCode: resp.StatusCode} + json.Unmarshal(body, &authError) + return authError + } + + apiError := StatusError{StatusCode: resp.StatusCode} + + err := json.Unmarshal(body, &apiError) + if err != nil { + // Use the full body as the message if we fail to decode a response. + apiError.ErrorMessage = string(body) + } + + return apiError +} + +// ClientFromEnvironment creates a new [Client] using configuration from the +// environment variable OLLAMA_HOST, which points to the network host and +// port on which the ollama service is listening. The format of this variable +// is: +// +// ://: +// +// If the variable is not specified, a default ollama host and port will be +// used. +func ClientFromEnvironment() (*Client, error) { + return &Client{ + base: envconfig.Host(), + http: http.DefaultClient, + }, nil +} + +func NewClient(base *url.URL, http *http.Client) *Client { + return &Client{ + base: base, + http: http, + } +} + +func getAuthorizationToken(ctx context.Context, challenge string) (string, error) { + token, err := auth.Sign(ctx, []byte(challenge)) + if err != nil { + return "", err + } + return token, nil +} + +func (c *Client) do(ctx context.Context, method, path string, reqData, respData any) error { + var reqBody io.Reader + var data []byte + var err error + + switch reqData := reqData.(type) { + case io.Reader: + // reqData is already an io.Reader + reqBody = reqData + case nil: + // noop + default: + data, err = json.Marshal(reqData) + if err != nil { + return err + } + + reqBody = bytes.NewReader(data) + } + + requestURL := c.base.JoinPath(path) + + var token string + if envconfig.UseAuth() || c.base.Hostname() == "ollama.com" { + now := strconv.FormatInt(time.Now().Unix(), 10) + chal := fmt.Sprintf("%s,%s?ts=%s", method, path, now) + token, err = getAuthorizationToken(ctx, chal) + if err != nil { + return err + } + + q := requestURL.Query() + q.Set("ts", now) + requestURL.RawQuery = q.Encode() + } + + request, err := http.NewRequestWithContext(ctx, method, requestURL.String(), reqBody) + if err != nil { + return err + } + + request.Header.Set("Content-Type", "application/json") + request.Header.Set("Accept", "application/json") + request.Header.Set("User-Agent", fmt.Sprintf("ollama/%s (%s %s) Go/%s", version.Version, runtime.GOARCH, runtime.GOOS, runtime.Version())) + + if token != "" { + request.Header.Set("Authorization", token) + } + + respObj, err := c.http.Do(request) + if err != nil { + return err + } + defer respObj.Body.Close() + + respBody, err := io.ReadAll(respObj.Body) + if err != nil { + return err + } + + if err := checkError(respObj, respBody); err != nil { + return err + } + + if len(respBody) > 0 && respData != nil { + if err := json.Unmarshal(respBody, respData); err != nil { + return err + } + } + return nil +} + +const maxBufferSize = 8 * format.MegaByte + +func (c *Client) stream(ctx context.Context, method, path string, data any, fn func([]byte) error) error { + var buf io.Reader + if data != nil { + bts, err := json.Marshal(data) + if err != nil { + return err + } + + buf = bytes.NewBuffer(bts) + } + + requestURL := c.base.JoinPath(path) + + var token string + if envconfig.UseAuth() || c.base.Hostname() == "ollama.com" { + var err error + now := strconv.FormatInt(time.Now().Unix(), 10) + chal := fmt.Sprintf("%s,%s?ts=%s", method, path, now) + token, err = getAuthorizationToken(ctx, chal) + if err != nil { + return err + } + + q := requestURL.Query() + q.Set("ts", now) + requestURL.RawQuery = q.Encode() + } + + request, err := http.NewRequestWithContext(ctx, method, requestURL.String(), buf) + if err != nil { + return err + } + + request.Header.Set("Content-Type", "application/json") + request.Header.Set("Accept", "application/x-ndjson") + request.Header.Set("User-Agent", fmt.Sprintf("ollama/%s (%s %s) Go/%s", version.Version, runtime.GOARCH, runtime.GOOS, runtime.Version())) + + if token != "" { + request.Header.Set("Authorization", token) + } + + response, err := c.http.Do(request) + if err != nil { + return err + } + defer response.Body.Close() + + scanner := bufio.NewScanner(response.Body) + // increase the buffer size to avoid running out of space + scanBuf := make([]byte, 0, maxBufferSize) + scanner.Buffer(scanBuf, maxBufferSize) + for scanner.Scan() { + var errorResponse struct { + Error string `json:"error,omitempty"` + SigninURL string `json:"signin_url,omitempty"` + } + + bts := scanner.Bytes() + if err := json.Unmarshal(bts, &errorResponse); err != nil { + if response.StatusCode >= http.StatusBadRequest { + return StatusError{ + StatusCode: response.StatusCode, + Status: response.Status, + ErrorMessage: string(bts), + } + } + return errors.New(string(bts)) + } + + if response.StatusCode == http.StatusUnauthorized { + return AuthorizationError{ + StatusCode: response.StatusCode, + Status: response.Status, + SigninURL: errorResponse.SigninURL, + } + } else if response.StatusCode >= http.StatusBadRequest { + return StatusError{ + StatusCode: response.StatusCode, + Status: response.Status, + ErrorMessage: errorResponse.Error, + } + } + + if errorResponse.Error != "" { + return errors.New(errorResponse.Error) + } + + if err := fn(bts); err != nil { + return err + } + } + + return nil +} + +// GenerateResponseFunc is a function that [Client.Generate] invokes every time +// a response is received from the service. If this function returns an error, +// [Client.Generate] will stop generating and return this error. +type GenerateResponseFunc func(GenerateResponse) error + +// Generate generates a response for a given prompt. The req parameter should +// be populated with prompt details. fn is called for each response (there may +// be multiple responses, e.g. in case streaming is enabled). +func (c *Client) Generate(ctx context.Context, req *GenerateRequest, fn GenerateResponseFunc) error { + return c.stream(ctx, http.MethodPost, "/api/generate", req, func(bts []byte) error { + var resp GenerateResponse + if err := json.Unmarshal(bts, &resp); err != nil { + return err + } + + return fn(resp) + }) +} + +// ChatResponseFunc is a function that [Client.Chat] invokes every time +// a response is received from the service. If this function returns an error, +// [Client.Chat] will stop generating and return this error. +type ChatResponseFunc func(ChatResponse) error + +// Chat generates the next message in a chat. [ChatRequest] may contain a +// sequence of messages which can be used to maintain chat history with a model. +// fn is called for each response (there may be multiple responses, e.g. if case +// streaming is enabled). +func (c *Client) Chat(ctx context.Context, req *ChatRequest, fn ChatResponseFunc) error { + return c.stream(ctx, http.MethodPost, "/api/chat", req, func(bts []byte) error { + var resp ChatResponse + if err := json.Unmarshal(bts, &resp); err != nil { + return err + } + + return fn(resp) + }) +} + +// PullProgressFunc is a function that [Client.Pull] invokes every time there +// is progress with a "pull" request sent to the service. If this function +// returns an error, [Client.Pull] will stop the process and return this error. +type PullProgressFunc func(ProgressResponse) error + +// Pull downloads a model from the ollama library. fn is called each time +// progress is made on the request and can be used to display a progress bar, +// etc. +func (c *Client) Pull(ctx context.Context, req *PullRequest, fn PullProgressFunc) error { + return c.stream(ctx, http.MethodPost, "/api/pull", req, func(bts []byte) error { + var resp ProgressResponse + if err := json.Unmarshal(bts, &resp); err != nil { + return err + } + + return fn(resp) + }) +} + +// PushProgressFunc is a function that [Client.Push] invokes when progress is +// made. +// It's similar to other progress function types like [PullProgressFunc]. +type PushProgressFunc func(ProgressResponse) error + +// Push uploads a model to the model library; requires registering for ollama.ai +// and adding a public key first. fn is called each time progress is made on +// the request and can be used to display a progress bar, etc. +func (c *Client) Push(ctx context.Context, req *PushRequest, fn PushProgressFunc) error { + return c.stream(ctx, http.MethodPost, "/api/push", req, func(bts []byte) error { + var resp ProgressResponse + if err := json.Unmarshal(bts, &resp); err != nil { + return err + } + + return fn(resp) + }) +} + +// CreateProgressFunc is a function that [Client.Create] invokes when progress +// is made. +// It's similar to other progress function types like [PullProgressFunc]. +type CreateProgressFunc func(ProgressResponse) error + +// Create creates a model from a [Modelfile]. fn is a progress function that +// behaves similarly to other methods (see [Client.Pull]). +// +// [Modelfile]: https://github.com/ollama/ollama/blob/main/docs/modelfile.mdx +func (c *Client) Create(ctx context.Context, req *CreateRequest, fn CreateProgressFunc) error { + return c.stream(ctx, http.MethodPost, "/api/create", req, func(bts []byte) error { + var resp ProgressResponse + if err := json.Unmarshal(bts, &resp); err != nil { + return err + } + + return fn(resp) + }) +} + +// List lists models that are available locally. +func (c *Client) List(ctx context.Context) (*ListResponse, error) { + var lr ListResponse + if err := c.do(ctx, http.MethodGet, "/api/tags", nil, &lr); err != nil { + return nil, err + } + return &lr, nil +} + +// ModelRecommendationsExperimental lists model recommendations from the local +// server's experimental recommendations endpoint. +func (c *Client) ModelRecommendationsExperimental(ctx context.Context) (*ModelRecommendationsResponse, error) { + var resp ModelRecommendationsResponse + if err := c.do(ctx, http.MethodGet, "/api/experimental/model-recommendations", nil, &resp); err != nil { + return nil, err + } + return &resp, nil +} + +// ListRunning lists running models. +func (c *Client) ListRunning(ctx context.Context) (*ProcessResponse, error) { + var lr ProcessResponse + if err := c.do(ctx, http.MethodGet, "/api/ps", nil, &lr); err != nil { + return nil, err + } + return &lr, nil +} + +// Copy copies a model - creating a model with another name from an existing +// model. +func (c *Client) Copy(ctx context.Context, req *CopyRequest) error { + if err := c.do(ctx, http.MethodPost, "/api/copy", req, nil); err != nil { + return err + } + return nil +} + +// Delete deletes a model and its data. +func (c *Client) Delete(ctx context.Context, req *DeleteRequest) error { + if err := c.do(ctx, http.MethodDelete, "/api/delete", req, nil); err != nil { + return err + } + return nil +} + +// Show obtains model information, including details, modelfile, license etc. +func (c *Client) Show(ctx context.Context, req *ShowRequest) (*ShowResponse, error) { + var resp ShowResponse + if err := c.do(ctx, http.MethodPost, "/api/show", req, &resp); err != nil { + return nil, err + } + return &resp, nil +} + +// Heartbeat checks if the server has started and is responsive; if yes, it +// returns nil, otherwise an error. +func (c *Client) Heartbeat(ctx context.Context) error { + if err := c.do(ctx, http.MethodHead, "/", nil, nil); err != nil { + return err + } + return nil +} + +// Embed generates embeddings from a model. +func (c *Client) Embed(ctx context.Context, req *EmbedRequest) (*EmbedResponse, error) { + var resp EmbedResponse + if err := c.do(ctx, http.MethodPost, "/api/embed", req, &resp); err != nil { + return nil, err + } + return &resp, nil +} + +// Embeddings generates an embedding from a model. +func (c *Client) Embeddings(ctx context.Context, req *EmbeddingRequest) (*EmbeddingResponse, error) { + var resp EmbeddingResponse + if err := c.do(ctx, http.MethodPost, "/api/embeddings", req, &resp); err != nil { + return nil, err + } + return &resp, nil +} + +// CreateBlob creates a blob from a file on the server. digest is the +// expected SHA256 digest of the file, and r represents the file. +func (c *Client) CreateBlob(ctx context.Context, digest string, r io.Reader) error { + return c.do(ctx, http.MethodPost, fmt.Sprintf("/api/blobs/%s", digest), r, nil) +} + +// Version returns the Ollama server version as a string. +func (c *Client) Version(ctx context.Context) (string, error) { + var version struct { + Version string `json:"version"` + } + + if err := c.do(ctx, http.MethodGet, "/api/version", nil, &version); err != nil { + return "", err + } + + return version.Version, nil +} + +// CloudStatusExperimental returns whether cloud features are disabled on the server. +func (c *Client) CloudStatusExperimental(ctx context.Context) (*StatusResponse, error) { + var status StatusResponse + if err := c.do(ctx, http.MethodGet, "/api/status", nil, &status); err != nil { + return nil, err + } + + return &status, nil +} + +// Signout will signout a client for a local ollama server. +func (c *Client) Signout(ctx context.Context) error { + return c.do(ctx, http.MethodPost, "/api/signout", nil, nil) +} + +// Disconnect will disconnect an ollama instance from ollama.com. +func (c *Client) Disconnect(ctx context.Context, encodedKey string) error { + return c.do(ctx, http.MethodDelete, fmt.Sprintf("/api/user/keys/%s", encodedKey), nil, nil) +} + +func (c *Client) Whoami(ctx context.Context) (*UserResponse, error) { + var resp UserResponse + if err := c.do(ctx, http.MethodPost, "/api/me", nil, &resp); err != nil { + return nil, err + } + return &resp, nil +} diff --git a/api/client_test.go b/api/client_test.go new file mode 100644 index 0000000..827e41d --- /dev/null +++ b/api/client_test.go @@ -0,0 +1,322 @@ +package api + +import ( + "encoding/json" + "fmt" + "net/http" + "net/http/httptest" + "net/url" + "strings" + "testing" +) + +func TestClientFromEnvironment(t *testing.T) { + type testCase struct { + value string + expect string + err error + } + + testCases := map[string]*testCase{ + "empty": {value: "", expect: "http://127.0.0.1:11434"}, + "only address": {value: "1.2.3.4", expect: "http://1.2.3.4:11434"}, + "only port": {value: ":1234", expect: "http://:1234"}, + "address and port": {value: "1.2.3.4:1234", expect: "http://1.2.3.4:1234"}, + "scheme http and address": {value: "http://1.2.3.4", expect: "http://1.2.3.4:80"}, + "scheme https and address": {value: "https://1.2.3.4", expect: "https://1.2.3.4:443"}, + "scheme, address, and port": {value: "https://1.2.3.4:1234", expect: "https://1.2.3.4:1234"}, + "hostname": {value: "example.com", expect: "http://example.com:11434"}, + "hostname and port": {value: "example.com:1234", expect: "http://example.com:1234"}, + "scheme http and hostname": {value: "http://example.com", expect: "http://example.com:80"}, + "scheme https and hostname": {value: "https://example.com", expect: "https://example.com:443"}, + "scheme, hostname, and port": {value: "https://example.com:1234", expect: "https://example.com:1234"}, + "trailing slash": {value: "example.com/", expect: "http://example.com:11434"}, + "trailing slash port": {value: "example.com:1234/", expect: "http://example.com:1234"}, + } + + for k, v := range testCases { + t.Run(k, func(t *testing.T) { + t.Setenv("OLLAMA_HOST", v.value) + + client, err := ClientFromEnvironment() + if err != v.err { + t.Fatalf("expected %s, got %s", v.err, err) + } + + if client.base.String() != v.expect { + t.Fatalf("expected %s, got %s", v.expect, client.base.String()) + } + }) + } +} + +// testError represents an internal error type with status code and message +// this is used since the error response from the server is not a standard error struct +type testError struct { + message string + statusCode int + raw bool // if true, write message as-is instead of JSON encoding +} + +func (e testError) Error() string { + return e.message +} + +func TestClientStream(t *testing.T) { + testCases := []struct { + name string + responses []any + wantErr string + }{ + { + name: "immediate error response", + responses: []any{ + testError{ + message: "test error message", + statusCode: http.StatusBadRequest, + }, + }, + wantErr: "test error message", + }, + { + name: "error after successful chunks, ok response", + responses: []any{ + ChatResponse{Message: Message{Content: "partial response 1"}}, + ChatResponse{Message: Message{Content: "partial response 2"}}, + testError{ + message: "mid-stream error", + statusCode: http.StatusOK, + }, + }, + wantErr: "mid-stream error", + }, + { + name: "http status error takes precedence over general error", + responses: []any{ + testError{ + message: "custom error message", + statusCode: http.StatusInternalServerError, + }, + }, + wantErr: "500", + }, + { + name: "successful stream completion", + responses: []any{ + ChatResponse{Message: Message{Content: "chunk 1"}}, + ChatResponse{Message: Message{Content: "chunk 2"}}, + ChatResponse{ + Message: Message{Content: "final chunk"}, + Done: true, + DoneReason: "stop", + }, + }, + }, + { + name: "plain text error response", + responses: []any{ + "internal server error", + }, + wantErr: "internal server error", + }, + { + name: "HTML error page", + responses: []any{ + "404 Not Found", + }, + wantErr: "404 Not Found", + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + flusher, ok := w.(http.Flusher) + if !ok { + t.Fatal("expected http.Flusher") + } + + w.Header().Set("Content-Type", "application/x-ndjson") + + for _, resp := range tc.responses { + if errResp, ok := resp.(testError); ok { + w.WriteHeader(errResp.statusCode) + err := json.NewEncoder(w).Encode(map[string]string{ + "error": errResp.message, + }) + if err != nil { + t.Fatal("failed to encode error response:", err) + } + return + } + + if str, ok := resp.(string); ok { + fmt.Fprintln(w, str) + flusher.Flush() + continue + } + + if err := json.NewEncoder(w).Encode(resp); err != nil { + t.Fatalf("failed to encode response: %v", err) + } + flusher.Flush() + } + })) + defer ts.Close() + + client := NewClient(&url.URL{Scheme: "http", Host: ts.Listener.Addr().String()}, http.DefaultClient) + + var receivedChunks []ChatResponse + err := client.stream(t.Context(), http.MethodPost, "/v1/chat", nil, func(chunk []byte) error { + var resp ChatResponse + if err := json.Unmarshal(chunk, &resp); err != nil { + return fmt.Errorf("failed to unmarshal chunk: %w", err) + } + receivedChunks = append(receivedChunks, resp) + return nil + }) + + if tc.wantErr != "" { + if err == nil { + t.Fatal("expected error but got nil") + } + if !strings.Contains(err.Error(), tc.wantErr) { + t.Errorf("expected error containing %q, got %v", tc.wantErr, err) + } + return + } + if err != nil { + t.Errorf("unexpected error: %v", err) + } + }) + } +} + +func TestClientDo(t *testing.T) { + testCases := []struct { + name string + response any + wantErr string + wantStatusCode int + }{ + { + name: "immediate error response", + response: testError{ + message: "test error message", + statusCode: http.StatusBadRequest, + }, + wantErr: "test error message", + wantStatusCode: http.StatusBadRequest, + }, + { + name: "server error response", + response: testError{ + message: "internal error", + statusCode: http.StatusInternalServerError, + }, + wantErr: "internal error", + wantStatusCode: http.StatusInternalServerError, + }, + { + name: "successful response", + response: struct { + ID string `json:"id"` + Success bool `json:"success"` + }{ + ID: "msg_123", + Success: true, + }, + }, + { + name: "plain text error response", + response: testError{ + message: "internal server error", + statusCode: http.StatusInternalServerError, + raw: true, + }, + wantErr: "internal server error", + wantStatusCode: http.StatusInternalServerError, + }, + { + name: "HTML error page", + response: testError{ + message: "404 Not Found", + statusCode: http.StatusNotFound, + raw: true, + }, + wantErr: "404 Not Found", + wantStatusCode: http.StatusNotFound, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if errResp, ok := tc.response.(testError); ok { + w.WriteHeader(errResp.statusCode) + if !errResp.raw { + err := json.NewEncoder(w).Encode(map[string]string{ + "error": errResp.message, + }) + if err != nil { + t.Fatal("failed to encode error response:", err) + } + } else { + // Write raw message (simulates non-JSON error responses) + fmt.Fprint(w, errResp.message) + } + return + } + + w.Header().Set("Content-Type", "application/json") + if err := json.NewEncoder(w).Encode(tc.response); err != nil { + t.Fatalf("failed to encode response: %v", err) + } + })) + defer ts.Close() + + client := NewClient(&url.URL{Scheme: "http", Host: ts.Listener.Addr().String()}, http.DefaultClient) + + var resp struct { + ID string `json:"id"` + Success bool `json:"success"` + } + err := client.do(t.Context(), http.MethodPost, "/v1/messages", nil, &resp) + + if tc.wantErr != "" { + if err == nil { + t.Fatalf("got nil, want error %q", tc.wantErr) + } + if err.Error() != tc.wantErr { + t.Errorf("error message mismatch: got %q, want %q", err.Error(), tc.wantErr) + } + if tc.wantStatusCode != 0 { + if statusErr, ok := err.(StatusError); ok { + if statusErr.StatusCode != tc.wantStatusCode { + t.Errorf("status code mismatch: got %d, want %d", statusErr.StatusCode, tc.wantStatusCode) + } + } else { + t.Errorf("expected StatusError, got %T", err) + } + } + return + } + + if err != nil { + t.Fatalf("got error %q, want nil", err) + } + + if expectedResp, ok := tc.response.(struct { + ID string `json:"id"` + Success bool `json:"success"` + }); ok { + if resp.ID != expectedResp.ID { + t.Errorf("response ID mismatch: got %q, want %q", resp.ID, expectedResp.ID) + } + if resp.Success != expectedResp.Success { + t.Errorf("response Success mismatch: got %v, want %v", resp.Success, expectedResp.Success) + } + } + }) + } +} diff --git a/api/examples/README.md b/api/examples/README.md new file mode 100644 index 0000000..e83b536 --- /dev/null +++ b/api/examples/README.md @@ -0,0 +1,18 @@ +# Ollama API Examples + +Run the examples in this directory with: + +```shell +go run example_name/main.go +``` + +## Chat - Chat with a model +- [chat/main.go](chat/main.go) + +## Generate - Generate text from a model +- [generate/main.go](generate/main.go) +- [generate-streaming/main.go](generate-streaming/main.go) + +## Pull - Pull a model +- [pull-progress/main.go](pull-progress/main.go) + diff --git a/api/examples/chat/main.go b/api/examples/chat/main.go new file mode 100644 index 0000000..b44a1ec --- /dev/null +++ b/api/examples/chat/main.go @@ -0,0 +1,51 @@ +package main + +import ( + "context" + "fmt" + "log" + + "github.com/ollama/ollama/api" +) + +func main() { + client, err := api.ClientFromEnvironment() + if err != nil { + log.Fatal(err) + } + + messages := []api.Message{ + { + Role: "system", + Content: "Provide very brief, concise responses", + }, + { + Role: "user", + Content: "Name some unusual animals", + }, + { + Role: "assistant", + Content: "Monotreme, platypus, echidna", + }, + { + Role: "user", + Content: "which of these is the most dangerous?", + }, + } + + ctx := context.Background() + req := &api.ChatRequest{ + Model: "llama3.2", + Messages: messages, + } + + respFunc := func(resp api.ChatResponse) error { + fmt.Print(resp.Message.Content) + return nil + } + + err = client.Chat(ctx, req, respFunc) + if err != nil { + log.Fatal(err) + } +} diff --git a/api/examples/generate-streaming/main.go b/api/examples/generate-streaming/main.go new file mode 100644 index 0000000..3acfb22 --- /dev/null +++ b/api/examples/generate-streaming/main.go @@ -0,0 +1,40 @@ +package main + +import ( + "context" + "fmt" + "log" + + "github.com/ollama/ollama/api" +) + +func main() { + client, err := api.ClientFromEnvironment() + if err != nil { + log.Fatal(err) + } + + // By default, GenerateRequest is streaming. + req := &api.GenerateRequest{ + Model: "gemma2", + Prompt: "how many planets are there?", + } + + ctx := context.Background() + respFunc := func(resp api.GenerateResponse) error { + // Only print the response here; GenerateResponse has a number of other + // interesting fields you want to examine. + + // In streaming mode, responses are partial so we call fmt.Print (and not + // Println) in order to avoid spurious newlines being introduced. The + // model will insert its own newlines if it wants. + fmt.Print(resp.Response) + return nil + } + + err = client.Generate(ctx, req, respFunc) + if err != nil { + log.Fatal(err) + } + fmt.Println() +} diff --git a/api/examples/generate/main.go b/api/examples/generate/main.go new file mode 100644 index 0000000..2fe2874 --- /dev/null +++ b/api/examples/generate/main.go @@ -0,0 +1,37 @@ +package main + +import ( + "context" + "fmt" + "log" + + "github.com/ollama/ollama/api" +) + +func main() { + client, err := api.ClientFromEnvironment() + if err != nil { + log.Fatal(err) + } + + req := &api.GenerateRequest{ + Model: "gemma2", + Prompt: "how many planets are there?", + + // set streaming to false + Stream: new(bool), + } + + ctx := context.Background() + respFunc := func(resp api.GenerateResponse) error { + // Only print the response here; GenerateResponse has a number of other + // interesting fields you want to examine. + fmt.Println(resp.Response) + return nil + } + + err = client.Generate(ctx, req, respFunc) + if err != nil { + log.Fatal(err) + } +} diff --git a/api/examples/multimodal/main.go b/api/examples/multimodal/main.go new file mode 100644 index 0000000..0b0f19e --- /dev/null +++ b/api/examples/multimodal/main.go @@ -0,0 +1,47 @@ +package main + +import ( + "context" + "fmt" + "log" + "os" + + "github.com/ollama/ollama/api" +) + +func main() { + if len(os.Args) <= 1 { + log.Fatal("usage: ") + } + + imgData, err := os.ReadFile(os.Args[1]) + if err != nil { + log.Fatal(err) + } + + client, err := api.ClientFromEnvironment() + if err != nil { + log.Fatal(err) + } + + req := &api.GenerateRequest{ + Model: "llava", + Prompt: "describe this image", + Images: []api.ImageData{imgData}, + } + + ctx := context.Background() + respFunc := func(resp api.GenerateResponse) error { + // In streaming mode, responses are partial so we call fmt.Print (and not + // Println) in order to avoid spurious newlines being introduced. The + // model will insert its own newlines if it wants. + fmt.Print(resp.Response) + return nil + } + + err = client.Generate(ctx, req, respFunc) + if err != nil { + log.Fatal(err) + } + fmt.Println() +} diff --git a/api/examples/pull-progress/main.go b/api/examples/pull-progress/main.go new file mode 100644 index 0000000..7486336 --- /dev/null +++ b/api/examples/pull-progress/main.go @@ -0,0 +1,31 @@ +package main + +import ( + "context" + "fmt" + "log" + + "github.com/ollama/ollama/api" +) + +func main() { + client, err := api.ClientFromEnvironment() + if err != nil { + log.Fatal(err) + } + + ctx := context.Background() + + req := &api.PullRequest{ + Model: "mistral", + } + progressFunc := func(resp api.ProgressResponse) error { + fmt.Printf("Progress: status=%v, total=%v, completed=%v\n", resp.Status, resp.Total, resp.Completed) + return nil + } + + err = client.Pull(ctx, req, progressFunc) + if err != nil { + log.Fatal(err) + } +} diff --git a/api/types.go b/api/types.go new file mode 100644 index 0000000..a46d3ed --- /dev/null +++ b/api/types.go @@ -0,0 +1,1318 @@ +package api + +import ( + "encoding/json" + "fmt" + "iter" + "log/slog" + "math" + "os" + "reflect" + "strconv" + "strings" + "time" + + "github.com/google/uuid" + + "github.com/ollama/ollama/envconfig" + "github.com/ollama/ollama/internal/orderedmap" + "github.com/ollama/ollama/types/model" +) + +// StatusError is an error with an HTTP status code and message. +type StatusError struct { + StatusCode int + Status string + ErrorMessage string `json:"error"` +} + +func (e StatusError) Error() string { + switch { + case e.Status != "" && e.ErrorMessage != "": + return fmt.Sprintf("%s: %s", e.Status, e.ErrorMessage) + case e.Status != "": + return e.Status + case e.ErrorMessage != "": + return e.ErrorMessage + default: + // this should not happen + return "something went wrong, please see the ollama server logs for details" + } +} + +type AuthorizationError struct { + StatusCode int + Status string + SigninURL string `json:"signin_url"` +} + +func (e AuthorizationError) Error() string { + if e.Status != "" { + return e.Status + } + return "something went wrong, please see the ollama server logs for details" +} + +// ImageData represents the raw binary data of an image file. +type ImageData []byte + +// GenerateRequest describes a request sent by [Client.Generate]. While you +// have to specify the Model and Prompt fields, all the other fields have +// reasonable defaults for basic uses. +type GenerateRequest struct { + // Model is the model name; it should be a name familiar to Ollama from + // the library at https://ollama.com/library + Model string `json:"model"` + + // Prompt is the textual prompt to send to the model. + Prompt string `json:"prompt"` + + // Suffix is the text that comes after the inserted text. + Suffix string `json:"suffix"` + + // System overrides the model's default system message/prompt. + System string `json:"system"` + + // Template overrides the model's default prompt template. + Template string `json:"template"` + + // Context is the context parameter returned from a previous call to + // [Client.Generate]. It can be used to keep a short conversational memory. + Context []int `json:"context,omitempty"` + + // Stream specifies whether the response is streaming; it is true by default. + Stream *bool `json:"stream,omitempty"` + + // Raw set to true means that no formatting will be applied to the prompt. + Raw bool `json:"raw,omitempty"` + + // Format specifies the format to return a response in. + Format json.RawMessage `json:"format,omitempty"` + + // KeepAlive controls how long the model will stay loaded in memory following + // this request. + KeepAlive *Duration `json:"keep_alive,omitempty"` + + // Images is an optional list of raw image bytes accompanying this + // request, for multimodal models. + Images []ImageData `json:"images,omitempty"` + + // Options lists model-specific options. For example, temperature can be + // set through this field, if the model supports it. + Options map[string]any `json:"options"` + + // Think controls whether thinking/reasoning models will think before + // responding. Can be a boolean (true/false) or a string ("high", "medium", "low") + // for supported models. Needs to be a pointer so we can distinguish between false + // (request that thinking _not_ be used) and unset (use the old behavior + // before this option was introduced) + Think *ThinkValue `json:"think,omitempty"` + + // Truncate is a boolean that, when set to true, truncates the chat history messages + // if the rendered prompt exceeds the context length limit. + Truncate *bool `json:"truncate,omitempty"` + + // Shift is a boolean that, when set to true, shifts the chat history + // when hitting the context length limit instead of erroring. + Shift *bool `json:"shift,omitempty"` + + // DebugRenderOnly is a debug option that, when set to true, returns the rendered + // template instead of calling the model. + DebugRenderOnly bool `json:"_debug_render_only,omitempty"` + + // Logprobs specifies whether to return log probabilities of the output tokens. + Logprobs bool `json:"logprobs,omitempty"` + + // TopLogprobs is the number of most likely tokens to return at each token position, + // each with an associated log probability. Only applies when Logprobs is true. + // Valid values are 0-20. Default is 0 (only return the selected token's logprob). + TopLogprobs int `json:"top_logprobs,omitempty"` + + // Experimental: Image generation fields (may change or be removed) + + // Width is the width of the generated image in pixels. + // Only used for image generation models. + Width int32 `json:"width,omitempty"` + + // Height is the height of the generated image in pixels. + // Only used for image generation models. + Height int32 `json:"height,omitempty"` + + // Steps is the number of diffusion steps for image generation. + // Only used for image generation models. + Steps int32 `json:"steps,omitempty"` +} + +// ChatRequest describes a request sent by [Client.Chat]. +type ChatRequest struct { + // Model is the model name, as in [GenerateRequest]. + Model string `json:"model"` + + // Messages is the messages of the chat - can be used to keep a chat memory. + Messages []Message `json:"messages"` + + // Stream enables streaming of returned responses; true by default. + Stream *bool `json:"stream,omitempty"` + + // Format is the format to return the response in (e.g. "json"). + Format json.RawMessage `json:"format,omitempty"` + + // KeepAlive controls how long the model will stay loaded into memory + // following the request. + KeepAlive *Duration `json:"keep_alive,omitempty"` + + // Tools is an optional list of tools the model has access to. + Tools `json:"tools,omitempty"` + + // Options lists model-specific options. + Options map[string]any `json:"options"` + + // Think controls whether thinking/reasoning models will think before + // responding. Can be a boolean (true/false) or a string ("high", "medium", "low") + // for supported models. + Think *ThinkValue `json:"think,omitempty"` + + // Truncate is a boolean that, when set to true, truncates the chat history messages + // if the rendered prompt exceeds the context length limit. + Truncate *bool `json:"truncate,omitempty"` + + // Shift is a boolean that, when set to true, shifts the chat history + // when hitting the context length limit instead of erroring. + Shift *bool `json:"shift,omitempty"` + + // DebugRenderOnly is a debug option that, when set to true, returns the rendered + // template instead of calling the model. + DebugRenderOnly bool `json:"_debug_render_only,omitempty"` + + // Logprobs specifies whether to return log probabilities of the output tokens. + Logprobs bool `json:"logprobs,omitempty"` + + // TopLogprobs is the number of most likely tokens to return at each token position, + // each with an associated log probability. Only applies when Logprobs is true. + // Valid values are 0-20. Default is 0 (only return the selected token's logprob). + TopLogprobs int `json:"top_logprobs,omitempty"` +} + +type Tools []Tool + +func (t Tools) String() string { + bts, _ := json.Marshal(t) + return string(bts) +} + +func (t Tool) String() string { + bts, _ := json.Marshal(t) + return string(bts) +} + +// Message is a single message in a chat sequence. The message contains the +// role ("system", "user", or "assistant"), the content and an optional list +// of images. +type Message struct { + Role string `json:"role"` + Content string `json:"content"` + // Thinking contains the text that was inside thinking tags in the + // original model output when ChatRequest.Think is enabled. + Thinking string `json:"thinking,omitempty"` + Images []ImageData `json:"images,omitempty"` + ToolCalls []ToolCall `json:"tool_calls,omitempty"` + ToolName string `json:"tool_name,omitempty"` + ToolCallID string `json:"tool_call_id,omitempty"` +} + +func (m *Message) UnmarshalJSON(b []byte) error { + type Alias Message + var a Alias + if err := json.Unmarshal(b, &a); err != nil { + return err + } + + *m = Message(a) + m.Role = strings.ToLower(m.Role) + return nil +} + +type ToolCall struct { + ID string `json:"id,omitempty"` + Function ToolCallFunction `json:"function"` +} + +type ToolCallFunction struct { + Index int `json:"index"` + Name string `json:"name"` + Arguments ToolCallFunctionArguments `json:"arguments"` +} + +// ToolCallFunctionArguments holds tool call arguments in insertion order. +type ToolCallFunctionArguments struct { + om *orderedmap.Map[string, any] +} + +// NewToolCallFunctionArguments creates a new empty ToolCallFunctionArguments. +func NewToolCallFunctionArguments() ToolCallFunctionArguments { + return ToolCallFunctionArguments{om: orderedmap.New[string, any]()} +} + +// Get retrieves a value by key. +func (t *ToolCallFunctionArguments) Get(key string) (any, bool) { + if t == nil || t.om == nil { + return nil, false + } + return t.om.Get(key) +} + +// Set sets a key-value pair, preserving insertion order. +func (t *ToolCallFunctionArguments) Set(key string, value any) { + if t == nil { + return + } + if t.om == nil { + t.om = orderedmap.New[string, any]() + } + t.om.Set(key, value) +} + +// Len returns the number of arguments. +func (t *ToolCallFunctionArguments) Len() int { + if t == nil || t.om == nil { + return 0 + } + return t.om.Len() +} + +// All returns an iterator over all key-value pairs in insertion order. +func (t *ToolCallFunctionArguments) All() iter.Seq2[string, any] { + if t == nil || t.om == nil { + return func(yield func(string, any) bool) {} + } + return t.om.All() +} + +// ToMap returns a regular map (order not preserved). +func (t *ToolCallFunctionArguments) ToMap() map[string]any { + if t == nil || t.om == nil { + return nil + } + return t.om.ToMap() +} + +func (t *ToolCallFunctionArguments) String() string { + if t == nil || t.om == nil { + return "{}" + } + bts, _ := json.Marshal(t.om) + return string(bts) +} + +func (t *ToolCallFunctionArguments) UnmarshalJSON(data []byte) error { + t.om = orderedmap.New[string, any]() + return json.Unmarshal(data, t.om) +} + +func (t ToolCallFunctionArguments) MarshalJSON() ([]byte, error) { + if t.om == nil { + return []byte("{}"), nil + } + return json.Marshal(t.om) +} + +type Tool struct { + Type string `json:"type"` + Items any `json:"items,omitempty"` + Function ToolFunction `json:"function"` +} + +// PropertyType can be either a string or an array of strings +type PropertyType []string + +// UnmarshalJSON implements the json.Unmarshaler interface +func (pt *PropertyType) UnmarshalJSON(data []byte) error { + // Try to unmarshal as a string first + var s string + if err := json.Unmarshal(data, &s); err == nil { + *pt = []string{s} + return nil + } + + // If that fails, try to unmarshal as an array of strings + var a []string + if err := json.Unmarshal(data, &a); err != nil { + return err + } + *pt = a + return nil +} + +// MarshalJSON implements the json.Marshaler interface +func (pt PropertyType) MarshalJSON() ([]byte, error) { + if len(pt) == 1 { + // If there's only one type, marshal as a string + return json.Marshal(pt[0]) + } + // Otherwise marshal as an array + return json.Marshal([]string(pt)) +} + +// String returns a string representation of the PropertyType +func (pt PropertyType) String() string { + if len(pt) == 0 { + return "" + } + if len(pt) == 1 { + return pt[0] + } + return fmt.Sprintf("%v", []string(pt)) +} + +// ToolPropertiesMap holds tool properties in insertion order. +type ToolPropertiesMap struct { + om *orderedmap.Map[string, ToolProperty] +} + +// NewToolPropertiesMap creates a new empty ToolPropertiesMap. +func NewToolPropertiesMap() *ToolPropertiesMap { + return &ToolPropertiesMap{om: orderedmap.New[string, ToolProperty]()} +} + +// Get retrieves a property by name. +func (t *ToolPropertiesMap) Get(key string) (ToolProperty, bool) { + if t == nil || t.om == nil { + return ToolProperty{}, false + } + return t.om.Get(key) +} + +// Set sets a property, preserving insertion order. +func (t *ToolPropertiesMap) Set(key string, value ToolProperty) { + if t == nil { + return + } + if t.om == nil { + t.om = orderedmap.New[string, ToolProperty]() + } + t.om.Set(key, value) +} + +// Len returns the number of properties. +func (t *ToolPropertiesMap) Len() int { + if t == nil || t.om == nil { + return 0 + } + return t.om.Len() +} + +// All returns an iterator over all properties in insertion order. +func (t *ToolPropertiesMap) All() iter.Seq2[string, ToolProperty] { + if t == nil || t.om == nil { + return func(yield func(string, ToolProperty) bool) {} + } + return t.om.All() +} + +// ToMap returns a regular map (order not preserved). +func (t *ToolPropertiesMap) ToMap() map[string]ToolProperty { + if t == nil || t.om == nil { + return nil + } + return t.om.ToMap() +} + +func (t ToolPropertiesMap) MarshalJSON() ([]byte, error) { + if t.om == nil { + return []byte("null"), nil + } + return json.Marshal(t.om) +} + +func (t *ToolPropertiesMap) UnmarshalJSON(data []byte) error { + t.om = orderedmap.New[string, ToolProperty]() + return json.Unmarshal(data, t.om) +} + +type ToolProperty struct { + AnyOf []ToolProperty `json:"anyOf,omitempty"` + Type PropertyType `json:"type,omitempty"` + Items any `json:"items,omitempty"` + Description string `json:"description,omitempty"` + Enum []any `json:"enum,omitempty"` + Properties *ToolPropertiesMap `json:"properties,omitempty"` + Required []string `json:"required,omitempty"` +} + +// ToTypeScriptType converts a ToolProperty to a TypeScript type string +func (tp ToolProperty) ToTypeScriptType() string { + if len(tp.AnyOf) > 0 { + var types []string + for _, anyOf := range tp.AnyOf { + types = append(types, anyOf.ToTypeScriptType()) + } + return strings.Join(types, " | ") + } + + if len(tp.Type) == 0 { + return "any" + } + + if len(tp.Type) == 1 { + return mapToTypeScriptType(tp.Type[0]) + } + + var types []string + for _, t := range tp.Type { + types = append(types, mapToTypeScriptType(t)) + } + return strings.Join(types, " | ") +} + +// mapToTypeScriptType maps JSON Schema types to TypeScript types +func mapToTypeScriptType(jsonType string) string { + switch jsonType { + case "string": + return "string" + case "number", "integer": + return "number" + case "boolean": + return "boolean" + case "array": + return "any[]" + case "object": + return "Record" + case "null": + return "null" + default: + return "any" + } +} + +type ToolFunctionParameters struct { + Type string `json:"type"` + Defs any `json:"$defs,omitempty"` + Items any `json:"items,omitempty"` + Required []string `json:"required,omitempty"` + Properties *ToolPropertiesMap `json:"properties"` +} + +func (t *ToolFunctionParameters) String() string { + bts, _ := json.Marshal(t) + return string(bts) +} + +type ToolFunction struct { + Name string `json:"name"` + Description string `json:"description,omitempty"` + Parameters ToolFunctionParameters `json:"parameters"` +} + +func (t *ToolFunction) String() string { + bts, _ := json.Marshal(t) + return string(bts) +} + +// TokenLogprob represents log probability information for a single token alternative. +type TokenLogprob struct { + // Token is the text representation of the token. + Token string `json:"token"` + + // Logprob is the log probability of this token. + Logprob float64 `json:"logprob"` + + // Bytes contains the raw byte representation of the token + Bytes []int `json:"bytes,omitempty"` +} + +// Logprob contains log probability information for a generated token. +type Logprob struct { + TokenLogprob + + // TopLogprobs contains the most likely tokens and their log probabilities + // at this position, if requested via TopLogprobs parameter. + TopLogprobs []TokenLogprob `json:"top_logprobs,omitempty"` +} + +// ChatResponse is the response returned by [Client.Chat]. Its fields are +// similar to [GenerateResponse]. +type ChatResponse struct { + // Model is the model name that generated the response. + Model string `json:"model"` + + // RemoteModel is the name of the upstream model that generated the response. + RemoteModel string `json:"remote_model,omitempty"` + + // RemoteHost is the URL of the upstream Ollama host that generated the response. + RemoteHost string `json:"remote_host,omitempty"` + + // CreatedAt is the timestamp of the response. + CreatedAt time.Time `json:"created_at"` + + // Message contains the message or part of a message from the model. + Message Message `json:"message"` + + // Done specifies if the response is complete. + Done bool `json:"done"` + + // DoneReason is the reason the model stopped generating text. + DoneReason string `json:"done_reason,omitempty"` + + DebugInfo *DebugInfo `json:"_debug_info,omitempty"` + + // Logprobs contains log probability information for the generated tokens, + // if requested via the Logprobs parameter. + Logprobs []Logprob `json:"logprobs,omitempty"` + + Metrics +} + +// DebugInfo contains debug information for template rendering +type DebugInfo struct { + RenderedTemplate string `json:"rendered_template"` + ImageCount int `json:"image_count,omitempty"` +} + +type Metrics struct { + TotalDuration time.Duration `json:"total_duration,omitempty"` + LoadDuration time.Duration `json:"load_duration,omitempty"` + PromptEvalCount int `json:"prompt_eval_count,omitempty"` + PromptEvalDuration time.Duration `json:"prompt_eval_duration,omitempty"` + EvalCount int `json:"eval_count,omitempty"` + EvalDuration time.Duration `json:"eval_duration,omitempty"` +} + +// Options specified in [GenerateRequest]. If you add a new option here, also +// add it to the API docs. +type Options struct { + Runner + + // Predict options used at runtime + NumKeep int `json:"num_keep,omitempty"` + Seed int `json:"seed,omitempty"` + NumPredict int `json:"num_predict,omitempty"` + TopK int `json:"top_k,omitempty"` + TopP float32 `json:"top_p,omitempty"` + MinP float32 `json:"min_p,omitempty"` + TypicalP float32 `json:"typical_p,omitempty"` + RepeatLastN int `json:"repeat_last_n,omitempty"` + Temperature float32 `json:"temperature,omitempty"` + RepeatPenalty float32 `json:"repeat_penalty,omitempty"` + PresencePenalty float32 `json:"presence_penalty,omitempty"` + FrequencyPenalty float32 `json:"frequency_penalty,omitempty"` + Stop []string `json:"stop,omitempty"` +} + +// Runner options which must be set when the model is loaded into memory +type Runner struct { + NumCtx int `json:"num_ctx,omitempty"` + NumBatch int `json:"num_batch,omitempty"` + NumGPU int `json:"num_gpu,omitempty"` + MainGPU int `json:"main_gpu,omitempty"` + UseMMap *bool `json:"use_mmap,omitempty"` + NumThread int `json:"num_thread,omitempty"` +} + +// EmbedRequest is the request passed to [Client.Embed]. +type EmbedRequest struct { + // Model is the model name. + Model string `json:"model"` + + // Input is the input to embed. + Input any `json:"input"` + + // KeepAlive controls how long the model will stay loaded in memory following + // this request. + KeepAlive *Duration `json:"keep_alive,omitempty"` + + // Truncate truncates the input to fit the model's max sequence length. + Truncate *bool `json:"truncate,omitempty"` + + // Dimensions truncates the output embedding to the specified dimension. + Dimensions int `json:"dimensions,omitempty"` + + // Options lists model-specific options. + Options map[string]any `json:"options"` +} + +// EmbedResponse is the response from [Client.Embed]. +type EmbedResponse struct { + Model string `json:"model"` + Embeddings [][]float32 `json:"embeddings"` + + TotalDuration time.Duration `json:"total_duration,omitempty"` + LoadDuration time.Duration `json:"load_duration,omitempty"` + PromptEvalCount int `json:"prompt_eval_count,omitempty"` +} + +// EmbeddingRequest is the request passed to [Client.Embeddings]. +type EmbeddingRequest struct { + // Model is the model name. + Model string `json:"model"` + + // Prompt is the textual prompt to embed. + Prompt string `json:"prompt"` + + // KeepAlive controls how long the model will stay loaded in memory following + // this request. + KeepAlive *Duration `json:"keep_alive,omitempty"` + + // Options lists model-specific options. + Options map[string]any `json:"options"` +} + +// EmbeddingResponse is the response from [Client.Embeddings]. +type EmbeddingResponse struct { + Embedding []float64 `json:"embedding"` +} + +// CreateRequest is the request passed to [Client.Create]. +type CreateRequest struct { + // Model is the model name to create. + Model string `json:"model"` + + // Stream specifies whether the response is streaming; it is true by default. + Stream *bool `json:"stream,omitempty"` + + // Quantize is the quantization format for the model; leave blank to not change the quantization level. + Quantize string `json:"quantize,omitempty"` + + // From is the name of the model or file to use as the source. + From string `json:"from,omitempty"` + + // RemoteHost is the URL of the upstream ollama API for the model (if any). + RemoteHost string `json:"remote_host,omitempty"` + + // Files is a map of files include when creating the model. + Files map[string]string `json:"files,omitempty"` + + // Adapters is a map of LoRA adapters to include when creating the model. + Adapters map[string]string `json:"adapters,omitempty"` + + // Template is the template used when constructing a request to the model. + Template string `json:"template,omitempty"` + + // License is a string or list of strings for licenses. + License any `json:"license,omitempty"` + + // System is the system prompt for the model. + System string `json:"system,omitempty"` + + // Parameters is a map of hyper-parameters which are applied to the model. + Parameters map[string]any `json:"parameters,omitempty"` + + // Messages is a list of messages added to the model before chat and generation requests. + Messages []Message `json:"messages,omitempty"` + + Renderer string `json:"renderer,omitempty"` + Parser string `json:"parser,omitempty"` + + // Requires is the minimum version of Ollama required by the model. + Requires string `json:"requires,omitempty"` + + // Info is a map of additional information for the model + Info map[string]any `json:"info,omitempty"` + + // Deprecated: set the model name with Model instead + Name string `json:"name"` + // Deprecated: use Quantize instead + Quantization string `json:"quantization,omitempty"` +} + +// DeleteRequest is the request passed to [Client.Delete]. +type DeleteRequest struct { + Model string `json:"model"` + + // Deprecated: set the model name with Model instead + Name string `json:"name"` +} + +// ShowRequest is the request passed to [Client.Show]. +type ShowRequest struct { + Model string `json:"model"` + System string `json:"system"` + + // Template is deprecated + Template string `json:"template"` + Verbose bool `json:"verbose"` + + Options map[string]any `json:"options"` + + // Deprecated: set the model name with Model instead + Name string `json:"name"` +} + +// ShowResponse is the response returned from [Client.Show]. +type ShowResponse struct { + License string `json:"license,omitempty"` + Modelfile string `json:"modelfile,omitempty"` + Parameters string `json:"parameters,omitempty"` + Template string `json:"template,omitempty"` + System string `json:"system,omitempty"` + Renderer string `json:"renderer,omitempty"` + Parser string `json:"parser,omitempty"` + Details ModelDetails `json:"details,omitempty"` + Messages []Message `json:"messages,omitempty"` + RemoteModel string `json:"remote_model,omitempty"` + RemoteHost string `json:"remote_host,omitempty"` + ModelInfo map[string]any `json:"model_info"` + ProjectorInfo map[string]any `json:"projector_info,omitempty"` + Tensors []Tensor `json:"tensors,omitempty"` + Capabilities []model.Capability `json:"capabilities,omitempty"` + ModifiedAt time.Time `json:"modified_at,omitempty"` + Requires string `json:"requires,omitempty"` +} + +// CopyRequest is the request passed to [Client.Copy]. +type CopyRequest struct { + Source string `json:"source"` + Destination string `json:"destination"` +} + +// PullRequest is the request passed to [Client.Pull]. +type PullRequest struct { + Model string `json:"model"` + Insecure bool `json:"insecure,omitempty"` // Deprecated: ignored + Username string `json:"username"` // Deprecated: ignored + Password string `json:"password"` // Deprecated: ignored + Stream *bool `json:"stream,omitempty"` + + // Deprecated: set the model name with Model instead + Name string `json:"name"` +} + +// ProgressResponse is the response passed to progress functions like +// [PullProgressFunc] and [PushProgressFunc]. +type ProgressResponse struct { + Status string `json:"status"` + Digest string `json:"digest,omitempty"` + Total int64 `json:"total,omitempty"` + Completed int64 `json:"completed,omitempty"` +} + +// PushRequest is the request passed to [Client.Push]. +type PushRequest struct { + Model string `json:"model"` + Insecure bool `json:"insecure,omitempty"` + Username string `json:"username"` + Password string `json:"password"` + Stream *bool `json:"stream,omitempty"` + + // Deprecated: set the model name with Model instead + Name string `json:"name"` +} + +// ListResponse is the response from [Client.List]. +type ListResponse struct { + Models []ListModelResponse `json:"models"` +} + +// ModelRecommendationsResponse is the response from [Client.ModelRecommendationsExperimental]. +type ModelRecommendationsResponse struct { + Recommendations []ModelRecommendation `json:"recommendations"` +} + +// ModelRecommendation is a single recommendation entry in [ModelRecommendationsResponse]. +type ModelRecommendation struct { + Model string `json:"model"` + Description string `json:"description"` + ContextLength int `json:"context_length,omitempty"` + MaxOutputTokens int `json:"max_output_tokens,omitempty"` + VRAMBytes int64 `json:"vram_bytes,omitempty"` + RequiredPlan string `json:"required_plan,omitempty"` +} + +// ProcessResponse is the response from [Client.Process]. +type ProcessResponse struct { + Models []ProcessModelResponse `json:"models"` +} + +// ListModelResponse is a single model description in [ListResponse]. +type ListModelResponse struct { + Name string `json:"name"` + Model string `json:"model"` + RemoteModel string `json:"remote_model,omitempty"` + RemoteHost string `json:"remote_host,omitempty"` + ModifiedAt time.Time `json:"modified_at"` + Size int64 `json:"size"` + Digest string `json:"digest"` + Details ModelDetails `json:"details,omitempty"` + Capabilities []model.Capability `json:"capabilities,omitempty"` +} + +// ProcessModelResponse is a single model description in [ProcessResponse]. +type ProcessModelResponse struct { + Name string `json:"name"` + Model string `json:"model"` + Size int64 `json:"size"` + Digest string `json:"digest"` + Details ModelDetails `json:"details,omitempty"` + ExpiresAt time.Time `json:"expires_at"` + SizeVRAM int64 `json:"size_vram"` + ContextLength int `json:"context_length"` +} + +type TokenResponse struct { + Token string `json:"token"` +} + +type CloudStatus struct { + Disabled bool `json:"disabled"` + Source string `json:"source"` +} + +// StatusResponse is the response from [Client.CloudStatusExperimental]. +type StatusResponse struct { + Cloud CloudStatus `json:"cloud"` +} + +// GenerateResponse is the response passed into [GenerateResponseFunc]. +type GenerateResponse struct { + // Model is the model name that generated the response. + Model string `json:"model"` + + // RemoteModel is the name of the upstream model that generated the response. + RemoteModel string `json:"remote_model,omitempty"` + + // RemoteHost is the URL of the upstream Ollama host that generated the response. + RemoteHost string `json:"remote_host,omitempty"` + + // CreatedAt is the timestamp of the response. + CreatedAt time.Time `json:"created_at"` + + // Response is the textual response itself. + Response string `json:"response"` + + // Thinking contains the text that was inside thinking tags in the + // original model output when ChatRequest.Think is enabled. + Thinking string `json:"thinking,omitempty"` + + // Done specifies if the response is complete. + Done bool `json:"done"` + + // DoneReason is the reason the model stopped generating text. + DoneReason string `json:"done_reason,omitempty"` + + // Context is an encoding of the conversation used in this response; this + // can be sent in the next request to keep a conversational memory. + Context []int `json:"context,omitempty"` + + Metrics + + ToolCalls []ToolCall `json:"tool_calls,omitempty"` + + DebugInfo *DebugInfo `json:"_debug_info,omitempty"` + + // Logprobs contains log probability information for the generated tokens, + // if requested via the Logprobs parameter. + Logprobs []Logprob `json:"logprobs,omitempty"` + + // Experimental: Image generation fields (may change or be removed) + + // Image contains a base64-encoded generated image. + // Only present for image generation models. + Image string `json:"image,omitempty"` + + // Completed is the number of completed steps in image generation. + // Only present for image generation models during streaming. + Completed int64 `json:"completed,omitempty"` + + // Total is the total number of steps for image generation. + // Only present for image generation models during streaming. + Total int64 `json:"total,omitempty"` +} + +// ModelDetails provides details about a model. +type ModelDetails struct { + ParentModel string `json:"parent_model"` + Format string `json:"format"` + Family string `json:"family"` + Families []string `json:"families"` + ParameterSize string `json:"parameter_size"` + QuantizationLevel string `json:"quantization_level"` + ContextLength int `json:"context_length,omitempty"` + EmbeddingLength int `json:"embedding_length,omitempty"` +} + +// UserResponse provides information about a user. +type UserResponse struct { + ID uuid.UUID `json:"id"` + Email string `json:"email"` + Name string `json:"name"` + Bio string `json:"bio,omitempty"` + AvatarURL string `json:"avatarurl,omitempty"` + FirstName string `json:"firstname,omitempty"` + LastName string `json:"lastname,omitempty"` + Plan string `json:"plan,omitempty"` +} + +// Tensor describes the metadata for a given tensor. +type Tensor struct { + Name string `json:"name"` + Type string `json:"type"` + Shape []uint64 `json:"shape"` +} + +func (m *Metrics) Summary() { + if m.TotalDuration > 0 { + fmt.Fprintf(os.Stderr, "total duration: %v\n", m.TotalDuration) + } + + if m.LoadDuration > 0 { + fmt.Fprintf(os.Stderr, "load duration: %v\n", m.LoadDuration) + } + + if m.PromptEvalCount > 0 { + fmt.Fprintf(os.Stderr, "prompt eval count: %d token(s)\n", m.PromptEvalCount) + } + + if m.PromptEvalDuration > 0 { + fmt.Fprintf(os.Stderr, "prompt eval duration: %s\n", m.PromptEvalDuration) + fmt.Fprintf(os.Stderr, "prompt eval rate: %.2f tokens/s\n", float64(m.PromptEvalCount)/m.PromptEvalDuration.Seconds()) + } + + if m.EvalCount > 0 { + fmt.Fprintf(os.Stderr, "eval count: %d token(s)\n", m.EvalCount) + } + + if m.EvalDuration > 0 { + fmt.Fprintf(os.Stderr, "eval duration: %s\n", m.EvalDuration) + fmt.Fprintf(os.Stderr, "eval rate: %.2f tokens/s\n", float64(m.EvalCount)/m.EvalDuration.Seconds()) + } +} + +func (opts *Options) FromMap(m map[string]any) error { + valueOpts := reflect.ValueOf(opts).Elem() // names of the fields in the options struct + typeOpts := reflect.TypeOf(opts).Elem() // types of the fields in the options struct + + // build map of json struct tags to their types + jsonOpts := make(map[string]reflect.StructField) + for _, field := range reflect.VisibleFields(typeOpts) { + jsonTag := strings.Split(field.Tag.Get("json"), ",")[0] + if jsonTag != "" { + jsonOpts[jsonTag] = field + } + } + + for key, val := range m { + opt, ok := jsonOpts[key] + if !ok { + slog.Warn("invalid option provided", "option", key) + continue + } + + field := valueOpts.FieldByName(opt.Name) + if field.IsValid() && field.CanSet() { + if val == nil { + continue + } + + switch field.Kind() { + case reflect.Int: + switch t := val.(type) { + case int64: + field.SetInt(t) + case float64: + // when JSON unmarshals numbers, it uses float64, not int + field.SetInt(int64(t)) + default: + return fmt.Errorf("option %q must be of type integer", key) + } + case reflect.Bool: + val, ok := val.(bool) + if !ok { + return fmt.Errorf("option %q must be of type boolean", key) + } + field.SetBool(val) + case reflect.Float32: + // JSON unmarshals to float64 + val, ok := val.(float64) + if !ok { + return fmt.Errorf("option %q must be of type float32", key) + } + field.SetFloat(val) + case reflect.String: + val, ok := val.(string) + if !ok { + return fmt.Errorf("option %q must be of type string", key) + } + field.SetString(val) + case reflect.Slice: + // JSON unmarshals to []any, not []string + val, ok := val.([]any) + if !ok { + return fmt.Errorf("option %q must be of type array", key) + } + // convert []any to []string + slice := make([]string, len(val)) + for i, item := range val { + str, ok := item.(string) + if !ok { + return fmt.Errorf("option %q must be of an array of strings", key) + } + slice[i] = str + } + field.Set(reflect.ValueOf(slice)) + case reflect.Pointer: + var b bool + if field.Type() == reflect.TypeOf(&b) { + val, ok := val.(bool) + if !ok { + return fmt.Errorf("option %q must be of type boolean", key) + } + field.Set(reflect.ValueOf(&val)) + } else { + return fmt.Errorf("unknown type loading config params: %v %v", field.Kind(), field.Type()) + } + default: + return fmt.Errorf("unknown type loading config params: %v", field.Kind()) + } + } + } + + return nil +} + +// DefaultOptions is the default set of options for [GenerateRequest]; these +// values are used unless the user specifies other values explicitly. +func DefaultOptions() Options { + return Options{ + // options set on request to runner + NumPredict: -1, + + // set a minimal num_keep to avoid issues on context shifts + NumKeep: 4, + Temperature: 0.8, + TopK: 40, + TopP: 0.9, + TypicalP: 1.0, + RepeatLastN: 64, + RepeatPenalty: 1.1, + PresencePenalty: 0.0, + FrequencyPenalty: 0.0, + Seed: -1, + + Runner: Runner{ + // options set when the model is loaded + NumCtx: int(envconfig.ContextLength()), + NumBatch: 512, + NumGPU: -1, // -1 here indicates that NumGPU should be set dynamically + NumThread: 0, // let the runtime decide + UseMMap: nil, + }, + } +} + +// ThinkValue represents a value that can be a boolean or a string ("high", "medium", "low", "max") +type ThinkValue struct { + // Value can be a bool or string + Value interface{} +} + +// IsValid checks if the ThinkValue is valid +func (t *ThinkValue) IsValid() bool { + if t == nil || t.Value == nil { + return true // nil is valid (means not set) + } + + switch v := t.Value.(type) { + case bool: + return true + case string: + return v == "high" || v == "medium" || v == "low" || v == "max" + default: + return false + } +} + +// IsBool returns true if the value is a boolean +func (t *ThinkValue) IsBool() bool { + if t == nil || t.Value == nil { + return false + } + _, ok := t.Value.(bool) + return ok +} + +// IsString returns true if the value is a string +func (t *ThinkValue) IsString() bool { + if t == nil || t.Value == nil { + return false + } + _, ok := t.Value.(string) + return ok +} + +// Bool returns the value as a bool (true if enabled in any way) +func (t *ThinkValue) Bool() bool { + if t == nil || t.Value == nil { + return false + } + + switch v := t.Value.(type) { + case bool: + return v + case string: + // Any string value ("high", "medium", "low", "max") means thinking is enabled + return v == "high" || v == "medium" || v == "low" || v == "max" + default: + return false + } +} + +// String returns the value as a string +func (t *ThinkValue) String() string { + if t == nil || t.Value == nil { + return "" + } + + switch v := t.Value.(type) { + case string: + return v + case bool: + if v { + return "medium" // Default level when just true + } + return "" + default: + return "" + } +} + +// UnmarshalJSON implements json.Unmarshaler +func (t *ThinkValue) UnmarshalJSON(data []byte) error { + // Try to unmarshal as bool first + var b bool + if err := json.Unmarshal(data, &b); err == nil { + t.Value = b + return nil + } + + // Try to unmarshal as string + var s string + if err := json.Unmarshal(data, &s); err == nil { + // Validate string values + if s != "high" && s != "medium" && s != "low" && s != "max" { + return fmt.Errorf("invalid think value: %q (must be \"high\", \"medium\", \"low\", \"max\", true, or false)", s) + } + t.Value = s + return nil + } + + return fmt.Errorf("think must be a boolean or string (\"high\", \"medium\", \"low\", \"max\", true, or false)") +} + +// MarshalJSON implements json.Marshaler +func (t *ThinkValue) MarshalJSON() ([]byte, error) { + if t == nil || t.Value == nil { + return []byte("null"), nil + } + return json.Marshal(t.Value) +} + +type Duration struct { + time.Duration +} + +func (d Duration) MarshalJSON() ([]byte, error) { + if d.Duration < 0 { + return []byte("-1"), nil + } + return []byte("\"" + d.Duration.String() + "\""), nil +} + +func (d *Duration) UnmarshalJSON(b []byte) (err error) { + var v any + if err := json.Unmarshal(b, &v); err != nil { + return err + } + + d.Duration = 5 * time.Minute + + switch t := v.(type) { + case float64: + if t < 0 { + d.Duration = time.Duration(math.MaxInt64) + } else { + d.Duration = time.Duration(t * float64(time.Second)) + } + case string: + d.Duration, err = time.ParseDuration(t) + if err != nil { + return err + } + if d.Duration < 0 { + d.Duration = time.Duration(math.MaxInt64) + } + default: + return fmt.Errorf("Unsupported type: '%s'", reflect.TypeOf(v)) + } + + return nil +} + +// FormatParams converts specified parameter options to their correct types +func FormatParams(params map[string][]string) (map[string]any, error) { + opts := Options{} + valueOpts := reflect.ValueOf(&opts).Elem() // names of the fields in the options struct + typeOpts := reflect.TypeOf(opts) // types of the fields in the options struct + + // build map of json struct tags to their types + jsonOpts := make(map[string]reflect.StructField) + for _, field := range reflect.VisibleFields(typeOpts) { + jsonTag := strings.Split(field.Tag.Get("json"), ",")[0] + if jsonTag != "" { + jsonOpts[jsonTag] = field + } + } + + out := make(map[string]any) + // iterate params and set values based on json struct tags + for key, vals := range params { + if opt, ok := jsonOpts[key]; !ok { + return nil, fmt.Errorf("unknown parameter '%s'", key) + } else { + field := valueOpts.FieldByName(opt.Name) + if field.IsValid() && field.CanSet() { + switch field.Kind() { + case reflect.Float32: + floatVal, err := strconv.ParseFloat(vals[0], 32) + if err != nil { + return nil, fmt.Errorf("invalid float value %s", vals) + } + + out[key] = float32(floatVal) + case reflect.Int: + intVal, err := strconv.ParseInt(vals[0], 10, 64) + if err != nil { + return nil, fmt.Errorf("invalid int value %s", vals) + } + + out[key] = intVal + case reflect.Bool: + boolVal, err := strconv.ParseBool(vals[0]) + if err != nil { + return nil, fmt.Errorf("invalid bool value %s", vals) + } + + out[key] = boolVal + case reflect.String: + out[key] = vals[0] + case reflect.Slice: + // TODO: only string slices are supported right now + out[key] = vals + case reflect.Pointer: + var b bool + if field.Type() == reflect.TypeOf(&b) { + boolVal, err := strconv.ParseBool(vals[0]) + if err != nil { + return nil, fmt.Errorf("invalid bool value %s", vals) + } + out[key] = &boolVal + } else { + return nil, fmt.Errorf("unknown type %s for %s", field.Kind(), key) + } + default: + return nil, fmt.Errorf("unknown type %s for %s", field.Kind(), key) + } + } + } + } + + return out, nil +} diff --git a/api/types_test.go b/api/types_test.go new file mode 100644 index 0000000..f7cbfe3 --- /dev/null +++ b/api/types_test.go @@ -0,0 +1,917 @@ +package api + +import ( + "encoding/json" + "errors" + "math" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +// testPropsMap creates a ToolPropertiesMap from a map (convenience function for tests, order not preserved) +func testPropsMap(m map[string]ToolProperty) *ToolPropertiesMap { + props := NewToolPropertiesMap() + for k, v := range m { + props.Set(k, v) + } + return props +} + +// testArgs creates ToolCallFunctionArguments from a map (convenience function for tests, order not preserved) +func testArgs(m map[string]any) ToolCallFunctionArguments { + args := NewToolCallFunctionArguments() + for k, v := range m { + args.Set(k, v) + } + return args +} + +func TestKeepAliveParsingFromJSON(t *testing.T) { + tests := []struct { + name string + req string + exp *Duration + }{ + { + name: "Unset", + req: `{ }`, + exp: nil, + }, + { + name: "Positive Integer", + req: `{ "keep_alive": 42 }`, + exp: &Duration{42 * time.Second}, + }, + { + name: "Positive Float", + req: `{ "keep_alive": 42.5 }`, + exp: &Duration{42500 * time.Millisecond}, + }, + { + name: "Positive Integer String", + req: `{ "keep_alive": "42m" }`, + exp: &Duration{42 * time.Minute}, + }, + { + name: "Negative Integer", + req: `{ "keep_alive": -1 }`, + exp: &Duration{math.MaxInt64}, + }, + { + name: "Negative Float", + req: `{ "keep_alive": -3.14 }`, + exp: &Duration{math.MaxInt64}, + }, + { + name: "Negative Integer String", + req: `{ "keep_alive": "-1m" }`, + exp: &Duration{math.MaxInt64}, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + var dec ChatRequest + err := json.Unmarshal([]byte(test.req), &dec) + require.NoError(t, err) + + assert.Equal(t, test.exp, dec.KeepAlive) + }) + } +} + +func TestDurationMarshalUnmarshal(t *testing.T) { + tests := []struct { + name string + input time.Duration + expected time.Duration + }{ + { + "negative duration", + time.Duration(-1), + time.Duration(math.MaxInt64), + }, + { + "positive duration", + 42 * time.Second, + 42 * time.Second, + }, + { + "another positive duration", + 42 * time.Minute, + 42 * time.Minute, + }, + { + "zero duration", + time.Duration(0), + time.Duration(0), + }, + { + "max duration", + time.Duration(math.MaxInt64), + time.Duration(math.MaxInt64), + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + b, err := json.Marshal(Duration{test.input}) + require.NoError(t, err) + + var d Duration + err = json.Unmarshal(b, &d) + require.NoError(t, err) + + assert.Equal(t, test.expected, d.Duration, "input %v, marshalled %v, got %v", test.input, string(b), d.Duration) + }) + } +} + +func TestUseMmapParsingFromJSON(t *testing.T) { + tr := true + fa := false + tests := []struct { + name string + req string + exp *bool + }{ + { + name: "Undefined", + req: `{ }`, + exp: nil, + }, + { + name: "True", + req: `{ "use_mmap": true }`, + exp: &tr, + }, + { + name: "False", + req: `{ "use_mmap": false }`, + exp: &fa, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + var oMap map[string]any + err := json.Unmarshal([]byte(test.req), &oMap) + require.NoError(t, err) + opts := DefaultOptions() + err = opts.FromMap(oMap) + require.NoError(t, err) + assert.Equal(t, test.exp, opts.UseMMap) + }) + } +} + +func TestUseMmapFormatParams(t *testing.T) { + tr := true + fa := false + tests := []struct { + name string + req map[string][]string + exp *bool + err error + }{ + { + name: "True", + req: map[string][]string{ + "use_mmap": {"true"}, + }, + exp: &tr, + err: nil, + }, + { + name: "False", + req: map[string][]string{ + "use_mmap": {"false"}, + }, + exp: &fa, + err: nil, + }, + { + name: "Numeric True", + req: map[string][]string{ + "use_mmap": {"1"}, + }, + exp: &tr, + err: nil, + }, + { + name: "Numeric False", + req: map[string][]string{ + "use_mmap": {"0"}, + }, + exp: &fa, + err: nil, + }, + { + name: "invalid string", + req: map[string][]string{ + "use_mmap": {"foo"}, + }, + exp: nil, + err: errors.New("invalid bool value [foo]"), + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + resp, err := FormatParams(test.req) + require.Equal(t, test.err, err) + respVal, ok := resp["use_mmap"] + if test.exp != nil { + assert.True(t, ok, "resp: %v", resp) + assert.Equal(t, *test.exp, *respVal.(*bool)) + } + }) + } +} + +func TestMessage_UnmarshalJSON(t *testing.T) { + tests := []struct { + input string + expected string + }{ + {`{"role": "USER", "content": "Hello!"}`, "user"}, + {`{"role": "System", "content": "Initialization complete."}`, "system"}, + {`{"role": "assistant", "content": "How can I help you?"}`, "assistant"}, + {`{"role": "TOOl", "content": "Access granted."}`, "tool"}, + } + + for _, test := range tests { + var msg Message + if err := json.Unmarshal([]byte(test.input), &msg); err != nil { + t.Errorf("Unexpected error: %v", err) + } + + if msg.Role != test.expected { + t.Errorf("role not lowercased: got %v, expected %v", msg.Role, test.expected) + } + } +} + +func TestToolFunction_UnmarshalJSON(t *testing.T) { + tests := []struct { + name string + input string + wantErr string + }{ + { + name: "valid enum with same types", + input: `{ + "name": "test", + "description": "test function", + "parameters": { + "type": "object", + "required": ["test"], + "properties": { + "test": { + "type": "string", + "description": "test prop", + "enum": ["a", "b", "c"] + } + } + } + }`, + wantErr: "", + }, + { + name: "empty enum array", + input: `{ + "name": "test", + "description": "test function", + "parameters": { + "type": "object", + "required": ["test"], + "properties": { + "test": { + "type": "string", + "description": "test prop", + "enum": [] + } + } + } + }`, + wantErr: "", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + var tf ToolFunction + err := json.Unmarshal([]byte(tt.input), &tf) + + if tt.wantErr != "" { + require.Error(t, err) + assert.Contains(t, err.Error(), tt.wantErr) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestToolFunctionParameters_MarshalJSON(t *testing.T) { + tests := []struct { + name string + input ToolFunctionParameters + expected string + }{ + { + name: "simple object with string property", + input: ToolFunctionParameters{ + Type: "object", + Required: []string{"name"}, + Properties: testPropsMap(map[string]ToolProperty{ + "name": {Type: PropertyType{"string"}}, + }), + }, + expected: `{"type":"object","required":["name"],"properties":{"name":{"type":"string"}}}`, + }, + { + name: "no required", + input: ToolFunctionParameters{ + Type: "object", + Properties: testPropsMap(map[string]ToolProperty{ + "name": {Type: PropertyType{"string"}}, + }), + }, + expected: `{"type":"object","properties":{"name":{"type":"string"}}}`, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + data, err := json.Marshal(test.input) + require.NoError(t, err) + assert.Equal(t, test.expected, string(data)) + }) + } +} + +func TestToolCallFunction_IndexAlwaysMarshals(t *testing.T) { + fn := ToolCallFunction{ + Name: "echo", + Arguments: testArgs(map[string]any{"message": "hi"}), + } + + data, err := json.Marshal(fn) + require.NoError(t, err) + + raw := map[string]any{} + require.NoError(t, json.Unmarshal(data, &raw)) + require.Contains(t, raw, "index") + assert.Equal(t, float64(0), raw["index"]) + + fn.Index = 3 + data, err = json.Marshal(fn) + require.NoError(t, err) + + raw = map[string]any{} + require.NoError(t, json.Unmarshal(data, &raw)) + require.Contains(t, raw, "index") + assert.Equal(t, float64(3), raw["index"]) +} + +func TestPropertyType_UnmarshalJSON(t *testing.T) { + tests := []struct { + name string + input string + expected PropertyType + }{ + { + name: "string type", + input: `"string"`, + expected: PropertyType{"string"}, + }, + { + name: "array of types", + input: `["string", "number"]`, + expected: PropertyType{"string", "number"}, + }, + { + name: "array with single type", + input: `["string"]`, + expected: PropertyType{"string"}, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + var pt PropertyType + if err := json.Unmarshal([]byte(test.input), &pt); err != nil { + t.Errorf("Unexpected error: %v", err) + } + + if len(pt) != len(test.expected) { + t.Errorf("Length mismatch: got %v, expected %v", len(pt), len(test.expected)) + } + + for i, v := range pt { + if v != test.expected[i] { + t.Errorf("Value mismatch at index %d: got %v, expected %v", i, v, test.expected[i]) + } + } + }) + } +} + +func TestPropertyType_MarshalJSON(t *testing.T) { + tests := []struct { + name string + input PropertyType + expected string + }{ + { + name: "single type", + input: PropertyType{"string"}, + expected: `"string"`, + }, + { + name: "multiple types", + input: PropertyType{"string", "number"}, + expected: `["string","number"]`, + }, + { + name: "empty type", + input: PropertyType{}, + expected: `[]`, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + data, err := json.Marshal(test.input) + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + + if string(data) != test.expected { + t.Errorf("Marshaled data mismatch: got %v, expected %v", string(data), test.expected) + } + }) + } +} + +func TestThinking_UnmarshalJSON(t *testing.T) { + tests := []struct { + name string + input string + expectedThinking *ThinkValue + expectedError bool + }{ + { + name: "true", + input: `{ "think": true }`, + expectedThinking: &ThinkValue{Value: true}, + }, + { + name: "false", + input: `{ "think": false }`, + expectedThinking: &ThinkValue{Value: false}, + }, + { + name: "unset", + input: `{ }`, + expectedThinking: nil, + }, + { + name: "string_high", + input: `{ "think": "high" }`, + expectedThinking: &ThinkValue{Value: "high"}, + }, + { + name: "string_medium", + input: `{ "think": "medium" }`, + expectedThinking: &ThinkValue{Value: "medium"}, + }, + { + name: "string_low", + input: `{ "think": "low" }`, + expectedThinking: &ThinkValue{Value: "low"}, + }, + { + name: "string_max", + input: `{ "think": "max" }`, + expectedThinking: &ThinkValue{Value: "max"}, + }, + { + name: "invalid_string", + input: `{ "think": "invalid" }`, + expectedThinking: nil, + expectedError: true, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + var req GenerateRequest + err := json.Unmarshal([]byte(test.input), &req) + if test.expectedError { + require.Error(t, err) + } else { + require.NoError(t, err) + if test.expectedThinking == nil { + assert.Nil(t, req.Think) + } else { + require.NotNil(t, req.Think) + assert.Equal(t, test.expectedThinking.Value, req.Think.Value) + } + } + }) + } +} + +func TestToolPropertyNestedProperties(t *testing.T) { + tests := []struct { + name string + input string + expected ToolProperty + }{ + { + name: "nested object properties", + input: `{ + "type": "object", + "description": "Location details", + "properties": { + "address": { + "type": "string", + "description": "Street address" + }, + "city": { + "type": "string", + "description": "City name" + } + } + }`, + expected: ToolProperty{ + Type: PropertyType{"object"}, + Description: "Location details", + Properties: testPropsMap(map[string]ToolProperty{ + "address": { + Type: PropertyType{"string"}, + Description: "Street address", + }, + "city": { + Type: PropertyType{"string"}, + Description: "City name", + }, + }), + }, + }, + { + name: "deeply nested properties", + input: `{ + "type": "object", + "description": "Event", + "properties": { + "location": { + "type": "object", + "description": "Location", + "properties": { + "coordinates": { + "type": "object", + "description": "GPS coordinates", + "properties": { + "lat": {"type": "number", "description": "Latitude"}, + "lng": {"type": "number", "description": "Longitude"} + } + } + } + } + } + }`, + expected: ToolProperty{ + Type: PropertyType{"object"}, + Description: "Event", + Properties: testPropsMap(map[string]ToolProperty{ + "location": { + Type: PropertyType{"object"}, + Description: "Location", + Properties: testPropsMap(map[string]ToolProperty{ + "coordinates": { + Type: PropertyType{"object"}, + Description: "GPS coordinates", + Properties: testPropsMap(map[string]ToolProperty{ + "lat": {Type: PropertyType{"number"}, Description: "Latitude"}, + "lng": {Type: PropertyType{"number"}, Description: "Longitude"}, + }), + }, + }), + }, + }), + }, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + var prop ToolProperty + err := json.Unmarshal([]byte(tt.input), &prop) + require.NoError(t, err) + + // Compare JSON representations since pointer comparison doesn't work + expectedJSON, err := json.Marshal(tt.expected) + require.NoError(t, err) + actualJSON, err := json.Marshal(prop) + require.NoError(t, err) + assert.JSONEq(t, string(expectedJSON), string(actualJSON)) + + // Round-trip test: marshal and unmarshal again + data, err := json.Marshal(prop) + require.NoError(t, err) + + var prop2 ToolProperty + err = json.Unmarshal(data, &prop2) + require.NoError(t, err) + + prop2JSON, err := json.Marshal(prop2) + require.NoError(t, err) + assert.JSONEq(t, string(expectedJSON), string(prop2JSON)) + }) + } +} + +func TestToolFunctionParameters_String(t *testing.T) { + tests := []struct { + name string + params ToolFunctionParameters + expected string + }{ + { + name: "simple object with string property", + params: ToolFunctionParameters{ + Type: "object", + Required: []string{"name"}, + Properties: testPropsMap(map[string]ToolProperty{ + "name": { + Type: PropertyType{"string"}, + Description: "The name of the person", + }, + }), + }, + expected: `{"type":"object","required":["name"],"properties":{"name":{"type":"string","description":"The name of the person"}}}`, + }, + { + name: "marshal failure returns empty string", + params: ToolFunctionParameters{ + Type: "object", + Defs: func() any { + // Create a cycle that will cause json.Marshal to fail + type selfRef struct { + Self *selfRef + } + s := &selfRef{} + s.Self = s + return s + }(), + Properties: testPropsMap(map[string]ToolProperty{}), + }, + expected: "", + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + result := test.params.String() + assert.Equal(t, test.expected, result) + }) + } +} + +func TestToolCallFunctionArguments_OrderPreservation(t *testing.T) { + t.Run("marshal preserves insertion order", func(t *testing.T) { + args := NewToolCallFunctionArguments() + args.Set("zebra", "z") + args.Set("apple", "a") + args.Set("mango", "m") + + data, err := json.Marshal(args) + require.NoError(t, err) + + // Should preserve insertion order, not alphabetical + assert.Equal(t, `{"zebra":"z","apple":"a","mango":"m"}`, string(data)) + }) + + t.Run("unmarshal preserves JSON order", func(t *testing.T) { + jsonData := `{"zebra":"z","apple":"a","mango":"m"}` + + var args ToolCallFunctionArguments + err := json.Unmarshal([]byte(jsonData), &args) + require.NoError(t, err) + + // Verify iteration order matches JSON order + var keys []string + for k := range args.All() { + keys = append(keys, k) + } + assert.Equal(t, []string{"zebra", "apple", "mango"}, keys) + }) + + t.Run("round trip preserves order", func(t *testing.T) { + original := `{"z":1,"a":2,"m":3,"b":4}` + + var args ToolCallFunctionArguments + err := json.Unmarshal([]byte(original), &args) + require.NoError(t, err) + + data, err := json.Marshal(args) + require.NoError(t, err) + + assert.Equal(t, original, string(data)) + }) + + t.Run("String method returns ordered JSON", func(t *testing.T) { + args := NewToolCallFunctionArguments() + args.Set("c", 3) + args.Set("a", 1) + args.Set("b", 2) + + assert.Equal(t, `{"c":3,"a":1,"b":2}`, args.String()) + }) + + t.Run("Get retrieves correct values", func(t *testing.T) { + args := NewToolCallFunctionArguments() + args.Set("key1", "value1") + args.Set("key2", 42) + + v, ok := args.Get("key1") + assert.True(t, ok) + assert.Equal(t, "value1", v) + + v, ok = args.Get("key2") + assert.True(t, ok) + assert.Equal(t, 42, v) + + _, ok = args.Get("nonexistent") + assert.False(t, ok) + }) + + t.Run("Len returns correct count", func(t *testing.T) { + args := NewToolCallFunctionArguments() + assert.Equal(t, 0, args.Len()) + + args.Set("a", 1) + assert.Equal(t, 1, args.Len()) + + args.Set("b", 2) + assert.Equal(t, 2, args.Len()) + }) + + t.Run("empty args marshal to empty object", func(t *testing.T) { + args := NewToolCallFunctionArguments() + data, err := json.Marshal(args) + require.NoError(t, err) + assert.Equal(t, `{}`, string(data)) + }) + + t.Run("zero value args marshal to empty object", func(t *testing.T) { + var args ToolCallFunctionArguments + assert.Equal(t, "{}", args.String()) + }) +} + +func TestToolPropertiesMap_OrderPreservation(t *testing.T) { + t.Run("marshal preserves insertion order", func(t *testing.T) { + props := NewToolPropertiesMap() + props.Set("zebra", ToolProperty{Type: PropertyType{"string"}}) + props.Set("apple", ToolProperty{Type: PropertyType{"number"}}) + props.Set("mango", ToolProperty{Type: PropertyType{"boolean"}}) + + data, err := json.Marshal(props) + require.NoError(t, err) + + // Should preserve insertion order, not alphabetical + expected := `{"zebra":{"type":"string"},"apple":{"type":"number"},"mango":{"type":"boolean"}}` + assert.Equal(t, expected, string(data)) + }) + + t.Run("unmarshal preserves JSON order", func(t *testing.T) { + jsonData := `{"zebra":{"type":"string"},"apple":{"type":"number"},"mango":{"type":"boolean"}}` + + var props ToolPropertiesMap + err := json.Unmarshal([]byte(jsonData), &props) + require.NoError(t, err) + + // Verify iteration order matches JSON order + var keys []string + for k := range props.All() { + keys = append(keys, k) + } + assert.Equal(t, []string{"zebra", "apple", "mango"}, keys) + }) + + t.Run("round trip preserves order", func(t *testing.T) { + original := `{"z":{"type":"string"},"a":{"type":"number"},"m":{"type":"boolean"}}` + + var props ToolPropertiesMap + err := json.Unmarshal([]byte(original), &props) + require.NoError(t, err) + + data, err := json.Marshal(props) + require.NoError(t, err) + + assert.Equal(t, original, string(data)) + }) + + t.Run("Get retrieves correct values", func(t *testing.T) { + props := NewToolPropertiesMap() + props.Set("name", ToolProperty{Type: PropertyType{"string"}, Description: "The name"}) + props.Set("age", ToolProperty{Type: PropertyType{"integer"}, Description: "The age"}) + + v, ok := props.Get("name") + assert.True(t, ok) + assert.Equal(t, "The name", v.Description) + + v, ok = props.Get("age") + assert.True(t, ok) + assert.Equal(t, "The age", v.Description) + + _, ok = props.Get("nonexistent") + assert.False(t, ok) + }) + + t.Run("Len returns correct count", func(t *testing.T) { + props := NewToolPropertiesMap() + assert.Equal(t, 0, props.Len()) + + props.Set("a", ToolProperty{}) + assert.Equal(t, 1, props.Len()) + + props.Set("b", ToolProperty{}) + assert.Equal(t, 2, props.Len()) + }) + + t.Run("nil props marshal to null", func(t *testing.T) { + var props *ToolPropertiesMap + data, err := json.Marshal(props) + require.NoError(t, err) + assert.Equal(t, `null`, string(data)) + }) + + t.Run("ToMap returns regular map", func(t *testing.T) { + props := NewToolPropertiesMap() + props.Set("a", ToolProperty{Type: PropertyType{"string"}}) + props.Set("b", ToolProperty{Type: PropertyType{"number"}}) + + m := props.ToMap() + assert.Equal(t, 2, len(m)) + assert.Equal(t, PropertyType{"string"}, m["a"].Type) + assert.Equal(t, PropertyType{"number"}, m["b"].Type) + }) +} + +func TestToolCallFunctionArguments_ComplexValues(t *testing.T) { + t.Run("nested objects preserve order", func(t *testing.T) { + jsonData := `{"outer":{"z":1,"a":2},"simple":"value"}` + + var args ToolCallFunctionArguments + err := json.Unmarshal([]byte(jsonData), &args) + require.NoError(t, err) + + // Outer keys should be in order + var keys []string + for k := range args.All() { + keys = append(keys, k) + } + assert.Equal(t, []string{"outer", "simple"}, keys) + }) + + t.Run("arrays as values", func(t *testing.T) { + args := NewToolCallFunctionArguments() + args.Set("items", []string{"a", "b", "c"}) + args.Set("numbers", []int{1, 2, 3}) + + data, err := json.Marshal(args) + require.NoError(t, err) + + assert.Equal(t, `{"items":["a","b","c"],"numbers":[1,2,3]}`, string(data)) + }) +} + +func TestToolPropertiesMap_NestedProperties(t *testing.T) { + t.Run("nested properties preserve order", func(t *testing.T) { + props := NewToolPropertiesMap() + + nestedProps := NewToolPropertiesMap() + nestedProps.Set("z_field", ToolProperty{Type: PropertyType{"string"}}) + nestedProps.Set("a_field", ToolProperty{Type: PropertyType{"number"}}) + + props.Set("outer", ToolProperty{ + Type: PropertyType{"object"}, + Properties: nestedProps, + }) + + data, err := json.Marshal(props) + require.NoError(t, err) + + // Both outer and inner should preserve order + expected := `{"outer":{"type":"object","properties":{"z_field":{"type":"string"},"a_field":{"type":"number"}}}}` + assert.Equal(t, expected, string(data)) + }) +} diff --git a/api/types_typescript_test.go b/api/types_typescript_test.go new file mode 100644 index 0000000..9902c5b --- /dev/null +++ b/api/types_typescript_test.go @@ -0,0 +1,142 @@ +package api + +import ( + "testing" +) + +func TestToolParameterToTypeScriptType(t *testing.T) { + tests := []struct { + name string + param ToolProperty + expected string + }{ + { + name: "single string type", + param: ToolProperty{ + Type: PropertyType{"string"}, + }, + expected: "string", + }, + { + name: "single number type", + param: ToolProperty{ + Type: PropertyType{"number"}, + }, + expected: "number", + }, + { + name: "integer maps to number", + param: ToolProperty{ + Type: PropertyType{"integer"}, + }, + expected: "number", + }, + { + name: "boolean type", + param: ToolProperty{ + Type: PropertyType{"boolean"}, + }, + expected: "boolean", + }, + { + name: "array type", + param: ToolProperty{ + Type: PropertyType{"array"}, + }, + expected: "any[]", + }, + { + name: "object type", + param: ToolProperty{ + Type: PropertyType{"object"}, + }, + expected: "Record", + }, + { + name: "null type", + param: ToolProperty{ + Type: PropertyType{"null"}, + }, + expected: "null", + }, + { + name: "multiple types as union", + param: ToolProperty{ + Type: PropertyType{"string", "number"}, + }, + expected: "string | number", + }, + { + name: "string or null union", + param: ToolProperty{ + Type: PropertyType{"string", "null"}, + }, + expected: "string | null", + }, + { + name: "anyOf with single types", + param: ToolProperty{ + AnyOf: []ToolProperty{ + {Type: PropertyType{"string"}}, + {Type: PropertyType{"number"}}, + }, + }, + expected: "string | number", + }, + { + name: "anyOf with multiple types in each branch", + param: ToolProperty{ + AnyOf: []ToolProperty{ + {Type: PropertyType{"string", "null"}}, + {Type: PropertyType{"number"}}, + }, + }, + expected: "string | null | number", + }, + { + name: "nested anyOf", + param: ToolProperty{ + AnyOf: []ToolProperty{ + {Type: PropertyType{"boolean"}}, + { + AnyOf: []ToolProperty{ + {Type: PropertyType{"string"}}, + {Type: PropertyType{"number"}}, + }, + }, + }, + }, + expected: "boolean | string | number", + }, + { + name: "empty type returns any", + param: ToolProperty{ + Type: PropertyType{}, + }, + expected: "any", + }, + { + name: "unknown type maps to any", + param: ToolProperty{ + Type: PropertyType{"unknown_type"}, + }, + expected: "any", + }, + { + name: "multiple types including array", + param: ToolProperty{ + Type: PropertyType{"string", "array", "null"}, + }, + expected: "string | any[] | null", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + result := tt.param.ToTypeScriptType() + if result != tt.expected { + t.Errorf("ToTypeScriptType() = %q, want %q", result, tt.expected) + } + }) + } +} diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..a83eb70 --- /dev/null +++ b/app/.gitignore @@ -0,0 +1,11 @@ +ollama.syso +*.crt +*.exe +/app/app +/app/squirrel +ollama +*cover* +.vscode +.env +.DS_Store +.claude diff --git a/app/README.md b/app/README.md new file mode 100644 index 0000000..95afcac --- /dev/null +++ b/app/README.md @@ -0,0 +1,97 @@ +# Ollama for macOS and Windows + +## Download + +- [macOS](https://github.com/ollama/app/releases/download/latest/Ollama.dmg) +- [Windows](https://github.com/ollama/app/releases/download/latest/OllamaSetup.exe) + +## Development + +### Desktop App + +```bash +go generate ./... && +go run ./cmd/app +``` + +### UI Development + +#### Setup + +Install required tools: + +```bash +go install github.com/tkrajina/typescriptify-golang-structs/tscriptify@latest +``` + +#### Develop UI (Development Mode) + +1. Start the React development server (with hot-reload): + +```bash +cd ui/app +npm install +npm run dev +``` + +2. In a separate terminal, run the Ollama app with the `-dev` flag: + +```bash +go generate ./... && +OLLAMA_DEBUG=1 go run ./cmd/app -dev +``` + +The `-dev` flag enables: + +- Loading the UI from the Vite dev server at http://localhost:5173 +- Fixed UI server port at http://127.0.0.1:3001 for API requests +- CORS headers for cross-origin requests +- Hot-reload support for UI development + +## Build + + +### Windows + +- https://jrsoftware.org/isinfo.php + + +**Dependencies** - either build a local copy of ollama, or use a github release +```powershell +# Local dependencies +.\scripts\deps_local.ps1 + +# Release dependencies +.\scripts\deps_release.ps1 0.6.8 +``` + +**Build** +```powershell +.\scripts\build_windows.ps1 +``` + +### macOS + +CI builds with Xcode 14.1 for OS compatibility prior to v13. If you want to manually build v11+ support, you can download the older Xcode [here](https://developer.apple.com/services-account/download?path=/Developer_Tools/Xcode_14.1/Xcode_14.1.xip), extract, then `mv ./Xcode.app /Applications/Xcode_14.1.0.app` then activate with: + +``` +export CGO_CFLAGS="-O3 -mmacosx-version-min=12.0" +export CGO_CXXFLAGS="-O3 -mmacosx-version-min=12.0" +export CGO_LDFLAGS="-mmacosx-version-min=12.0" +export SDKROOT=/Applications/Xcode_14.1.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk +export DEVELOPER_DIR=/Applications/Xcode_14.1.0.app/Contents/Developer +``` + +**Dependencies** - either build a local copy of Ollama, or use a GitHub release: +```sh +# Local dependencies +./scripts/deps_local.sh + +# Release dependencies +./scripts/deps_release.sh 0.6.8 +``` + +**Build** +```sh +./scripts/build_darwin.sh +``` diff --git a/app/assets/app.ico b/app/assets/app.ico new file mode 100644 index 0000000..875924f Binary files /dev/null and b/app/assets/app.ico differ diff --git a/app/assets/assets.go b/app/assets/assets.go new file mode 100644 index 0000000..1146e41 --- /dev/null +++ b/app/assets/assets.go @@ -0,0 +1,19 @@ +//go:build windows || darwin + +package assets + +import ( + "embed" + "io/fs" +) + +//go:embed *.ico +var icons embed.FS + +func ListIcons() ([]string, error) { + return fs.Glob(icons, "*") +} + +func GetIcon(filename string) ([]byte, error) { + return icons.ReadFile(filename) +} diff --git a/app/assets/background.png b/app/assets/background.png new file mode 100644 index 0000000..bbfc587 Binary files /dev/null and b/app/assets/background.png differ diff --git a/app/assets/setup.bmp b/app/assets/setup.bmp new file mode 100644 index 0000000..ff58b90 Binary files /dev/null and b/app/assets/setup.bmp differ diff --git a/app/assets/tray.ico b/app/assets/tray.ico new file mode 100644 index 0000000..5786698 Binary files /dev/null and b/app/assets/tray.ico differ diff --git a/app/assets/tray_upgrade.ico b/app/assets/tray_upgrade.ico new file mode 100644 index 0000000..4cb604c Binary files /dev/null and b/app/assets/tray_upgrade.ico differ diff --git a/app/auth/connect.go b/app/auth/connect.go new file mode 100644 index 0000000..2d3297e --- /dev/null +++ b/app/auth/connect.go @@ -0,0 +1,26 @@ +//go:build windows || darwin + +package auth + +import ( + "encoding/base64" + "fmt" + "net/url" + "os" + + "github.com/ollama/ollama/auth" +) + +// BuildConnectURL generates the connect URL with the public key and device name +func BuildConnectURL(baseURL string) (string, error) { + pubKey, err := auth.GetPublicKey() + if err != nil { + return "", fmt.Errorf("failed to get public key: %w", err) + } + + encodedKey := base64.RawURLEncoding.EncodeToString([]byte(pubKey)) + hostname, _ := os.Hostname() + encodedDevice := url.QueryEscape(hostname) + + return fmt.Sprintf("%s/connect?name=%s&key=%s&launch=true", baseURL, encodedDevice, encodedKey), nil +} diff --git a/app/cmd/app/AppDelegate.h b/app/cmd/app/AppDelegate.h new file mode 100644 index 0000000..b758252 --- /dev/null +++ b/app/cmd/app/AppDelegate.h @@ -0,0 +1,7 @@ +#import + +@interface AppDelegate : NSObject + +- (void)applicationDidFinishLaunching:(NSNotification *)aNotification; + +@end \ No newline at end of file diff --git a/app/cmd/app/app.go b/app/cmd/app/app.go new file mode 100644 index 0000000..9c8b736 --- /dev/null +++ b/app/cmd/app/app.go @@ -0,0 +1,507 @@ +//go:build windows || darwin + +package main + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "io" + "log/slog" + "net" + "net/http" + "net/url" + "os" + "os/exec" + "os/signal" + "path/filepath" + "runtime" + "strings" + "syscall" + "time" + + "github.com/google/uuid" + "github.com/ollama/ollama/app/auth" + "github.com/ollama/ollama/app/logrotate" + "github.com/ollama/ollama/app/server" + "github.com/ollama/ollama/app/store" + "github.com/ollama/ollama/app/tools" + "github.com/ollama/ollama/app/ui" + "github.com/ollama/ollama/app/updater" + "github.com/ollama/ollama/app/version" +) + +var ( + wv = &Webview{} + uiServerPort int + appStore *store.Store +) + +var debug = strings.EqualFold(os.Getenv("OLLAMA_DEBUG"), "true") || os.Getenv("OLLAMA_DEBUG") == "1" + +var ( + fastStartup = false + devMode = false +) + +type appMove int + +const ( + CannotMove appMove = iota + UserDeclinedMove + MoveCompleted + AlreadyMoved + LoginSession + PermissionDenied + MoveError +) + +func main() { + startHidden := false + var urlSchemeRequest string + if len(os.Args) > 1 { + for _, arg := range os.Args { + // Handle URL scheme requests (Windows) + if strings.HasPrefix(arg, "ollama://") { + urlSchemeRequest = arg + slog.Info("received URL scheme request", "url", arg) + continue + } + switch arg { + case "serve": + fmt.Fprintln(os.Stderr, "serve command not supported, use ollama") + os.Exit(1) + case "version", "-v", "--version": + fmt.Println(version.Version) + os.Exit(0) + case "background": + // When running the process in this "background" mode, we spawn a + // child process for the main app. This is necessary so the + // "Allow in the Background" setting in MacOS can be unchecked + // without breaking the main app. Two copies of the app are + // present in the bundle, one for the main app and one for the + // background initiator. + fmt.Fprintln(os.Stdout, "starting in background") + runInBackground() + os.Exit(0) + case "hidden", "-j", "--hide": + // startHidden suppresses the UI on startup, and can be triggered multiple ways + // On windows, path based via login startup detection + // On MacOS via [NSApp isHidden] from `open -j -a /Applications/Ollama.app` or equivalent + // On both via the "hidden" command line argument + startHidden = true + case "--fast-startup": + // Skip optional steps like pending updates to start quickly for immediate use + fastStartup = true + case "-dev", "--dev": + // Development mode: use local dev server and enable CORS + devMode = true + } + } + } + + level := slog.LevelInfo + if debug { + level = slog.LevelDebug + } + + logrotate.Rotate(appLogPath) + if _, err := os.Stat(filepath.Dir(appLogPath)); errors.Is(err, os.ErrNotExist) { + if err := os.MkdirAll(filepath.Dir(appLogPath), 0o755); err != nil { + slog.Error(fmt.Sprintf("failed to create server log dir %v", err)) + return + } + } + + var logFile io.Writer + var err error + logFile, err = os.OpenFile(appLogPath, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0o755) + if err != nil { + slog.Error(fmt.Sprintf("failed to create server log %v", err)) + return + } + // Detect if we're a GUI app on windows, and if not, send logs to console as well + if os.Stderr.Fd() != 0 { + // Console app detected + logFile = io.MultiWriter(os.Stderr, logFile) + } + + handler := slog.NewTextHandler(logFile, &slog.HandlerOptions{ + Level: level, + AddSource: true, + ReplaceAttr: func(_ []string, attr slog.Attr) slog.Attr { + if attr.Key == slog.SourceKey { + source := attr.Value.Any().(*slog.Source) + source.File = filepath.Base(source.File) + } + return attr + }, + }) + + slog.SetDefault(slog.New(handler)) + logStartup() + + // On Windows, check if another instance is running and send URL to it + // Do this after logging is set up so we can debug issues + if runtime.GOOS == "windows" && urlSchemeRequest != "" { + slog.Debug("checking for existing instance", "url", urlSchemeRequest) + if checkAndHandleExistingInstance(urlSchemeRequest) { + // The function will exit if it successfully sends to another instance + // If we reach here, we're the first/only instance + } else { + // No existing instance found, handle the URL scheme in this instance + go func() { + handleURLSchemeInCurrentInstance(urlSchemeRequest) + }() + } + } + + // Detect if this is a first start after an upgrade, in + // which case we need to do some cleanup + var skipMove bool + if _, err := os.Stat(updater.UpgradeMarkerFile); err == nil { + slog.Debug("first start after upgrade") + err = updater.DoPostUpgradeCleanup() + if err != nil { + slog.Error("failed to cleanup prior version", "error", err) + } + // We never prompt to move the app after an upgrade + skipMove = true + // Start hidden after updates to prevent UI from opening automatically + startHidden = true + } + + if !skipMove && !fastStartup { + if maybeMoveAndRestart() == MoveCompleted { + return + } + } + + // Check if another instance is already running + // On Windows, focus the existing instance; on other platforms, kill it + handleExistingInstance(startHidden) + + // on macOS, offer the user to create a symlink + // from /usr/local/bin/ollama to the app bundle + installSymlink() + + var ln net.Listener + if devMode { + // Use a fixed port in dev mode for predictable API access + ln, err = net.Listen("tcp", "127.0.0.1:3001") + } else { + ln, err = net.Listen("tcp", "127.0.0.1:0") + } + if err != nil { + slog.Error("failed to find available port", "error", err) + return + } + + port := ln.Addr().(*net.TCPAddr).Port + token := uuid.NewString() + wv.port = port + wv.token = token + uiServerPort = port + + st := &store.Store{} + appStore = st + + // Enable CORS in development mode + if devMode { + os.Setenv("OLLAMA_CORS", "1") + + // Check if Vite dev server is running on port 5173 + var conn net.Conn + var err error + for _, addr := range []string{"127.0.0.1:5173", "localhost:5173"} { + conn, err = net.DialTimeout("tcp", addr, 2*time.Second) + if err == nil { + conn.Close() + break + } + } + + if err != nil { + slog.Error("Vite dev server not running on port 5173") + fmt.Fprintln(os.Stderr, "Error: Vite dev server is not running on port 5173") + fmt.Fprintln(os.Stderr, "Please run 'npm run dev' in the ui/app directory to start the UI in development mode") + os.Exit(1) + } + } + + // Initialize tools registry + toolRegistry := tools.NewRegistry() + slog.Info("initialized tools registry", "tool_count", len(toolRegistry.List())) + + // ctx is the app-level context that will be used to stop the app + ctx, cancel := context.WithCancel(context.Background()) + + // octx is the ollama server context that will be used to stop the ollama server + octx, ocancel := context.WithCancel(ctx) + + // TODO (jmorganca): instead we should instantiate the + // webview with the store instead of assigning it here, however + // making the webview a global variable is easier for now + wv.Store = st + done := make(chan error, 1) + osrv := server.New(st, devMode) + go func() { + slog.Info("starting ollama server") + done <- osrv.Run(octx) + }() + + upd := &updater.Updater{Store: st} + + uiServer := ui.Server{ + Token: token, + Restart: func() { + ocancel() + <-done + octx, ocancel = context.WithCancel(ctx) + go func() { + done <- osrv.Run(octx) + }() + }, + Store: st, + ToolRegistry: toolRegistry, + Dev: devMode, + Logger: slog.Default(), + Updater: upd, + UpdateAvailableFunc: func() { + UpdateAvailable("") + }, + } + + srv := &http.Server{ + Handler: uiServer.Handler(), + } + + // Start the UI server + slog.Info("starting ui server", "port", port) + go func() { + slog.Debug("starting ui server on port", "port", port) + err = srv.Serve(ln) + if err != nil && !errors.Is(err, http.ErrServerClosed) { + slog.Warn("desktop server", "error", err) + } + slog.Debug("background desktop server done") + }() + + upd.StartBackgroundUpdaterChecker(ctx, UpdateAvailable) + + // Check for pending updates on startup (show tray notification if update is ready) + if updater.IsUpdatePending() { + // On Windows, the tray is initialized in osRun(). Calling UpdateAvailable + // before that would dereference a nil tray callback. + // TODO: refactor so the update check runs after platform init on all platforms. + if runtime.GOOS == "windows" { + slog.Debug("update pending on startup, deferring tray notification until tray initialization") + } else { + slog.Debug("update pending on startup, showing tray notification") + UpdateAvailable("") + } + } + + hasCompletedFirstRun, err := st.HasCompletedFirstRun() + if err != nil { + slog.Error("failed to load has completed first run", "error", err) + } + + if !hasCompletedFirstRun { + err = st.SetHasCompletedFirstRun(true) + if err != nil { + slog.Error("failed to set has completed first run", "error", err) + } + } + + // capture SIGINT and SIGTERM signals and gracefully shutdown the app + signals := make(chan os.Signal, 1) + signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM) + go func() { + <-signals + slog.Info("received SIGINT or SIGTERM signal, shutting down") + quit() + }() + + if urlSchemeRequest != "" { + go func() { + handleURLSchemeInCurrentInstance(urlSchemeRequest) + }() + } else { + slog.Debug("no URL scheme request to handle") + } + + go func() { + slog.Debug("waiting for ollama server to be ready") + if err := ui.WaitForServer(ctx, 10*time.Second); err != nil { + slog.Warn("ollama server not ready, continuing anyway", "error", err) + } + + if _, err := uiServer.UserData(ctx); err != nil { + slog.Warn("failed to load user data", "error", err) + } + }() + + osRun(cancel, hasCompletedFirstRun, startHidden) + + slog.Info("shutting down desktop server") + if err := srv.Close(); err != nil { + slog.Warn("error shutting down desktop server", "error", err) + } + + slog.Info("shutting down ollama server") + cancel() + <-done +} + +func startHiddenTasks() { + // If an upgrade is ready and we're in hidden mode, perform it at startup. + // If we're not in hidden mode, we want to start as fast as possible and not + // slow the user down with an upgrade. + if updater.IsUpdatePending() { + if fastStartup { + // CLI triggered app startup use-case + slog.Info("deferring pending update for fast startup") + } else { + // Check if auto-update is enabled before automatically upgrading + settings, err := appStore.Settings() + if err != nil { + slog.Warn("failed to load settings for upgrade check", "error", err) + } else if !settings.AutoUpdateEnabled { + slog.Info("auto-update disabled, skipping automatic upgrade at startup") + // Still show tray notification so user knows update is ready + UpdateAvailable("") + return + } + + if err := updater.DoUpgradeAtStartup(); err != nil { + slog.Info("unable to perform upgrade at startup", "error", err) + // Make sure the restart to upgrade menu shows so we can attempt an interactive upgrade to get authorization + UpdateAvailable("") + } else { + slog.Debug("launching new version...") + // TODO - consider a timer that aborts if this takes too long and we haven't been killed yet... + LaunchNewApp() + os.Exit(0) + } + } + } +} + +func checkUserLoggedIn(uiServerPort int) bool { + if uiServerPort == 0 { + slog.Debug("UI server not ready yet, skipping auth check") + return false + } + + resp, err := http.Post(fmt.Sprintf("http://127.0.0.1:%d/api/me", uiServerPort), "application/json", nil) + if err != nil { + slog.Debug("failed to call local auth endpoint", "error", err) + return false + } + defer resp.Body.Close() + + // Check if the response is successful + if resp.StatusCode != http.StatusOK { + slog.Debug("auth endpoint returned non-OK status", "status", resp.StatusCode) + return false + } + + var user struct { + ID string `json:"id"` + Name string `json:"name"` + } + + if err := json.NewDecoder(resp.Body).Decode(&user); err != nil { + slog.Debug("failed to parse user response", "error", err) + return false + } + + // Verify we have a valid user with an ID and name + if user.ID == "" || user.Name == "" { + slog.Debug("user response missing required fields", "id", user.ID, "name", user.Name) + return false + } + + slog.Debug("user is logged in", "user_id", user.ID, "user_name", user.Name) + return true +} + +// handleConnectURLScheme fetches the connect URL and opens it in the browser +func handleConnectURLScheme() { + if checkUserLoggedIn(uiServerPort) { + slog.Info("user is already logged in, opening app instead") + showWindow(wv.webview.Window()) + return + } + + connectURL, err := auth.BuildConnectURL("https://ollama.com") + if err != nil { + slog.Error("failed to build connect URL", "error", err) + openInBrowser("https://ollama.com/connect") + return + } + + openInBrowser(connectURL) +} + +// openInBrowser opens the specified URL in the default browser +func openInBrowser(url string) { + var cmd string + var args []string + + switch runtime.GOOS { + case "windows": + cmd = "rundll32" + args = []string{"url.dll,FileProtocolHandler", url} + case "darwin": + cmd = "open" + args = []string{url} + default: // "linux", "freebsd", "openbsd", "netbsd"... should not reach here + slog.Warn("unsupported OS for openInBrowser", "os", runtime.GOOS) + } + + slog.Info("executing browser command", "cmd", cmd, "args", args) + if err := exec.Command(cmd, args...).Start(); err != nil { + slog.Error("failed to open URL in browser", "url", url, "cmd", cmd, "args", args, "error", err) + } +} + +// parseURLScheme parses an ollama:// URL and validates it +// Supports: ollama:// (open app) and ollama://connect (OAuth) +func parseURLScheme(urlSchemeRequest string) (isConnect bool, err error) { + parsedURL, err := url.Parse(urlSchemeRequest) + if err != nil { + return false, fmt.Errorf("invalid URL: %w", err) + } + + // Check if this is a connect URL + if parsedURL.Host == "connect" || strings.TrimPrefix(parsedURL.Path, "/") == "connect" { + return true, nil + } + + // Allow bare ollama:// or ollama:/// to open the app + if (parsedURL.Host == "" && parsedURL.Path == "") || parsedURL.Path == "/" { + return false, nil + } + + return false, fmt.Errorf("unsupported ollama:// URL path: %s", urlSchemeRequest) +} + +// handleURLSchemeInCurrentInstance processes URL scheme requests in the current instance +func handleURLSchemeInCurrentInstance(urlSchemeRequest string) { + isConnect, err := parseURLScheme(urlSchemeRequest) + if err != nil { + slog.Error("failed to parse URL scheme request", "url", urlSchemeRequest, "error", err) + return + } + + if isConnect { + handleConnectURLScheme() + } else { + if wv.webview != nil { + showWindow(wv.webview.Window()) + } + } +} diff --git a/app/cmd/app/app_darwin.go b/app/cmd/app/app_darwin.go new file mode 100644 index 0000000..8e886a1 --- /dev/null +++ b/app/cmd/app/app_darwin.go @@ -0,0 +1,262 @@ +//go:build windows || darwin + +package main + +// #cgo CFLAGS: -x objective-c +// #cgo LDFLAGS: -framework Webkit -framework Cocoa -framework LocalAuthentication -framework ServiceManagement +// #include "app_darwin.h" +// #include "../../updater/updater_darwin.h" +// typedef const char cchar_t; +import "C" + +import ( + "log/slog" + "os" + "os/exec" + "path/filepath" + "strings" + "time" + "unsafe" + + "github.com/ollama/ollama/app/updater" + "github.com/ollama/ollama/app/version" +) + +var ollamaPath = func() string { + if updater.BundlePath != "" { + return filepath.Join(updater.BundlePath, "Contents", "Resources", "ollama") + } + + pwd, err := os.Getwd() + if err != nil { + slog.Warn("failed to get pwd", "error", err) + return "" + } + return filepath.Join(pwd, "ollama") +}() + +var ( + isApp = updater.BundlePath != "" + appLogPath = filepath.Join(os.Getenv("HOME"), ".ollama", "logs", "app.log") + launchAgentPath = filepath.Join(os.Getenv("HOME"), "Library", "LaunchAgents", "com.ollama.ollama.plist") +) + +// TODO(jmorganca): pre-create the window and pass +// it to the webview instead of using the internal one +// +//export StartUI +func StartUI(path *C.cchar_t) { + p := C.GoString(path) + wv.Run(p) + styleWindow(wv.webview.Window()) + C.setWindowDelegate(wv.webview.Window()) +} + +//export ShowUI +func ShowUI() { + // If webview is already running, just show the window + if wv.IsRunning() && wv.webview != nil { + showWindow(wv.webview.Window()) + } else { + root := C.CString("/") + defer C.free(unsafe.Pointer(root)) + StartUI(root) + } +} + +//export StopUI +func StopUI() { + wv.Terminate() +} + +//export StartUpdate +func StartUpdate() { + if err := updater.DoUpgrade(true); err != nil { + slog.Error("upgrade failed", "error", err) + return + } + slog.Debug("launching new version...") + // TODO - consider a timer that aborts if this takes too long and we haven't been killed yet... + LaunchNewApp() + // not reached if upgrade works, the new app will kill this process +} + +//export darwinStartHiddenTasks +func darwinStartHiddenTasks() { + startHiddenTasks() +} + +func init() { + // Temporary code to mimic Squirrel ShipIt behavior + if len(os.Args) > 2 { + if os.Args[1] == "___launch___" { + path := strings.TrimPrefix(os.Args[2], "file://") + slog.Info("Ollama binary called as ShipIt - launching", "app", path) + appName := C.CString(path) + defer C.free(unsafe.Pointer(appName)) + C.launchApp(appName) + slog.Info("other instance has been launched") + time.Sleep(5 * time.Second) + slog.Info("exiting with zero status") + os.Exit(0) + } + } +} + +// maybeMoveAndRestart checks if we should relocate +// and returns true if we did and should immediately exit +func maybeMoveAndRestart() appMove { + if updater.BundlePath == "" { + // Typically developer mode with 'go run ./cmd/app' + return CannotMove + } + // Respect users intent if they chose "keep" vs. "replace" when dragging to Applications + if strings.HasPrefix(updater.BundlePath, strings.TrimSuffix(updater.SystemWidePath, filepath.Ext(updater.SystemWidePath))) { + return AlreadyMoved + } + + // Ask to move to applications directory + status := (appMove)(C.askToMoveToApplications()) + if status == MoveCompleted { + // Double check + if _, err := os.Stat(updater.SystemWidePath); err != nil { + slog.Warn("stat failure after move", "path", updater.SystemWidePath, "error", err) + return MoveError + } + } + return status +} + +// handleExistingInstance handles existing instances on macOS +func handleExistingInstance(_ bool) { + C.killOtherInstances() +} + +func installSymlink() { + if !isApp { + return + } + cliPath := C.CString(ollamaPath) + defer C.free(unsafe.Pointer(cliPath)) + + // Check the users path first + cmd, _ := exec.LookPath("ollama") + if cmd != "" { + resolved, err := os.Readlink(cmd) + if err == nil { + tmp, err := filepath.Abs(resolved) + if err == nil { + resolved = tmp + } + } else { + resolved = cmd + } + if resolved == ollamaPath { + slog.Info("ollama already in users PATH", "cli", cmd) + return + } + } + + code := C.installSymlink(cliPath) + if code != 0 { + slog.Error("Failed to install symlink") + } +} + +func UpdateAvailable(ver string) error { + slog.Debug("update detected, adjusting menu") + // TODO (jmorganca): find a better check for development mode than checking the bundle path + if updater.BundlePath != "" { + C.updateAvailable() + } + return nil +} + +func osRun(_ func(), hasCompletedFirstRun, startHidden bool) { + registerLaunchAgent(hasCompletedFirstRun) + + // Run the native macOS app + // Note: this will block until the app is closed + slog.Debug("starting native darwin event loop") + C.run(C._Bool(hasCompletedFirstRun), C._Bool(startHidden)) +} + +func quit() { + C.quit() +} + +func LaunchNewApp() { + appName := C.CString(updater.BundlePath) + defer C.free(unsafe.Pointer(appName)) + C.launchApp(appName) +} + +func registerLaunchAgent(hasCompletedFirstRun bool) { + // Remove any stale Login Item registrations + C.unregisterSelfFromLoginItem() + + C.registerSelfAsLoginItem(C._Bool(hasCompletedFirstRun)) +} + +func logStartup() { + appPath := updater.BundlePath + if appPath == updater.SystemWidePath { + // Detect sandboxed scenario + exe, err := os.Executable() + if err == nil { + p := filepath.Dir(exe) + if filepath.Base(p) == "MacOS" { + p = filepath.Dir(filepath.Dir(p)) + if p != appPath { + slog.Info("starting sandboxed Ollama", "app", appPath, "sandbox", p) + return + } + } + } + } + slog.Info("starting Ollama", "app", appPath, "version", version.Version, "OS", updater.UserAgentOS) +} + +func hideWindow(ptr unsafe.Pointer) { + C.hideWindow(C.uintptr_t(uintptr(ptr))) +} + +func showWindow(ptr unsafe.Pointer) { + C.showWindow(C.uintptr_t(uintptr(ptr))) +} + +func styleWindow(ptr unsafe.Pointer) { + C.styleWindow(C.uintptr_t(uintptr(ptr))) +} + +func runInBackground() { + cmd := exec.Command(filepath.Join(updater.BundlePath, "Contents", "MacOS", "Ollama"), "hidden") + if cmd != nil { + err := cmd.Run() + if err != nil { + slog.Error("failed to run Ollama", "bundlePath", updater.BundlePath, "error", err) + os.Exit(1) + } + } else { + slog.Error("failed to start Ollama in background", "bundlePath", updater.BundlePath) + os.Exit(1) + } +} + +func drag(ptr unsafe.Pointer) { + C.drag(C.uintptr_t(uintptr(ptr))) +} + +func doubleClick(ptr unsafe.Pointer) { + C.doubleClick(C.uintptr_t(uintptr(ptr))) +} + +//export handleConnectURL +func handleConnectURL() { + handleConnectURLScheme() +} + +// checkAndHandleExistingInstance is not needed on non-Windows platforms +func checkAndHandleExistingInstance(_ string) bool { + return false +} diff --git a/app/cmd/app/app_darwin.h b/app/cmd/app/app_darwin.h new file mode 100644 index 0000000..4a5ba05 --- /dev/null +++ b/app/cmd/app/app_darwin.h @@ -0,0 +1,43 @@ +#import +#import + +@interface AppDelegate : NSObject +- (void)applicationDidFinishLaunching:(NSNotification *)aNotification; +@end + +enum AppMove +{ + CannotMove, + UserDeclinedMove, + MoveCompleted, + AlreadyMoved, + LoginSession, + PermissionDenied, + MoveError, +}; + +void run(bool firstTimeRun, bool startHidden); +void killOtherInstances(); +enum AppMove askToMoveToApplications(); +int createSymlinkWithAuthorization(); +int installSymlink(const char *cliPath); +extern void Restart(); +// extern void Quit(); +void StartUI(const char *path); +void ShowUI(); +void StopUI(); +void StartUpdate(); +void darwinStartHiddenTasks(); +void launchApp(const char *appPath); +void updateAvailable(); +void quit(); +void uiRequest(char *path); +void registerSelfAsLoginItem(bool firstTimeRun); +void unregisterSelfFromLoginItem(); +void setWindowDelegate(void *window); +void showWindow(uintptr_t wndPtr); +void hideWindow(uintptr_t wndPtr); +void styleWindow(uintptr_t wndPtr); +void drag(uintptr_t wndPtr); +void doubleClick(uintptr_t wndPtr); +void handleConnectURL(); diff --git a/app/cmd/app/app_darwin.m b/app/cmd/app/app_darwin.m new file mode 100644 index 0000000..65f91b3 --- /dev/null +++ b/app/cmd/app/app_darwin.m @@ -0,0 +1,1131 @@ +#import "app_darwin.h" +#import "menu.h" +#import "../../updater/updater_darwin.h" +#import +#import +#import +#import +#import +#import +#import + +extern NSString *SystemWidePath; + +@interface AppDelegate () +@property(strong, nonatomic) NSStatusItem *statusItem; +@property(assign, nonatomic) BOOL updateAvailable; +@property(assign, nonatomic) BOOL systemShutdownInProgress; +@end + +@implementation AppDelegate + +bool firstTimeRun,startHidden; // Set in run before initialization + +- (void)application:(NSApplication *)application openURLs:(NSArray *)urls { + for (NSURL *url in urls) { + if ([url.scheme isEqualToString:@"ollama"]) { + NSString *path = url.path; + + if (path && ([path isEqualToString:@"/connect"] || [url.host isEqualToString:@"connect"])) { + // Special case: handle connect by opening browser instead of app + handleConnectURL(); + } else { + // Set app to be active and visible + [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; + [NSApp activateIgnoringOtherApps:YES]; + } + + break; + } + } +} + +- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { + // Register for system shutdown/restart notification so we can allow termination + [[[NSWorkspace sharedWorkspace] notificationCenter] + addObserver:self + selector:@selector(systemWillPowerOff:) + name:NSWorkspaceWillPowerOffNotification + object:nil]; + + // if we're in development mode, set the app icon + NSString *bundlePath = [[NSBundle mainBundle] bundlePath]; + if (![bundlePath hasSuffix:@".app"]) { + NSString *cwdPath = + [[NSFileManager defaultManager] currentDirectoryPath]; + NSString *iconPath = [cwdPath + stringByAppendingPathComponent: + [NSString + stringWithFormat: + @"darwin/Ollama.app/Contents/Resources/icon.icns"]]; + NSImage *customIcon = [[NSImage alloc] initWithContentsOfFile:iconPath]; + [NSApp setApplicationIconImage:customIcon]; + } + + // Create status item and menu + NSMenu *menu = [[NSMenu alloc] init]; + NSMenuItem *openMenuItem = + [[NSMenuItem alloc] initWithTitle:@"Open Ollama" + action:@selector(openUI) + keyEquivalent:@""]; + [openMenuItem setTarget:self]; + [menu addItem:openMenuItem]; + + [menu addItemWithTitle:@"Settings..." + action:@selector(settingsUI) + keyEquivalent:@","]; + [menu addItem:[NSMenuItem separatorItem]]; + + NSMenuItem *updateAvailable = + [[NSMenuItem alloc] initWithTitle:@"An update is available" + action:nil + keyEquivalent:@""]; + [updateAvailable setEnabled:NO]; + [updateAvailable setHidden:YES]; + [menu addItem:updateAvailable]; + + NSMenuItem *restartMenuItem = + [[NSMenuItem alloc] initWithTitle:@"Restart to update" + action:@selector(startUpdate) + keyEquivalent:@""]; + [restartMenuItem setTarget:self]; + [restartMenuItem setHidden:YES]; + [menu addItem:restartMenuItem]; + + [menu addItem:[NSMenuItem separatorItem]]; + + [menu addItemWithTitle:@"Quit Ollama" + action:@selector(quit) + keyEquivalent:@"q"]; + + self.statusItem = [[NSStatusBar systemStatusBar] + statusItemWithLength:NSVariableStatusItemLength]; + [self.statusItem addObserver:self + forKeyPath:@"button.effectiveAppearance" + options:NSKeyValueObservingOptionNew | + NSKeyValueObservingOptionInitial + context:nil]; + + self.statusItem.menu = menu; + [self showIcon]; + + // Application menu + NSString *appName = @"Ollama"; + + NSMenu *mainMenu = [[NSMenu alloc] init]; + NSMenuItem *appMenuItem = [[NSMenuItem alloc] initWithTitle:appName + action:nil + keyEquivalent:@""]; + NSMenu *appMenu = [[NSMenu alloc] initWithTitle:appName]; + [appMenuItem setSubmenu:appMenu]; + [mainMenu addItem:appMenuItem]; + + [appMenu addItemWithTitle:[NSString stringWithFormat:@"About %@", appName] + action:@selector(aboutOllama) + keyEquivalent:@""]; + [appMenu addItem:[NSMenuItem separatorItem]]; + [appMenu addItemWithTitle:@"Settings..." + action:@selector(settingsUI) + keyEquivalent:@","]; + [appMenu addItem:[NSMenuItem separatorItem]]; + [appMenu addItemWithTitle:[NSString stringWithFormat:@"Hide %@", appName] + action:@selector(hide:) + keyEquivalent:@"h"]; + + NSMenuItem *hideOthers = [[NSMenuItem alloc] initWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"]; + hideOthers.keyEquivalentModifierMask = NSEventModifierFlagOption | NSEventModifierFlagCommand; + [appMenu addItem:hideOthers]; + [appMenu addItemWithTitle:@"Show All" + action:@selector(unhideAllApplications:) + keyEquivalent:@""]; + [appMenu addItem:[NSMenuItem separatorItem]]; + [appMenu addItemWithTitle:[NSString stringWithFormat:@"Quit %@", appName] + action:@selector(hide) + keyEquivalent:@"q"]; + + NSMenuItem *fileMenuItem = [[NSMenuItem alloc] init]; + NSMenu *fileMenu = [[NSMenu alloc] initWithTitle:@"File"]; + + NSMenuItem *newChatItem = [[NSMenuItem alloc] initWithTitle:@"New Chat" + action:@selector(newChat) + keyEquivalent:@"n"]; + [newChatItem setTarget:self]; + [fileMenu addItem:newChatItem]; + [fileMenu addItem:[NSMenuItem separatorItem]]; + + NSMenuItem *closeItem = [[NSMenuItem alloc] initWithTitle:@"Close Window" action:@selector(hide:) keyEquivalent:@"w"]; + [fileMenu addItem:closeItem]; + [fileMenuItem setSubmenu:fileMenu]; + [mainMenu addItem:fileMenuItem]; + + NSMenuItem *editMenuItem = [[NSMenuItem alloc] init]; + NSMenu *editMenu = [[NSMenu alloc] initWithTitle:@"Edit"]; + + [editMenu addItemWithTitle:@"Undo" + action:@selector(undo:) + keyEquivalent:@"z"]; + [editMenu addItemWithTitle:@"Redo" + action:@selector(redo:) + keyEquivalent:@"Z"]; + [editMenu addItem:[NSMenuItem separatorItem]]; + [editMenu addItemWithTitle:@"Cut" + action:@selector(cut:) + keyEquivalent:@"x"]; + [editMenu addItemWithTitle:@"Copy" + action:@selector(copy:) + keyEquivalent:@"c"]; + [editMenu addItemWithTitle:@"Paste" + action:@selector(paste:) + keyEquivalent:@"v"]; + [editMenu addItemWithTitle:@"Select All" + action:@selector(selectAll:) + keyEquivalent:@"a"]; + + [editMenuItem setSubmenu:editMenu]; + [mainMenu addItem:editMenuItem]; + + NSMenuItem *windowMenuItem = [[NSMenuItem alloc] init]; + NSMenu *windowMenu = [[NSMenu alloc] initWithTitle:@"Window"]; + [windowMenu addItemWithTitle:@"Minimize" + action:@selector(performMiniaturize:) + keyEquivalent:@"m"]; + [windowMenu addItemWithTitle:@"Zoom" + action:@selector(performZoom:) + keyEquivalent:@""]; + [windowMenu addItem:[NSMenuItem separatorItem]]; + [windowMenu addItemWithTitle:@"Bring All to Front" + action:@selector(arrangeInFront:) + keyEquivalent:@""]; + [windowMenuItem setSubmenu:windowMenu]; + [mainMenu addItem:windowMenuItem]; + [NSApp setWindowsMenu:windowMenu]; + + NSMenuItem *helpMenuItem = [[NSMenuItem alloc] init]; + NSMenu *helpMenu = [[NSMenu alloc] initWithTitle:@"Help"]; + [helpMenu addItemWithTitle:[NSString stringWithFormat:@"%@ Help", appName] + action:@selector(openHelp:) + keyEquivalent:@"?"]; + [helpMenuItem setSubmenu:helpMenu]; + [mainMenu addItem:helpMenuItem]; + [NSApp setHelpMenu:helpMenu]; + [NSApp setMainMenu:mainMenu]; + + BOOL hidden = [NSApp isHidden]; + dispatch_async(dispatch_get_main_queue(), ^{ + if (hidden || startHidden) { + darwinStartHiddenTasks(); + } else { + if (!startHidden) { + StartUI("/"); + } + } + }); +} + +- (void)applicationDidBecomeActive:(NSNotification *)notification { + NSRunningApplication *currentApp = [NSRunningApplication currentApplication]; + if (currentApp.activationPolicy == NSApplicationActivationPolicyAccessory) { + for (NSWindow *window in [NSApp windows]) { + if ([window isVisible]) { + // Switch to regular activation policy since we have a visible window + [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; + return; + } + } + [NSApp hide:nil]; + return; + } +} + +- (BOOL)applicationShouldHandleReopen:(NSApplication *)sender hasVisibleWindows:(BOOL)hasVisibleWindows { + [self openUI]; + return YES; +} + +- (void)showUpdateAvailable { + self.updateAvailable = YES; + [self.statusItem.menu.itemArray[3] setHidden:NO]; + [self.statusItem.menu.itemArray[4] setHidden:NO]; + [self showIcon]; +} + +- (void)aboutOllama { + [[NSApplication sharedApplication] orderFrontStandardAboutPanel:nil]; + [NSApp activateIgnoringOtherApps:YES]; +} + +- (void)openHelp:(id)sender { + NSURL *url = [NSURL URLWithString:@"https://docs.ollama.com/"]; + [[NSWorkspace sharedWorkspace] openURL:url]; +} + +- (void)settingsUI { + [self uiRequest:@"/settings"]; +} + +- (void)openUI { + ShowUI(); +} + +- (void)newChat { + [self uiRequest:@"/c/new"]; +} + +- (void)uiRequest:(NSString *)path { + if (path == nil) { + appLogInfo(@"app UI request for URL is missing"); + } + + appLogInfo([NSString + stringWithFormat:@"XXX got app UI request for URL: %@", path]); + StartUI([path UTF8String]); +} + +- (void)startUpdate { + StartUpdate(); + [NSApp activateIgnoringOtherApps:YES]; +} + +- (void)systemWillPowerOff:(NSNotification *)notification { + // Set flag so applicationShouldTerminate: knows to allow termination. + // The system will call applicationShouldTerminate: after posting this notification. + self.systemShutdownInProgress = YES; +} + +- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { + // Allow termination if the system is shutting down or restarting + if (self.systemShutdownInProgress) { + return NSTerminateNow; + } + // Otherwise just hide the app (for Cmd+Q, close button, etc.) + [NSApp hide:nil]; + [NSApp setActivationPolicy:NSApplicationActivationPolicyAccessory]; + return NSTerminateCancel; +} + +- (IBAction)terminate:(id)sender { + [NSApp hide:nil]; + [NSApp setActivationPolicy:NSApplicationActivationPolicyAccessory]; +} + +- (BOOL)windowShouldClose:(id)sender { + [NSApp hide:nil]; + return NO; +} + +- (void)showIcon { + NSAppearance *appearance = self.statusItem.button.effectiveAppearance; + NSString *appearanceName = (NSString *)(appearance.name); + NSString *iconName = @"ollama"; + if (self.updateAvailable) { + iconName = [iconName stringByAppendingString:@"Update"]; + } + if ([appearanceName containsString:@"Dark"]) { + iconName = [iconName stringByAppendingString:@"Dark"]; + } + + NSImage *statusImage; + NSBundle *bundle = [NSBundle mainBundle]; + if (![bundle.bundlePath hasSuffix:@".app"]) { + NSString *cwdPath = + [[NSFileManager defaultManager] currentDirectoryPath]; + NSString *bundlePath = + [cwdPath stringByAppendingPathComponent: + [NSString stringWithFormat:@"darwin/Ollama.app"]]; + bundle = [NSBundle bundleWithPath:bundlePath]; + } + + statusImage = [bundle imageForResource:iconName]; + [statusImage setTemplate:YES]; + self.statusItem.button.image = statusImage; +} + +- (void)observeValueForKeyPath:(NSString *)keyPath + ofObject:(id)object + change:(NSDictionary *)change + context:(void *)context { + [self showIcon]; +} + +- (void)hide { + [NSApp hide:nil]; + [NSApp setActivationPolicy:NSApplicationActivationPolicyAccessory]; +} + +- (void)quit { + [NSApp stop:self]; + [NSApp postEvent:[NSEvent otherEventWithType:NSEventTypeApplicationDefined + location:NSZeroPoint + modifierFlags:0 + timestamp:0 + windowNumber:0 + context:nil + subtype:0 + data1:0 + data2:0] + atStart:YES]; +} + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +- (void)registerSelfAsLoginItem:(BOOL)firstTimeRun { + appLogInfo(@"using v13+ SMAppService for login registration"); + // Maps to the file Ollama.app/Contents/Library/LaunchAgents/com.ollama.ollama.plist + SMAppService* service = [SMAppService agentServiceWithPlistName:@"com.ollama.ollama.plist"]; + if (!service) { + appLogInfo(@"SMAppService failed to find service for com.ollama.ollama.plist"); + return; + } + SMAppServiceStatus status = [service status]; + switch (status) { + case SMAppServiceStatusNotRegistered: + appLogInfo(@"service not registered, registering now"); + break; + case SMAppServiceStatusEnabled: + appLogInfo(@"service is already enabled, no need to register again"); + return; + case SMAppServiceStatusRequiresApproval: + // User has disabled our login behavior explicitly so leave it as is + appLogInfo(@"service is currently disabled and will not start at login"); + return; + case SMAppServiceStatusNotFound: + appLogInfo(@"service not found, registering now"); + break; + default: + appLogInfo([NSString stringWithFormat:@"unexpected status: %ld", (long)status]); + break; + } + NSError *error = nil; + if (![service registerAndReturnError:&error]) { + appLogInfo([NSString stringWithFormat:@"Failed to register %@ as a login item: %@", NSBundle.mainBundle.bundleURL, error]); + return; + } + return; +} + +/// Remove ollama from the deprecated Login Items list as we now use LaunchAgents +- (void)unregisterSelfFromLoginItem { + NSURL *bundleURL = NSBundle.mainBundle.bundleURL; + NSString *bundlePrefix = [SystemWidePath stringByDeletingPathExtension]; + + LSSharedFileListRef loginItems = + LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL); + if (!loginItems) { + return; + } + + UInt32 seed; + CFArrayRef currentItems = LSSharedFileListCopySnapshot(loginItems, &seed); + + for (id item in (__bridge NSArray *)currentItems) { + CFURLRef itemURL = NULL; + if (LSSharedFileListItemResolve((LSSharedFileListItemRef)item, 0, + &itemURL, NULL) == noErr) { + CFStringRef loginPath = CFURLCopyFileSystemPath(itemURL, kCFURLPOSIXPathStyle); + // Compare the prefix to match against "keep existing" flow, e.g. // "/Applications/Ollama.app" vs "/Applications/Ollama 2.app" + if (loginPath && [(NSString *)loginPath hasPrefix:bundlePrefix]) { + appLogInfo([NSString stringWithFormat:@"removing login item %@", loginPath]); + LSSharedFileListItemRemove(loginItems, + (LSSharedFileListItemRef)item); + } + if (itemURL) { + CFRelease(itemURL); + } + } else if (!itemURL) { + // If the user has removed the App that has a current login item, we can't use + // LSSharedFileListItemResolve to get the file path, since it doesn't "resolve" + CFStringRef displayName = LSSharedFileListItemCopyDisplayName((LSSharedFileListItemRef)item); + if (displayName) { + NSString *name = (__bridge NSString *)displayName; + if ([name hasPrefix:@"Ollama"]) { + LSSharedFileListItemRemove(loginItems, (LSSharedFileListItemRef)item); + appLogInfo([NSString stringWithFormat:@"removing dangling login item %@", displayName]); + } + CFRelease(displayName); + } + } + } + if (currentItems) { + CFRelease(currentItems); + } + CFRelease(loginItems); +} +#pragma clang diagnostic pop + +- (void)windowWillEnterFullScreen:(NSNotification *)notification { + NSWindow *w = notification.object; + if (w.toolbar != nil) { + [w.toolbar setVisible:NO]; // hide the (empty) toolbar + } +} + +- (void)windowDidExitFullScreen:(NSNotification *)notification { + NSWindow *w = notification.object; + if (w.toolbar != nil) { + [w.toolbar setVisible:YES]; // show it again + } +} + +- (void) webView:(WKWebView *)webView +decidePolicyForNavigationAction:(WKNavigationAction *)action + decisionHandler:(void (^)(WKNavigationActionPolicy))handler +{ + NSURL *url = action.request.URL; + if (action.navigationType == WKNavigationTypeLinkActivated) { + NSString *host = [url.host lowercaseString]; + if ([host isEqualToString:@"localhost"] || + [host isEqualToString:@"127.0.0.1"]) { + handler(WKNavigationActionPolicyCancel); + NSString *path = url.path; + if (path.length == 0) { + path = @"/"; + } + [self uiRequest:path]; + return; + } + + [[NSWorkspace sharedWorkspace] openURL:url]; + handler(WKNavigationActionPolicyCancel); + return; + } + handler(WKNavigationActionPolicyAllow); +} + +- (nullable WKWebView *)webView:(WKWebView *)webView + createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration + forNavigationAction:(WKNavigationAction *)action + windowFeatures:(WKWindowFeatures *)features +{ + // "Open Link in New Window" (or target="_blank") ends up here. + NSURL *url = action.request.URL; + if (url) { + NSString *host = [url.host lowercaseString]; + if ([host isEqualToString:@"localhost"] || + [host isEqualToString:@"127.0.0.1"]) { + return nil; + } + [[NSWorkspace sharedWorkspace] openURL:url]; + } + return nil; +} + +// TODO (jmorganca): the confirm button is always "Confirm" +// it should be customizable in the future +- (void)webView:(WKWebView *)webView + runJavaScriptConfirmPanelWithMessage:(NSString *)message + initiatedByFrame:(WKFrameInfo *)frame + completionHandler:(void (^)(BOOL))completionHandler { + + NSAlert *alert = [[NSAlert alloc] init]; + [alert setMessageText:message]; + [alert addButtonWithTitle:@"Confirm"]; + [alert addButtonWithTitle:@"Cancel"]; + + completionHandler([alert runModal] == NSAlertFirstButtonReturn); +} + +// HACK (jmorganca): remove the "Copy Link with Highlight" item from the context menu by +// swizzling the WKWebView's willOpenMenu:withEvent: method. In the future we should probably +// subclass the WKWebView and override the context menu items, but this is a quick fix for now. ++ (void)load { + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + [self swizzleWKWebViewContextMenu]; + }); +} + ++ (void)swizzleWKWebViewContextMenu { + Class class = [WKWebView class]; + + SEL originalSelector = @selector(willOpenMenu:withEvent:); + SEL swizzledSelector = @selector(ollama_willOpenMenu:withEvent:); + + Method originalMethod = class_getInstanceMethod(class, originalSelector); + Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector); + BOOL didAddMethod = class_addMethod(class, originalSelector, + method_getImplementation(swizzledMethod), + method_getTypeEncoding(swizzledMethod)); + + if (didAddMethod) { + class_replaceMethod(class, + swizzledSelector, + method_getImplementation(originalMethod), + method_getTypeEncoding(originalMethod)); + } else { + method_exchangeImplementations(originalMethod, swizzledMethod); + } +} + +@end + +@implementation WKWebView (OllamaContextMenu) +- (void)ollama_willOpenMenu:(NSMenu *)menu withEvent:(NSEvent *)event { + [self ollama_willOpenMenu:menu withEvent:event]; + NSMutableArray *itemsToRemove = [NSMutableArray array]; + for (NSMenuItem *item in menu.itemArray) { + if ([item.title containsString:@"Copy Link with Highlight"] || + [item.title containsString:@"Open Link in New Window"] || + [item.title containsString:@"Services"] || + [item.title containsString:@"Download Linked File"] || + [item.title containsString:@"Back"] || + [item.title containsString:@"Reload"] || + [item.title containsString:@"Refresh"] || + [item.title containsString:@"Open Link"] || + [item.title containsString:@"Copy Link"] || + [item.title containsString:@"Share"]) { + [itemsToRemove addObject:item]; + continue; + } + } + + for (NSMenuItem *item in itemsToRemove) { + [menu removeItem:item]; + } + + int customItemCount = menu_get_item_count(); + if (customItemCount > 0) { + menuItem* customItems = (menuItem*)menu_get_items(); + if (customItems) { + NSInteger insertIndex = 0; + + for (int i = 0; i < customItemCount; i++) { + if (customItems[i].separator) { + [menu insertItem:[NSMenuItem separatorItem] atIndex:insertIndex++]; + } else if (customItems[i].label) { + NSString *label = [NSString stringWithUTF8String:customItems[i].label]; + NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:label + action:@selector(handleCustomMenuItem:) + keyEquivalent:@""]; + [item setTarget:self]; + [item setRepresentedObject:label]; + [item setEnabled:customItems[i].enabled]; + [menu insertItem:item atIndex:insertIndex++]; + } + } + + // Add separator after custom items if there are remaining items + if (insertIndex > 0 && menu.itemArray.count > insertIndex) { + [menu insertItem:[NSMenuItem separatorItem] atIndex:insertIndex]; + } + } + } +} + +- (void)handleCustomMenuItem:(NSMenuItem *)sender { + NSString *label = [sender representedObject]; + if (label) { + menu_handle_selection((char*)[label UTF8String]); + } +} + +@end + +AppDelegate *appDelegate; +void run(bool ftr, bool sh) { + [NSApplication sharedApplication]; + [NSApp setActivationPolicy:NSApplicationActivationPolicyAccessory]; + appDelegate = [[AppDelegate alloc] init]; + [NSApp setDelegate:appDelegate]; + firstTimeRun = ftr; + startHidden = sh; + [NSApp run]; + StopUI(); +} + +// killOtherInstances kills all other instances of the app currently +// running. This way we can ensure that only the most recently started +// instance of Ollama is running +void killOtherInstances() { + pid_t myPid = getpid(); + NSArray *apps = [[NSWorkspace sharedWorkspace] runningApplications]; + + for (NSRunningApplication *app in apps) { + NSString *bundleId = app.bundleIdentifier; + + // Skip apps without bundle identifiers + if (!bundleId || [bundleId length] == 0) { + continue; + } + + if ([bundleId isEqualToString:[[NSBundle mainBundle] bundleIdentifier]] || + [bundleId isEqualToString:@"ai.ollama.ollama"] || + [bundleId isEqualToString:@"com.electron.ollama"]) { + + pid_t pid = app.processIdentifier; + if (pid != myPid && pid > 0) { + appLogInfo([NSString stringWithFormat:@"terminating other ollama instance %d", pid]); + kill(pid, SIGTERM); + } else if (pid == -1) { + appLogInfo([NSString stringWithFormat:@"skipping app with invalid pid: %@", bundleId]); + } + } + } +} + +// Move the source bundle to the system-wide applications location +// without prompting for additional authorization +bool moveToApplications(const char *src) { + NSString *bundlePath = @(src); + appLogInfo([NSString + stringWithFormat: + @"trying move to /Applications without extra authorization"]); + NSFileManager *fileManager = [NSFileManager defaultManager]; + + // Check if the newPath already exists + if ([fileManager fileExistsAtPath:SystemWidePath]) { + appLogInfo([NSString stringWithFormat:@"existing install exists"]); + NSError *removeError = nil; + [fileManager removeItemAtPath:SystemWidePath error:&removeError]; + if (removeError) { + appLogInfo([NSString + stringWithFormat:@"Error removing without authorization %@: %@", + SystemWidePath, removeError]); + return false; + } + } + + // Move can be problematic, so use copy + NSError *err = nil; + [fileManager copyItemAtPath:bundlePath toPath:SystemWidePath error:&err]; + if (err) { + appLogInfo( + [NSString stringWithFormat: + @"unable to copy without authorization %@ to %@: %@", + bundlePath, SystemWidePath, err]); + return false; + } + + // Best effort attempt to remove old content + if ([fileManager isDeletableFileAtPath:bundlePath]) { + err = nil; + [fileManager trashItemAtURL:[NSURL fileURLWithPath:bundlePath] + resultingItemURL:nil + error:&err]; + if (err) { + appLogInfo( + [NSString stringWithFormat:@"unable to clean up now stale " + @"bundle via file manager %@: %@", + bundlePath, err]); + } + } else { + appLogInfo([NSString stringWithFormat:@"unable to clean up now stale " + @"bundle via file manager %@", + bundlePath]); + } + + appLogInfo([NSString stringWithFormat:@"app relocated %@ to %@", bundlePath, + SystemWidePath]); + return true; +} + +AuthorizationRef getSymlinkAuthorization() { + return getAuthorization(@"Ollama is trying to install its command line " + @"interface (CLI) tool.", + @"symlink"); +} + +// Prompt the user for authorization and move to the system wide +// location +// +// Note: this flow must not be executed from the old app instance +// otherwise the malware scanner will trigger on subsequent +// AuthorizationExecuteWithPrivileges calls as it can not +// verify the calling app's signature on the filesystem +// once the files are removed +bool moveToApplicationsWithAuthorization(const char *src) { + int pid, status; + AuthorizationRef authRef = getAppInstallAuthorization(); + if (authRef == NULL) { + return NO; + } + + // Remove existing /Applications/Ollama.app (if any) + // - We do this via /bin/rm with elevated privileges + // + const char *rmTool = "/bin/rm"; + const char *rmArgs[] = {"-rf", [SystemWidePath UTF8String], NULL}; + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + OSStatus err = AuthorizationExecuteWithPrivileges( + authRef, rmTool, kAuthorizationFlagDefaults, (char *const *)rmArgs, + NULL); +#pragma clang diagnostic pop + + if (err != errAuthorizationSuccess) { + appLogInfo([NSString + stringWithFormat:@"Failed to remove existing %@. err = %d", + SystemWidePath, err]); + AuthorizationFree(authRef, kAuthorizationFlagDestroyRights); + return NO; + } + + // wait for the command to finish + pid = wait(&status); + if (pid == -1 || !WIFEXITED(status)) { + appLogInfo([NSString stringWithFormat:@"rm of %@ failed pid=%d exit=%d", + SystemWidePath, pid, + WEXITSTATUS(status)]); + } + appLogDebug([NSString + stringWithFormat:@"finished cleaning up prior %@", SystemWidePath]); + + // Copy bundle to /Applications + // We can't use mv as we may be denied if we're sandboxed + const char *cpTool = "/bin/cp"; + const char *cpArgs[] = {"-pR", src, [SystemWidePath UTF8String], NULL}; + appLogDebug([NSString stringWithFormat:@"running authorized cp -pR %s %@", + src, SystemWidePath]); + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + err = AuthorizationExecuteWithPrivileges(authRef, cpTool, + kAuthorizationFlagDefaults, + (char *const *)cpArgs, NULL); +#pragma clang diagnostic pop + + if (err != errAuthorizationSuccess) { + appLogInfo( + [NSString stringWithFormat:@"Failed to copy %s -> %@. err = %d", + src, SystemWidePath, err]); + AuthorizationFree(authRef, kAuthorizationFlagDestroyRights); + return NO; + } + + // Wait for the command to finish + pid = wait(&status); + appLogInfo([NSString stringWithFormat:@"cp -pR %s %@ - pid=%d exit=%d", src, + SystemWidePath, pid, + WEXITSTATUS(status)]); + + if (pid == -1 || !WIFEXITED(status) || WEXITSTATUS(status)) { + AuthorizationFree(authRef, kAuthorizationFlagDestroyRights); + return NO; + } + + // Copy worked, now best effort try to clean up the source bundle + // Try file manager, then authorized rm -rf + NSFileManager *fileManager = [NSFileManager defaultManager]; + NSString *bundlePath = @(src); + NSError *removeError = nil; + err = [fileManager trashItemAtURL:[NSURL fileURLWithPath:bundlePath] + resultingItemURL:nil + error:&removeError]; + if (removeError) { + appLogInfo( + [NSString stringWithFormat:@"unable to clean up now stale " + @"bundle via NSFileManager %@: %@", + bundlePath, removeError]); + const char *rm2Args[] = {"-rf", src, NULL}; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + err = AuthorizationExecuteWithPrivileges(authRef, rmTool, + kAuthorizationFlagDefaults, + (char *const *)rm2Args, NULL); +#pragma clang diagnostic pop + if (err != errAuthorizationSuccess) { + appLogInfo([NSString + stringWithFormat:@"Failed to remove existing %s. err = %d", src, + err]); + } else { + // wait for the command to finish + pid = wait(&status); + appLogInfo([NSString stringWithFormat:@"rm of %s pid=%d exit=%d", + src, pid, + WEXITSTATUS(status)]); + if (pid == -1 || !WIFEXITED(status) || WEXITSTATUS(status)) { + appLogInfo([NSString + stringWithFormat:@"rm of %s failed pid=%d exit=%d", src, + pid, WEXITSTATUS(status)]); + } else { + appLogDebug([NSString + stringWithFormat:@"finished cleaning up %s", src]); + } + } + } + AuthorizationFree(authRef, kAuthorizationFlagDestroyRights); + return YES; +} + +enum AppMove askToMoveToApplications() { + NSAppleEventDescriptor *evt = + [[NSAppleEventManager sharedAppleEventManager] currentAppleEvent]; + if (!evt || [evt eventID] != kAEOpenApplication) { + // This scenario triggers if we were launched from a double click, + // or the CLI spawns the app via open -a Ollama.app + appLogDebug([NSString + stringWithFormat:@"launched from double click or open -a"]); + } + NSAppleEventDescriptor *prop = + [evt paramDescriptorForKeyword:keyAEPropData]; + if (prop && [prop enumCodeValue] == keyAELaunchedAsLogInItem) { + // For a login session launch, we don't want to prompt for moving if + // the user opted out + appLogDebug([NSString stringWithFormat:@"launched from login"]); + return LoginSession; + } + pid_t pid = getpid(); + NSString *bundlePath = [[NSBundle mainBundle] bundlePath]; + appLogInfo(@"asking to move to system wide location"); + + NSAlert *alert = [[NSAlert alloc] init]; + [alert setMessageText:@"Move to Applications?"]; + [alert setInformativeText: + @"Ollama works best when run from the Applications directory."]; + [alert addButtonWithTitle:@"Move to Applications"]; + [alert addButtonWithTitle:@"Don't move"]; + + [NSApp activateIgnoringOtherApps:YES]; + + if ([alert runModal] != NSAlertFirstButtonReturn) { + appLogInfo([NSString + stringWithFormat:@"user rejected moving to /Applications"]); + return UserDeclinedMove; + } + + // move to applications + if (!moveToApplications([bundlePath UTF8String])) { + if (!moveToApplicationsWithAuthorization([bundlePath UTF8String])) { + appLogInfo([NSString + stringWithFormat:@"unable to move with authorization"]); + return PermissionDenied; + } + } + + appLogInfo([NSString + stringWithFormat:@"Launching %@ from PID=%d", SystemWidePath, pid]); + NSError *error = nil; + NSWorkspace *workspace = [NSWorkspace sharedWorkspace]; +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + [workspace launchApplicationAtURL:[NSURL fileURLWithPath:SystemWidePath] + options:NSWorkspaceLaunchNewInstance | + NSWorkspaceLaunchDefault + configuration:@{} + error:&error]; + return MoveCompleted; +} + +void launchApp(const char *appPath) { + pid_t pid = getpid(); + appLogInfo([NSString + stringWithFormat:@"Launching %@ from PID=%d", @(appPath), pid]); + NSError *error = nil; + NSWorkspace *workspace = [NSWorkspace sharedWorkspace]; +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + [workspace launchApplicationAtURL:[NSURL fileURLWithPath:@(appPath)] + options:NSWorkspaceLaunchNewInstance | + NSWorkspaceLaunchDefault + configuration:@{} + error:&error]; +} + +int installSymlink(const char *cliPath) { + NSString *linkPath = @"/usr/local/bin/ollama"; + NSString *dirPath = @"/usr/local/bin"; + NSError *error = nil; + + NSFileManager *fileManager = [NSFileManager defaultManager]; + NSString *symlinkPath = + [fileManager destinationOfSymbolicLinkAtPath:linkPath error:&error]; + NSString *resPath = [NSString stringWithUTF8String:cliPath]; + + // if the symlink already exists and points to the right place, don't + // prompt + if ([symlinkPath isEqualToString:resPath]) { + appLogDebug( + @"symbolic link already exists and points to the right place"); + return 0; + } + + // Get authorization once for both operations + AuthorizationRef authRef = getSymlinkAuthorization(); + if (authRef == NULL) { + return NO; + } + + // Check if /usr/local/bin directory exists, create it if it doesn't + BOOL isDirectory; + if (![fileManager fileExistsAtPath:dirPath isDirectory:&isDirectory] || !isDirectory) { + appLogInfo(@"/usr/local/bin directory does not exist, creating it"); + + const char *mkdirTool = "/bin/mkdir"; + const char *mkdirArgs[] = {"-p", [dirPath UTF8String], NULL}; + +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + OSStatus err = AuthorizationExecuteWithPrivileges( + authRef, mkdirTool, kAuthorizationFlagDefaults, (char *const *)mkdirArgs, + NULL); + if (err != errAuthorizationSuccess) { + appLogInfo(@"Failed to create /usr/local/bin directory"); + AuthorizationFree(authRef, kAuthorizationFlagDestroyRights); + return -1; + } + + // Wait for mkdir to complete + int status; + wait(&status); + } + + // Create the symlink using the same authorization + const char *toolPath = "/bin/ln"; + const char *args[] = {"-s", "-F", [resPath UTF8String], + "/usr/local/bin/ollama", NULL}; + FILE *pipe = NULL; + +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + OSStatus err = AuthorizationExecuteWithPrivileges( + authRef, toolPath, kAuthorizationFlagDefaults, (char *const *)args, + &pipe); + if (err != errAuthorizationSuccess) { + appLogInfo(@"Failed to create symlink"); + AuthorizationFree(authRef, kAuthorizationFlagDestroyRights); + return -1; + } + + AuthorizationFree(authRef, kAuthorizationFlagDestroyRights); + return 0; +} + +void updateAvailable() { + dispatch_async(dispatch_get_main_queue(), ^{ + [appDelegate showUpdateAvailable]; + }); +} + +void quit() { + dispatch_async(dispatch_get_main_queue(), ^{ + [appDelegate quit]; + }); +} + +void uiRequest(char *path) { + NSString *p = [NSString stringWithFormat:@"%s", path]; + appLogInfo([NSString stringWithFormat:@"XXX UI request for URL: %@", p]); + dispatch_async(dispatch_get_main_queue(), ^{ + [appDelegate uiRequest:p]; + }); +} + +void registerSelfAsLoginItem(bool firstTimeRun) { + dispatch_async(dispatch_get_main_queue(), ^{ + [appDelegate registerSelfAsLoginItem:firstTimeRun]; + }); +} + +void unregisterSelfFromLoginItem() { + dispatch_async(dispatch_get_main_queue(), ^{ + [appDelegate unregisterSelfFromLoginItem]; + }); +} + +static WKWebView *FindWKWebView(NSView *root) { + if ([root isKindOfClass:[WKWebView class]]) { + return (WKWebView *)root; + } + for (NSView *child in root.subviews) { + WKWebView *found = FindWKWebView(child); + if (found) { + return found; + } + } + return nil; +} + +void setWindowDelegate(void* window) { + NSWindow *w = (__bridge NSWindow *)window; + [w setDelegate:appDelegate]; + WKWebView *webView = FindWKWebView(w.contentView); + if (webView) { + webView.navigationDelegate = appDelegate; + webView.UIDelegate = appDelegate; + } +} + +void hideWindow(uintptr_t wndPtr) { + NSWindow *w = (__bridge NSWindow *)wndPtr; + [NSApp setActivationPolicy:NSApplicationActivationPolicyAccessory]; + [w orderOut:nil]; +} + +void showWindow(uintptr_t wndPtr) { + NSWindow *w = (__bridge NSWindow *)wndPtr; + + [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; + + dispatch_async(dispatch_get_main_queue(), ^{ + [NSApp unhide:nil]; + [NSApp activateIgnoringOtherApps:YES]; + [w makeKeyAndOrderFront:nil]; + }); +} + +void styleWindow(uintptr_t wndPtr) { + NSWindow *w = (__bridge NSWindow *)wndPtr; + if (!w) return; + + // Define the desired style mask + NSWindowStyleMask desiredStyleMask = NSWindowStyleMaskTitled | + NSWindowStyleMaskClosable | + NSWindowStyleMaskMiniaturizable | + NSWindowStyleMaskResizable | + NSWindowStyleMaskFullSizeContentView | + NSWindowStyleMaskUnifiedTitleAndToolbar; + + if (!(w.styleMask & NSWindowStyleMaskFullScreen)) { + w.styleMask = desiredStyleMask; + } + + if (w.toolbar == nil) { + NSToolbar *tb = [[NSToolbar alloc] initWithIdentifier:@"OllamaToolbar"]; + tb.displayMode = NSToolbarDisplayModeIconOnly; + tb.showsBaselineSeparator = NO; + w.toolbar = tb; + } + + w.titleVisibility = NSWindowTitleHidden; + w.titlebarAppearsTransparent = YES; + w.toolbarStyle = NSWindowToolbarStyleUnified; + w.movableByWindowBackground = NO; + w.hasShadow = YES; + + NSView *cv = w.contentView; + cv.wantsLayer = YES; + CALayer *L = cv.layer; + L.cornerRadius = 0.0; + L.masksToBounds = NO; + L.borderColor = nil; + L.borderWidth = 0.0; +} + +void drag(uintptr_t wndPtr) { + NSWindow *w = (__bridge NSWindow *)wndPtr; + if (!w) return; + NSPoint mouseLoc = [NSEvent mouseLocation]; + NSPoint locInWindow = [w convertPointFromScreen:mouseLoc]; + + NSEvent *e = [NSEvent mouseEventWithType:NSEventTypeLeftMouseDown + location:locInWindow + modifierFlags:0 + timestamp:NSTimeIntervalSince1970 + windowNumber:[w windowNumber] + context:nil + eventNumber:0 + clickCount:1 + pressure:1.0]; + [w performWindowDragWithEvent:e]; +} + +void doubleClick(uintptr_t wndPtr) { + NSWindow *w = (__bridge NSWindow *)wndPtr; + if (!w) return; + + // Respect the user's Dock preference + NSString *action = + [[NSUserDefaults standardUserDefaults] stringForKey:@"AppleActionOnDoubleClick"]; + + if ([action isEqualToString:@"Minimize"]) { + [w performMiniaturize:nil]; + } else { + [w performZoom:nil]; + } +} diff --git a/app/cmd/app/app_windows.go b/app/cmd/app/app_windows.go new file mode 100644 index 0000000..3e2196d --- /dev/null +++ b/app/cmd/app/app_windows.go @@ -0,0 +1,448 @@ +//go:build windows || darwin + +package main + +import ( + "errors" + "fmt" + "io" + "log" + "log/slog" + "os" + "os/exec" + "os/signal" + "path/filepath" + "runtime" + "strings" + "syscall" + "unsafe" + + "github.com/ollama/ollama/app/updater" + "github.com/ollama/ollama/app/version" + "github.com/ollama/ollama/app/wintray" + "golang.org/x/sys/windows" +) + +var ( + u32 = windows.NewLazySystemDLL("User32.dll") + pBringWindowToTop = u32.NewProc("BringWindowToTop") + pShowWindow = u32.NewProc("ShowWindow") + pSendMessage = u32.NewProc("SendMessageA") + pGetSystemMetrics = u32.NewProc("GetSystemMetrics") + pGetWindowRect = u32.NewProc("GetWindowRect") + pSetWindowPos = u32.NewProc("SetWindowPos") + pSetForegroundWindow = u32.NewProc("SetForegroundWindow") + pSetActiveWindow = u32.NewProc("SetActiveWindow") + pIsIconic = u32.NewProc("IsIconic") + + appPath = filepath.Join(os.Getenv("LOCALAPPDATA"), "Programs", "Ollama") + appLogPath = filepath.Join(os.Getenv("LOCALAPPDATA"), "Ollama", "app.log") + startupShortcut = filepath.Join(os.Getenv("APPDATA"), "Microsoft", "Windows", "Start Menu", "Programs", "Startup", "Ollama.lnk") + ollamaPath string + DesktopAppName = "ollama app.exe" +) + +func init() { + // With alternate install location use executable location + exe, err := os.Executable() + if err != nil { + slog.Warn("error discovering executable directory", "error", err) + } else { + appPath = filepath.Dir(exe) + } + ollamaPath = filepath.Join(appPath, "ollama.exe") + + // Handle developer mode (go run ./cmd/app) + if _, err := os.Stat(ollamaPath); err != nil { + pwd, err := os.Getwd() + if err != nil { + slog.Warn("missing ollama.exe and failed to get pwd", "error", err) + return + } + distAppPath := filepath.Join(pwd, "dist", "windows-"+runtime.GOARCH) + distOllamaPath := filepath.Join(distAppPath, "ollama.exe") + if _, err := os.Stat(distOllamaPath); err == nil { + slog.Info("detected developer mode") + appPath = distAppPath + ollamaPath = distOllamaPath + } + } +} + +func maybeMoveAndRestart() appMove { + return 0 +} + +// handleExistingInstance checks for existing instances and optionally focuses them +func handleExistingInstance(startHidden bool) { + if wintray.CheckAndFocusExistingInstance(!startHidden) { + slog.Info("existing instance found, exiting") + os.Exit(0) + } +} + +func installSymlink() {} + +type appCallbacks struct { + t wintray.TrayCallbacks + shutdown func() +} + +var app = &appCallbacks{} + +func (ac *appCallbacks) UIRun(path string) { + wv.Run(path) +} + +func (*appCallbacks) UIShow() { + if wv.webview != nil { + showWindow(wv.webview.Window()) + } else { + wv.Run("/") + } +} + +func (*appCallbacks) UITerminate() { + wv.Terminate() +} + +func (*appCallbacks) UIRunning() bool { + return wv.IsRunning() +} + +func (app *appCallbacks) Quit() { + app.t.Quit() + wv.Terminate() +} + +// TODO - reconcile with above for consistency between mac/windows +func quit() { + wv.Terminate() +} + +func (app *appCallbacks) DoUpdate() { + // Safeguard in case we have requests in flight that need to drain... + slog.Info("Waiting for server to shutdown") + + app.shutdown() + + if err := updater.DoUpgrade(true); err != nil { + slog.Warn(fmt.Sprintf("upgrade attempt failed: %s", err)) + } +} + +// HandleURLScheme implements the URLSchemeHandler interface +func (app *appCallbacks) HandleURLScheme(urlScheme string) { + handleURLSchemeRequest(urlScheme) +} + +// handleURLSchemeRequest processes URL scheme requests from other instances +func handleURLSchemeRequest(urlScheme string) { + isConnect, err := parseURLScheme(urlScheme) + if err != nil { + slog.Error("failed to parse URL scheme request", "url", urlScheme, "error", err) + return + } + + if isConnect { + handleConnectURLScheme() + } else { + if wv.webview != nil { + showWindow(wv.webview.Window()) + } + } +} + +func UpdateAvailable(ver string) error { + if app.t == nil { + slog.Debug("tray not yet initialized, skipping update notification") + return nil + } + return app.t.UpdateAvailable(ver) +} + +func osRun(shutdown func(), hasCompletedFirstRun, startHidden bool) { + var err error + app.shutdown = shutdown + app.t, err = wintray.NewTray(app) + if err != nil { + log.Fatalf("Failed to start: %s", err) + } + + // Check for pending updates now that the tray is initialized. + // The platform-independent check in app.go fires before osRun, + // when app.t is still nil, so we must re-check here. + if updater.IsUpdatePending() { + slog.Debug("update pending on startup, showing tray notification") + UpdateAvailable("") + } + + signals := make(chan os.Signal, 1) + signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM) + + // TODO - can this be generalized? + go func() { + <-signals + slog.Debug("shutting down due to signal") + app.t.Quit() + wv.Terminate() + }() + + // On windows, we run the final tasks in the main thread + // before starting the tray event loop. These final tasks + // may trigger the UI, and must do that from the main thread. + if !startHidden { + // Determine if the process was started from a shortcut + // ~\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\Ollama + const STARTF_TITLEISLINKNAME = 0x00000800 + var info windows.StartupInfo + if err := windows.GetStartupInfo(&info); err != nil { + slog.Debug("unable to retrieve startup info", "error", err) + } else if info.Flags&STARTF_TITLEISLINKNAME == STARTF_TITLEISLINKNAME { + linkPath := windows.UTF16PtrToString(info.Title) + if strings.Contains(linkPath, "Startup") { + startHidden = true + } + } + } + if startHidden { + startHiddenTasks() + } else { + ptr := wv.Run("/") + + // Set the window icon using the tray icon + if ptr != nil { + iconHandle := app.t.GetIconHandle() + if iconHandle != 0 { + hwnd := uintptr(ptr) + const ICON_SMALL = 0 + const ICON_BIG = 1 + const WM_SETICON = 0x0080 + + pSendMessage.Call(hwnd, uintptr(WM_SETICON), uintptr(ICON_SMALL), uintptr(iconHandle)) + pSendMessage.Call(hwnd, uintptr(WM_SETICON), uintptr(ICON_BIG), uintptr(iconHandle)) + } + } + + centerWindow(ptr) + } + + if !hasCompletedFirstRun { + // Only create the login shortcut on first start + // so we can respect users deletion of the link + err = createLoginShortcut() + if err != nil { + slog.Warn("unable to create login shortcut", "error", err) + } + } + + app.t.TrayRun() // This will block the main thread +} + +func createLoginShortcut() error { + // The installer lays down a shortcut for us so we can copy it without + // having to resort to calling COM APIs to establish the shortcut + shortcutOrigin := filepath.Join(appPath, "lib", "Ollama.lnk") + + _, err := os.Stat(startupShortcut) + if err != nil { + if errors.Is(err, os.ErrNotExist) { + in, err := os.Open(shortcutOrigin) + if err != nil { + return fmt.Errorf("unable to open shortcut %s : %w", shortcutOrigin, err) + } + defer in.Close() + out, err := os.Create(startupShortcut) + if err != nil { + return fmt.Errorf("unable to open startup link %s : %w", startupShortcut, err) + } + defer out.Close() + _, err = io.Copy(out, in) + if err != nil { + return fmt.Errorf("unable to copy shortcut %s : %w", startupShortcut, err) + } + err = out.Sync() + if err != nil { + return fmt.Errorf("unable to sync shortcut %s : %w", startupShortcut, err) + } + slog.Info("Created Startup shortcut", "shortcut", startupShortcut) + } else { + slog.Warn("unexpected error looking up Startup shortcut", "error", err) + } + } else { + slog.Debug("Startup link already exists", "shortcut", startupShortcut) + } + return nil +} + +func LaunchNewApp() { +} + +func logStartup() { + slog.Info("starting Ollama", "app", appPath, "version", version.Version, "OS", updater.UserAgentOS) +} + +const ( + SW_HIDE = 0 // Hides the window + SW_SHOW = 5 // Shows window in its current size/position + SW_SHOWNA = 8 // Shows without activating + SW_MINIMIZE = 6 // Minimizes the window + SW_RESTORE = 9 // Restores to previous size/position + SW_SHOWDEFAULT = 10 // Sets show state based on program state + SM_CXSCREEN = 0 + SM_CYSCREEN = 1 + HWND_TOP = 0 + SWP_NOSIZE = 0x0001 + SWP_NOMOVE = 0x0002 + SWP_NOZORDER = 0x0004 + SWP_SHOWWINDOW = 0x0040 + + // Menu constants + MF_STRING = 0x00000000 + MF_SEPARATOR = 0x00000800 + MF_GRAYED = 0x00000001 + TPM_RETURNCMD = 0x0100 +) + +// POINT structure for cursor position +type POINT struct { + X int32 + Y int32 +} + +// Rect structure for GetWindowRect +type Rect struct { + Left int32 + Top int32 + Right int32 + Bottom int32 +} + +func centerWindow(ptr unsafe.Pointer) { + hwnd := uintptr(ptr) + if hwnd == 0 { + return + } + + var rect Rect + pGetWindowRect.Call(hwnd, uintptr(unsafe.Pointer(&rect))) + + screenWidth, _, _ := pGetSystemMetrics.Call(uintptr(SM_CXSCREEN)) + screenHeight, _, _ := pGetSystemMetrics.Call(uintptr(SM_CYSCREEN)) + + windowWidth := rect.Right - rect.Left + windowHeight := rect.Bottom - rect.Top + + x := (int32(screenWidth) - windowWidth) / 2 + y := (int32(screenHeight) - windowHeight) / 2 + + // Ensure the window is not positioned off-screen + if x < 0 { + x = 0 + } + if y < 0 { + y = 0 + } + + pSetWindowPos.Call( + hwnd, + uintptr(HWND_TOP), + uintptr(x), + uintptr(y), + uintptr(windowWidth), // Keep original width + uintptr(windowHeight), // Keep original height + uintptr(SWP_SHOWWINDOW), + ) +} + +func showWindow(ptr unsafe.Pointer) { + hwnd := uintptr(ptr) + if hwnd != 0 { + iconHandle := app.t.GetIconHandle() + if iconHandle != 0 { + const ICON_SMALL = 0 + const ICON_BIG = 1 + const WM_SETICON = 0x0080 + + pSendMessage.Call(hwnd, uintptr(WM_SETICON), uintptr(ICON_SMALL), uintptr(iconHandle)) + pSendMessage.Call(hwnd, uintptr(WM_SETICON), uintptr(ICON_BIG), uintptr(iconHandle)) + } + + // Check if window is minimized + isMinimized, _, _ := pIsIconic.Call(hwnd) + if isMinimized != 0 { + // Restore the window if it's minimized + pShowWindow.Call(hwnd, uintptr(SW_RESTORE)) + } + + // Show the window + pShowWindow.Call(hwnd, uintptr(SW_SHOW)) + + // Bring window to top + pBringWindowToTop.Call(hwnd) + + // Force window to foreground + pSetForegroundWindow.Call(hwnd) + + // Make it the active window + pSetActiveWindow.Call(hwnd) + + // Ensure window is positioned on top + pSetWindowPos.Call( + hwnd, + uintptr(HWND_TOP), + 0, 0, 0, 0, + uintptr(SWP_NOSIZE|SWP_NOMOVE|SWP_SHOWWINDOW), + ) + } +} + +// HideWindow hides the application window +func hideWindow(ptr unsafe.Pointer) { + hwnd := uintptr(ptr) + if hwnd != 0 { + pShowWindow.Call( + hwnd, + uintptr(SW_HIDE), + ) + } +} + +func runInBackground() { + exe, err := os.Executable() + if err != nil { + slog.Error("failed to get executable path", "error", err) + os.Exit(1) + } + cmd := exec.Command(exe, "hidden") + if cmd != nil { + err = cmd.Run() + if err != nil { + slog.Error("failed to run Ollama", "exe", exe, "error", err) + os.Exit(1) + } + } else { + slog.Error("failed to start Ollama", "exe", exe) + os.Exit(1) + } +} + +func drag(ptr unsafe.Pointer) {} + +func doubleClick(ptr unsafe.Pointer) {} + +// checkAndHandleExistingInstance checks if another instance is running and sends the URL to it +func checkAndHandleExistingInstance(urlSchemeRequest string) bool { + if urlSchemeRequest == "" { + return false + } + + // Try to send URL to existing instance using wintray messaging + if wintray.CheckAndSendToExistingInstance(urlSchemeRequest) { + os.Exit(0) + return true + } + + // No existing instance, we'll handle it ourselves + return false +} diff --git a/app/cmd/app/menu.h b/app/cmd/app/menu.h new file mode 100644 index 0000000..1ff94cb --- /dev/null +++ b/app/cmd/app/menu.h @@ -0,0 +1,27 @@ +#ifndef MENU_H +#define MENU_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct +{ + char *label; + int enabled; + int separator; +} menuItem; + +// TODO (jmorganca): these need to be forward declared in the webview.h file +// for now but ideally they should be in this header file on windows too +#ifndef WIN32 +int menu_get_item_count(); +void *menu_get_items(); +void menu_handle_selection(char *item); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/app/cmd/app/webview.go b/app/cmd/app/webview.go new file mode 100644 index 0000000..9332f10 --- /dev/null +++ b/app/cmd/app/webview.go @@ -0,0 +1,528 @@ +//go:build windows || darwin + +package main + +// #include "menu.h" +import "C" + +import ( + "encoding/base64" + "encoding/json" + "fmt" + "log/slog" + "net/http" + "os" + "path/filepath" + "runtime" + "strings" + "sync" + "time" + "unsafe" + + "github.com/ollama/ollama/app/dialog" + "github.com/ollama/ollama/app/store" + "github.com/ollama/ollama/app/webview" +) + +type Webview struct { + port int + token string + webview webview.WebView + mutex sync.Mutex + + Store *store.Store +} + +// Run initializes the webview and starts its event loop. +// Note: this must be called from the primary app thread +// This returns the OS native window handle to the caller +func (w *Webview) Run(path string) unsafe.Pointer { + var url string + if devMode { + // In development mode, use the local dev server + url = fmt.Sprintf("http://localhost:5173%s", path) + } else { + url = fmt.Sprintf("http://127.0.0.1:%d%s", w.port, path) + } + w.mutex.Lock() + defer w.mutex.Unlock() + + if w.webview == nil { + // Note: turning on debug on macos throws errors but is marginally functional for debugging + // TODO (jmorganca): we should pre-create the window and then provide it here to + // webview so we can hide it from the start and make other modifications + wv := webview.New(debug) + // start the window hidden + hideWindow(wv.Window()) + wv.SetTitle("Ollama") + + // TODO (jmorganca): this isn't working yet since it needs to be set + // on the first page load, ideally in an interstitial page like `/token` + // that exists only to set the cookie and redirect to / + // wv.Init(fmt.Sprintf(`document.cookie = "token=%s; path=/"`, w.token)) + init := ` + // Disable reload + document.addEventListener('keydown', function(e) { + if ((e.ctrlKey || e.metaKey) && e.key === 'r') { + e.preventDefault(); + return false; + } + }); + + // Prevent back/forward navigation + window.addEventListener('popstate', function(e) { + e.preventDefault(); + history.pushState(null, '', window.location.pathname); + return false; + }); + + // Clear history on load + window.addEventListener('load', function() { + history.pushState(null, '', window.location.pathname); + window.history.replaceState(null, '', window.location.pathname); + }); + + // Set token cookie + document.cookie = "token=` + w.token + `; path=/"; + ` + // Windows-specific scrollbar styling + if runtime.GOOS == "windows" { + init += ` + // Fix scrollbar styling for Edge WebView2 on Windows only + function updateScrollbarStyles() { + const isDark = window.matchMedia('(prefers-color-scheme: dark)').matches; + const existingStyle = document.getElementById('scrollbar-style'); + if (existingStyle) existingStyle.remove(); + + const style = document.createElement('style'); + style.id = 'scrollbar-style'; + + if (isDark) { + style.textContent = ` + "`" + ` + ::-webkit-scrollbar { width: 6px !important; height: 6px !important; } + ::-webkit-scrollbar-track { background: #1a1a1a !important; } + ::-webkit-scrollbar-thumb { background: #404040 !important; border-radius: 6px !important; } + ::-webkit-scrollbar-thumb:hover { background: #505050 !important; } + ::-webkit-scrollbar-corner { background: #1a1a1a !important; } + ::-webkit-scrollbar-button { + background: transparent !important; + border: none !important; + width: 0px !important; + height: 0px !important; + margin: 0 !important; + padding: 0 !important; + } + ::-webkit-scrollbar-button:vertical:start:decrement { + background: transparent !important; + height: 0px !important; + } + ::-webkit-scrollbar-button:vertical:end:increment { + background: transparent !important; + height: 0px !important; + } + ::-webkit-scrollbar-button:horizontal:start:decrement { + background: transparent !important; + width: 0px !important; + } + ::-webkit-scrollbar-button:horizontal:end:increment { + background: transparent !important; + width: 0px !important; + } + ` + "`" + `; + } else { + style.textContent = ` + "`" + ` + ::-webkit-scrollbar { width: 6px !important; height: 6px !important; } + ::-webkit-scrollbar-track { background: #f0f0f0 !important; } + ::-webkit-scrollbar-thumb { background: #c0c0c0 !important; border-radius: 6px !important; } + ::-webkit-scrollbar-thumb:hover { background: #a0a0a0 !important; } + ::-webkit-scrollbar-corner { background: #f0f0f0 !important; } + ::-webkit-scrollbar-button { + background: transparent !important; + border: none !important; + width: 0px !important; + height: 0px !important; + margin: 0 !important; + padding: 0 !important; + } + ::-webkit-scrollbar-button:vertical:start:decrement { + background: transparent !important; + height: 0px !important; + } + ::-webkit-scrollbar-button:vertical:end:increment { + background: transparent !important; + height: 0px !important; + } + ::-webkit-scrollbar-button:horizontal:start:decrement { + background: transparent !important; + width: 0px !important; + } + ::-webkit-scrollbar-button:horizontal:end:increment { + background: transparent !important; + width: 0px !important; + } + ` + "`" + `; + } + document.head.appendChild(style); + } + + window.addEventListener('load', updateScrollbarStyles); + window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', updateScrollbarStyles); + ` + } + // on windows make ctrl+n open new chat + // TODO (jmorganca): later we should use proper accelerators + // once we introduce a native menu for the window + // this is only used on windows since macOS uses the proper accelerators + if runtime.GOOS == "windows" { + init += ` + document.addEventListener('keydown', function(e) { + if ((e.ctrlKey || e.metaKey) && e.key === 'n') { + e.preventDefault(); + // Use the existing navigation method + history.pushState({}, '', '/c/new'); + window.dispatchEvent(new PopStateEvent('popstate')); + return false; + } + }); + ` + } + + init += ` + window.OLLAMA_WEBSEARCH = true; + ` + + wv.Init(init) + + // Add keyboard handler for zoom + wv.Init(` + window.addEventListener('keydown', function(e) { + // CMD/Ctrl + Plus/Equals (zoom in) + if ((e.metaKey || e.ctrlKey) && (e.key === '+' || e.key === '=')) { + e.preventDefault(); + window.zoomIn && window.zoomIn(); + return false; + } + + // CMD/Ctrl + Minus (zoom out) + if ((e.metaKey || e.ctrlKey) && e.key === '-') { + e.preventDefault(); + window.zoomOut && window.zoomOut(); + return false; + } + + // CMD/Ctrl + 0 (reset zoom) + if ((e.metaKey || e.ctrlKey) && e.key === '0') { + e.preventDefault(); + window.zoomReset && window.zoomReset(); + return false; + } + }, true); + `) + + wv.Bind("zoomIn", func() { + current := wv.GetZoom() + wv.SetZoom(current + 0.1) + }) + + wv.Bind("zoomOut", func() { + current := wv.GetZoom() + wv.SetZoom(current - 0.1) + }) + + wv.Bind("zoomReset", func() { + wv.SetZoom(1.0) + }) + + wv.Bind("ready", func() { + showWindow(wv.Window()) + }) + + wv.Bind("close", func() { + hideWindow(wv.Window()) + }) + + // Webviews do not allow access to the file system by default, so we need to + // bind file system operations here + wv.Bind("selectModelsDirectory", func() { + go func() { + // Helper function to call the JavaScript callback with data or null + callCallback := func(data interface{}) { + dataJSON, _ := json.Marshal(data) + wv.Dispatch(func() { + wv.Eval(fmt.Sprintf("window.__selectModelsDirectoryCallback && window.__selectModelsDirectoryCallback(%s)", dataJSON)) + }) + } + + directory, err := dialog.Directory().Title("Select Model Directory").ShowHidden(true).Browse() + if err != nil { + slog.Debug("Directory selection cancelled or failed", "error", err) + callCallback(nil) + return + } + slog.Debug("Directory selected", "path", directory) + callCallback(directory) + }() + }) + + // Bind selectFiles function for selecting multiple files at once + wv.Bind("selectFiles", func() { + go func() { + // Helper function to call the JavaScript callback with data or null + callCallback := func(data interface{}) { + dataJSON, _ := json.Marshal(data) + wv.Dispatch(func() { + wv.Eval(fmt.Sprintf("window.__selectFilesCallback && window.__selectFilesCallback(%s)", dataJSON)) + }) + } + + // Define allowed extensions for native dialog filtering + textExts := []string{ + "pdf", "docx", "txt", "md", "csv", "json", "xml", "html", "htm", + "js", "jsx", "ts", "tsx", "py", "java", "cpp", "c", "cc", "h", "cs", "php", "rb", + "go", "rs", "swift", "kt", "scala", "sh", "bat", "yaml", "yml", "toml", "ini", + "cfg", "conf", "log", "rtf", + } + imageExts := []string{"png", "jpg", "jpeg", "webp"} + allowedExts := append(textExts, imageExts...) + + // Use native multiple file selection with extension filtering + filenames, err := dialog.File(). + Filter("Supported Files", allowedExts...). + Title("Select Files"). + LoadMultiple() + if err != nil { + slog.Debug("Multiple file selection cancelled or failed", "error", err) + callCallback(nil) + return + } + + if len(filenames) == 0 { + callCallback(nil) + return + } + + var files []map[string]string + maxFileSize := int64(10 * 1024 * 1024) // 10MB + + for _, filename := range filenames { + // Check file extension (double-check after native dialog filtering) + ext := strings.ToLower(strings.TrimPrefix(filepath.Ext(filename), ".")) + validExt := false + for _, allowedExt := range allowedExts { + if ext == allowedExt { + validExt = true + break + } + } + if !validExt { + slog.Warn("file extension not allowed, skipping", "filename", filepath.Base(filename), "extension", ext) + continue + } + + // Check file size before reading (pre-filter large files) + fileStat, err := os.Stat(filename) + if err != nil { + slog.Error("failed to get file info", "error", err, "filename", filename) + continue + } + + if fileStat.Size() > maxFileSize { + slog.Warn("file too large, skipping", "filename", filepath.Base(filename), "size", fileStat.Size()) + continue + } + + fileBytes, err := os.ReadFile(filename) + if err != nil { + slog.Error("failed to read file", "error", err, "filename", filename) + continue + } + + mimeType := http.DetectContentType(fileBytes) + dataURL := fmt.Sprintf("data:%s;base64,%s", mimeType, base64.StdEncoding.EncodeToString(fileBytes)) + + fileResult := map[string]string{ + "filename": filepath.Base(filename), + "path": filename, + "dataURL": dataURL, + } + + files = append(files, fileResult) + } + + if len(files) == 0 { + callCallback(nil) + } else { + callCallback(files) + } + }() + }) + + wv.Bind("drag", func() { + wv.Dispatch(func() { + drag(wv.Window()) + }) + }) + + wv.Bind("doubleClick", func() { + wv.Dispatch(func() { + doubleClick(wv.Window()) + }) + }) + + // Add binding for working directory selection + wv.Bind("selectWorkingDirectory", func() { + go func() { + // Helper function to call the JavaScript callback with data or null + callCallback := func(data interface{}) { + dataJSON, _ := json.Marshal(data) + wv.Dispatch(func() { + wv.Eval(fmt.Sprintf("window.__selectWorkingDirectoryCallback && window.__selectWorkingDirectoryCallback(%s)", dataJSON)) + }) + } + + directory, err := dialog.Directory().Title("Select Working Directory").ShowHidden(true).Browse() + if err != nil { + slog.Debug("Directory selection cancelled or failed", "error", err) + callCallback(nil) + return + } + slog.Debug("Directory selected", "path", directory) + callCallback(directory) + }() + }) + + wv.Bind("setContextMenuItems", func(items []map[string]interface{}) error { + menuMutex.Lock() + defer menuMutex.Unlock() + + if len(menuItems) > 0 { + pinner.Unpin() + } + + menuItems = nil + for _, item := range items { + menuItem := C.menuItem{ + label: C.CString(item["label"].(string)), + enabled: 0, + separator: 0, + } + + if item["enabled"] != nil { + menuItem.enabled = 1 + } + + if item["separator"] != nil { + menuItem.separator = 1 + } + menuItems = append(menuItems, menuItem) + } + return nil + }) + + // Debounce resize events + var resizeTimer *time.Timer + var resizeMutex sync.Mutex + + wv.Bind("resize", func(width, height int) { + if w.Store != nil { + resizeMutex.Lock() + if resizeTimer != nil { + resizeTimer.Stop() + } + resizeTimer = time.AfterFunc(100*time.Millisecond, func() { + err := w.Store.SetWindowSize(width, height) + if err != nil { + slog.Error("failed to set window size", "error", err) + } + }) + resizeMutex.Unlock() + } + }) + + // On Darwin, we can't have 2 threads both running global event loops + // but on Windows, the event loops are tied to the window, so we're + // able to run in both the tray and webview + if runtime.GOOS != "darwin" { + slog.Debug("starting webview event loop") + go func() { + wv.Run() + slog.Debug("webview event loop exited") + }() + } + + if w.Store != nil { + width, height, err := w.Store.WindowSize() + if err != nil { + slog.Error("failed to get window size", "error", err) + } + if width > 0 && height > 0 { + wv.SetSize(width, height, webview.HintNone) + } else { + wv.SetSize(800, 600, webview.HintNone) + } + } + wv.SetSize(800, 600, webview.HintMin) + + w.webview = wv + w.webview.Navigate(url) + } else { + w.webview.Eval(fmt.Sprintf(` + history.pushState({}, '', '%s'); + `, path)) + showWindow(w.webview.Window()) + } + + return w.webview.Window() +} + +func (w *Webview) Terminate() { + w.mutex.Lock() + if w.webview == nil { + w.mutex.Unlock() + return + } + + wv := w.webview + w.webview = nil + w.mutex.Unlock() + wv.Terminate() + wv.Destroy() +} + +func (w *Webview) IsRunning() bool { + w.mutex.Lock() + defer w.mutex.Unlock() + return w.webview != nil +} + +var ( + menuItems []C.menuItem + menuMutex sync.RWMutex + pinner runtime.Pinner +) + +//export menu_get_item_count +func menu_get_item_count() C.int { + menuMutex.RLock() + defer menuMutex.RUnlock() + return C.int(len(menuItems)) +} + +//export menu_get_items +func menu_get_items() unsafe.Pointer { + menuMutex.RLock() + defer menuMutex.RUnlock() + + if len(menuItems) == 0 { + return nil + } + + // Return pointer to the slice data + pinner.Pin(&menuItems[0]) + return unsafe.Pointer(&menuItems[0]) +} + +//export menu_handle_selection +func menu_handle_selection(item *C.char) { + wv.webview.Eval(fmt.Sprintf("window.handleContextMenuResult('%s')", C.GoString(item))) +} diff --git a/app/cmd/squirrel/Info.plist b/app/cmd/squirrel/Info.plist new file mode 100644 index 0000000..14de76d --- /dev/null +++ b/app/cmd/squirrel/Info.plist @@ -0,0 +1,40 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + Squirrel + CFBundleIconFile + + CFBundleIdentifier + com.github.Squirrel + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + Squirrel + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + DTCompiler + com.apple.compilers.llvm.clang.1_0 + DTSDKBuild + 22E245 + DTSDKName + macosx13.3 + DTXcode + 1431 + DTXcodeBuild + 14E300c + NSHumanReadableCopyright + Copyright © 2013 GitHub. All rights reserved. + NSPrincipalClass + + + \ No newline at end of file diff --git a/app/darwin/Ollama.app/Contents/Info.plist b/app/darwin/Ollama.app/Contents/Info.plist new file mode 100644 index 0000000..5d9b4ca --- /dev/null +++ b/app/darwin/Ollama.app/Contents/Info.plist @@ -0,0 +1,51 @@ + + + + + CFBundleDisplayName + Ollama + CFBundleExecutable + Ollama + CFBundleIconFile + icon.icns + CFBundleIdentifier + com.electron.ollama + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + Ollama + CFBundlePackageType + APPL + CFBundleShortVersionString + 0.0.0 + CFBundleVersion + 0.0.0 + DTCompiler + com.apple.compilers.llvm.clang.1_0 + DTSDKBuild + 22E245 + DTSDKName + macosx14.0 + DTXcode + 1431 + DTXcodeBuild + 14E300c + LSApplicationCategoryType + public.app-category.developer-tools + LSMinimumSystemVersion + 14.0 + LSUIElement + + CFBundleURLTypes + + + CFBundleURLName + Ollama URL + CFBundleURLSchemes + + ollama + + + + + diff --git a/app/darwin/Ollama.app/Contents/Library/LaunchAgents/com.ollama.ollama.plist b/app/darwin/Ollama.app/Contents/Library/LaunchAgents/com.ollama.ollama.plist new file mode 100644 index 0000000..563f7bd --- /dev/null +++ b/app/darwin/Ollama.app/Contents/Library/LaunchAgents/com.ollama.ollama.plist @@ -0,0 +1,25 @@ + + + + + Label + com.ollama.ollama + BundleProgram + Contents/Frameworks/Squirrel.framework/Versions/A/Squirrel + ProgramArguments + + Contents/Frameworks/Squirrel.framework/Versions/A/Squirrel + background + + RunAtLoad + + LimitLoadToSessionType + Aqua + POSIXSpawnType + Interactive + LSUIElement + + LSBackgroundOnly + + + \ No newline at end of file diff --git a/app/darwin/Ollama.app/Contents/Resources/icon.icns b/app/darwin/Ollama.app/Contents/Resources/icon.icns new file mode 100644 index 0000000..e25734d Binary files /dev/null and b/app/darwin/Ollama.app/Contents/Resources/icon.icns differ diff --git a/app/darwin/Ollama.app/Contents/Resources/ollama.png b/app/darwin/Ollama.app/Contents/Resources/ollama.png new file mode 100644 index 0000000..8daa976 Binary files /dev/null and b/app/darwin/Ollama.app/Contents/Resources/ollama.png differ diff --git a/app/darwin/Ollama.app/Contents/Resources/ollama@2x.png b/app/darwin/Ollama.app/Contents/Resources/ollama@2x.png new file mode 100644 index 0000000..d226d0f Binary files /dev/null and b/app/darwin/Ollama.app/Contents/Resources/ollama@2x.png differ diff --git a/app/darwin/Ollama.app/Contents/Resources/ollamaDark.png b/app/darwin/Ollama.app/Contents/Resources/ollamaDark.png new file mode 100644 index 0000000..34a8f89 Binary files /dev/null and b/app/darwin/Ollama.app/Contents/Resources/ollamaDark.png differ diff --git a/app/darwin/Ollama.app/Contents/Resources/ollamaDark@2x.png b/app/darwin/Ollama.app/Contents/Resources/ollamaDark@2x.png new file mode 100644 index 0000000..f2436e4 Binary files /dev/null and b/app/darwin/Ollama.app/Contents/Resources/ollamaDark@2x.png differ diff --git a/app/darwin/Ollama.app/Contents/Resources/ollamaUpdate.png b/app/darwin/Ollama.app/Contents/Resources/ollamaUpdate.png new file mode 100644 index 0000000..2e9aab3 Binary files /dev/null and b/app/darwin/Ollama.app/Contents/Resources/ollamaUpdate.png differ diff --git a/app/darwin/Ollama.app/Contents/Resources/ollamaUpdate@2x.png b/app/darwin/Ollama.app/Contents/Resources/ollamaUpdate@2x.png new file mode 100644 index 0000000..471fe13 Binary files /dev/null and b/app/darwin/Ollama.app/Contents/Resources/ollamaUpdate@2x.png differ diff --git a/app/darwin/Ollama.app/Contents/Resources/ollamaUpdateDark.png b/app/darwin/Ollama.app/Contents/Resources/ollamaUpdateDark.png new file mode 100644 index 0000000..b7f3fd6 Binary files /dev/null and b/app/darwin/Ollama.app/Contents/Resources/ollamaUpdateDark.png differ diff --git a/app/darwin/Ollama.app/Contents/Resources/ollamaUpdateDark@2x.png b/app/darwin/Ollama.app/Contents/Resources/ollamaUpdateDark@2x.png new file mode 100644 index 0000000..5672c1a Binary files /dev/null and b/app/darwin/Ollama.app/Contents/Resources/ollamaUpdateDark@2x.png differ diff --git a/app/dialog/LICENSE b/app/dialog/LICENSE new file mode 100644 index 0000000..75bff9f --- /dev/null +++ b/app/dialog/LICENSE @@ -0,0 +1,15 @@ +ISC License + +Copyright (c) 2018, the dialog authors. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. \ No newline at end of file diff --git a/app/dialog/cocoa/dlg.h b/app/dialog/cocoa/dlg.h new file mode 100644 index 0000000..302cd2e --- /dev/null +++ b/app/dialog/cocoa/dlg.h @@ -0,0 +1,43 @@ +#include + +typedef enum { + MSG_YESNO, + MSG_ERROR, + MSG_INFO, +} AlertStyle; + +typedef struct { + char* msg; + char* title; + AlertStyle style; +} AlertDlgParams; + +#define LOADDLG 0 +#define SAVEDLG 1 +#define DIRDLG 2 // browse for directory + +typedef struct { + int mode; /* which dialog style to invoke (see earlier defines) */ + char* buf; /* buffer to store selected file */ + int nbuf; /* number of bytes allocated at buf */ + char* title; /* title for dialog box (can be nil) */ + void** exts; /* list of valid extensions (elements actual type is NSString*) */ + int numext; /* number of items in exts */ + int relaxext; /* allow other extensions? */ + char* startDir; /* directory to start in (can be nil) */ + char* filename; /* default filename for dialog box (can be nil) */ + int showHidden; /* show hidden files? */ + int allowMultiple; /* allow multiple file selection? */ +} FileDlgParams; + +typedef enum { + DLG_OK, + DLG_CANCEL, + DLG_URLFAIL, +} DlgResult; + +DlgResult alertDlg(AlertDlgParams*); +DlgResult fileDlg(FileDlgParams*); + +void* NSStr(void* buf, int len); +void NSRelease(void* obj); diff --git a/app/dialog/cocoa/dlg.m b/app/dialog/cocoa/dlg.m new file mode 100644 index 0000000..3585197 --- /dev/null +++ b/app/dialog/cocoa/dlg.m @@ -0,0 +1,218 @@ +#import +#include "dlg.h" +#include +#include + +// Import UniformTypeIdentifiers for macOS 11+ +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 110000 +#import +#endif + +void* NSStr(void* buf, int len) { + return (void*)[[NSString alloc] initWithBytes:buf length:len encoding:NSUTF8StringEncoding]; +} + +void checkActivationPolicy() { + NSApplicationActivationPolicy policy = [NSApp activationPolicy]; + // prohibited NSApp will not show the panel at all. + // It probably means that this is not run in a GUI app, that would set the policy on its own, + // but in a terminal app - setting it to accessory will allow dialogs to show + if (policy == NSApplicationActivationPolicyProhibited) { + [NSApp setActivationPolicy:NSApplicationActivationPolicyAccessory]; + } +} + +void NSRelease(void* obj) { + [(NSObject*)obj release]; +} + +@interface AlertDlg : NSObject { + AlertDlgParams* params; + DlgResult result; +} ++ (AlertDlg*)init:(AlertDlgParams*)params; +- (DlgResult)run; +@end + +DlgResult alertDlg(AlertDlgParams* params) { + return [[AlertDlg init:params] run]; +} + +@implementation AlertDlg ++ (AlertDlg*)init:(AlertDlgParams*)params { + AlertDlg* d = [AlertDlg alloc]; + d->params = params; + return d; +} + +- (DlgResult)run { + if(![NSThread isMainThread]) { + [self performSelectorOnMainThread:@selector(run) withObject:nil waitUntilDone:YES]; + return self->result; + } + NSAlert* alert = [[NSAlert alloc] init]; + if(self->params->title != nil) { + [[alert window] setTitle:[[NSString alloc] initWithUTF8String:self->params->title]]; + } + [alert setMessageText:[[NSString alloc] initWithUTF8String:self->params->msg]]; + switch (self->params->style) { + case MSG_YESNO: + [alert addButtonWithTitle:@"Yes"]; + [alert addButtonWithTitle:@"No"]; + break; + case MSG_ERROR: + [alert setIcon:[NSImage imageNamed:NSImageNameCaution]]; + [alert addButtonWithTitle:@"OK"]; + break; + case MSG_INFO: + [alert setIcon:[NSImage imageNamed:NSImageNameInfo]]; + [alert addButtonWithTitle:@"OK"]; + break; + } + + checkActivationPolicy(); + + self->result = [alert runModal] == NSAlertFirstButtonReturn ? DLG_OK : DLG_CANCEL; + return self->result; +} +@end + +@interface FileDlg : NSObject { + FileDlgParams* params; + DlgResult result; +} ++ (FileDlg*)init:(FileDlgParams*)params; +- (DlgResult)run; +@end + +DlgResult fileDlg(FileDlgParams* params) { + return [[FileDlg init:params] run]; +} + +@implementation FileDlg ++ (FileDlg*)init:(FileDlgParams*)params { + FileDlg* d = [FileDlg alloc]; + d->params = params; + return d; +} + +- (DlgResult)run { + if(![NSThread isMainThread]) { + [self performSelectorOnMainThread:@selector(run) withObject:nil waitUntilDone:YES]; + } else if(self->params->mode == SAVEDLG) { + self->result = [self save]; + } else { + self->result = [self load]; + } + return self->result; +} + +- (NSInteger)runPanel:(NSSavePanel*)panel { + [panel setFloatingPanel:YES]; + [panel setShowsHiddenFiles:self->params->showHidden ? YES : NO]; + [panel setCanCreateDirectories:YES]; + if(self->params->title != nil) { + [panel setTitle:[[NSString alloc] initWithUTF8String:self->params->title]]; + } + // Use modern allowedContentTypes API for better file type support (especially video files) + if(self->params->numext > 0) { + NSMutableArray *utTypes = [NSMutableArray arrayWithCapacity:self->params->numext]; + NSString** exts = (NSString**)self->params->exts; + for(int i = 0; i < self->params->numext; i++) { + UTType *type = [UTType typeWithFilenameExtension:exts[i]]; + if(type) { + [utTypes addObject:type]; + } + } + if([utTypes count] > 0) { + [panel setAllowedContentTypes:utTypes]; + } + } + if(self->params->relaxext) { + [panel setAllowsOtherFileTypes:YES]; + } + if(self->params->startDir) { + [panel setDirectoryURL:[NSURL URLWithString:[[NSString alloc] initWithUTF8String:self->params->startDir]]]; + } + if(self->params->filename != nil) { + [panel setNameFieldStringValue:[[NSString alloc] initWithUTF8String:self->params->filename]]; + } + + checkActivationPolicy(); + + return [panel runModal]; +} + +- (DlgResult)save { + NSSavePanel* panel = [NSSavePanel savePanel]; + if(![self runPanel:panel]) { + return DLG_CANCEL; + } else if(![[panel URL] getFileSystemRepresentation:self->params->buf maxLength:self->params->nbuf]) { + return DLG_URLFAIL; + } + return DLG_OK; +} + +- (DlgResult)load { + NSOpenPanel* panel = [NSOpenPanel openPanel]; + if(self->params->mode == DIRDLG) { + [panel setCanChooseDirectories:YES]; + [panel setCanChooseFiles:NO]; + } + + if(self->params->allowMultiple) { + [panel setAllowsMultipleSelection:YES]; + } + + if(![self runPanel:panel]) { + return DLG_CANCEL; + } + + NSArray* urls = [panel URLs]; + if([urls count] == 0) { + return DLG_CANCEL; + } + + if(self->params->allowMultiple) { + // For multiple files, we need to return all paths separated by null bytes + char* bufPtr = self->params->buf; + int remainingBuf = self->params->nbuf; + + // Calculate total required buffer size first + int totalSize = 0; + for(NSURL* url in urls) { + char tempBuf[PATH_MAX]; + if(![url getFileSystemRepresentation:tempBuf maxLength:PATH_MAX]) { + return DLG_URLFAIL; + } + totalSize += strlen(tempBuf) + 1; // +1 for null terminator + } + totalSize += 1; // Final null terminator + + if(totalSize > self->params->nbuf) { + // Not enough buffer space + return DLG_URLFAIL; + } + + // Now actually copy the paths (we know we have space) + bufPtr = self->params->buf; + for(NSURL* url in urls) { + char tempBuf[PATH_MAX]; + [url getFileSystemRepresentation:tempBuf maxLength:PATH_MAX]; + int pathLen = strlen(tempBuf); + strcpy(bufPtr, tempBuf); + bufPtr += pathLen + 1; + } + *bufPtr = '\0'; // Final null terminator + } else { + // Single file/directory selection - write path to buffer + NSURL* url = [urls firstObject]; + if(![url getFileSystemRepresentation:self->params->buf maxLength:self->params->nbuf]) { + return DLG_URLFAIL; + } + } + + return DLG_OK; +} + +@end diff --git a/app/dialog/cocoa/dlg_darwin.go b/app/dialog/cocoa/dlg_darwin.go new file mode 100644 index 0000000..6bfae5a --- /dev/null +++ b/app/dialog/cocoa/dlg_darwin.go @@ -0,0 +1,183 @@ +package cocoa + +// #cgo darwin LDFLAGS: -framework Cocoa -framework UniformTypeIdentifiers +// #include +// #include +// #include "dlg.h" +import "C" + +import ( + "bytes" + "errors" + "unsafe" +) + +type AlertParams struct { + p C.AlertDlgParams +} + +func mkAlertParams(msg, title string, style C.AlertStyle) *AlertParams { + a := AlertParams{C.AlertDlgParams{msg: C.CString(msg), style: style}} + if title != "" { + a.p.title = C.CString(title) + } + return &a +} + +func (a *AlertParams) run() C.DlgResult { + return C.alertDlg(&a.p) +} + +func (a *AlertParams) free() { + C.free(unsafe.Pointer(a.p.msg)) + if a.p.title != nil { + C.free(unsafe.Pointer(a.p.title)) + } +} + +func nsStr(s string) unsafe.Pointer { + return C.NSStr(unsafe.Pointer(&[]byte(s)[0]), C.int(len(s))) +} + +func YesNoDlg(msg, title string) bool { + a := mkAlertParams(msg, title, C.MSG_YESNO) + defer a.free() + return a.run() == C.DLG_OK +} + +func InfoDlg(msg, title string) { + a := mkAlertParams(msg, title, C.MSG_INFO) + defer a.free() + a.run() +} + +func ErrorDlg(msg, title string) { + a := mkAlertParams(msg, title, C.MSG_ERROR) + defer a.free() + a.run() +} + +const ( + BUFSIZE = C.PATH_MAX + MULTI_FILE_BUF_SIZE = 32768 +) + +// MultiFileDlg opens a file dialog that allows multiple file selection +func MultiFileDlg(title string, exts []string, relaxExt bool, startDir string, showHidden bool) ([]string, error) { + return fileDlgWithOptions(C.LOADDLG, title, exts, relaxExt, startDir, "", showHidden, true) +} + +// FileDlg opens a file dialog for single file selection (kept for compatibility) +func FileDlg(save bool, title string, exts []string, relaxExt bool, startDir string, filename string, showHidden bool) (string, error) { + mode := C.LOADDLG + if save { + mode = C.SAVEDLG + } + files, err := fileDlgWithOptions(mode, title, exts, relaxExt, startDir, filename, showHidden, false) + if err != nil { + return "", err + } + if len(files) == 0 { + return "", nil + } + return files[0], nil +} + +func DirDlg(title string, startDir string, showHidden bool) (string, error) { + files, err := fileDlgWithOptions(C.DIRDLG, title, nil, false, startDir, "", showHidden, false) + if err != nil { + return "", err + } + if len(files) == 0 { + return "", nil + } + return files[0], nil +} + +// fileDlgWithOptions is the unified file dialog function that handles both single and multiple selection +func fileDlgWithOptions(mode int, title string, exts []string, relaxExt bool, startDir, filename string, showHidden, allowMultiple bool) ([]string, error) { + // Use larger buffer for multiple files, smaller for single + bufSize := BUFSIZE + if allowMultiple { + bufSize = MULTI_FILE_BUF_SIZE + } + + p := C.FileDlgParams{ + mode: C.int(mode), + nbuf: C.int(bufSize), + } + + if allowMultiple { + p.allowMultiple = C.int(1) // Enable multiple selection //nolint:structcheck + } + if showHidden { + p.showHidden = 1 + } + + p.buf = (*C.char)(C.malloc(C.size_t(bufSize))) + defer C.free(unsafe.Pointer(p.buf)) + buf := (*(*[MULTI_FILE_BUF_SIZE]byte)(unsafe.Pointer(p.buf)))[:bufSize] + + if title != "" { + p.title = C.CString(title) + defer C.free(unsafe.Pointer(p.title)) + } + if startDir != "" { + p.startDir = C.CString(startDir) + defer C.free(unsafe.Pointer(p.startDir)) + } + if filename != "" { + p.filename = C.CString(filename) + defer C.free(unsafe.Pointer(p.filename)) + } + + if len(exts) > 0 { + if len(exts) > 999 { + panic("more than 999 extensions not supported") + } + ptrSize := int(unsafe.Sizeof(&title)) + p.exts = (*unsafe.Pointer)(C.malloc(C.size_t(ptrSize * len(exts)))) + defer C.free(unsafe.Pointer(p.exts)) + cext := (*(*[999]unsafe.Pointer)(unsafe.Pointer(p.exts)))[:] + for i, ext := range exts { + cext[i] = nsStr(ext) + defer C.NSRelease(cext[i]) + } + p.numext = C.int(len(exts)) + if relaxExt { + p.relaxext = 1 + } + } + + // Execute dialog and parse results + switch C.fileDlg(&p) { + case C.DLG_OK: + if allowMultiple { + // Parse multiple null-terminated strings from buffer + var files []string + start := 0 + for i := range len(buf) - 1 { + if buf[i] == 0 { + if i > start { + files = append(files, string(buf[start:i])) + } + start = i + 1 + // Check for double null (end of list) + if i+1 < len(buf) && buf[i+1] == 0 { + break + } + } + } + return files, nil + } else { + // Single file - return as array for consistency + filename := string(buf[:bytes.Index(buf, []byte{0})]) + return []string{filename}, nil + } + case C.DLG_CANCEL: + return nil, nil + case C.DLG_URLFAIL: + return nil, errors.New("failed to get file-system representation for selected URL") + } + panic("unhandled case") +} diff --git a/app/dialog/dlgs.go b/app/dialog/dlgs.go new file mode 100644 index 0000000..700f79f --- /dev/null +++ b/app/dialog/dlgs.go @@ -0,0 +1,182 @@ +//go:build windows || darwin + +// Package dialog provides a simple cross-platform common dialog API. +// Eg. to prompt the user with a yes/no dialog: +// +// if dialog.MsgDlg("%s", "Do you want to continue?").YesNo() { +// // user pressed Yes +// } +// +// The general usage pattern is to call one of the toplevel *Dlg functions +// which return a *Builder structure. From here you can optionally call +// configuration functions (eg. Title) to customise the dialog, before +// using a launcher function to run the dialog. +package dialog + +import ( + "errors" + "fmt" +) + +// ErrCancelled is an error returned when a user cancels/closes a dialog. +var ErrCancelled = errors.New("Cancelled") + +// Cancelled refers to ErrCancelled. +// Deprecated: Use ErrCancelled instead. +var Cancelled = ErrCancelled + +// Dlg is the common type for dialogs. +type Dlg struct { + Title string +} + +// MsgBuilder is used for creating message boxes. +type MsgBuilder struct { + Dlg + Msg string +} + +// Message initialises a MsgBuilder with the provided message. +func Message(format string, args ...interface{}) *MsgBuilder { + return &MsgBuilder{Msg: fmt.Sprintf(format, args...)} +} + +// Title specifies what the title of the message dialog will be. +func (b *MsgBuilder) Title(title string) *MsgBuilder { + b.Dlg.Title = title + return b +} + +// YesNo spawns the message dialog with two buttons, "Yes" and "No". +// Returns true iff the user selected "Yes". +func (b *MsgBuilder) YesNo() bool { + return b.yesNo() +} + +// Info spawns the message dialog with an information icon and single button, "Ok". +func (b *MsgBuilder) Info() { + b.info() +} + +// Error spawns the message dialog with an error icon and single button, "Ok". +func (b *MsgBuilder) Error() { + b.error() +} + +// FileFilter represents a category of files (eg. audio files, spreadsheets). +type FileFilter struct { + Desc string + Extensions []string +} + +// FileBuilder is used for creating file browsing dialogs. +type FileBuilder struct { + Dlg + StartDir string + StartFile string + Filters []FileFilter + ShowHiddenFiles bool +} + +// File initialises a FileBuilder using the default configuration. +func File() *FileBuilder { + return &FileBuilder{} +} + +// Title specifies the title to be used for the dialog. +func (b *FileBuilder) Title(title string) *FileBuilder { + b.Dlg.Title = title + return b +} + +// Filter adds a category of files to the types allowed by the dialog. Multiple +// calls to Filter are cumulative - any of the provided categories will be allowed. +// By default all files can be selected. +// +// The special extension '*' allows all files to be selected when the Filter is active. +func (b *FileBuilder) Filter(desc string, extensions ...string) *FileBuilder { + filt := FileFilter{desc, extensions} + if len(filt.Extensions) == 0 { + filt.Extensions = append(filt.Extensions, "*") + } + b.Filters = append(b.Filters, filt) + return b +} + +// SetStartDir specifies the initial directory of the dialog. +func (b *FileBuilder) SetStartDir(startDir string) *FileBuilder { + b.StartDir = startDir + return b +} + +// SetStartFile specifies the initial file name of the dialog. +func (b *FileBuilder) SetStartFile(startFile string) *FileBuilder { + b.StartFile = startFile + return b +} + +// ShowHiddenFiles sets whether hidden files should be visible in the dialog. +func (b *FileBuilder) ShowHidden(show bool) *FileBuilder { + b.ShowHiddenFiles = show + return b +} + +// Load spawns the file selection dialog using the configured settings, +// asking the user to select a single file. Returns ErrCancelled as the error +// if the user cancels or closes the dialog. +func (b *FileBuilder) Load() (string, error) { + return b.load() +} + +// LoadMultiple spawns the file selection dialog using the configured settings, +// asking the user to select multiple files. Returns ErrCancelled as the error +// if the user cancels or closes the dialog. +func (b *FileBuilder) LoadMultiple() ([]string, error) { + return b.loadMultiple() +} + +// Save spawns the file selection dialog using the configured settings, +// asking the user for a filename to save as. If the chosen file exists, the +// user is prompted whether they want to overwrite the file. Returns +// ErrCancelled as the error if the user cancels/closes the dialog, or selects +// not to overwrite the file. +func (b *FileBuilder) Save() (string, error) { + return b.save() +} + +// DirectoryBuilder is used for directory browse dialogs. +type DirectoryBuilder struct { + Dlg + StartDir string + ShowHiddenFiles bool +} + +// Directory initialises a DirectoryBuilder using the default configuration. +func Directory() *DirectoryBuilder { + return &DirectoryBuilder{} +} + +// Browse spawns the directory selection dialog using the configured settings, +// asking the user to select a single folder. Returns ErrCancelled as the error +// if the user cancels or closes the dialog. +func (b *DirectoryBuilder) Browse() (string, error) { + return b.browse() +} + +// Title specifies the title to be used for the dialog. +func (b *DirectoryBuilder) Title(title string) *DirectoryBuilder { + b.Dlg.Title = title + return b +} + +// StartDir specifies the initial directory to be used for the dialog. +func (b *DirectoryBuilder) SetStartDir(dir string) *DirectoryBuilder { + b.StartDir = dir + return b +} + +// ShowHiddenFiles sets whether hidden files should be visible in the dialog. +func (b *DirectoryBuilder) ShowHidden(show bool) *DirectoryBuilder { + b.ShowHiddenFiles = show + return b +} diff --git a/app/dialog/dlgs_darwin.go b/app/dialog/dlgs_darwin.go new file mode 100644 index 0000000..8d0f08d --- /dev/null +++ b/app/dialog/dlgs_darwin.go @@ -0,0 +1,82 @@ +package dialog + +import ( + "github.com/ollama/ollama/app/dialog/cocoa" +) + +func (b *MsgBuilder) yesNo() bool { + return cocoa.YesNoDlg(b.Msg, b.Dlg.Title) +} + +func (b *MsgBuilder) info() { + cocoa.InfoDlg(b.Msg, b.Dlg.Title) +} + +func (b *MsgBuilder) error() { + cocoa.ErrorDlg(b.Msg, b.Dlg.Title) +} + +func (b *FileBuilder) load() (string, error) { + return b.run(false) +} + +func (b *FileBuilder) loadMultiple() ([]string, error) { + return b.runMultiple() +} + +func (b *FileBuilder) save() (string, error) { + return b.run(true) +} + +func (b *FileBuilder) run(save bool) (string, error) { + star := false + var exts []string + for _, filt := range b.Filters { + for _, ext := range filt.Extensions { + if ext == "*" { + star = true + } else { + exts = append(exts, ext) + } + } + } + if star && save { + /* OSX doesn't allow the user to switch visible file types/extensions. Also + ** NSSavePanel's allowsOtherFileTypes property has no effect for an open + ** dialog, so if "*" is a possible extension we must always show all files. */ + exts = nil + } + f, err := cocoa.FileDlg(save, b.Dlg.Title, exts, star, b.StartDir, b.StartFile, b.ShowHiddenFiles) + if f == "" && err == nil { + return "", ErrCancelled + } + return f, err +} + +func (b *FileBuilder) runMultiple() ([]string, error) { + star := false + var exts []string + for _, filt := range b.Filters { + for _, ext := range filt.Extensions { + if ext == "*" { + star = true + } else { + exts = append(exts, ext) + } + } + } + + files, err := cocoa.MultiFileDlg(b.Dlg.Title, exts, star, b.StartDir, b.ShowHiddenFiles) + if len(files) == 0 && err == nil { + return nil, ErrCancelled + } + return files, err +} + +func (b *DirectoryBuilder) browse() (string, error) { + f, err := cocoa.DirDlg(b.Dlg.Title, b.StartDir, b.ShowHiddenFiles) + if f == "" && err == nil { + return "", ErrCancelled + } + return f, err +} diff --git a/app/dialog/dlgs_windows.go b/app/dialog/dlgs_windows.go new file mode 100644 index 0000000..51ba9ee --- /dev/null +++ b/app/dialog/dlgs_windows.go @@ -0,0 +1,241 @@ +package dialog + +import ( + "fmt" + "reflect" + "syscall" + "unicode/utf16" + "unsafe" + + "github.com/TheTitanrain/w32" +) + +const multiFileBufferSize = w32.MAX_PATH * 10 + +type WinDlgError int + +func (e WinDlgError) Error() string { + return fmt.Sprintf("CommDlgExtendedError: %#x", int(e)) +} + +func err() error { + e := w32.CommDlgExtendedError() + if e == 0 { + return ErrCancelled + } + return WinDlgError(e) +} + +func (b *MsgBuilder) yesNo() bool { + r := w32.MessageBox(w32.HWND(0), b.Msg, firstOf(b.Dlg.Title, "Confirm?"), w32.MB_YESNO) + return r == w32.IDYES +} + +func (b *MsgBuilder) info() { + w32.MessageBox(w32.HWND(0), b.Msg, firstOf(b.Dlg.Title, "Information"), w32.MB_OK|w32.MB_ICONINFORMATION) +} + +func (b *MsgBuilder) error() { + w32.MessageBox(w32.HWND(0), b.Msg, firstOf(b.Dlg.Title, "Error"), w32.MB_OK|w32.MB_ICONERROR) +} + +type filedlg struct { + buf []uint16 + filters []uint16 + opf *w32.OPENFILENAME +} + +func (d filedlg) Filename() string { + i := 0 + for i < len(d.buf) && d.buf[i] != 0 { + i++ + } + return string(utf16.Decode(d.buf[:i])) +} + +func (d filedlg) parseMultipleFilenames() []string { + var files []string + i := 0 + + // Find first null terminator (directory path) + for i < len(d.buf) && d.buf[i] != 0 { + i++ + } + + if i >= len(d.buf) { + return files + } + + // Get directory path + dirPath := string(utf16.Decode(d.buf[:i])) + i++ // Skip null terminator + + // Check if there are more files (multiple selection) + if i < len(d.buf) && d.buf[i] != 0 { + // Multiple files selected - parse filenames + for i < len(d.buf) { + start := i + // Find next null terminator + for i < len(d.buf) && d.buf[i] != 0 { + i++ + } + if i >= len(d.buf) { + break + } + + if start < i { + filename := string(utf16.Decode(d.buf[start:i])) + if dirPath != "" { + files = append(files, dirPath+"\\"+filename) + } else { + files = append(files, filename) + } + } + i++ // Skip null terminator + if i >= len(d.buf) || d.buf[i] == 0 { + break // End of list + } + } + } else { + // Single file selected + files = append(files, dirPath) + } + + return files +} + +func (b *FileBuilder) load() (string, error) { + d := openfile(w32.OFN_FILEMUSTEXIST|w32.OFN_NOCHANGEDIR, b) + if w32.GetOpenFileName(d.opf) { + return d.Filename(), nil + } + return "", err() +} + +func (b *FileBuilder) loadMultiple() ([]string, error) { + d := openfile(w32.OFN_FILEMUSTEXIST|w32.OFN_NOCHANGEDIR|w32.OFN_ALLOWMULTISELECT|w32.OFN_EXPLORER, b) + d.buf = make([]uint16, multiFileBufferSize) + d.opf.File = utf16ptr(d.buf) + d.opf.MaxFile = uint32(len(d.buf)) + + if w32.GetOpenFileName(d.opf) { + return d.parseMultipleFilenames(), nil + } + return nil, err() +} + +func (b *FileBuilder) save() (string, error) { + d := openfile(w32.OFN_OVERWRITEPROMPT|w32.OFN_NOCHANGEDIR, b) + if w32.GetSaveFileName(d.opf) { + return d.Filename(), nil + } + return "", err() +} + +/* syscall.UTF16PtrFromString not sufficient because we need to encode embedded NUL bytes */ +func utf16ptr(utf16 []uint16) *uint16 { + if utf16[len(utf16)-1] != 0 { + panic("refusing to make ptr to non-NUL terminated utf16 slice") + } + h := (*reflect.SliceHeader)(unsafe.Pointer(&utf16)) + return (*uint16)(unsafe.Pointer(h.Data)) +} + +func utf16slice(ptr *uint16) []uint16 { //nolint:unused + hdr := reflect.SliceHeader{Data: uintptr(unsafe.Pointer(ptr)), Len: 1, Cap: 1} + slice := *((*[]uint16)(unsafe.Pointer(&hdr))) //nolint:govet + i := 0 + for slice[len(slice)-1] != 0 { + i++ + } + hdr.Len = i + slice = *((*[]uint16)(unsafe.Pointer(&hdr))) //nolint:govet + return slice +} + +func openfile(flags uint32, b *FileBuilder) (d filedlg) { + d.buf = make([]uint16, w32.MAX_PATH) + if b.StartFile != "" { + initialName, _ := syscall.UTF16FromString(b.StartFile) + for i := 0; i < len(initialName) && i < w32.MAX_PATH; i++ { + d.buf[i] = initialName[i] + } + } + d.opf = &w32.OPENFILENAME{ + File: utf16ptr(d.buf), + MaxFile: uint32(len(d.buf)), + Flags: flags, + } + d.opf.StructSize = uint32(unsafe.Sizeof(*d.opf)) + if b.StartDir != "" { + d.opf.InitialDir, _ = syscall.UTF16PtrFromString(b.StartDir) + } + if b.Dlg.Title != "" { + d.opf.Title, _ = syscall.UTF16PtrFromString(b.Dlg.Title) + } + for _, filt := range b.Filters { + /* build utf16 string of form "Music File\0*.mp3;*.ogg;*.wav;\0" */ + d.filters = append(d.filters, utf16.Encode([]rune(filt.Desc))...) + d.filters = append(d.filters, 0) + for _, ext := range filt.Extensions { + s := fmt.Sprintf("*.%s;", ext) + d.filters = append(d.filters, utf16.Encode([]rune(s))...) + } + d.filters = append(d.filters, 0) + } + if d.filters != nil { + d.filters = append(d.filters, 0, 0) // two extra NUL chars to terminate the list + d.opf.Filter = utf16ptr(d.filters) + } + return d +} + +type dirdlg struct { + bi *w32.BROWSEINFO +} + +const ( + bffm_INITIALIZED = 1 + bffm_SELCHANGED = 2 + bffm_VALIDATEFAILEDA = 3 + bffm_VALIDATEFAILEDW = 4 + bffm_SETSTATUSTEXTA = (w32.WM_USER + 100) + bffm_SETSTATUSTEXTW = (w32.WM_USER + 104) + bffm_ENABLEOK = (w32.WM_USER + 101) + bffm_SETSELECTIONA = (w32.WM_USER + 102) + bffm_SETSELECTIONW = (w32.WM_USER + 103) + bffm_SETOKTEXT = (w32.WM_USER + 105) + bffm_SETEXPANDED = (w32.WM_USER + 106) + bffm_SETSTATUSTEXT = bffm_SETSTATUSTEXTW + bffm_SETSELECTION = bffm_SETSELECTIONW + bffm_VALIDATEFAILED = bffm_VALIDATEFAILEDW +) + +func callbackDefaultDir(hwnd w32.HWND, msg uint, lParam, lpData uintptr) int { + if msg == bffm_INITIALIZED { + _ = w32.SendMessage(hwnd, bffm_SETSELECTION, w32.TRUE, lpData) + } + return 0 +} + +func selectdir(b *DirectoryBuilder) (d dirdlg) { + d.bi = &w32.BROWSEINFO{Flags: w32.BIF_RETURNONLYFSDIRS | w32.BIF_NEWDIALOGSTYLE} + if b.Dlg.Title != "" { + d.bi.Title, _ = syscall.UTF16PtrFromString(b.Dlg.Title) + } + if b.StartDir != "" { + s16, _ := syscall.UTF16PtrFromString(b.StartDir) + d.bi.LParam = uintptr(unsafe.Pointer(s16)) + d.bi.CallbackFunc = syscall.NewCallback(callbackDefaultDir) + } + return d +} + +func (b *DirectoryBuilder) browse() (string, error) { + d := selectdir(b) + res := w32.SHBrowseForFolder(d.bi) + if res == 0 { + return "", ErrCancelled + } + return w32.SHGetPathFromIDList(res), nil +} diff --git a/app/dialog/util.go b/app/dialog/util.go new file mode 100644 index 0000000..2848c47 --- /dev/null +++ b/app/dialog/util.go @@ -0,0 +1,12 @@ +//go:build windows + +package dialog + +func firstOf(args ...string) string { + for _, arg := range args { + if arg != "" { + return arg + } + } + return "" +} diff --git a/app/format/field.go b/app/format/field.go new file mode 100644 index 0000000..090bdf7 --- /dev/null +++ b/app/format/field.go @@ -0,0 +1,30 @@ +//go:build windows || darwin + +package format + +import ( + "strings" + "unicode" +) + +// KebabCase converts a string from camelCase or PascalCase to kebab-case. +// (e.g. "camelCase" -> "camel-case") +func KebabCase(str string) string { + var result strings.Builder + + for i, char := range str { + if i > 0 { + prevChar := rune(str[i-1]) + + // Add hyphen before uppercase letters + if unicode.IsUpper(char) && + (unicode.IsLower(prevChar) || unicode.IsDigit(prevChar) || + (i < len(str)-1 && unicode.IsLower(rune(str[i+1])))) { + result.WriteRune('-') + } + } + result.WriteRune(unicode.ToLower(char)) + } + + return result.String() +} diff --git a/app/format/field_test.go b/app/format/field_test.go new file mode 100644 index 0000000..9ea8431 --- /dev/null +++ b/app/format/field_test.go @@ -0,0 +1,34 @@ +//go:build windows || darwin + +package format + +import "testing" + +func TestKebabCase(t *testing.T) { + tests := []struct { + input string + expected string + }{ + {"already-kebab-case", "already-kebab-case"}, + {"simpleCamelCase", "simple-camel-case"}, + {"PascalCase", "pascal-case"}, + {"camelCaseWithNumber123", "camel-case-with-number123"}, + {"APIResponse", "api-response"}, + {"mixedCASE", "mixed-case"}, + {"WithACRONYMS", "with-acronyms"}, + {"ALLCAPS", "allcaps"}, + {"camelCaseWITHMixedACRONYMS", "camel-case-with-mixed-acronyms"}, + {"numbers123in456string", "numbers123in456string"}, + {"5", "5"}, + {"S", "s"}, + } + + for _, tt := range tests { + t.Run(tt.input, func(t *testing.T) { + result := KebabCase(tt.input) + if result != tt.expected { + t.Errorf("toKebabCase(%q) = %q, want %q", tt.input, result, tt.expected) + } + }) + } +} diff --git a/app/logrotate/logrotate.go b/app/logrotate/logrotate.go new file mode 100644 index 0000000..df8ba9c --- /dev/null +++ b/app/logrotate/logrotate.go @@ -0,0 +1,45 @@ +//go:build windows || darwin + +// package logrotate provides utilities for rotating logs +// TODO (jmorgan): this most likely doesn't need it's own +// package and can be moved to app where log files are created +package logrotate + +import ( + "log/slog" + "os" + "strconv" + "strings" +) + +const MaxLogFiles = 5 + +func Rotate(filename string) { + if _, err := os.Stat(filename); os.IsNotExist(err) { + return + } + + index := strings.LastIndex(filename, ".") + pre := filename[:index] + post := "." + filename[index+1:] + for i := MaxLogFiles; i > 0; i-- { + older := pre + "-" + strconv.Itoa(i) + post + newer := pre + "-" + strconv.Itoa(i-1) + post + if i == 1 { + newer = pre + post + } + if _, err := os.Stat(newer); err == nil { + if _, err := os.Stat(older); err == nil { + err := os.Remove(older) + if err != nil { + slog.Warn("Failed to remove older log", "older", older, "error", err) + continue + } + } + err := os.Rename(newer, older) + if err != nil { + slog.Warn("Failed to rotate log", "older", older, "newer", newer, "error", err) + } + } + } +} diff --git a/app/logrotate/logrotate_test.go b/app/logrotate/logrotate_test.go new file mode 100644 index 0000000..5eef5b4 --- /dev/null +++ b/app/logrotate/logrotate_test.go @@ -0,0 +1,70 @@ +//go:build windows || darwin + +package logrotate + +import ( + "os" + "path/filepath" + "strconv" + "testing" +) + +func TestRotate(t *testing.T) { + logDir := t.TempDir() + logFile := filepath.Join(logDir, "testlog.log") + + // No log exists + Rotate(logFile) + + if err := os.WriteFile(logFile, []byte("1"), 0o644); err != nil { + t.Fatal(err) + } + if _, err := os.Stat(logFile); os.IsNotExist(err) { + t.Fatal("expected log file to exist") + } + + // First rotation + Rotate(logFile) + if _, err := os.Stat(filepath.Join(logDir, "testlog-1.log")); os.IsNotExist(err) { + t.Fatal("expected rotated log file to exist") + } + if _, err := os.Stat(filepath.Join(logDir, "testlog-2.log")); !os.IsNotExist(err) { + t.Fatal("expected no second rotated log file") + } + if _, err := os.Stat(logFile); !os.IsNotExist(err) { + t.Fatal("expected original log file to be moved") + } + + // Should be a no-op without a new log + Rotate(logFile) + if _, err := os.Stat(filepath.Join(logDir, "testlog-1.log")); os.IsNotExist(err) { + t.Fatal("expected rotated log file to still exist") + } + if _, err := os.Stat(filepath.Join(logDir, "testlog-2.log")); !os.IsNotExist(err) { + t.Fatal("expected no second rotated log file") + } + if _, err := os.Stat(logFile); !os.IsNotExist(err) { + t.Fatal("expected no original log file") + } + + for i := 2; i <= MaxLogFiles+1; i++ { + if err := os.WriteFile(logFile, []byte(strconv.Itoa(i)), 0o644); err != nil { + t.Fatal(err) + } + if _, err := os.Stat(logFile); os.IsNotExist(err) { + t.Fatal("expected log file to exist") + } + Rotate(logFile) + if _, err := os.Stat(logFile); !os.IsNotExist(err) { + t.Fatal("expected log file to be moved") + } + for j := 1; j < i; j++ { + if _, err := os.Stat(filepath.Join(logDir, "testlog-"+strconv.Itoa(j)+".log")); os.IsNotExist(err) { + t.Fatalf("expected rotated log file %d to exist", j) + } + } + if _, err := os.Stat(filepath.Join(logDir, "testlog-"+strconv.Itoa(i+1)+".log")); !os.IsNotExist(err) { + t.Fatalf("expected no rotated log file %d", i+1) + } + } +} diff --git a/app/ollama.iss b/app/ollama.iss new file mode 100644 index 0000000..2f2aa23 --- /dev/null +++ b/app/ollama.iss @@ -0,0 +1,374 @@ +; Inno Setup Installer for Ollama +; +; To build the installer use the build script invoked from the top of the source tree +; +; powershell -ExecutionPolicy Bypass -File .\scripts\build_windows.ps + + +#define MyAppName "Ollama" +#if GetEnv("PKG_VERSION") != "" + #define MyAppVersion GetEnv("PKG_VERSION") +#else + #define MyAppVersion "0.0.0" +#endif +#define MyAppPublisher "Ollama" +#define MyAppURL "https://ollama.com/" +#define MyAppExeName "ollama app.exe" +#define MyIcon ".\assets\app.ico" + +[Setup] +; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications. +; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) +AppId={{44E83376-CE68-45EB-8FC1-393500EB558C} +AppName={#MyAppName} +AppVersion={#MyAppVersion} +VersionInfoVersion={#MyAppVersion} +;AppVerName={#MyAppName} {#MyAppVersion} +AppPublisher={#MyAppPublisher} +AppPublisherURL={#MyAppURL} +AppSupportURL={#MyAppURL} +AppUpdatesURL={#MyAppURL} +ArchitecturesAllowed=x64compatible arm64 +ArchitecturesInstallIn64BitMode=x64compatible arm64 +DefaultDirName={localappdata}\Programs\{#MyAppName} +DefaultGroupName={#MyAppName} +DisableProgramGroupPage=yes +PrivilegesRequired=lowest +OutputBaseFilename="OllamaSetup" +SetupIconFile={#MyIcon} +UninstallDisplayIcon={uninstallexe} +Compression=lzma2/ultra64 +LZMAUseSeparateProcess=yes +LZMANumBlockThreads=8 +SolidCompression=yes +WizardStyle=modern +ChangesEnvironment=yes +OutputDir=..\dist\ + +; Disable logging once everything's battle tested +; Filename will be %TEMP%\Setup Log*.txt +SetupLogging=yes +CloseApplications=no +RestartApplications=no +RestartIfNeededByRun=no + +; https://jrsoftware.org/ishelp/index.php?topic=setup_wizardimagefile +WizardSmallImageFile=.\assets\setup.bmp + +; Ollama requires Windows 10 22H2 or newer for proper unicode rendering +; TODO: consider setting this to 10.0.19045 +MinVersion=10.0.10240 + +; First release that supports WinRT UI Composition for win32 apps +; MinVersion=10.0.17134 +; First release with XAML Islands - possible UI path forward +; MinVersion=10.0.18362 + +; quiet... +DisableDirPage=yes +DisableFinishedPage=yes +DisableReadyMemo=yes +DisableReadyPage=yes +DisableStartupPrompt=yes + +; TODO - percentage can't be set less than 100, so how to make it shorter? +; WizardSizePercent=100,80 + +#if GetEnv("KEY_CONTAINER") +SignTool=MySignTool +SignedUninstaller=yes +#endif + +SetupMutex=OllamaSetupMutex + +[Languages] +Name: "english"; MessagesFile: "compiler:Default.isl" + +[LangOptions] +DialogFontSize=12 + +[Files] +#if FileExists("..\dist\windows-ollama-app-amd64.exe") +Source: "..\dist\windows-ollama-app-amd64.exe"; DestDir: "{app}"; DestName: "{#MyAppExeName}" ;Check: not IsArm64(); Flags: ignoreversion 64bit; BeforeInstall: TaskKill('{#MyAppExeName}') +Source: "..\dist\windows-amd64\vc_redist.x64.exe"; DestDir: "{tmp}"; Check: not IsArm64() and vc_redist_needed(); Flags: deleteafterinstall +Source: "..\dist\windows-amd64\ollama.exe"; DestDir: "{app}"; Check: not IsArm64(); Flags: ignoreversion 64bit; BeforeInstall: TaskKill('ollama.exe') +Source: "..\dist\windows-amd64\lib\ollama\*"; DestDir: "{app}\lib\ollama\"; Check: not IsArm64(); Flags: ignoreversion 64bit recursesubdirs +#endif + +; For local development, rely on binary compatibility at runtime since we can't cross compile +#if FileExists("..\dist\windows-ollama-app-arm64.exe") +Source: "..\dist\windows-ollama-app-arm64.exe"; DestDir: "{app}"; DestName: "{#MyAppExeName}" ;Check: IsArm64(); Flags: ignoreversion 64bit; BeforeInstall: TaskKill('{#MyAppExeName}') +#else +Source: "..\dist\windows-ollama-app-amd64.exe"; DestDir: "{app}"; DestName: "{#MyAppExeName}" ;Check: IsArm64(); Flags: ignoreversion 64bit; BeforeInstall: TaskKill('{#MyAppExeName}') +#endif + +#if FileExists("..\dist\windows-arm64\ollama.exe") +Source: "..\dist\windows-arm64\vc_redist.arm64.exe"; DestDir: "{tmp}"; Check: IsArm64() and vc_redist_needed(); Flags: deleteafterinstall +Source: "..\dist\windows-arm64\ollama.exe"; DestDir: "{app}"; Check: IsArm64(); Flags: ignoreversion 64bit; BeforeInstall: TaskKill('ollama.exe') +#endif + +Source: ".\assets\app.ico"; DestDir: "{app}"; Flags: ignoreversion + +[Icons] +Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}\app.ico" +Name: "{app}\lib\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}\app.ico" +Name: "{userprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}\app.ico" + +[InstallDelete] +Type: files; Name: "{%LOCALAPPDATA}\Ollama\updates" + +[Run] +#if DirExists("..\dist\windows-arm64") +Filename: "{tmp}\vc_redist.arm64.exe"; Parameters: "/install /passive /norestart"; Check: IsArm64() and vc_redist_needed(); StatusMsg: "Installing VC++ Redistributables..."; Flags: waituntilterminated +#endif +#if DirExists("..\dist\windows-amd64") +Filename: "{tmp}\vc_redist.x64.exe"; Parameters: "/install /passive /norestart"; Check: not IsArm64() and vc_redist_needed(); StatusMsg: "Installing VC++ Redistributables..."; Flags: waituntilterminated +#endif +Filename: "{cmd}"; Parameters: "/C set PATH={app};%PATH% & ""{app}\{#MyAppExeName}"""; Flags: postinstall nowait runhidden + +[UninstallRun] +; Filename: "{cmd}"; Parameters: "/C ""taskkill /im ''{#MyAppExeName}'' /f /t"; Flags: runhidden +; Filename: "{cmd}"; Parameters: "/C ""taskkill /im ollama.exe /f /t"; Flags: runhidden +Filename: "taskkill"; Parameters: "/im ""{#MyAppExeName}"" /f /t"; Flags: runhidden +Filename: "taskkill"; Parameters: "/im ""ollama.exe"" /f /t"; Flags: runhidden +; HACK! need to give the server and app enough time to exit +; TODO - convert this to a Pascal code script so it waits until they're no longer running, then completes +Filename: "{cmd}"; Parameters: "/c timeout 5"; Flags: runhidden + +[UninstallDelete] +Type: filesandordirs; Name: "{%TEMP}\ollama*" +Type: filesandordirs; Name: "{%LOCALAPPDATA}\Ollama" +Type: filesandordirs; Name: "{%LOCALAPPDATA}\Programs\Ollama" +Type: filesandordirs; Name: "{%USERPROFILE}\.ollama\history" +Type: filesandordirs; Name: "{userstartup}\{#MyAppName}.lnk" +; NOTE: if the user has a custom OLLAMA_MODELS it will be preserved + +[InstallDelete] +Type: filesandordirs; Name: "{%TEMP}\ollama*" +Type: filesandordirs; Name: "{app}\lib\ollama" + +[Messages] +WizardReady=Ollama +ReadyLabel1=%nLet's get you up and running with your own large language models. +SetupAppRunningError=Another Ollama installer is running.%n%nPlease cancel or finish the other installer, then click OK to continue with this install, or Cancel to exit. + + +;FinishedHeadingLabel=Run your first model +;FinishedLabel=%nRun this command in a PowerShell or cmd terminal.%n%n%n ollama run llama3.2 +;ClickFinish=%n + +[Registry] +Root: HKCU; Subkey: "Environment"; \ + ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}"; \ + Check: NeedsAddPath('{app}') +; Register ollama:// URL protocol +Root: HKCU; Subkey: "Software\Classes\ollama"; ValueType: string; ValueName: ""; ValueData: "URL:Ollama Protocol"; Flags: uninsdeletekey +Root: HKCU; Subkey: "Software\Classes\ollama"; ValueType: string; ValueName: "URL Protocol"; ValueData: ""; Flags: uninsdeletekey +Root: HKCU; Subkey: "Software\Classes\ollama\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1"""; Flags: uninsdeletekey + +[Code] + +function NeedsAddPath(Param: string): boolean; +var + OrigPath: string; +begin + if not RegQueryStringValue(HKEY_CURRENT_USER, + 'Environment', + 'Path', OrigPath) + then begin + Result := True; + exit; + end; + { look for the path with leading and trailing semicolon } + { Pos() returns 0 if not found } + Result := Pos(';' + ExpandConstant(Param) + ';', ';' + OrigPath + ';') = 0; +end; + +{ --- VC Runtime libraries discovery code - Only install vc_redist if it isn't already installed ----- } +const VCRTL_MIN_V1 = 14; +const VCRTL_MIN_V2 = 40; +const VCRTL_MIN_V3 = 33807; +const VCRTL_MIN_V4 = 0; + + // check if the minimum required vc redist is installed (by looking the registry) +function vc_redist_needed (): Boolean; +var + sRegKey: string; + v1: Cardinal; + v2: Cardinal; + v3: Cardinal; + v4: Cardinal; +begin + if (IsArm64()) then begin + sRegKey := 'SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\arm64'; + end else begin + sRegKey := 'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64'; + end; + if (RegQueryDWordValue (HKEY_LOCAL_MACHINE, sRegKey, 'Major', v1) and + RegQueryDWordValue (HKEY_LOCAL_MACHINE, sRegKey, 'Minor', v2) and + RegQueryDWordValue (HKEY_LOCAL_MACHINE, sRegKey, 'Bld', v3) and + RegQueryDWordValue (HKEY_LOCAL_MACHINE, sRegKey, 'RBld', v4)) then + begin + Log ('VC Redist version: ' + IntToStr (v1) + + '.' + IntToStr (v2) + '.' + IntToStr (v3) + + '.' + IntToStr (v4)); + { Version info was found. Return true if later or equal to our + minimal required version RTL_MIN_Vx } + Result := not ( + (v1 > VCRTL_MIN_V1) or ((v1 = VCRTL_MIN_V1) and + ((v2 > VCRTL_MIN_V2) or ((v2 = VCRTL_MIN_V2) and + ((v3 > VCRTL_MIN_V3) or ((v3 = VCRTL_MIN_V3) and + (v4 >= VCRTL_MIN_V4))))))); + end + else + Result := TRUE; +end; + +function GetDirSize(Path: String): Int64; +var + FindRec: TFindRec; + FilePath: string; + Size: Int64; +begin + if FindFirst(Path + '\*', FindRec) then begin + Result := 0; + try + repeat + if (FindRec.Name <> '.') and (FindRec.Name <> '..') then begin + FilePath := Path + '\' + FindRec.Name; + if (FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY) <> 0 then begin + Size := GetDirSize(FilePath); + end else begin + Size := Int64(FindRec.SizeHigh) shl 32 + FindRec.SizeLow; + end; + Result := Result + Size; + end; + until not FindNext(FindRec); + finally + FindClose(FindRec); + end; + end else begin + Log(Format('Failed to list %s', [Path])); + Result := -1; + end; +end; + +var + DeleteModelsChecked: Boolean; + ModelsDir: string; + +procedure InitializeUninstallProgressForm(); +var + UninstallPage: TNewNotebookPage; + UninstallButton: TNewButton; + DeleteModelsCheckbox: TNewCheckBox; + OriginalPageNameLabel: string; + OriginalPageDescriptionLabel: string; + OriginalCancelButtonEnabled: Boolean; + OriginalCancelButtonModalResult: Integer; + ctrl: TWinControl; + ModelDirA: AnsiString; + ModelsSize: Int64; +begin + if not UninstallSilent then begin + ctrl := UninstallProgressForm.CancelButton; + UninstallButton := TNewButton.Create(UninstallProgressForm); + UninstallButton.Parent := UninstallProgressForm; + UninstallButton.Left := ctrl.Left - ctrl.Width - ScaleX(10); + UninstallButton.Top := ctrl.Top; + UninstallButton.Width := ctrl.Width; + UninstallButton.Height := ctrl.Height; + UninstallButton.TabOrder := ctrl.TabOrder; + UninstallButton.Caption := 'Uninstall'; + UninstallButton.ModalResult := mrOK; + UninstallProgressForm.CancelButton.TabOrder := UninstallButton.TabOrder + 1; + UninstallPage := TNewNotebookPage.Create(UninstallProgressForm); + UninstallPage.Notebook := UninstallProgressForm.InnerNotebook; + UninstallPage.Parent := UninstallProgressForm.InnerNotebook; + UninstallPage.Align := alClient; + UninstallProgressForm.InnerNotebook.ActivePage := UninstallPage; + + ctrl := UninstallProgressForm.StatusLabel; + with TNewStaticText.Create(UninstallProgressForm) do begin + Parent := UninstallPage; + Top := ctrl.Top; + Left := ctrl.Left; + Width := ctrl.Width; + Height := ctrl.Height; + AutoSize := False; + ShowAccelChar := False; + Caption := ''; + end; + + if (DirExists(GetEnv('USERPROFILE') + '\.ollama\models\blobs')) then begin + ModelsDir := GetEnv('USERPROFILE') + '\.ollama\models'; + ModelsSize := GetDirSize(ModelsDir); + end; + + DeleteModelsCheckbox := TNewCheckBox.Create(UninstallProgressForm); + DeleteModelsCheckbox.Parent := UninstallPage; + DeleteModelsCheckbox.Top := ctrl.Top + ScaleY(30); + DeleteModelsCheckbox.Left := ctrl.Left; + DeleteModelsCheckbox.Width := ScaleX(300); + if ModelsSize > 1024*1024*1024 then begin + DeleteModelsCheckbox.Caption := 'Remove models (' + IntToStr(ModelsSize/(1024*1024*1024)) + ' GB) ' + ModelsDir; + end else if ModelsSize > 1024*1024 then begin + DeleteModelsCheckbox.Caption := 'Remove models (' + IntToStr(ModelsSize/(1024*1024)) + ' MB) ' + ModelsDir; + end else begin + DeleteModelsCheckbox.Caption := 'Remove models ' + ModelsDir; + end; + DeleteModelsCheckbox.Checked := True; + + OriginalPageNameLabel := UninstallProgressForm.PageNameLabel.Caption; + OriginalPageDescriptionLabel := UninstallProgressForm.PageDescriptionLabel.Caption; + OriginalCancelButtonEnabled := UninstallProgressForm.CancelButton.Enabled; + OriginalCancelButtonModalResult := UninstallProgressForm.CancelButton.ModalResult; + + UninstallProgressForm.PageNameLabel.Caption := ''; + UninstallProgressForm.PageDescriptionLabel.Caption := ''; + UninstallProgressForm.CancelButton.Enabled := True; + UninstallProgressForm.CancelButton.ModalResult := mrCancel; + + if UninstallProgressForm.ShowModal = mrCancel then Abort; + + UninstallButton.Visible := False; + UninstallProgressForm.PageNameLabel.Caption := OriginalPageNameLabel; + UninstallProgressForm.PageDescriptionLabel.Caption := OriginalPageDescriptionLabel; + UninstallProgressForm.CancelButton.Enabled := OriginalCancelButtonEnabled; + UninstallProgressForm.CancelButton.ModalResult := OriginalCancelButtonModalResult; + + UninstallProgressForm.InnerNotebook.ActivePage := UninstallProgressForm.InstallingPage; + + if DeleteModelsCheckbox.Checked then begin + DeleteModelsChecked:=True; + end else begin + DeleteModelsChecked:=False; + end; + end; +end; + +procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep); +begin + if CurUninstallStep = usDone then begin + if DeleteModelsChecked then begin + Log('user requested model cleanup'); + if (VarIsEmpty(ModelsDir)) then begin + Log('cleaning up home directory models') + DelTree(GetEnv('USERPROFILE') + '\.ollama\models', True, True, True); + end else begin + Log('cleaning up custom directory models ' + ModelsDir) + DelTree(ModelsDir + '\blobs', True, True, True); + DelTree(ModelsDir + '\manifests', True, True, True); + end; + end else begin + Log('user requested to preserve model dir'); + end; + end; +end; + +procedure TaskKill(FileName: String); +var + ResultCode: Integer; +begin + Exec('taskkill.exe', '/f /im ' + '"' + FileName + '"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode); +end; diff --git a/app/ollama.rc b/app/ollama.rc new file mode 100644 index 0000000..acd8449 --- /dev/null +++ b/app/ollama.rc @@ -0,0 +1,29 @@ +#include + +VS_VERSION_INFO VERSIONINFO + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "Ollama" + VALUE "InternalName", "Ollama" + VALUE "OriginalFilename", "ollama app.exe" + VALUE "ProductName", "Ollama" + END + END + + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END diff --git a/app/server/server.go b/app/server/server.go new file mode 100644 index 0000000..ef5c057 --- /dev/null +++ b/app/server/server.go @@ -0,0 +1,409 @@ +//go:build windows || darwin + +package server + +import ( + "bufio" + "context" + "errors" + "fmt" + "io" + "log/slog" + "os" + "os/exec" + "path/filepath" + "regexp" + "runtime" + "strconv" + "strings" + "time" + + "github.com/ollama/ollama/app/logrotate" + "github.com/ollama/ollama/app/store" +) + +const restartDelay = time.Second + +// Server is a managed ollama server process +type Server struct { + store *store.Store + bin string // resolved path to `ollama` + log io.WriteCloser + dev bool // true if running with the dev flag +} + +type InferenceCompute struct { + Library string + Variant string + Compute string + Driver string + Name string + VRAM string +} + +type InferenceInfo struct { + Computes []InferenceCompute + DefaultContextLength int +} + +func New(s *store.Store, devMode bool) *Server { + p := resolvePath("ollama") + return &Server{store: s, bin: p, dev: devMode} +} + +func resolvePath(name string) string { + // look in the app bundle first + if exe, _ := os.Executable(); exe != "" { + var dir string + if runtime.GOOS == "windows" { + dir = filepath.Dir(exe) + } else { + dir = filepath.Join(filepath.Dir(exe), "..", "Resources") + } + if _, err := os.Stat(filepath.Join(dir, name)); err == nil { + return filepath.Join(dir, name) + } + } + + // check the development dist path + for _, path := range []string{ + filepath.Join("dist", runtime.GOOS, name), + filepath.Join("dist", runtime.GOOS+"-"+runtime.GOARCH, name), + } { + if _, err := os.Stat(path); err == nil { + return path + } + } + + // fallback to system path + if p, _ := exec.LookPath(name); p != "" { + return p + } + + return name +} + +func ollamaServeArgs(args []string) bool { + if len(args) < 2 { + return false + } + + switch strings.Trim(filepath.Base(args[0]), `"`) { + case "ollama", "ollama.exe": + default: + return false + } + + for _, rawArg := range args[1:] { + arg := strings.Trim(rawArg, `"`) + if strings.HasPrefix(arg, "-") { + continue + } + + return arg == "serve" || arg == "start" + } + + return false +} + +// cleanup checks the pid file for a running ollama process +// and shuts it down gracefully if it is running +func cleanup() error { + data, err := os.ReadFile(pidFile) + if err != nil { + if os.IsNotExist(err) { + return nil + } + return err + } + defer os.Remove(pidFile) + + pid, err := strconv.Atoi(strings.TrimSpace(string(data))) + if err != nil { + return err + } + + proc, err := os.FindProcess(pid) + if err != nil { + return nil + } + + ok, err := terminated(pid) + if err != nil { + slog.Debug("cleanup: error checking if terminated", "pid", pid, "err", err) + } + if ok { + return nil + } + + slog.Info("detected previous ollama process, cleaning up", "pid", pid) + return stop(proc) +} + +// stop waits for a process with the provided pid to exit by polling +// `terminated(pid)`. If the process has not exited within 5 seconds, it logs a +// warning and kills the process. +func stop(proc *os.Process) error { + if proc == nil { + return nil + } + + if err := terminate(proc); err != nil { + slog.Warn("graceful terminate failed, killing", "err", err) + return proc.Kill() + } + + deadline := time.NewTimer(5 * time.Second) + defer deadline.Stop() + + for { + select { + case <-deadline.C: + slog.Warn("timeout waiting for graceful shutdown; killing", "pid", proc.Pid) + return proc.Kill() + default: + ok, err := terminated(proc.Pid) + if err != nil { + slog.Error("error checking if ollama process is terminated", "err", err) + return err + } + if ok { + return nil + } + time.Sleep(10 * time.Millisecond) + } + } +} + +func (s *Server) Run(ctx context.Context) error { + l, err := openRotatingLog() + if err != nil { + return err + } + s.log = l + defer s.log.Close() + + if err := cleanup(); err != nil { + slog.Warn("failed to cleanup previous ollama process", "err", err) + } + + reaped := false + for ctx.Err() == nil { + select { + case <-ctx.Done(): + return ctx.Err() + case <-time.After(restartDelay): + } + + cmd, err := s.cmd(ctx) + if err != nil { + return err + } + + if err := cmd.Start(); err != nil { + return err + } + + err = os.WriteFile(pidFile, []byte(strconv.Itoa(cmd.Process.Pid)), 0o644) + if err != nil { + slog.Warn("failed to write pid file", "file", pidFile, "err", err) + } + + if err = cmd.Wait(); err != nil && !errors.Is(err, context.Canceled) { + var exitErr *exec.ExitError + if errors.As(err, &exitErr) && exitErr.ExitCode() == 1 && !s.dev && !reaped { + reaped = true + // This could be a port conflict, try to kill any existing ollama processes + if err := reapServers(); err != nil { + slog.Warn("failed to stop existing ollama server", "err", err) + } else { + slog.Debug("conflicting server stopped, waiting for port to be released") + continue + } + } + slog.Error("ollama exited", "err", err) + } + } + return ctx.Err() +} + +func (s *Server) cmd(ctx context.Context) (*exec.Cmd, error) { + settings, err := s.store.Settings() + if err != nil { + return nil, err + } + + cloudDisabled, err := s.store.CloudDisabled() + if err != nil { + return nil, err + } + + cmd := commandContext(ctx, s.bin, "serve") + cmd.Stdout, cmd.Stderr = s.log, s.log + + // Copy and mutate the environment to merge in settings the user has specified without dups + env := map[string]string{} + for _, kv := range os.Environ() { + s := strings.SplitN(kv, "=", 2) + env[s[0]] = s[1] + } + if settings.Expose { + env["OLLAMA_HOST"] = "0.0.0.0" + } + if settings.Browser { + env["OLLAMA_ORIGINS"] = "*" + } + if settings.Models != "" { + if _, err := os.Stat(settings.Models); err == nil { + env["OLLAMA_MODELS"] = settings.Models + } else { + slog.Warn("models path not accessible, using default", "path", settings.Models, "err", err) + } + } + if settings.ContextLength > 0 { + env["OLLAMA_CONTEXT_LENGTH"] = strconv.Itoa(settings.ContextLength) + } + if cloudDisabled { + env["OLLAMA_NO_CLOUD"] = "1" + } else { + env["OLLAMA_NO_CLOUD"] = "0" + } + cmd.Env = []string{} + for k, v := range env { + cmd.Env = append(cmd.Env, k+"="+v) + } + + cmd.Cancel = func() error { + if cmd.Process == nil { + return nil + } + return stop(cmd.Process) + } + + return cmd, nil +} + +func openRotatingLog() (io.WriteCloser, error) { + // TODO consider rotation based on size or time, not just every server invocation + dir := filepath.Dir(serverLogPath) + if err := os.MkdirAll(dir, 0o755); err != nil { + return nil, fmt.Errorf("create log directory: %w", err) + } + + logrotate.Rotate(serverLogPath) + f, err := os.OpenFile(serverLogPath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o644) + if err != nil { + return nil, fmt.Errorf("open log file: %w", err) + } + return f, nil +} + +// Attempt to retrieve inference compute information from the server +// log. Set ctx to timeout to control how long to wait for the logs to appear +func GetInferenceInfo(ctx context.Context) (*InferenceInfo, error) { + info := &InferenceInfo{} + computeMarker := regexp.MustCompile(`inference compute.*library=`) + defaultCtxMarker := regexp.MustCompile(`vram-based default context`) + defaultCtxRegex := regexp.MustCompile(`default_num_ctx=(\d+)`) + + q := `inference compute.*%s=["]([^"]*)["]` + nq := `inference compute.*%s=(\S+)\s` + type regex struct { + q *regexp.Regexp + nq *regexp.Regexp + } + regexes := map[string]regex{ + "library": { + q: regexp.MustCompile(fmt.Sprintf(q, "library")), + nq: regexp.MustCompile(fmt.Sprintf(nq, "library")), + }, + "variant": { + q: regexp.MustCompile(fmt.Sprintf(q, "variant")), + nq: regexp.MustCompile(fmt.Sprintf(nq, "variant")), + }, + "compute": { + q: regexp.MustCompile(fmt.Sprintf(q, "compute")), + nq: regexp.MustCompile(fmt.Sprintf(nq, "compute")), + }, + "driver": { + q: regexp.MustCompile(fmt.Sprintf(q, "driver")), + nq: regexp.MustCompile(fmt.Sprintf(nq, "driver")), + }, + "name": { + q: regexp.MustCompile(fmt.Sprintf(q, "name")), + nq: regexp.MustCompile(fmt.Sprintf(nq, "name")), + }, + "total": { + q: regexp.MustCompile(fmt.Sprintf(q, "total")), + nq: regexp.MustCompile(fmt.Sprintf(nq, "total")), + }, + } + get := func(field, line string) string { + regex, ok := regexes[field] + if !ok { + slog.Warn("missing field", "field", field) + return "" + } + match := regex.q.FindStringSubmatch(line) + + if len(match) > 1 { + return match[1] + } + match = regex.nq.FindStringSubmatch(line) + if len(match) > 1 { + return match[1] + } + return "" + } + for { + select { + case <-ctx.Done(): + return nil, fmt.Errorf("timeout scanning server log for inference compute details") + default: + } + file, err := os.Open(serverLogPath) + if err != nil { + slog.Debug("failed to open server log", "log", serverLogPath, "error", err) + time.Sleep(time.Second) + continue + } + defer file.Close() + scanner := bufio.NewScanner(file) + for scanner.Scan() { + line := scanner.Text() + // Check for inference compute lines + if computeMarker.MatchString(line) { + ic := InferenceCompute{ + Library: get("library", line), + Variant: get("variant", line), + Compute: get("compute", line), + Driver: get("driver", line), + Name: get("name", line), + VRAM: get("total", line), + } + + slog.Info("Matched", "inference compute", ic) + info.Computes = append(info.Computes, ic) + continue + } + // Check for default context length line + if defaultCtxMarker.MatchString(line) { + match := defaultCtxRegex.FindStringSubmatch(line) + if len(match) > 1 { + numCtx, err := strconv.Atoi(match[1]) + if err == nil { + info.DefaultContextLength = numCtx + slog.Info("Matched default context length", "default_num_ctx", numCtx) + } + } + return info, nil + } + // If we've found compute info but hit a non-matching line, return what we have + // This handles older server versions that don't log the default context line + if len(info.Computes) > 0 { + return info, nil + } + } + time.Sleep(100 * time.Millisecond) + } +} diff --git a/app/server/server_test.go b/app/server/server_test.go new file mode 100644 index 0000000..cb96742 --- /dev/null +++ b/app/server/server_test.go @@ -0,0 +1,400 @@ +//go:build windows || darwin + +package server + +import ( + "context" + "os" + "path/filepath" + "reflect" + "strings" + "testing" + "time" + + "github.com/ollama/ollama/app/store" +) + +func TestNew(t *testing.T) { + tmpDir := t.TempDir() + st := &store.Store{DBPath: filepath.Join(tmpDir, "db.sqlite")} + defer st.Close() // Ensure database is closed before cleanup + s := New(st, false) + + if s == nil { + t.Fatal("expected non-nil server") + } + + if s.bin == "" { + t.Error("expected non-empty bin path") + } +} + +func TestServerCmd(t *testing.T) { + os.Unsetenv("OLLAMA_HOST") + os.Unsetenv("OLLAMA_ORIGINS") + os.Unsetenv("OLLAMA_MODELS") + var defaultModels string + home, err := os.UserHomeDir() + if err == nil { + defaultModels = filepath.Join(home, ".ollama", "models") + os.MkdirAll(defaultModels, 0o755) + } + + tmpModels := t.TempDir() + tests := []struct { + name string + settings store.Settings + want []string + dont []string + }{ + { + name: "default", + settings: store.Settings{}, + want: []string{"OLLAMA_MODELS=" + defaultModels}, + dont: []string{"OLLAMA_HOST=", "OLLAMA_ORIGINS="}, + }, + { + name: "expose", + settings: store.Settings{Expose: true}, + want: []string{"OLLAMA_HOST=0.0.0.0", "OLLAMA_MODELS=" + defaultModels}, + dont: []string{"OLLAMA_ORIGINS="}, + }, + { + name: "browser", + settings: store.Settings{Browser: true}, + want: []string{"OLLAMA_ORIGINS=*", "OLLAMA_MODELS=" + defaultModels}, + dont: []string{"OLLAMA_HOST="}, + }, + { + name: "models", + settings: store.Settings{Models: tmpModels}, + want: []string{"OLLAMA_MODELS=" + tmpModels}, + dont: []string{"OLLAMA_HOST=", "OLLAMA_ORIGINS="}, + }, + { + name: "inaccessible_models", + settings: store.Settings{Models: "/nonexistent/external/drive/models"}, + want: []string{}, + dont: []string{"OLLAMA_MODELS="}, + }, + { + name: "all", + settings: store.Settings{ + Expose: true, + Browser: true, + Models: tmpModels, + }, + want: []string{ + "OLLAMA_HOST=0.0.0.0", + "OLLAMA_ORIGINS=*", + "OLLAMA_MODELS=" + tmpModels, + }, + dont: []string{}, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + tmpDir := t.TempDir() + st := &store.Store{DBPath: filepath.Join(tmpDir, "db.sqlite")} + defer st.Close() // Ensure database is closed before cleanup + st.SetSettings(tt.settings) + s := &Server{ + store: st, + } + + cmd, err := s.cmd(t.Context()) + if err != nil { + t.Fatalf("s.cmd() error = %v", err) + } + + for _, want := range tt.want { + found := false + for _, env := range cmd.Env { + if strings.HasPrefix(env, want) { + found = true + break + } + } + if !found { + t.Errorf("expected environment variable containing %s", want) + } + } + + for _, dont := range tt.dont { + for _, env := range cmd.Env { + if strings.HasPrefix(env, dont) { + t.Errorf("unexpected environment variable: %s", env) + } + } + } + + if cmd.Cancel == nil { + t.Error("expected non-nil cancel function") + } + }) + } +} + +func TestServerCmdCloudSettingEnv(t *testing.T) { + tests := []struct { + name string + envValue string + configContent string + want string + }{ + { + name: "default cloud enabled", + want: "OLLAMA_NO_CLOUD=0", + }, + { + name: "env disables cloud", + envValue: "1", + want: "OLLAMA_NO_CLOUD=1", + }, + { + name: "config disables cloud", + configContent: `{"disable_ollama_cloud": true}`, + want: "OLLAMA_NO_CLOUD=1", + }, + { + name: "invalid env disables cloud", + envValue: "invalid", + want: "OLLAMA_NO_CLOUD=1", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + tmpHome := t.TempDir() + t.Setenv("HOME", tmpHome) + t.Setenv("USERPROFILE", tmpHome) + t.Setenv("OLLAMA_NO_CLOUD", tt.envValue) + + if tt.configContent != "" { + configDir := filepath.Join(tmpHome, ".ollama") + if err := os.MkdirAll(configDir, 0o755); err != nil { + t.Fatalf("mkdir config dir: %v", err) + } + configPath := filepath.Join(configDir, "server.json") + if err := os.WriteFile(configPath, []byte(tt.configContent), 0o644); err != nil { + t.Fatalf("write config: %v", err) + } + } + + st := &store.Store{DBPath: filepath.Join(t.TempDir(), "db.sqlite")} + defer st.Close() + + s := &Server{store: st} + cmd, err := s.cmd(t.Context()) + if err != nil { + t.Fatalf("s.cmd() error = %v", err) + } + + found := false + for _, env := range cmd.Env { + if env == tt.want { + found = true + break + } + } + if !found { + t.Fatalf("expected environment variable %q in command env", tt.want) + } + }) + } +} + +func TestOllamaServeArgs(t *testing.T) { + tests := []struct { + name string + args []string + want bool + }{ + { + name: "system ollama serve", + args: []string{"ollama", "serve"}, + want: true, + }, + { + name: "relative path ollama serve", + args: []string{"./ollama", "serve"}, + want: true, + }, + { + name: "serve after other flags", + args: []string{"./ollama", "--verbose", "serve"}, + want: true, + }, + { + name: "start alias", + args: []string{"ollama", "start"}, + want: true, + }, + { + name: "launch command", + args: []string{"ollama", "launch", "opencode"}, + want: false, + }, + { + name: "run command with model named serve", + args: []string{"ollama", "run", "serve"}, + want: false, + }, + { + name: "launch command with serve in passthrough args", + args: []string{"ollama", "launch", "codex", "--", "-p", "serve"}, + want: false, + }, + { + name: "different executable", + args: []string{"go", "run", "serve"}, + want: false, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := ollamaServeArgs(tt.args); got != tt.want { + t.Fatalf("ollamaServeArgs(%v) = %v, want %v", tt.args, got, tt.want) + } + }) + } +} + +func TestGetInferenceInfo(t *testing.T) { + tests := []struct { + name string + log string + expComputes []InferenceCompute + expDefaultCtxLen int + }{ + { + name: "metal", + log: `time=2025-06-30T09:23:07.374-07:00 level=DEBUG source=sched.go:108 msg="starting llm scheduler" +time=2025-06-30T09:23:07.416-07:00 level=INFO source=types.go:130 msg="inference compute" id=0 library=metal variant="" compute="" driver=0.0 name="" total="96.0 GiB" available="96.0 GiB" +time=2025-06-30T09:23:07.417-07:00 level=INFO source=routes.go:1721 msg="vram-based default context" total_vram="96.0 GiB" default_num_ctx=262144 +time=2025-06-30T09:25:56.197-07:00 level=DEBUG source=ggml.go:155 msg="key not found" key=general.alignment default=32 +`, + expComputes: []InferenceCompute{{ + Library: "metal", + Driver: "0.0", + VRAM: "96.0 GiB", + }}, + expDefaultCtxLen: 262144, + }, + { + name: "cpu", + log: `time=2025-07-01T17:59:51.470Z level=INFO source=gpu.go:377 msg="no compatible GPUs were discovered" +time=2025-07-01T17:59:51.470Z level=INFO source=types.go:130 msg="inference compute" id=0 library=cpu variant="" compute="" driver=0.0 name="" total="31.3 GiB" available="30.4 GiB" +time=2025-07-01T17:59:51.471Z level=INFO source=routes.go:1721 msg="vram-based default context" total_vram="31.3 GiB" default_num_ctx=32768 +[GIN] 2025/07/01 - 18:00:09 | 200 | 50.263µs | 100.126.204.152 | HEAD "/" +`, + expComputes: []InferenceCompute{{ + Library: "cpu", + Driver: "0.0", + VRAM: "31.3 GiB", + }}, + expDefaultCtxLen: 32768, + }, + { + name: "cuda1", + log: `time=2025-07-01T19:33:43.162Z level=DEBUG source=amd_linux.go:419 msg="amdgpu driver not detected /sys/module/amdgpu" +releasing cuda driver library +time=2025-07-01T19:33:43.162Z level=INFO source=types.go:130 msg="inference compute" id=GPU-452cac9f-6960-839c-4fb3-0cec83699196 library=cuda variant=v12 compute=6.1 driver=12.7 name="NVIDIA GeForce GT 1030" total="3.9 GiB" available="3.9 GiB" +time=2025-07-01T19:33:43.163Z level=INFO source=routes.go:1721 msg="vram-based default context" total_vram="3.9 GiB" default_num_ctx=4096 +[GIN] 2025/07/01 - 18:00:09 | 200 | 50.263µs | 100.126.204.152 | HEAD "/" +`, + expComputes: []InferenceCompute{{ + Library: "cuda", + Variant: "v12", + Compute: "6.1", + Driver: "12.7", + Name: "NVIDIA GeForce GT 1030", + VRAM: "3.9 GiB", + }}, + expDefaultCtxLen: 4096, + }, + { + name: "frank", + log: `time=2025-07-01T19:36:13.315Z level=INFO source=amd_linux.go:386 msg="amdgpu is supported" gpu=GPU-9abb57639fa80c50 gpu_type=gfx1030 + releasing cuda driver library + time=2025-07-01T19:36:13.315Z level=INFO source=types.go:130 msg="inference compute" id=GPU-d6de3398-9932-6902-11ec-fee8e424c8a2 library=cuda variant=v12 compute=7.5 driver=12.8 name="NVIDIA GeForce RTX 2080 Ti" total="10.6 GiB" available="10.4 GiB" + time=2025-07-01T19:36:13.315Z level=INFO source=types.go:130 msg="inference compute" id=GPU-9abb57639fa80c50 library=rocm variant="" compute=gfx1030 driver=6.3 name=1002:73bf total="16.0 GiB" available="1.3 GiB" + time=2025-07-01T19:36:13.316Z level=INFO source=routes.go:1721 msg="vram-based default context" total_vram="26.6 GiB" default_num_ctx=32768 + [GIN] 2025/07/01 - 18:00:09 | 200 | 50.263µs | 100.126.204.152 | HEAD "/" + `, + expComputes: []InferenceCompute{ + { + Library: "cuda", + Variant: "v12", + Compute: "7.5", + Driver: "12.8", + Name: "NVIDIA GeForce RTX 2080 Ti", + VRAM: "10.6 GiB", + }, + { + Library: "rocm", + Compute: "gfx1030", + Driver: "6.3", + Name: "1002:73bf", + VRAM: "16.0 GiB", + }, + }, + expDefaultCtxLen: 32768, + }, + { + name: "missing_default_context", + log: `time=2025-06-30T09:23:07.374-07:00 level=DEBUG source=sched.go:108 msg="starting llm scheduler" +time=2025-06-30T09:23:07.416-07:00 level=INFO source=types.go:130 msg="inference compute" id=0 library=metal variant="" compute="" driver=0.0 name="" total="96.0 GiB" available="96.0 GiB" +time=2025-06-30T09:25:56.197-07:00 level=DEBUG source=ggml.go:155 msg="key not found" key=general.alignment default=32 +`, + expComputes: []InferenceCompute{{ + Library: "metal", + Driver: "0.0", + VRAM: "96.0 GiB", + }}, + expDefaultCtxLen: 0, // No default context line, should return 0 + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + tmpDir := t.TempDir() + serverLogPath = filepath.Join(tmpDir, "server.log") + err := os.WriteFile(serverLogPath, []byte(tt.log), 0o644) + if err != nil { + t.Fatalf("failed to write log file %s: %s", serverLogPath, err) + } + ctx, cancel := context.WithTimeout(t.Context(), 10*time.Millisecond) + defer cancel() + info, err := GetInferenceInfo(ctx) + if err != nil { + t.Fatalf("failed to get inference info: %v", err) + } + if !reflect.DeepEqual(info.Computes, tt.expComputes) { + t.Fatalf("computes mismatch\ngot:\n%#v\nwant:\n%#v", info.Computes, tt.expComputes) + } + if info.DefaultContextLength != tt.expDefaultCtxLen { + t.Fatalf("default context length mismatch: got %d, want %d", info.DefaultContextLength, tt.expDefaultCtxLen) + } + }) + } +} + +func TestGetInferenceInfoTimeout(t *testing.T) { + ctx, cancel := context.WithTimeout(t.Context(), 10*time.Millisecond) + defer cancel() + tmpDir := t.TempDir() + serverLogPath = filepath.Join(tmpDir, "server.log") + err := os.WriteFile(serverLogPath, []byte("foo\nbar\nbaz\n"), 0o644) + if err != nil { + t.Fatalf("failed to write log file %s: %s", serverLogPath, err) + } + _, err = GetInferenceInfo(ctx) + if err == nil { + t.Fatal("expected timeout") + } + if !strings.Contains(err.Error(), "timeout") { + t.Fatalf("unexpected error: %s", err) + } +} diff --git a/app/server/server_unix.go b/app/server/server_unix.go new file mode 100644 index 0000000..1f40f5b --- /dev/null +++ b/app/server/server_unix.go @@ -0,0 +1,117 @@ +//go:build darwin + +package server + +import ( + "context" + "errors" + "fmt" + "log/slog" + "os" + "os/exec" + "path/filepath" + "strconv" + "strings" + "syscall" +) + +var ( + pidFile = filepath.Join(os.Getenv("HOME"), "Library", "Application Support", "Ollama", "ollama.pid") + serverLogPath = filepath.Join(os.Getenv("HOME"), ".ollama", "logs", "server.log") +) + +func commandContext(ctx context.Context, name string, arg ...string) *exec.Cmd { + return exec.CommandContext(ctx, name, arg...) +} + +func terminate(proc *os.Process) error { + return proc.Signal(os.Interrupt) +} + +func terminated(pid int) (bool, error) { + proc, err := os.FindProcess(pid) + if err != nil { + return false, fmt.Errorf("failed to find process: %v", err) + } + + err = proc.Signal(syscall.Signal(0)) + if err != nil { + if errors.Is(err, os.ErrProcessDone) || errors.Is(err, syscall.ESRCH) { + return true, nil + } + + return false, fmt.Errorf("error signaling process: %v", err) + } + + return false, nil +} + +func ollamaServeProcess(pid int) bool { + output, err := exec.Command("ps", "-p", strconv.Itoa(pid), "-o", "args=").Output() + if err != nil { + slog.Debug("failed to inspect ollama process", "pid", pid, "err", err) + return false + } + + return ollamaServeArgs(strings.Fields(strings.TrimSpace(string(output)))) +} + +// reapServers kills external ollama serve processes except our own. +func reapServers() error { + // Get our own PID to avoid killing ourselves + currentPID := os.Getpid() + + // Use pkill to kill ollama processes + // -x matches the whole command name exactly + // We'll get the list first, then kill selectively + cmd := exec.Command("pgrep", "-x", "ollama") + output, err := cmd.Output() + if err != nil { + // No ollama processes found + slog.Debug("no ollama processes found") + return nil //nolint:nilerr + } + + pidsStr := strings.TrimSpace(string(output)) + if pidsStr == "" { + return nil + } + + pids := strings.Split(pidsStr, "\n") + for _, pidStr := range pids { + pidStr = strings.TrimSpace(pidStr) + if pidStr == "" { + continue + } + + pid, err := strconv.Atoi(pidStr) + if err != nil { + slog.Debug("failed to parse PID", "pidStr", pidStr, "err", err) + continue + } + if pid == currentPID { + continue + } + if !ollamaServeProcess(pid) { + continue + } + + proc, err := os.FindProcess(pid) + if err != nil { + slog.Debug("failed to find process", "pid", pid, "err", err) + continue + } + + if err := proc.Signal(syscall.SIGTERM); err != nil { + // Try SIGKILL if SIGTERM fails + if err := proc.Signal(syscall.SIGKILL); err != nil { + slog.Warn("failed to stop external ollama process", "pid", pid, "err", err) + continue + } + } + + slog.Info("stopped external ollama process", "pid", pid) + } + + return nil +} diff --git a/app/server/server_windows.go b/app/server/server_windows.go new file mode 100644 index 0000000..06d7ba6 --- /dev/null +++ b/app/server/server_windows.go @@ -0,0 +1,174 @@ +package server + +import ( + "context" + "fmt" + "log/slog" + "os" + "os/exec" + "path/filepath" + "strconv" + "strings" + "syscall" + + "golang.org/x/sys/windows" +) + +var ( + pidFile = filepath.Join(os.Getenv("LOCALAPPDATA"), "Ollama", "ollama.pid") + serverLogPath = filepath.Join(os.Getenv("LOCALAPPDATA"), "Ollama", "server.log") +) + +func commandContext(ctx context.Context, name string, arg ...string) *exec.Cmd { + cmd := exec.CommandContext(ctx, name, arg...) + cmd.SysProcAttr = &syscall.SysProcAttr{ + HideWindow: true, + CreationFlags: windows.CREATE_NEW_PROCESS_GROUP, + } + + return cmd +} + +func terminate(proc *os.Process) error { + dll, err := windows.LoadDLL("kernel32.dll") + if err != nil { + return err + } + defer dll.Release() + + pid := proc.Pid + + f, err := dll.FindProc("AttachConsole") + if err != nil { + return err + } + + r1, _, err := f.Call(uintptr(pid)) + if r1 == 0 && err != syscall.ERROR_ACCESS_DENIED { + return err + } + + f, err = dll.FindProc("SetConsoleCtrlHandler") + if err != nil { + return err + } + + r1, _, err = f.Call(0, 1) + if r1 == 0 { + return err + } + + f, err = dll.FindProc("GenerateConsoleCtrlEvent") + if err != nil { + return err + } + + r1, _, err = f.Call(windows.CTRL_BREAK_EVENT, uintptr(pid)) + if r1 == 0 { + return err + } + + r1, _, err = f.Call(windows.CTRL_C_EVENT, uintptr(pid)) + if r1 == 0 { + return err + } + + return nil +} + +const STILL_ACTIVE = 259 + +func terminated(pid int) (bool, error) { + hProcess, err := windows.OpenProcess(windows.PROCESS_QUERY_INFORMATION, false, uint32(pid)) + if err != nil { + if errno, ok := err.(windows.Errno); ok && errno == windows.ERROR_INVALID_PARAMETER { + return true, nil + } + return false, fmt.Errorf("failed to open process: %v", err) + } + defer windows.CloseHandle(hProcess) + + var exitCode uint32 + err = windows.GetExitCodeProcess(hProcess, &exitCode) + if err != nil { + return false, fmt.Errorf("failed to get exit code: %v", err) + } + + if exitCode == STILL_ACTIVE { + return false, nil + } + + return true, nil +} + +func ollamaServeProcess(pid int) bool { + cmd := exec.Command("wmic", "process", "where", fmt.Sprintf("ProcessId=%d", pid), "get", "CommandLine", "/value") + cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true} + output, err := cmd.Output() + if err != nil { + slog.Debug("failed to inspect ollama process", "pid", pid, "err", err) + return false + } + + for _, line := range strings.Split(string(output), "\n") { + line = strings.TrimSpace(line) + commandLine, ok := strings.CutPrefix(line, "CommandLine=") + if !ok { + continue + } + + return ollamaServeArgs(strings.Fields(strings.ToLower(commandLine))) + } + + return false +} + +// reapServers kills external ollama serve processes except our own. +func reapServers() error { + // Get current process ID to avoid killing ourselves + currentPID := os.Getpid() + + // Use wmic to find ollama processes + cmd := exec.Command("wmic", "process", "where", "name='ollama.exe'", "get", "ProcessId") + cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true} + output, err := cmd.Output() + if err != nil { + // No ollama processes found + slog.Debug("no ollama processes found") + return nil //nolint:nilerr + } + + lines := strings.Split(string(output), "\n") + var pids []string + for _, line := range lines { + line = strings.TrimSpace(line) + if line == "" || line == "ProcessId" { + continue + } + + if _, err := strconv.Atoi(line); err == nil { + pids = append(pids, line) + } + } + + for _, pidStr := range pids { + pid, err := strconv.Atoi(pidStr) + if err != nil { + continue + } + + if pid == currentPID { + continue + } + if !ollamaServeProcess(pid) { + continue + } + + cmd := exec.Command("taskkill", "/F", "/PID", pidStr) + if err := cmd.Run(); err != nil { + slog.Warn("failed to kill ollama process", "pid", pid, "err", err) + } + } + + return nil +} diff --git a/app/store/cloud_config.go b/app/store/cloud_config.go new file mode 100644 index 0000000..7a71cbd --- /dev/null +++ b/app/store/cloud_config.go @@ -0,0 +1,128 @@ +//go:build windows || darwin + +package store + +import ( + "encoding/json" + "errors" + "fmt" + "os" + "path/filepath" + + "github.com/ollama/ollama/envconfig" +) + +const serverConfigFilename = "server.json" + +type serverConfig struct { + DisableOllamaCloud bool `json:"disable_ollama_cloud,omitempty"` +} + +// CloudDisabled returns whether cloud features should be disabled. +// The source of truth is: OLLAMA_NO_CLOUD OR ~/.ollama/server.json:disable_ollama_cloud. +func (s *Store) CloudDisabled() (bool, error) { + disabled, _, err := s.CloudStatus() + return disabled, err +} + +// CloudStatus returns whether cloud is disabled and the source of that decision. +// Source is one of: "none", "env", "config", "both". +func (s *Store) CloudStatus() (bool, string, error) { + if err := s.ensureDB(); err != nil { + return false, "", err + } + + configDisabled, err := readServerConfigCloudDisabled() + if err != nil { + return false, "", err + } + + envDisabled := envconfig.NoCloudEnv() + return envDisabled || configDisabled, cloudStatusSource(envDisabled, configDisabled), nil +} + +// SetCloudEnabled writes the cloud setting to ~/.ollama/server.json. +func (s *Store) SetCloudEnabled(enabled bool) error { + if err := s.ensureDB(); err != nil { + return err + } + return setCloudEnabled(enabled) +} + +func setCloudEnabled(enabled bool) error { + configPath, err := serverConfigPath() + if err != nil { + return err + } + + if err := os.MkdirAll(filepath.Dir(configPath), 0o755); err != nil { + return fmt.Errorf("create server config directory: %w", err) + } + + configMap := map[string]any{} + if data, err := os.ReadFile(configPath); err == nil { + if err := json.Unmarshal(data, &configMap); err != nil { + // If the existing file is invalid JSON, overwrite with a fresh object. + configMap = map[string]any{} + } + } else if !errors.Is(err, os.ErrNotExist) { + return fmt.Errorf("read server config: %w", err) + } + + configMap["disable_ollama_cloud"] = !enabled + + data, err := json.MarshalIndent(configMap, "", " ") + if err != nil { + return fmt.Errorf("marshal server config: %w", err) + } + data = append(data, '\n') + + if err := os.WriteFile(configPath, data, 0o644); err != nil { + return fmt.Errorf("write server config: %w", err) + } + + return nil +} + +func readServerConfigCloudDisabled() (bool, error) { + configPath, err := serverConfigPath() + if err != nil { + return false, err + } + + data, err := os.ReadFile(configPath) + if err != nil { + if errors.Is(err, os.ErrNotExist) { + return false, nil + } + return false, fmt.Errorf("read server config: %w", err) + } + + var cfg serverConfig + // Invalid or unexpected JSON should not block startup; treat as default. + if json.Unmarshal(data, &cfg) == nil { + return cfg.DisableOllamaCloud, nil + } + return false, nil +} + +func serverConfigPath() (string, error) { + home, err := os.UserHomeDir() + if err != nil { + return "", fmt.Errorf("resolve home directory: %w", err) + } + return filepath.Join(home, ".ollama", serverConfigFilename), nil +} + +func cloudStatusSource(envDisabled bool, configDisabled bool) string { + switch { + case envDisabled && configDisabled: + return "both" + case envDisabled: + return "env" + case configDisabled: + return "config" + default: + return "none" + } +} diff --git a/app/store/cloud_config_test.go b/app/store/cloud_config_test.go new file mode 100644 index 0000000..a8154d6 --- /dev/null +++ b/app/store/cloud_config_test.go @@ -0,0 +1,130 @@ +//go:build windows || darwin + +package store + +import ( + "encoding/json" + "os" + "path/filepath" + "testing" +) + +func TestCloudDisabled(t *testing.T) { + tests := []struct { + name string + envValue string + configContent string + wantDisabled bool + wantSource string + }{ + { + name: "default enabled", + wantDisabled: false, + wantSource: "none", + }, + { + name: "env disables cloud", + envValue: "1", + wantDisabled: true, + wantSource: "env", + }, + { + name: "config disables cloud", + configContent: `{"disable_ollama_cloud": true}`, + wantDisabled: true, + wantSource: "config", + }, + { + name: "env and config", + envValue: "1", + configContent: `{"disable_ollama_cloud": false}`, + wantDisabled: true, + wantSource: "env", + }, + { + name: "invalid config is ignored", + configContent: `{bad`, + wantDisabled: false, + wantSource: "none", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + tmpHome := t.TempDir() + setTestHome(t, tmpHome) + t.Setenv("OLLAMA_NO_CLOUD", tt.envValue) + + if tt.configContent != "" { + configDir := filepath.Join(tmpHome, ".ollama") + if err := os.MkdirAll(configDir, 0o755); err != nil { + t.Fatalf("mkdir config dir: %v", err) + } + configPath := filepath.Join(configDir, serverConfigFilename) + if err := os.WriteFile(configPath, []byte(tt.configContent), 0o644); err != nil { + t.Fatalf("write config: %v", err) + } + } + + s := &Store{DBPath: filepath.Join(tmpHome, "db.sqlite")} + defer s.Close() + + disabled, err := s.CloudDisabled() + if err != nil { + t.Fatalf("CloudDisabled() error = %v", err) + } + if disabled != tt.wantDisabled { + t.Fatalf("CloudDisabled() = %v, want %v", disabled, tt.wantDisabled) + } + + statusDisabled, source, err := s.CloudStatus() + if err != nil { + t.Fatalf("CloudStatus() error = %v", err) + } + if statusDisabled != tt.wantDisabled { + t.Fatalf("CloudStatus() disabled = %v, want %v", statusDisabled, tt.wantDisabled) + } + if source != tt.wantSource { + t.Fatalf("CloudStatus() source = %v, want %v", source, tt.wantSource) + } + }) + } +} + +func TestSetCloudEnabled(t *testing.T) { + tmpHome := t.TempDir() + setTestHome(t, tmpHome) + + configDir := filepath.Join(tmpHome, ".ollama") + if err := os.MkdirAll(configDir, 0o755); err != nil { + t.Fatalf("mkdir config dir: %v", err) + } + configPath := filepath.Join(configDir, serverConfigFilename) + if err := os.WriteFile(configPath, []byte(`{"another_key":"value","disable_ollama_cloud":true}`), 0o644); err != nil { + t.Fatalf("seed config: %v", err) + } + + s := &Store{DBPath: filepath.Join(tmpHome, "db.sqlite")} + defer s.Close() + + if err := s.SetCloudEnabled(true); err != nil { + t.Fatalf("SetCloudEnabled(true) error = %v", err) + } + + data, err := os.ReadFile(configPath) + if err != nil { + t.Fatalf("read config: %v", err) + } + + var got map[string]any + if err := json.Unmarshal(data, &got); err != nil { + t.Fatalf("unmarshal config: %v", err) + } + + if got["disable_ollama_cloud"] != false { + t.Fatalf("disable_ollama_cloud = %v, want false", got["disable_ollama_cloud"]) + } + if got["another_key"] != "value" { + t.Fatalf("another_key = %v, want value", got["another_key"]) + } +} diff --git a/app/store/database.go b/app/store/database.go new file mode 100644 index 0000000..6c6767c --- /dev/null +++ b/app/store/database.go @@ -0,0 +1,1347 @@ +//go:build windows || darwin + +package store + +import ( + "database/sql" + "encoding/json" + "fmt" + "strings" + "time" + + _ "github.com/mattn/go-sqlite3" +) + +// currentSchemaVersion defines the current database schema version. +// Increment this when making schema changes that require migrations. +const currentSchemaVersion = 16 + +// database wraps the SQLite connection. +// SQLite handles its own locking for concurrent access: +// - Multiple readers can access the database simultaneously +// - Writers are serialized (only one writer at a time) +// - WAL mode allows readers to not block writers +// This means we don't need application-level locks for database operations. +type database struct { + conn *sql.DB +} + +func newDatabase(dbPath string) (*database, error) { + // Open database connection + conn, err := sql.Open("sqlite3", dbPath+"?_foreign_keys=on&_journal_mode=WAL&_busy_timeout=5000&_txlock=immediate") + if err != nil { + return nil, fmt.Errorf("open database: %w", err) + } + + // Test the connection + if err := conn.Ping(); err != nil { + conn.Close() + return nil, fmt.Errorf("ping database: %w", err) + } + + db := &database{conn: conn} + + // Initialize schema + if err := db.init(); err != nil { + conn.Close() + return nil, fmt.Errorf("initialize database: %w", err) + } + + return db, nil +} + +func (db *database) Close() error { + _, _ = db.conn.Exec("PRAGMA wal_checkpoint(TRUNCATE);") + + return db.conn.Close() +} + +func (db *database) init() error { + if _, err := db.conn.Exec("PRAGMA foreign_keys = ON"); err != nil { + return fmt.Errorf("enable foreign keys: %w", err) + } + + schema := fmt.Sprintf(` + CREATE TABLE IF NOT EXISTS settings ( + id INTEGER PRIMARY KEY CHECK (id = 1), + device_id TEXT NOT NULL DEFAULT '', + has_completed_first_run BOOLEAN NOT NULL DEFAULT 0, + expose BOOLEAN NOT NULL DEFAULT 0, + survey BOOLEAN NOT NULL DEFAULT TRUE, + browser BOOLEAN NOT NULL DEFAULT 0, + models TEXT NOT NULL DEFAULT '', + agent BOOLEAN NOT NULL DEFAULT 0, + tools BOOLEAN NOT NULL DEFAULT 0, + working_dir TEXT NOT NULL DEFAULT '', + context_length INTEGER NOT NULL DEFAULT 0, + window_width INTEGER NOT NULL DEFAULT 0, + window_height INTEGER NOT NULL DEFAULT 0, + config_migrated BOOLEAN NOT NULL DEFAULT 0, + airplane_mode BOOLEAN NOT NULL DEFAULT 0, + turbo_enabled BOOLEAN NOT NULL DEFAULT 0, + websearch_enabled BOOLEAN NOT NULL DEFAULT 0, + selected_model TEXT NOT NULL DEFAULT '', + sidebar_open BOOLEAN NOT NULL DEFAULT 0, + last_home_view TEXT NOT NULL DEFAULT 'launch', + think_enabled BOOLEAN NOT NULL DEFAULT 0, + think_level TEXT NOT NULL DEFAULT '', + cloud_setting_migrated BOOLEAN NOT NULL DEFAULT 0, + remote TEXT NOT NULL DEFAULT '', -- deprecated + auto_update_enabled BOOLEAN NOT NULL DEFAULT 1, + schema_version INTEGER NOT NULL DEFAULT %d + ); + + -- Insert default settings row if it doesn't exist + INSERT OR IGNORE INTO settings (id) VALUES (1); + + CREATE TABLE IF NOT EXISTS chats ( + id TEXT PRIMARY KEY, + title TEXT NOT NULL DEFAULT '', + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + browser_state TEXT + ); + + CREATE TABLE IF NOT EXISTS messages ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + chat_id TEXT NOT NULL, + role TEXT NOT NULL, + content TEXT NOT NULL DEFAULT '', + thinking TEXT NOT NULL DEFAULT '', + stream BOOLEAN NOT NULL DEFAULT 0, + model_name TEXT, + model_cloud BOOLEAN, -- deprecated + model_ollama_host BOOLEAN, -- deprecated + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + thinking_time_start TIMESTAMP, + thinking_time_end TIMESTAMP, + tool_result TEXT, + FOREIGN KEY (chat_id) REFERENCES chats(id) ON DELETE CASCADE + ); + + CREATE INDEX IF NOT EXISTS idx_messages_chat_id ON messages(chat_id); + + CREATE TABLE IF NOT EXISTS tool_calls ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + message_id INTEGER NOT NULL, + type TEXT NOT NULL, + function_name TEXT NOT NULL, + function_arguments TEXT NOT NULL, + function_result TEXT, + FOREIGN KEY (message_id) REFERENCES messages(id) ON DELETE CASCADE + ); + + CREATE INDEX IF NOT EXISTS idx_tool_calls_message_id ON tool_calls(message_id); + + CREATE TABLE IF NOT EXISTS attachments ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + message_id INTEGER NOT NULL, + filename TEXT NOT NULL, + data BLOB NOT NULL, + FOREIGN KEY (message_id) REFERENCES messages(id) ON DELETE CASCADE + ); + + CREATE INDEX IF NOT EXISTS idx_attachments_message_id ON attachments(message_id); + + CREATE TABLE IF NOT EXISTS users ( + name TEXT NOT NULL DEFAULT '', + email TEXT NOT NULL DEFAULT '', + plan TEXT NOT NULL DEFAULT '', + cached_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP + ); + `, currentSchemaVersion) + + _, err := db.conn.Exec(schema) + if err != nil { + return err + } + + // Check and upgrade schema version if needed + if err := db.migrate(); err != nil { + return fmt.Errorf("migrate schema: %w", err) + } + + // Clean up orphaned records created before foreign key constraints were properly enforced + // TODO: Can eventually be removed - cleans up data from foreign key bug (ollama/ollama#11785, ollama/app#476) + if err := db.cleanupOrphanedData(); err != nil { + return fmt.Errorf("cleanup orphaned data: %w", err) + } + + return nil +} + +// migrate handles database schema migrations +func (db *database) migrate() error { + // Get current schema version + version, err := db.getSchemaVersion() + if err != nil { + return fmt.Errorf("get schema version after migration attempt: %w", err) + } + + // Run migrations for each version + for version < currentSchemaVersion { + switch version { + case 1: + // Migrate from version 1 to 2: add context_length column + if err := db.migrateV1ToV2(); err != nil { + return fmt.Errorf("migrate v1 to v2: %w", err) + } + version = 2 + case 2: + // Migrate from version 2 to 3: create attachments table + if err := db.migrateV2ToV3(); err != nil { + return fmt.Errorf("migrate v2 to v3: %w", err) + } + version = 3 + case 3: + // Migrate from version 3 to 4: add tool_result column to messages table + if err := db.migrateV3ToV4(); err != nil { + return fmt.Errorf("migrate v3 to v4: %w", err) + } + version = 4 + case 4: + // add airplane_mode column to settings table + if err := db.migrateV4ToV5(); err != nil { + return fmt.Errorf("migrate v4 to v5: %w", err) + } + version = 5 + case 5: + // add turbo_enabled column to settings table + if err := db.migrateV5ToV6(); err != nil { + return fmt.Errorf("migrate v5 to v6: %w", err) + } + version = 6 + case 6: + // add missing index for attachments table + if err := db.migrateV6ToV7(); err != nil { + return fmt.Errorf("migrate v6 to v7: %w", err) + } + version = 7 + case 7: + // add think_enabled and think_level columns to settings table + if err := db.migrateV7ToV8(); err != nil { + return fmt.Errorf("migrate v7 to v8: %w", err) + } + version = 8 + case 8: + // add browser_state column to chats table + if err := db.migrateV8ToV9(); err != nil { + return fmt.Errorf("migrate v8 to v9: %w", err) + } + version = 9 + case 9: + // add cached user table + if err := db.migrateV9ToV10(); err != nil { + return fmt.Errorf("migrate v9 to v10: %w", err) + } + version = 10 + case 10: + // remove remote column from settings table + if err := db.migrateV10ToV11(); err != nil { + return fmt.Errorf("migrate v10 to v11: %w", err) + } + version = 11 + case 11: + // bring back remote column for backwards compatibility (deprecated) + if err := db.migrateV11ToV12(); err != nil { + return fmt.Errorf("migrate v11 to v12: %w", err) + } + version = 12 + case 12: + // add cloud_setting_migrated column to settings table + if err := db.migrateV12ToV13(); err != nil { + return fmt.Errorf("migrate v12 to v13: %w", err) + } + version = 13 + case 13: + // change default context_length from 4096 to 0 (VRAM-based tiered defaults) + if err := db.migrateV13ToV14(); err != nil { + return fmt.Errorf("migrate v13 to v14: %w", err) + } + version = 14 + case 14: + // add auto_update_enabled column to settings table + if err := db.migrateV14ToV15(); err != nil { + return fmt.Errorf("migrate v14 to v15: %w", err) + } + version = 15 + case 15: + // add last_home_view column to settings table + if err := db.migrateV15ToV16(); err != nil { + return fmt.Errorf("migrate v15 to v16: %w", err) + } + version = 16 + default: + // If we have a version we don't recognize, just set it to current + // This might happen during development + version = currentSchemaVersion + } + } + + return nil +} + +// migrateV1ToV2 adds the context_length column to the settings table +func (db *database) migrateV1ToV2() error { + _, err := db.conn.Exec(`ALTER TABLE settings ADD COLUMN context_length INTEGER NOT NULL DEFAULT 4096;`) + if err != nil && !duplicateColumnError(err) { + return fmt.Errorf("add context_length column: %w", err) + } + + _, err = db.conn.Exec(`ALTER TABLE settings ADD COLUMN survey BOOLEAN NOT NULL DEFAULT TRUE;`) + if err != nil && !duplicateColumnError(err) { + return fmt.Errorf("add survey column: %w", err) + } + + _, err = db.conn.Exec(`UPDATE settings SET schema_version = 2;`) + if err != nil { + return fmt.Errorf("update schema version: %w", err) + } + return nil +} + +// migrateV2ToV3 creates the attachments table +func (db *database) migrateV2ToV3() error { + _, err := db.conn.Exec(` + CREATE TABLE IF NOT EXISTS attachments ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + message_id INTEGER NOT NULL, + filename TEXT NOT NULL, + data BLOB NOT NULL, + FOREIGN KEY (message_id) REFERENCES messages(id) ON DELETE CASCADE + ) + `) + if err != nil { + return fmt.Errorf("create attachments table: %w", err) + } + + _, err = db.conn.Exec(`UPDATE settings SET schema_version = 3`) + if err != nil { + return fmt.Errorf("update schema version: %w", err) + } + + return nil +} + +func (db *database) migrateV3ToV4() error { + _, err := db.conn.Exec(`ALTER TABLE messages ADD COLUMN tool_result TEXT;`) + if err != nil && !duplicateColumnError(err) { + return fmt.Errorf("add tool_result column: %w", err) + } + + _, err = db.conn.Exec(`UPDATE settings SET schema_version = 4;`) + if err != nil { + return fmt.Errorf("update schema version: %w", err) + } + + return nil +} + +// migrateV4ToV5 adds the airplane_mode column to the settings table +func (db *database) migrateV4ToV5() error { + _, err := db.conn.Exec(`ALTER TABLE settings ADD COLUMN airplane_mode BOOLEAN NOT NULL DEFAULT 0;`) + if err != nil && !duplicateColumnError(err) { + return fmt.Errorf("add airplane_mode column: %w", err) + } + + _, err = db.conn.Exec(`UPDATE settings SET schema_version = 5;`) + if err != nil { + return fmt.Errorf("update schema version: %w", err) + } + + return nil +} + +// migrateV5ToV6 adds the turbo_enabled, websearch_enabled, selected_model, sidebar_open columns to the settings table +func (db *database) migrateV5ToV6() error { + _, err := db.conn.Exec(`ALTER TABLE settings ADD COLUMN turbo_enabled BOOLEAN NOT NULL DEFAULT 0;`) + if err != nil && !duplicateColumnError(err) { + return fmt.Errorf("add turbo_enabled column: %w", err) + } + + _, err = db.conn.Exec(`ALTER TABLE settings ADD COLUMN websearch_enabled BOOLEAN NOT NULL DEFAULT 0;`) + if err != nil && !duplicateColumnError(err) { + return fmt.Errorf("add websearch_enabled column: %w", err) + } + + _, err = db.conn.Exec(`ALTER TABLE settings ADD COLUMN selected_model TEXT NOT NULL DEFAULT '';`) + if err != nil && !duplicateColumnError(err) { + return fmt.Errorf("add selected_model column: %w", err) + } + + _, err = db.conn.Exec(`ALTER TABLE settings ADD COLUMN sidebar_open BOOLEAN NOT NULL DEFAULT 0;`) + if err != nil && !duplicateColumnError(err) { + return fmt.Errorf("add sidebar_open column: %w", err) + } + + _, err = db.conn.Exec(`UPDATE settings SET schema_version = 6;`) + if err != nil { + return fmt.Errorf("update schema version: %w", err) + } + + return nil +} + +// migrateV6ToV7 adds the missing index for the attachments table +func (db *database) migrateV6ToV7() error { + _, err := db.conn.Exec(`CREATE INDEX IF NOT EXISTS idx_attachments_message_id ON attachments(message_id);`) + if err != nil { + return fmt.Errorf("create attachments index: %w", err) + } + + _, err = db.conn.Exec(`UPDATE settings SET schema_version = 7;`) + if err != nil { + return fmt.Errorf("update schema version: %w", err) + } + + return nil +} + +// migrateV7ToV8 adds the think_enabled and think_level columns to the settings table +func (db *database) migrateV7ToV8() error { + _, err := db.conn.Exec(`ALTER TABLE settings ADD COLUMN think_enabled BOOLEAN NOT NULL DEFAULT 0;`) + if err != nil && !duplicateColumnError(err) { + return fmt.Errorf("add think_enabled column: %w", err) + } + + _, err = db.conn.Exec(`ALTER TABLE settings ADD COLUMN think_level TEXT NOT NULL DEFAULT '';`) + if err != nil && !duplicateColumnError(err) { + return fmt.Errorf("add think_level column: %w", err) + } + + _, err = db.conn.Exec(`UPDATE settings SET schema_version = 8;`) + if err != nil { + return fmt.Errorf("update schema version: %w", err) + } + + return nil +} + +// migrateV8ToV9 adds browser_state to chats and bumps schema +func (db *database) migrateV8ToV9() error { + _, err := db.conn.Exec(` + ALTER TABLE chats ADD COLUMN browser_state TEXT; + UPDATE settings SET schema_version = 9; + `) + + if err != nil && !duplicateColumnError(err) { + return fmt.Errorf("add browser_state column: %w", err) + } + + return nil +} + +// migrateV9ToV10 adds users table +func (db *database) migrateV9ToV10() error { + _, err := db.conn.Exec(` + CREATE TABLE IF NOT EXISTS users ( + name TEXT NOT NULL DEFAULT '', + email TEXT NOT NULL DEFAULT '', + plan TEXT NOT NULL DEFAULT '', + cached_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP + ); + UPDATE settings SET schema_version = 10; + `) + if err != nil { + return fmt.Errorf("create users table: %w", err) + } + + return nil +} + +// migrateV10ToV11 removes the remote column from the settings table +func (db *database) migrateV10ToV11() error { + _, err := db.conn.Exec(`ALTER TABLE settings DROP COLUMN remote`) + if err != nil && !columnNotExists(err) { + return fmt.Errorf("drop remote column: %w", err) + } + + _, err = db.conn.Exec(`UPDATE settings SET schema_version = 11`) + if err != nil { + return fmt.Errorf("update schema version: %w", err) + } + + return nil +} + +// migrateV11ToV12 brings back the remote column for backwards compatibility (deprecated) +func (db *database) migrateV11ToV12() error { + _, err := db.conn.Exec(`ALTER TABLE settings ADD COLUMN remote TEXT NOT NULL DEFAULT ''`) + if err != nil && !duplicateColumnError(err) { + return fmt.Errorf("add remote column: %w", err) + } + + _, err = db.conn.Exec(`UPDATE settings SET schema_version = 12`) + if err != nil { + return fmt.Errorf("update schema version: %w", err) + } + + return nil +} + +// migrateV12ToV13 adds cloud_setting_migrated to settings. +func (db *database) migrateV12ToV13() error { + _, err := db.conn.Exec(`ALTER TABLE settings ADD COLUMN cloud_setting_migrated BOOLEAN NOT NULL DEFAULT 0`) + if err != nil && !duplicateColumnError(err) { + return fmt.Errorf("add cloud_setting_migrated column: %w", err) + } + + _, err = db.conn.Exec(`UPDATE settings SET schema_version = 13`) + if err != nil { + return fmt.Errorf("update schema version: %w", err) + } + + return nil +} + +// migrateV13ToV14 changes the default context_length from 4096 to 0. +// When context_length is 0, the ollama server uses VRAM-based tiered defaults. +func (db *database) migrateV13ToV14() error { + _, err := db.conn.Exec(`UPDATE settings SET context_length = 0 WHERE context_length = 4096`) + if err != nil { + return fmt.Errorf("update context_length default: %w", err) + } + + _, err = db.conn.Exec(`UPDATE settings SET schema_version = 14`) + if err != nil { + return fmt.Errorf("update schema version: %w", err) + } + + return nil +} + +// migrateV14ToV15 adds the auto_update_enabled column to the settings table +func (db *database) migrateV14ToV15() error { + _, err := db.conn.Exec(`ALTER TABLE settings ADD COLUMN auto_update_enabled BOOLEAN NOT NULL DEFAULT 1`) + if err != nil && !duplicateColumnError(err) { + return fmt.Errorf("add auto_update_enabled column: %w", err) + } + + _, err = db.conn.Exec(`UPDATE settings SET schema_version = 15`) + if err != nil { + return fmt.Errorf("update schema version: %w", err) + } + + return nil +} + +// migrateV15ToV16 adds the last_home_view column to the settings table +func (db *database) migrateV15ToV16() error { + _, err := db.conn.Exec(`ALTER TABLE settings ADD COLUMN last_home_view TEXT NOT NULL DEFAULT 'launch'`) + if err != nil && !duplicateColumnError(err) { + return fmt.Errorf("add last_home_view column: %w", err) + } + + _, err = db.conn.Exec(`UPDATE settings SET schema_version = 16`) + if err != nil { + return fmt.Errorf("update schema version: %w", err) + } + + return nil +} + +// cleanupOrphanedData removes orphaned records that may exist due to the foreign key bug +func (db *database) cleanupOrphanedData() error { + _, err := db.conn.Exec(` + DELETE FROM tool_calls + WHERE message_id NOT IN (SELECT id FROM messages) + `) + if err != nil { + return fmt.Errorf("cleanup orphaned tool_calls: %w", err) + } + + _, err = db.conn.Exec(` + DELETE FROM attachments + WHERE message_id NOT IN (SELECT id FROM messages) + `) + if err != nil { + return fmt.Errorf("cleanup orphaned attachments: %w", err) + } + + _, err = db.conn.Exec(` + DELETE FROM messages + WHERE chat_id NOT IN (SELECT id FROM chats) + `) + if err != nil { + return fmt.Errorf("cleanup orphaned messages: %w", err) + } + + return nil +} + +func duplicateColumnError(err error) bool { + return err != nil && strings.Contains(err.Error(), "duplicate column name") +} + +func columnNotExists(err error) bool { + return err != nil && strings.Contains(err.Error(), "no such column") +} + +func (db *database) getAllChats() ([]Chat, error) { + // Query chats with their first user message and latest update time + query := ` + SELECT + c.id, + c.title, + c.created_at, + COALESCE(first_msg.content, '') as first_user_content, + COALESCE(datetime(MAX(m.updated_at)), datetime(c.created_at)) as last_updated + FROM chats c + LEFT JOIN ( + SELECT chat_id, content, MIN(id) as min_id + FROM messages + WHERE role = 'user' + GROUP BY chat_id + ) first_msg ON c.id = first_msg.chat_id + LEFT JOIN messages m ON c.id = m.chat_id + GROUP BY c.id, c.title, c.created_at, first_msg.content + ORDER BY last_updated DESC + ` + + rows, err := db.conn.Query(query) + if err != nil { + return nil, fmt.Errorf("query chats: %w", err) + } + defer rows.Close() + + var chats []Chat + for rows.Next() { + var chat Chat + var createdAt time.Time + var firstUserContent string + var lastUpdatedStr string + + err := rows.Scan( + &chat.ID, + &chat.Title, + &createdAt, + &firstUserContent, + &lastUpdatedStr, + ) + + // Parse the last updated time + lastUpdated, _ := time.Parse("2006-01-02 15:04:05", lastUpdatedStr) + if err != nil { + return nil, fmt.Errorf("scan chat: %w", err) + } + + chat.CreatedAt = createdAt + + // Add a dummy first user message for the UI to display + // This is just for the excerpt, full messages are loaded when needed + chat.Messages = []Message{} + if firstUserContent != "" { + chat.Messages = append(chat.Messages, Message{ + Role: "user", + Content: firstUserContent, + UpdatedAt: lastUpdated, + }) + } + + chats = append(chats, chat) + } + + if err := rows.Err(); err != nil { + return nil, fmt.Errorf("iterate chats: %w", err) + } + + return chats, nil +} + +func (db *database) getChatWithOptions(id string, loadAttachmentData bool) (*Chat, error) { + query := ` + SELECT id, title, created_at, browser_state + FROM chats + WHERE id = ? + ` + + var chat Chat + var createdAt time.Time + var browserState sql.NullString + + err := db.conn.QueryRow(query, id).Scan( + &chat.ID, + &chat.Title, + &createdAt, + &browserState, + ) + if err != nil { + if err == sql.ErrNoRows { + return nil, fmt.Errorf("chat not found") + } + return nil, fmt.Errorf("query chat: %w", err) + } + + chat.CreatedAt = createdAt + if browserState.Valid && browserState.String != "" { + var raw json.RawMessage + if err := json.Unmarshal([]byte(browserState.String), &raw); err == nil { + chat.BrowserState = raw + } + } + + messages, err := db.getMessages(id, loadAttachmentData) + if err != nil { + return nil, fmt.Errorf("get messages: %w", err) + } + chat.Messages = messages + + return &chat, nil +} + +func (db *database) saveChat(chat Chat) error { + tx, err := db.conn.Begin() + if err != nil { + return fmt.Errorf("begin transaction: %w", err) + } + defer tx.Rollback() + + // Use COALESCE for browser_state to avoid wiping an existing + // chat-level browser_state when saving a chat that doesn't include a new state payload. + // Many code paths call SetChat to update metadata/messages only; without COALESCE the + // UPSERT would overwrite browser_state with NULL, breaking revisit rendering that relies + // on the last persisted full tool state. + query := ` + INSERT INTO chats (id, title, created_at, browser_state) + VALUES (?, ?, ?, ?) + ON CONFLICT(id) DO UPDATE SET + title = excluded.title, + browser_state = COALESCE(excluded.browser_state, chats.browser_state) + ` + + var browserState sql.NullString + if chat.BrowserState != nil { + browserState = sql.NullString{String: string(chat.BrowserState), Valid: true} + } + + _, err = tx.Exec(query, + chat.ID, + chat.Title, + chat.CreatedAt, + browserState, + ) + if err != nil { + return fmt.Errorf("save chat: %w", err) + } + + // Delete existing messages (we'll re-insert all) + _, err = tx.Exec("DELETE FROM messages WHERE chat_id = ?", chat.ID) + if err != nil { + return fmt.Errorf("delete messages: %w", err) + } + + // Insert messages + for _, msg := range chat.Messages { + messageID, err := db.insertMessage(tx, chat.ID, msg) + if err != nil { + return fmt.Errorf("insert message: %w", err) + } + + // Insert tool calls if any + for _, toolCall := range msg.ToolCalls { + err := db.insertToolCall(tx, messageID, toolCall) + if err != nil { + return fmt.Errorf("insert tool call: %w", err) + } + } + } + + return tx.Commit() +} + +// updateChatBrowserState updates only the browser_state for a chat +func (db *database) updateChatBrowserState(chatID string, state json.RawMessage) error { + _, err := db.conn.Exec(`UPDATE chats SET browser_state = ? WHERE id = ?`, string(state), chatID) + if err != nil { + return fmt.Errorf("update chat browser state: %w", err) + } + return nil +} + +func (db *database) deleteChat(id string) error { + _, err := db.conn.Exec("DELETE FROM chats WHERE id = ?", id) + if err != nil { + return fmt.Errorf("delete chat: %w", err) + } + + _, _ = db.conn.Exec("PRAGMA wal_checkpoint(TRUNCATE);") + + return nil +} + +func (db *database) updateLastMessage(chatID string, msg Message) error { + tx, err := db.conn.Begin() + if err != nil { + return fmt.Errorf("begin transaction: %w", err) + } + defer tx.Rollback() + + // Get the ID of the last message + var messageID int64 + err = tx.QueryRow(` + SELECT MAX(id) FROM messages WHERE chat_id = ? + `, chatID).Scan(&messageID) + if err != nil { + return fmt.Errorf("get last message id: %w", err) + } + + query := ` + UPDATE messages + SET content = ?, thinking = ?, model_name = ?, updated_at = ?, thinking_time_start = ?, thinking_time_end = ?, tool_result = ? + WHERE id = ? + ` + + var thinkingTimeStart, thinkingTimeEnd sql.NullTime + if msg.ThinkingTimeStart != nil { + thinkingTimeStart = sql.NullTime{Time: *msg.ThinkingTimeStart, Valid: true} + } + if msg.ThinkingTimeEnd != nil { + thinkingTimeEnd = sql.NullTime{Time: *msg.ThinkingTimeEnd, Valid: true} + } + + var modelName sql.NullString + if msg.Model != "" { + modelName = sql.NullString{String: msg.Model, Valid: true} + } + + var toolResultJSON sql.NullString + if msg.ToolResult != nil { + resultBytes, err := json.Marshal(msg.ToolResult) + if err != nil { + return fmt.Errorf("marshal tool result: %w", err) + } + toolResultJSON = sql.NullString{String: string(resultBytes), Valid: true} + } + + result, err := tx.Exec(query, + msg.Content, + msg.Thinking, + modelName, + msg.UpdatedAt, + thinkingTimeStart, + thinkingTimeEnd, + toolResultJSON, + messageID, + ) + if err != nil { + return fmt.Errorf("update last message: %w", err) + } + + rowsAffected, err := result.RowsAffected() + if err != nil { + return fmt.Errorf("get rows affected: %w", err) + } + if rowsAffected == 0 { + return fmt.Errorf("no message found to update") + } + + _, err = tx.Exec("DELETE FROM attachments WHERE message_id = ?", messageID) + if err != nil { + return fmt.Errorf("delete existing attachments: %w", err) + } + for _, att := range msg.Attachments { + err := db.insertAttachment(tx, messageID, att) + if err != nil { + return fmt.Errorf("insert attachment: %w", err) + } + } + + _, err = tx.Exec("DELETE FROM tool_calls WHERE message_id = ?", messageID) + if err != nil { + return fmt.Errorf("delete existing tool calls: %w", err) + } + for _, toolCall := range msg.ToolCalls { + err := db.insertToolCall(tx, messageID, toolCall) + if err != nil { + return fmt.Errorf("insert tool call: %w", err) + } + } + + return tx.Commit() +} + +func (db *database) appendMessage(chatID string, msg Message) error { + tx, err := db.conn.Begin() + if err != nil { + return fmt.Errorf("begin transaction: %w", err) + } + defer tx.Rollback() + + messageID, err := db.insertMessage(tx, chatID, msg) + if err != nil { + return fmt.Errorf("insert message: %w", err) + } + + // Insert tool calls if any + for _, toolCall := range msg.ToolCalls { + err := db.insertToolCall(tx, messageID, toolCall) + if err != nil { + return fmt.Errorf("insert tool call: %w", err) + } + } + + return tx.Commit() +} + +func (db *database) getMessages(chatID string, loadAttachmentData bool) ([]Message, error) { + query := ` + SELECT id, role, content, thinking, stream, model_name, created_at, updated_at, thinking_time_start, thinking_time_end, tool_result + FROM messages + WHERE chat_id = ? + ORDER BY id ASC + ` + + rows, err := db.conn.Query(query, chatID) + if err != nil { + return nil, fmt.Errorf("query messages: %w", err) + } + defer rows.Close() + + var messages []Message + for rows.Next() { + var msg Message + var messageID int64 + var thinkingTimeStart, thinkingTimeEnd sql.NullTime + var modelName sql.NullString + var toolResult sql.NullString + + err := rows.Scan( + &messageID, + &msg.Role, + &msg.Content, + &msg.Thinking, + &msg.Stream, + &modelName, + &msg.CreatedAt, + &msg.UpdatedAt, + &thinkingTimeStart, + &thinkingTimeEnd, + &toolResult, + ) + if err != nil { + return nil, fmt.Errorf("scan message: %w", err) + } + + attachments, err := db.getAttachments(messageID, loadAttachmentData) + if err != nil { + return nil, fmt.Errorf("get attachments: %w", err) + } + msg.Attachments = attachments + + if thinkingTimeStart.Valid { + msg.ThinkingTimeStart = &thinkingTimeStart.Time + } + if thinkingTimeEnd.Valid { + msg.ThinkingTimeEnd = &thinkingTimeEnd.Time + } + + // Parse tool result from JSON if present + if toolResult.Valid && toolResult.String != "" { + var result json.RawMessage + if err := json.Unmarshal([]byte(toolResult.String), &result); err == nil { + msg.ToolResult = &result + } + } + + // Set model if present + if modelName.Valid && modelName.String != "" { + msg.Model = modelName.String + } + + // Get tool calls for this message + toolCalls, err := db.getToolCalls(messageID) + if err != nil { + return nil, fmt.Errorf("get tool calls: %w", err) + } + msg.ToolCalls = toolCalls + + messages = append(messages, msg) + } + + if err := rows.Err(); err != nil { + return nil, fmt.Errorf("iterate messages: %w", err) + } + + return messages, nil +} + +func (db *database) insertMessage(tx *sql.Tx, chatID string, msg Message) (int64, error) { + query := ` + INSERT INTO messages (chat_id, role, content, thinking, stream, model_name, created_at, updated_at, thinking_time_start, thinking_time_end, tool_result) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) + ` + + var thinkingTimeStart, thinkingTimeEnd sql.NullTime + if msg.ThinkingTimeStart != nil { + thinkingTimeStart = sql.NullTime{Time: *msg.ThinkingTimeStart, Valid: true} + } + if msg.ThinkingTimeEnd != nil { + thinkingTimeEnd = sql.NullTime{Time: *msg.ThinkingTimeEnd, Valid: true} + } + + var modelName sql.NullString + if msg.Model != "" { + modelName = sql.NullString{String: msg.Model, Valid: true} + } + + var toolResultJSON sql.NullString + if msg.ToolResult != nil { + resultBytes, err := json.Marshal(msg.ToolResult) + if err != nil { + return 0, fmt.Errorf("marshal tool result: %w", err) + } + toolResultJSON = sql.NullString{String: string(resultBytes), Valid: true} + } + + result, err := tx.Exec(query, + chatID, + msg.Role, + msg.Content, + msg.Thinking, + msg.Stream, + modelName, + msg.CreatedAt, + msg.UpdatedAt, + thinkingTimeStart, + thinkingTimeEnd, + toolResultJSON, + ) + if err != nil { + return 0, err + } + + messageID, err := result.LastInsertId() + if err != nil { + return 0, err + } + + for _, att := range msg.Attachments { + err := db.insertAttachment(tx, messageID, att) + if err != nil { + return 0, fmt.Errorf("insert attachment: %w", err) + } + } + + return messageID, nil +} + +func (db *database) getAttachments(messageID int64, loadData bool) ([]File, error) { + var query string + if loadData { + query = ` + SELECT filename, data + FROM attachments + WHERE message_id = ? + ORDER BY id ASC + ` + } else { + query = ` + SELECT filename, '' as data + FROM attachments + WHERE message_id = ? + ORDER BY id ASC + ` + } + + rows, err := db.conn.Query(query, messageID) + if err != nil { + return nil, fmt.Errorf("query attachments: %w", err) + } + defer rows.Close() + + var attachments []File + for rows.Next() { + var file File + err := rows.Scan(&file.Filename, &file.Data) + if err != nil { + return nil, fmt.Errorf("scan attachment: %w", err) + } + attachments = append(attachments, file) + } + + if err := rows.Err(); err != nil { + return nil, fmt.Errorf("iterate attachments: %w", err) + } + + return attachments, nil +} + +func (db *database) getToolCalls(messageID int64) ([]ToolCall, error) { + query := ` + SELECT type, function_name, function_arguments, function_result + FROM tool_calls + WHERE message_id = ? + ORDER BY id ASC + ` + + rows, err := db.conn.Query(query, messageID) + if err != nil { + return nil, fmt.Errorf("query tool calls: %w", err) + } + defer rows.Close() + + var toolCalls []ToolCall + for rows.Next() { + var tc ToolCall + var functionResult sql.NullString + + err := rows.Scan( + &tc.Type, + &tc.Function.Name, + &tc.Function.Arguments, + &functionResult, + ) + if err != nil { + return nil, fmt.Errorf("scan tool call: %w", err) + } + + if functionResult.Valid && functionResult.String != "" { + // Parse the JSON result + var result json.RawMessage + if err := json.Unmarshal([]byte(functionResult.String), &result); err == nil { + tc.Function.Result = &result + } + } + + toolCalls = append(toolCalls, tc) + } + + if err := rows.Err(); err != nil { + return nil, fmt.Errorf("iterate tool calls: %w", err) + } + + return toolCalls, nil +} + +func (db *database) insertAttachment(tx *sql.Tx, messageID int64, file File) error { + query := ` + INSERT INTO attachments (message_id, filename, data) + VALUES (?, ?, ?) + ` + _, err := tx.Exec(query, messageID, file.Filename, file.Data) + return err +} + +func (db *database) insertToolCall(tx *sql.Tx, messageID int64, tc ToolCall) error { + query := ` + INSERT INTO tool_calls (message_id, type, function_name, function_arguments, function_result) + VALUES (?, ?, ?, ?, ?) + ` + + var functionResult sql.NullString + if tc.Function.Result != nil { + // Convert result to JSON + resultJSON, err := json.Marshal(tc.Function.Result) + if err != nil { + return fmt.Errorf("marshal tool result: %w", err) + } + functionResult = sql.NullString{String: string(resultJSON), Valid: true} + } + + _, err := tx.Exec(query, + messageID, + tc.Type, + tc.Function.Name, + tc.Function.Arguments, + functionResult, + ) + return err +} + +// Settings operations + +func (db *database) getID() (string, error) { + var id string + err := db.conn.QueryRow("SELECT device_id FROM settings").Scan(&id) + if err != nil { + return "", fmt.Errorf("get device id: %w", err) + } + return id, nil +} + +func (db *database) setID(id string) error { + _, err := db.conn.Exec("UPDATE settings SET device_id = ?", id) + if err != nil { + return fmt.Errorf("set device id: %w", err) + } + return nil +} + +func (db *database) getHasCompletedFirstRun() (bool, error) { + var hasCompletedFirstRun bool + err := db.conn.QueryRow("SELECT has_completed_first_run FROM settings").Scan(&hasCompletedFirstRun) + if err != nil { + return false, fmt.Errorf("get has completed first run: %w", err) + } + return hasCompletedFirstRun, nil +} + +func (db *database) setHasCompletedFirstRun(hasCompletedFirstRun bool) error { + _, err := db.conn.Exec("UPDATE settings SET has_completed_first_run = ?", hasCompletedFirstRun) + if err != nil { + return fmt.Errorf("set has completed first run: %w", err) + } + return nil +} + +func (db *database) getSettings() (Settings, error) { + var s Settings + + err := db.conn.QueryRow(` + SELECT expose, survey, browser, models, agent, tools, working_dir, context_length, turbo_enabled, websearch_enabled, selected_model, sidebar_open, last_home_view, think_enabled, think_level, auto_update_enabled + FROM settings + `).Scan(&s.Expose, &s.Survey, &s.Browser, &s.Models, &s.Agent, &s.Tools, &s.WorkingDir, &s.ContextLength, &s.TurboEnabled, &s.WebSearchEnabled, &s.SelectedModel, &s.SidebarOpen, &s.LastHomeView, &s.ThinkEnabled, &s.ThinkLevel, &s.AutoUpdateEnabled) + if err != nil { + return Settings{}, fmt.Errorf("get settings: %w", err) + } + + return s, nil +} + +func (db *database) setSettings(s Settings) error { + lastHomeView := strings.ToLower(strings.TrimSpace(s.LastHomeView)) + validLaunchView := map[string]struct{}{ + "launch": {}, + "openclaw": {}, + "claude": {}, + "hermes": {}, + "codex": {}, + "codex-app": {}, + "copilot": {}, + "opencode": {}, + "droid": {}, + "pi": {}, + } + if lastHomeView != "chat" { + if _, ok := validLaunchView[lastHomeView]; !ok { + lastHomeView = "launch" + } + } + + _, err := db.conn.Exec(` + UPDATE settings + SET expose = ?, survey = ?, browser = ?, models = ?, agent = ?, tools = ?, working_dir = ?, context_length = ?, turbo_enabled = ?, websearch_enabled = ?, selected_model = ?, sidebar_open = ?, last_home_view = ?, think_enabled = ?, think_level = ?, auto_update_enabled = ? + `, s.Expose, s.Survey, s.Browser, s.Models, s.Agent, s.Tools, s.WorkingDir, s.ContextLength, s.TurboEnabled, s.WebSearchEnabled, s.SelectedModel, s.SidebarOpen, lastHomeView, s.ThinkEnabled, s.ThinkLevel, s.AutoUpdateEnabled) + if err != nil { + return fmt.Errorf("set settings: %w", err) + } + return nil +} + +func (db *database) isCloudSettingMigrated() (bool, error) { + var migrated bool + err := db.conn.QueryRow("SELECT cloud_setting_migrated FROM settings").Scan(&migrated) + if err != nil { + return false, fmt.Errorf("get cloud setting migration status: %w", err) + } + return migrated, nil +} + +func (db *database) setCloudSettingMigrated(migrated bool) error { + _, err := db.conn.Exec("UPDATE settings SET cloud_setting_migrated = ?", migrated) + if err != nil { + return fmt.Errorf("set cloud setting migration status: %w", err) + } + return nil +} + +func (db *database) getAirplaneMode() (bool, error) { + var airplaneMode bool + err := db.conn.QueryRow("SELECT airplane_mode FROM settings").Scan(&airplaneMode) + if err != nil { + return false, fmt.Errorf("get airplane_mode: %w", err) + } + return airplaneMode, nil +} + +func (db *database) getWindowSize() (int, int, error) { + var width, height int + err := db.conn.QueryRow("SELECT window_width, window_height FROM settings").Scan(&width, &height) + if err != nil { + return 0, 0, fmt.Errorf("get window size: %w", err) + } + return width, height, nil +} + +func (db *database) setWindowSize(width, height int) error { + _, err := db.conn.Exec("UPDATE settings SET window_width = ?, window_height = ?", width, height) + if err != nil { + return fmt.Errorf("set window size: %w", err) + } + return nil +} + +func (db *database) isConfigMigrated() (bool, error) { + var migrated bool + err := db.conn.QueryRow("SELECT config_migrated FROM settings").Scan(&migrated) + if err != nil { + return false, fmt.Errorf("get config migrated: %w", err) + } + return migrated, nil +} + +func (db *database) setConfigMigrated(migrated bool) error { + _, err := db.conn.Exec("UPDATE settings SET config_migrated = ?", migrated) + if err != nil { + return fmt.Errorf("set config migrated: %w", err) + } + return nil +} + +func (db *database) getSchemaVersion() (int, error) { + var version int + err := db.conn.QueryRow("SELECT schema_version FROM settings").Scan(&version) + if err != nil { + return 0, fmt.Errorf("get schema version: %w", err) + } + return version, nil +} + +func (db *database) setSchemaVersion(version int) error { + _, err := db.conn.Exec("UPDATE settings SET schema_version = ?", version) + if err != nil { + return fmt.Errorf("set schema version: %w", err) + } + return nil +} + +func (db *database) getUser() (*User, error) { + var user User + err := db.conn.QueryRow(` + SELECT name, email, plan, cached_at + FROM users + LIMIT 1 + `).Scan(&user.Name, &user.Email, &user.Plan, &user.CachedAt) + if err != nil { + if err == sql.ErrNoRows { + return nil, nil // No user cached yet + } + return nil, fmt.Errorf("get user: %w", err) + } + + return &user, nil +} + +func (db *database) setUser(user User) error { + if err := db.clearUser(); err != nil { + return fmt.Errorf("before set: %w", err) + } + + _, err := db.conn.Exec(` + INSERT INTO users (name, email, plan, cached_at) + VALUES (?, ?, ?, ?) + `, user.Name, user.Email, user.Plan, user.CachedAt) + if err != nil { + return fmt.Errorf("set user: %w", err) + } + + return nil +} + +func (db *database) clearUser() error { + _, err := db.conn.Exec("DELETE FROM users") + if err != nil { + return fmt.Errorf("clear user: %w", err) + } + return nil +} diff --git a/app/store/database_test.go b/app/store/database_test.go new file mode 100644 index 0000000..3411e11 --- /dev/null +++ b/app/store/database_test.go @@ -0,0 +1,483 @@ +//go:build windows || darwin + +package store + +import ( + "database/sql" + "fmt" + "os" + "path/filepath" + "sort" + "strings" + "testing" + "time" + + "github.com/google/go-cmp/cmp" + _ "github.com/mattn/go-sqlite3" +) + +func TestSchemaMigrations(t *testing.T) { + t.Run("schema comparison after migration", func(t *testing.T) { + tmpDir := t.TempDir() + migratedDBPath := filepath.Join(tmpDir, "migrated.db") + migratedDB := loadV2Schema(t, migratedDBPath) + defer migratedDB.Close() + + if err := migratedDB.migrate(); err != nil { + t.Fatalf("migration failed: %v", err) + } + + // Create fresh database with current schema + freshDBPath := filepath.Join(tmpDir, "fresh.db") + freshDB, err := newDatabase(freshDBPath) + if err != nil { + t.Fatalf("failed to create fresh database: %v", err) + } + defer freshDB.Close() + + // Extract tables and indexes from both databases, directly comparing their schemas won't work due to ordering + migratedSchema := schemaMap(migratedDB) + freshSchema := schemaMap(freshDB) + + if !cmp.Equal(migratedSchema, freshSchema) { + t.Errorf("Schema difference found:\n%s", cmp.Diff(freshSchema, migratedSchema)) + } + + // Verify both databases have the same final schema version + migratedVersion, _ := migratedDB.getSchemaVersion() + freshVersion, _ := freshDB.getSchemaVersion() + if migratedVersion != freshVersion { + t.Errorf("schema version mismatch: migrated=%d, fresh=%d", migratedVersion, freshVersion) + } + }) + + t.Run("idempotent migrations", func(t *testing.T) { + tmpDir := t.TempDir() + dbPath := filepath.Join(tmpDir, "test.db") + db := loadV2Schema(t, dbPath) + defer db.Close() + + // Run migration twice + if err := db.migrate(); err != nil { + t.Fatalf("first migration failed: %v", err) + } + + if err := db.migrate(); err != nil { + t.Fatalf("second migration failed: %v", err) + } + + // Verify schema version is still correct + version, err := db.getSchemaVersion() + if err != nil { + t.Fatalf("failed to get schema version: %v", err) + } + if version != currentSchemaVersion { + t.Errorf("expected schema version %d after double migration, got %d", currentSchemaVersion, version) + } + }) + + t.Run("init database has correct schema version", func(t *testing.T) { + tmpDir := t.TempDir() + dbPath := filepath.Join(tmpDir, "test.db") + db, err := newDatabase(dbPath) + if err != nil { + t.Fatalf("failed to create database: %v", err) + } + defer db.Close() + + // Get the schema version from the newly initialized database + version, err := db.getSchemaVersion() + if err != nil { + t.Fatalf("failed to get schema version: %v", err) + } + + // Verify it matches the currentSchemaVersion constant + if version != currentSchemaVersion { + t.Errorf("expected schema version %d in initialized database, got %d", currentSchemaVersion, version) + } + }) +} + +func TestMigrationV13ToV14ContextLength(t *testing.T) { + tmpDir := t.TempDir() + dbPath := filepath.Join(tmpDir, "test.db") + + db, err := newDatabase(dbPath) + if err != nil { + t.Fatalf("failed to create database: %v", err) + } + defer db.Close() + + _, err = db.conn.Exec("UPDATE settings SET context_length = 4096, schema_version = 13") + if err != nil { + t.Fatalf("failed to seed v13 settings row: %v", err) + } + + if err := db.migrate(); err != nil { + t.Fatalf("migration from v13 to v14 failed: %v", err) + } + + var contextLength int + if err := db.conn.QueryRow("SELECT context_length FROM settings").Scan(&contextLength); err != nil { + t.Fatalf("failed to read context_length: %v", err) + } + + if contextLength != 0 { + t.Fatalf("expected context_length to migrate to 0, got %d", contextLength) + } + + version, err := db.getSchemaVersion() + if err != nil { + t.Fatalf("failed to get schema version: %v", err) + } + if version != currentSchemaVersion { + t.Fatalf("expected schema version %d, got %d", currentSchemaVersion, version) + } +} + +func TestMigrationV15ToV16LastHomeViewDefaultsToLaunch(t *testing.T) { + tmpDir := t.TempDir() + dbPath := filepath.Join(tmpDir, "test.db") + + db, err := newDatabase(dbPath) + if err != nil { + t.Fatalf("failed to create database: %v", err) + } + defer db.Close() + + if _, err := db.conn.Exec(` + ALTER TABLE settings DROP COLUMN last_home_view; + UPDATE settings SET schema_version = 15; + `); err != nil { + t.Fatalf("failed to seed v15 settings row: %v", err) + } + + if err := db.migrate(); err != nil { + t.Fatalf("migration from v15 to v16 failed: %v", err) + } + + var lastHomeView string + if err := db.conn.QueryRow("SELECT last_home_view FROM settings").Scan(&lastHomeView); err != nil { + t.Fatalf("failed to read last_home_view: %v", err) + } + + if lastHomeView != "launch" { + t.Fatalf("expected last_home_view to default to launch after migration, got %q", lastHomeView) + } + + version, err := db.getSchemaVersion() + if err != nil { + t.Fatalf("failed to get schema version: %v", err) + } + if version != currentSchemaVersion { + t.Fatalf("expected schema version %d, got %d", currentSchemaVersion, version) + } +} + +func TestChatDeletionWithCascade(t *testing.T) { + t.Run("chat deletion cascades to related messages", func(t *testing.T) { + tmpDir := t.TempDir() + dbPath := filepath.Join(tmpDir, "test.db") + db, err := newDatabase(dbPath) + if err != nil { + t.Fatalf("failed to create database: %v", err) + } + defer db.Close() + + // Create test chat + testChatID := "test-chat-cascade-123" + testChat := Chat{ + ID: testChatID, + Title: "Test Chat for Cascade Delete", + CreatedAt: time.Now(), + Messages: []Message{ + { + Role: "user", + Content: "Hello, this is a test message", + CreatedAt: time.Now(), + UpdatedAt: time.Now(), + }, + { + Role: "assistant", + Content: "Hi there! This is a response.", + CreatedAt: time.Now(), + UpdatedAt: time.Now(), + }, + }, + } + + // Save the chat with messages + if err := db.saveChat(testChat); err != nil { + t.Fatalf("failed to save test chat: %v", err) + } + + // Verify chat and messages exist + chatCount := countRows(t, db, "chats") + messageCount := countRows(t, db, "messages") + + if chatCount != 1 { + t.Errorf("expected 1 chat, got %d", chatCount) + } + if messageCount != 2 { + t.Errorf("expected 2 messages, got %d", messageCount) + } + + // Verify specific chat exists + var exists bool + err = db.conn.QueryRow("SELECT EXISTS(SELECT 1 FROM chats WHERE id = ?)", testChatID).Scan(&exists) + if err != nil { + t.Fatalf("failed to check chat existence: %v", err) + } + if !exists { + t.Error("test chat should exist before deletion") + } + + // Verify messages exist for this chat + messageCountForChat := countRowsWithCondition(t, db, "messages", "chat_id = ?", testChatID) + if messageCountForChat != 2 { + t.Errorf("expected 2 messages for test chat, got %d", messageCountForChat) + } + + // Delete the chat + if err := db.deleteChat(testChatID); err != nil { + t.Fatalf("failed to delete chat: %v", err) + } + + // Verify chat is deleted + chatCountAfter := countRows(t, db, "chats") + if chatCountAfter != 0 { + t.Errorf("expected 0 chats after deletion, got %d", chatCountAfter) + } + + // Verify messages are CASCADE deleted + messageCountAfter := countRows(t, db, "messages") + if messageCountAfter != 0 { + t.Errorf("expected 0 messages after CASCADE deletion, got %d", messageCountAfter) + } + + // Verify specific chat no longer exists + err = db.conn.QueryRow("SELECT EXISTS(SELECT 1 FROM chats WHERE id = ?)", testChatID).Scan(&exists) + if err != nil { + t.Fatalf("failed to check chat existence after deletion: %v", err) + } + if exists { + t.Error("test chat should not exist after deletion") + } + + // Verify no orphaned messages remain + orphanedCount := countRowsWithCondition(t, db, "messages", "chat_id = ?", testChatID) + if orphanedCount != 0 { + t.Errorf("expected 0 orphaned messages, got %d", orphanedCount) + } + }) + + t.Run("foreign keys are enabled", func(t *testing.T) { + tmpDir := t.TempDir() + dbPath := filepath.Join(tmpDir, "test.db") + db, err := newDatabase(dbPath) + if err != nil { + t.Fatalf("failed to create database: %v", err) + } + defer db.Close() + + // Verify foreign keys are enabled + var foreignKeysEnabled int + err = db.conn.QueryRow("PRAGMA foreign_keys").Scan(&foreignKeysEnabled) + if err != nil { + t.Fatalf("failed to check foreign keys: %v", err) + } + if foreignKeysEnabled != 1 { + t.Errorf("expected foreign keys to be enabled (1), got %d", foreignKeysEnabled) + } + }) + + // This test is only relevant for v8 migrations, but we keep it here for now + // since it's a useful test to ensure that we don't introduce any new orphaned data + t.Run("cleanup orphaned data", func(t *testing.T) { + tmpDir := t.TempDir() + dbPath := filepath.Join(tmpDir, "test.db") + db, err := newDatabase(dbPath) + if err != nil { + t.Fatalf("failed to create database: %v", err) + } + defer db.Close() + + // First disable foreign keys to simulate the bug from ollama/ollama#11785 + _, err = db.conn.Exec("PRAGMA foreign_keys = OFF") + if err != nil { + t.Fatalf("failed to disable foreign keys: %v", err) + } + + // Create a chat and message + testChatID := "orphaned-test-chat" + testMessageID := int64(999) + + _, err = db.conn.Exec("INSERT INTO chats (id, title) VALUES (?, ?)", testChatID, "Orphaned Test Chat") + if err != nil { + t.Fatalf("failed to insert test chat: %v", err) + } + + _, err = db.conn.Exec("INSERT INTO messages (id, chat_id, role, content) VALUES (?, ?, ?, ?)", + testMessageID, testChatID, "user", "test message") + if err != nil { + t.Fatalf("failed to insert test message: %v", err) + } + + // Delete chat but keep message (simulating the bug from ollama/ollama#11785) + _, err = db.conn.Exec("DELETE FROM chats WHERE id = ?", testChatID) + if err != nil { + t.Fatalf("failed to delete chat: %v", err) + } + + // Verify we have orphaned message + orphanedCount := countRowsWithCondition(t, db, "messages", "chat_id = ?", testChatID) + if orphanedCount != 1 { + t.Errorf("expected 1 orphaned message, got %d", orphanedCount) + } + + // Run cleanup + if err := db.cleanupOrphanedData(); err != nil { + t.Fatalf("failed to cleanup orphaned data: %v", err) + } + + // Verify orphaned message is gone + orphanedCountAfter := countRowsWithCondition(t, db, "messages", "chat_id = ?", testChatID) + if orphanedCountAfter != 0 { + t.Errorf("expected 0 orphaned messages after cleanup, got %d", orphanedCountAfter) + } + }) +} + +func countRows(t *testing.T, db *database, table string) int { + t.Helper() + var count int + err := db.conn.QueryRow(fmt.Sprintf("SELECT COUNT(*) FROM %s", table)).Scan(&count) + if err != nil { + t.Fatalf("failed to count rows in %s: %v", table, err) + } + return count +} + +func countRowsWithCondition(t *testing.T, db *database, table, condition string, args ...interface{}) int { + t.Helper() + var count int + query := fmt.Sprintf("SELECT COUNT(*) FROM %s WHERE %s", table, condition) + err := db.conn.QueryRow(query, args...).Scan(&count) + if err != nil { + t.Fatalf("failed to count rows with condition: %v", err) + } + return count +} + +// Test helpers for schema migration testing + +// schemaMap returns both tables/columns and indexes (ignoring order) +func schemaMap(db *database) map[string]interface{} { + result := make(map[string]any) + + result["tables"] = columnMap(db) + result["indexes"] = indexMap(db) + + return result +} + +// columnMap returns a map of table names to their column sets (ignoring order) +func columnMap(db *database) map[string][]string { + result := make(map[string][]string) + + // Get all table names + tableQuery := `SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' ORDER BY name` + rows, _ := db.conn.Query(tableQuery) + defer rows.Close() + + for rows.Next() { + var tableName string + rows.Scan(&tableName) + + // Get columns for this table + colQuery := fmt.Sprintf("PRAGMA table_info(%s)", tableName) + colRows, _ := db.conn.Query(colQuery) + + var columns []string + for colRows.Next() { + var cid int + var name, dataType sql.NullString + var notNull, primaryKey int + var defaultValue sql.NullString + + colRows.Scan(&cid, &name, &dataType, ¬Null, &defaultValue, &primaryKey) + + // Create a normalized column description + colDesc := fmt.Sprintf("%s %s", name.String, dataType.String) + if notNull == 1 { + colDesc += " NOT NULL" + } + if defaultValue.Valid && defaultValue.String != "" { + // Skip DEFAULT for schema_version as it doesn't get updated during migrations + if name.String != "schema_version" { + colDesc += " DEFAULT " + defaultValue.String + } + } + if primaryKey == 1 { + colDesc += " PRIMARY KEY" + } + + columns = append(columns, colDesc) + } + colRows.Close() + + // Sort columns to ignore order differences + sort.Strings(columns) + result[tableName] = columns + } + + return result +} + +// indexMap returns a map of index names to their definitions +func indexMap(db *database) map[string]string { + result := make(map[string]string) + + // Get all indexes (excluding auto-created primary key indexes) + indexQuery := `SELECT name, sql FROM sqlite_master WHERE type='index' AND name NOT LIKE 'sqlite_%' AND sql IS NOT NULL ORDER BY name` + rows, _ := db.conn.Query(indexQuery) + defer rows.Close() + + for rows.Next() { + var name, sql string + rows.Scan(&name, &sql) + + // Normalize the SQL by removing extra whitespace + sql = strings.Join(strings.Fields(sql), " ") + result[name] = sql + } + + return result +} + +// loadV2Schema loads the version 2 schema from testdata/schema.sql +func loadV2Schema(t *testing.T, dbPath string) *database { + t.Helper() + + // Read the v1 schema file + schemaFile := filepath.Join("testdata", "schema.sql") + schemaSQL, err := os.ReadFile(schemaFile) + if err != nil { + t.Fatalf("failed to read schema file: %v", err) + } + + // Open database connection + conn, err := sql.Open("sqlite3", dbPath+"?_foreign_keys=on&_journal_mode=WAL&_busy_timeout=5000&_txlock=immediate") + if err != nil { + t.Fatalf("failed to open database: %v", err) + } + + // Execute the v1 schema + _, err = conn.Exec(string(schemaSQL)) + if err != nil { + conn.Close() + t.Fatalf("failed to execute v1 schema: %v", err) + } + + return &database{conn: conn} +} diff --git a/app/store/image.go b/app/store/image.go new file mode 100644 index 0000000..c7e6f9f --- /dev/null +++ b/app/store/image.go @@ -0,0 +1,128 @@ +//go:build windows || darwin + +package store + +import ( + "crypto/sha256" + "encoding/hex" + "fmt" + "os" + "path/filepath" + "strings" +) + +type Image struct { + Filename string `json:"filename"` + Path string `json:"path"` + Size int64 `json:"size,omitempty"` + MimeType string `json:"mime_type,omitempty"` +} + +// Bytes loads image data from disk for a given ImageData reference +func (i *Image) Bytes() ([]byte, error) { + return ImgBytes(i.Path) +} + +// ImgBytes reads image data from the specified file path +func ImgBytes(path string) ([]byte, error) { + if path == "" { + return nil, fmt.Errorf("empty image path") + } + + data, err := os.ReadFile(path) + if err != nil { + return nil, fmt.Errorf("read image file %s: %w", path, err) + } + + return data, nil +} + +// ImgDir returns the directory path for storing images for a specific chat +func (s *Store) ImgDir() string { + dbPath := s.DBPath + if dbPath == "" { + dbPath = defaultDBPath + } + storeDir := filepath.Dir(dbPath) + return filepath.Join(storeDir, "cache", "images") +} + +// ImgToFile saves image data to disk and returns ImageData reference +func (s *Store) ImgToFile(chatID string, imageBytes []byte, filename, mimeType string) (Image, error) { + baseImageDir := s.ImgDir() + if err := os.MkdirAll(baseImageDir, 0o755); err != nil { + return Image{}, fmt.Errorf("create base image directory: %w", err) + } + + // Root prevents path traversal issues + root, err := os.OpenRoot(baseImageDir) + if err != nil { + return Image{}, fmt.Errorf("open image root directory: %w", err) + } + defer root.Close() + + // Create chat-specific subdirectory within the root + chatDir := sanitize(chatID) + if err := root.Mkdir(chatDir, 0o755); err != nil && !os.IsExist(err) { + return Image{}, fmt.Errorf("create chat directory: %w", err) + } + + // Generate a unique filename to avoid conflicts + // Use hash of content + original filename for uniqueness + hash := sha256.Sum256(imageBytes) + hashStr := hex.EncodeToString(hash[:])[:16] // Use first 16 chars of hash + + // Extract file extension from original filename or mime type + ext := filepath.Ext(filename) + if ext == "" { + switch mimeType { + case "image/jpeg": + ext = ".jpg" + case "image/png": + ext = ".png" + case "image/webp": + ext = ".webp" + default: + ext = ".img" + } + } + + // Create unique filename: hash + original name + extension + baseFilename := sanitize(strings.TrimSuffix(filename, ext)) + uniqueFilename := fmt.Sprintf("%s_%s%s", hashStr, baseFilename, ext) + relativePath := filepath.Join(chatDir, uniqueFilename) + file, err := root.Create(relativePath) + if err != nil { + return Image{}, fmt.Errorf("create image file: %w", err) + } + defer file.Close() + + if _, err := file.Write(imageBytes); err != nil { + return Image{}, fmt.Errorf("write image data: %w", err) + } + + return Image{ + Filename: uniqueFilename, + Path: filepath.Join(baseImageDir, relativePath), + Size: int64(len(imageBytes)), + MimeType: mimeType, + }, nil +} + +// sanitize removes unsafe characters from filenames +func sanitize(filename string) string { + // Convert to safe characters only + safe := strings.Map(func(r rune) rune { + if (r >= 'a' && r <= 'z') || (r >= 'A' && r <= 'Z') || (r >= '0' && r <= '9') || r == '-' { + return r + } + return '_' + }, filename) + + // Clean up and validate + safe = strings.Trim(safe, "_") + if safe == "" { + return "image" + } + return safe +} diff --git a/app/store/migration_test.go b/app/store/migration_test.go new file mode 100644 index 0000000..0b3c061 --- /dev/null +++ b/app/store/migration_test.go @@ -0,0 +1,290 @@ +//go:build windows || darwin + +package store + +import ( + "database/sql" + "encoding/json" + "os" + "path/filepath" + "testing" +) + +func TestConfigMigration(t *testing.T) { + tmpDir := t.TempDir() + // Create a legacy config.json + legacyConfig := legacyData{ + ID: "test-device-id-12345", + FirstTimeRun: true, // In old system, true meant "has completed first run" + } + + configData, err := json.MarshalIndent(legacyConfig, "", " ") + if err != nil { + t.Fatal(err) + } + + configPath := filepath.Join(tmpDir, "config.json") + if err := os.WriteFile(configPath, configData, 0o644); err != nil { + t.Fatal(err) + } + + // Override the legacy config path for testing + oldLegacyConfigPath := legacyConfigPath + legacyConfigPath = configPath + defer func() { legacyConfigPath = oldLegacyConfigPath }() + + // Create store with database in same directory + s := Store{DBPath: filepath.Join(tmpDir, "db.sqlite")} + defer s.Close() + + // First access should trigger migration + id, err := s.ID() + if err != nil { + t.Fatalf("failed to get ID: %v", err) + } + + if id != "test-device-id-12345" { + t.Errorf("expected migrated ID 'test-device-id-12345', got '%s'", id) + } + + // Check HasCompletedFirstRun + hasCompleted, err := s.HasCompletedFirstRun() + if err != nil { + t.Fatalf("failed to get has completed first run: %v", err) + } + + if !hasCompleted { + t.Error("expected has completed first run to be true after migration") + } + + // Verify migration is marked as complete + migrated, err := s.db.isConfigMigrated() + if err != nil { + t.Fatalf("failed to check migration status: %v", err) + } + + if !migrated { + t.Error("expected config to be marked as migrated") + } + + // Create a new store instance to verify migration doesn't run again + s2 := Store{DBPath: filepath.Join(tmpDir, "db.sqlite")} + defer s2.Close() + + // Delete the config file to ensure we're not reading from it + os.Remove(configPath) + + // Verify data is still there + id2, err := s2.ID() + if err != nil { + t.Fatalf("failed to get ID from second store: %v", err) + } + + if id2 != "test-device-id-12345" { + t.Errorf("expected persisted ID 'test-device-id-12345', got '%s'", id2) + } +} + +func TestNoConfigToMigrate(t *testing.T) { + tmpDir := t.TempDir() + // Override the legacy config path for testing + oldLegacyConfigPath := legacyConfigPath + legacyConfigPath = filepath.Join(tmpDir, "config.json") + defer func() { legacyConfigPath = oldLegacyConfigPath }() + + // Create store without any config.json + s := Store{DBPath: filepath.Join(tmpDir, "db.sqlite")} + defer s.Close() + + // Should generate a new ID + id, err := s.ID() + if err != nil { + t.Fatalf("failed to get ID: %v", err) + } + + if id == "" { + t.Error("expected auto-generated ID, got empty string") + } + + // HasCompletedFirstRun should be false (default) + hasCompleted, err := s.HasCompletedFirstRun() + if err != nil { + t.Fatalf("failed to get has completed first run: %v", err) + } + + if hasCompleted { + t.Error("expected has completed first run to be false by default") + } + + // Migration should still be marked as complete + migrated, err := s.db.isConfigMigrated() + if err != nil { + t.Fatalf("failed to check migration status: %v", err) + } + + if !migrated { + t.Error("expected config to be marked as migrated even with no config.json") + } +} + +func TestCloudMigrationFromAirplaneMode(t *testing.T) { + tmpHome := t.TempDir() + setTestHome(t, tmpHome) + t.Setenv("OLLAMA_NO_CLOUD", "") + + dbPath := filepath.Join(tmpHome, "db.sqlite") + db, err := newDatabase(dbPath) + if err != nil { + t.Fatalf("failed to create database: %v", err) + } + + if _, err := db.conn.Exec("UPDATE settings SET airplane_mode = 1, cloud_setting_migrated = 0"); err != nil { + db.Close() + t.Fatalf("failed to seed airplane migration state: %v", err) + } + db.Close() + + s := Store{DBPath: dbPath} + defer s.Close() + + // Trigger DB initialization + one-time cloud migration. + if _, err := s.ID(); err != nil { + t.Fatalf("failed to initialize store: %v", err) + } + + disabled, err := s.CloudDisabled() + if err != nil { + t.Fatalf("CloudDisabled() error: %v", err) + } + if !disabled { + t.Fatal("expected cloud to be disabled after migrating airplane_mode=true") + } + + configPath := filepath.Join(tmpHome, ".ollama", serverConfigFilename) + data, err := os.ReadFile(configPath) + if err != nil { + t.Fatalf("failed to read migrated server config: %v", err) + } + + var cfg map[string]any + if err := json.Unmarshal(data, &cfg); err != nil { + t.Fatalf("failed to parse migrated server config: %v", err) + } + if cfg["disable_ollama_cloud"] != true { + t.Fatalf("disable_ollama_cloud = %v, want true", cfg["disable_ollama_cloud"]) + } + + var airplaneMode, migrated bool + if err := s.db.conn.QueryRow("SELECT airplane_mode, cloud_setting_migrated FROM settings").Scan(&airplaneMode, &migrated); err != nil { + t.Fatalf("failed to read migration flags from DB: %v", err) + } + if !airplaneMode { + t.Fatal("expected legacy airplane_mode value to remain unchanged") + } + if !migrated { + t.Fatal("expected cloud_setting_migrated to be true") + } +} + +const ( + v1Schema = ` + CREATE TABLE IF NOT EXISTS settings ( + id INTEGER PRIMARY KEY CHECK (id = 1), + device_id TEXT NOT NULL DEFAULT '', + has_completed_first_run BOOLEAN NOT NULL DEFAULT 0, + expose BOOLEAN NOT NULL DEFAULT 0, + browser BOOLEAN NOT NULL DEFAULT 0, + models TEXT NOT NULL DEFAULT '', + remote TEXT NOT NULL DEFAULT '', + agent BOOLEAN NOT NULL DEFAULT 0, + tools BOOLEAN NOT NULL DEFAULT 0, + working_dir TEXT NOT NULL DEFAULT '', + window_width INTEGER NOT NULL DEFAULT 0, + window_height INTEGER NOT NULL DEFAULT 0, + config_migrated BOOLEAN NOT NULL DEFAULT 0, + schema_version INTEGER NOT NULL DEFAULT 1 + ); + + -- Insert default settings row if it doesn't exist + INSERT OR IGNORE INTO settings (id) VALUES (1); + + CREATE TABLE IF NOT EXISTS chats ( + id TEXT PRIMARY KEY, + title TEXT NOT NULL DEFAULT '', + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP + ); + + CREATE TABLE IF NOT EXISTS messages ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + chat_id TEXT NOT NULL, + role TEXT NOT NULL, + content TEXT NOT NULL DEFAULT '', + thinking TEXT NOT NULL DEFAULT '', + stream BOOLEAN NOT NULL DEFAULT 0, + model_name TEXT, + model_cloud BOOLEAN, + model_ollama_host BOOLEAN, + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + thinking_time_start TIMESTAMP, + thinking_time_end TIMESTAMP, + FOREIGN KEY (chat_id) REFERENCES chats(id) ON DELETE CASCADE + ); + + CREATE INDEX IF NOT EXISTS idx_messages_chat_id ON messages(chat_id); + + CREATE TABLE IF NOT EXISTS tool_calls ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + message_id INTEGER NOT NULL, + type TEXT NOT NULL, + function_name TEXT NOT NULL, + function_arguments TEXT NOT NULL, + function_result TEXT, + FOREIGN KEY (message_id) REFERENCES messages(id) ON DELETE CASCADE + ); + + CREATE INDEX IF NOT EXISTS idx_tool_calls_message_id ON tool_calls(message_id); + ` +) + +func TestMigrationFromEpoc(t *testing.T) { + tmpDir := t.TempDir() + s := Store{DBPath: filepath.Join(tmpDir, "db.sqlite")} + defer s.Close() + // Open database connection + conn, err := sql.Open("sqlite3", s.DBPath+"?_foreign_keys=on&_journal_mode=WAL") + if err != nil { + t.Fatal(err) + } + // Test the connection + if err := conn.Ping(); err != nil { + conn.Close() + t.Fatal(err) + } + s.db = &database{conn: conn} + t.Logf("DB created: %s", s.DBPath) + _, err = s.db.conn.Exec(v1Schema) + if err != nil { + t.Fatal(err) + } + version, err := s.db.getSchemaVersion() + if err != nil { + t.Fatalf("failed to get schema version: %v", err) + } + if version != 1 { + t.Fatalf("expected: %d\n got: %d", 1, version) + } + + t.Logf("v1 schema created") + if err := s.db.migrate(); err != nil { + t.Fatal(err) + } + t.Logf("migrations completed") + version, err = s.db.getSchemaVersion() + if err != nil { + t.Fatalf("failed to get schema version: %v", err) + } + if version != currentSchemaVersion { + t.Fatalf("expected: %d\n got: %d", currentSchemaVersion, version) + } +} diff --git a/app/store/schema.sql b/app/store/schema.sql new file mode 100644 index 0000000..8f944ff --- /dev/null +++ b/app/store/schema.sql @@ -0,0 +1,61 @@ +-- This is the version 2 schema for the app database, the first released schema to users. +-- Do not modify this file. It is used to test that the database schema stays in a consistent state between schema migrations. + +CREATE TABLE IF NOT EXISTS settings ( + id INTEGER PRIMARY KEY CHECK (id = 1), + device_id TEXT NOT NULL DEFAULT '', + has_completed_first_run BOOLEAN NOT NULL DEFAULT 0, + expose BOOLEAN NOT NULL DEFAULT 0, + survey BOOLEAN NOT NULL DEFAULT TRUE, + browser BOOLEAN NOT NULL DEFAULT 0, + models TEXT NOT NULL DEFAULT '', + remote TEXT NOT NULL DEFAULT '', + agent BOOLEAN NOT NULL DEFAULT 0, + tools BOOLEAN NOT NULL DEFAULT 0, + working_dir TEXT NOT NULL DEFAULT '', + context_length INTEGER NOT NULL DEFAULT 4096, + window_width INTEGER NOT NULL DEFAULT 0, + window_height INTEGER NOT NULL DEFAULT 0, + config_migrated BOOLEAN NOT NULL DEFAULT 0, + schema_version INTEGER NOT NULL DEFAULT 2 +); + +-- Insert default settings row if it doesn't exist +INSERT OR IGNORE INTO settings (id) VALUES (1); + +CREATE TABLE IF NOT EXISTS chats ( + id TEXT PRIMARY KEY, + title TEXT NOT NULL DEFAULT '', + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE TABLE IF NOT EXISTS messages ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + chat_id TEXT NOT NULL, + role TEXT NOT NULL, + content TEXT NOT NULL DEFAULT '', + thinking TEXT NOT NULL DEFAULT '', + stream BOOLEAN NOT NULL DEFAULT 0, + model_name TEXT, + model_cloud BOOLEAN, + model_ollama_host BOOLEAN, + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + thinking_time_start TIMESTAMP, + thinking_time_end TIMESTAMP, + FOREIGN KEY (chat_id) REFERENCES chats(id) ON DELETE CASCADE +); + +CREATE INDEX IF NOT EXISTS idx_messages_chat_id ON messages(chat_id); + +CREATE TABLE IF NOT EXISTS tool_calls ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + message_id INTEGER NOT NULL, + type TEXT NOT NULL, + function_name TEXT NOT NULL, + function_arguments TEXT NOT NULL, + function_result TEXT, + FOREIGN KEY (message_id) REFERENCES messages(id) ON DELETE CASCADE +); + +CREATE INDEX IF NOT EXISTS idx_tool_calls_message_id ON tool_calls(message_id); diff --git a/app/store/schema_test.go b/app/store/schema_test.go new file mode 100644 index 0000000..a6d4690 --- /dev/null +++ b/app/store/schema_test.go @@ -0,0 +1,60 @@ +//go:build windows || darwin + +package store + +import ( + "path/filepath" + "testing" +) + +func TestSchemaVersioning(t *testing.T) { + tmpDir := t.TempDir() + // Override legacy config path to avoid migration logs + oldLegacyConfigPath := legacyConfigPath + legacyConfigPath = filepath.Join(tmpDir, "config.json") + defer func() { legacyConfigPath = oldLegacyConfigPath }() + + t.Run("new database has correct schema version", func(t *testing.T) { + dbPath := filepath.Join(tmpDir, "new_db.sqlite") + db, err := newDatabase(dbPath) + if err != nil { + t.Fatalf("failed to create database: %v", err) + } + defer db.Close() + + // Check schema version + version, err := db.getSchemaVersion() + if err != nil { + t.Fatalf("failed to get schema version: %v", err) + } + + if version != currentSchemaVersion { + t.Errorf("expected schema version %d, got %d", currentSchemaVersion, version) + } + }) + + t.Run("can update schema version", func(t *testing.T) { + dbPath := filepath.Join(tmpDir, "update_db.sqlite") + db, err := newDatabase(dbPath) + if err != nil { + t.Fatalf("failed to create database: %v", err) + } + defer db.Close() + + // Set a different version + testVersion := 42 + if err := db.setSchemaVersion(testVersion); err != nil { + t.Fatalf("failed to set schema version: %v", err) + } + + // Verify it was updated + version, err := db.getSchemaVersion() + if err != nil { + t.Fatalf("failed to get schema version: %v", err) + } + + if version != testVersion { + t.Errorf("expected schema version %d, got %d", testVersion, version) + } + }) +} diff --git a/app/store/store.go b/app/store/store.go new file mode 100644 index 0000000..369c1db --- /dev/null +++ b/app/store/store.go @@ -0,0 +1,536 @@ +//go:build windows || darwin + +// Package store provides a simple JSON file store for the desktop application +// to save and load data such as ollama server configuration, messages, +// login information and more. +package store + +import ( + "encoding/json" + "fmt" + "log/slog" + "os" + "path/filepath" + "runtime" + "sync" + "time" + + "github.com/google/uuid" + "github.com/ollama/ollama/app/types/not" +) + +type File struct { + Filename string `json:"filename"` + Data []byte `json:"data"` +} + +type User struct { + Name string `json:"name"` + Email string `json:"email"` + Plan string `json:"plan"` + CachedAt time.Time `json:"cachedAt"` +} + +type Message struct { + Role string `json:"role"` + Content string `json:"content"` + Thinking string `json:"thinking"` + Stream bool `json:"stream"` + Model string `json:"model,omitempty"` + Attachments []File `json:"attachments,omitempty"` + ToolCalls []ToolCall `json:"tool_calls,omitempty"` + ToolCall *ToolCall `json:"tool_call,omitempty"` + ToolName string `json:"tool_name,omitempty"` + ToolResult *json.RawMessage `json:"tool_result,omitempty"` + CreatedAt time.Time `json:"created_at"` + UpdatedAt time.Time `json:"updated_at"` + ThinkingTimeStart *time.Time `json:"thinkingTimeStart,omitempty" ts_type:"Date | undefined" ts_transform:"__VALUE__ && new Date(__VALUE__)"` + ThinkingTimeEnd *time.Time `json:"thinkingTimeEnd,omitempty" ts_type:"Date | undefined" ts_transform:"__VALUE__ && new Date(__VALUE__)"` +} + +// MessageOptions contains optional parameters for creating a Message +type MessageOptions struct { + Model string + Attachments []File + Stream bool + Thinking string + ToolCalls []ToolCall + ToolCall *ToolCall + ToolResult *json.RawMessage + ThinkingTimeStart *time.Time + ThinkingTimeEnd *time.Time +} + +// NewMessage creates a new Message with the given options +func NewMessage(role, content string, opts *MessageOptions) Message { + now := time.Now() + msg := Message{ + Role: role, + Content: content, + CreatedAt: now, + UpdatedAt: now, + } + + if opts != nil { + msg.Model = opts.Model + msg.Attachments = opts.Attachments + msg.Stream = opts.Stream + msg.Thinking = opts.Thinking + msg.ToolCalls = opts.ToolCalls + msg.ToolCall = opts.ToolCall + msg.ToolResult = opts.ToolResult + msg.ThinkingTimeStart = opts.ThinkingTimeStart + msg.ThinkingTimeEnd = opts.ThinkingTimeEnd + } + + return msg +} + +type ToolCall struct { + Type string `json:"type"` + Function ToolFunction `json:"function"` +} + +type ToolFunction struct { + Name string `json:"name"` + Arguments string `json:"arguments"` + Result any `json:"result,omitempty"` +} + +type Model struct { + Model string `json:"model"` // Model name + Digest string `json:"digest,omitempty"` // Model digest from the registry + ModifiedAt *time.Time `json:"modified_at,omitempty"` // When the model was last modified locally +} + +type Chat struct { + ID string `json:"id"` + Messages []Message `json:"messages"` + Title string `json:"title"` + CreatedAt time.Time `json:"created_at"` + BrowserState json.RawMessage `json:"browser_state,omitempty" ts_type:"BrowserStateData"` +} + +// NewChat creates a new Chat with the ID, with CreatedAt timestamp initialized +func NewChat(id string) *Chat { + return &Chat{ + ID: id, + Messages: []Message{}, + CreatedAt: time.Now(), + } +} + +type Settings struct { + // Expose is a boolean that indicates if the ollama server should + // be exposed to the network + Expose bool + + // Browser is a boolean that indicates if the ollama server should + // be exposed to browser windows (e.g. CORS set to allow all origins) + Browser bool + + // Survey is a boolean that indicates if the user allows anonymous + // inference information to be shared with Ollama + Survey bool + + // Models is a string that contains the models to load on startup + Models string + + // TODO(parthsareen): temporary for experimentation + // Agent indicates if the app should use multi-turn tools to fulfill user requests + Agent bool + + // Tools indicates if the app should use single-turn tools to fulfill user requests + Tools bool + + // WorkingDir specifies the working directory for all agent operations + WorkingDir string + + // ContextLength specifies the context length for the ollama server (using OLLAMA_CONTEXT_LENGTH) + ContextLength int + + // TurboEnabled indicates if Ollama Turbo features are enabled + TurboEnabled bool + + // Maps gpt-oss specific frontend name' BrowserToolEnabled' to db field 'websearch_enabled' + WebSearchEnabled bool + + // ThinkEnabled indicates if thinking is enabled + ThinkEnabled bool + + // ThinkLevel indicates the level of thinking to use for models that support multiple levels + ThinkLevel string + + // SelectedModel stores the last model that the user selected + SelectedModel string + + // SidebarOpen indicates if the chat sidebar is open + SidebarOpen bool + + // LastHomeView stores the preferred home route target ("chat" or integration name) + LastHomeView string + + // AutoUpdateEnabled indicates if automatic updates should be downloaded + AutoUpdateEnabled bool +} + +type Store struct { + // DBPath allows overriding the default database path (mainly for testing) + DBPath string + + // dbMu protects database initialization only + dbMu sync.Mutex + db *database +} + +var defaultDBPath = func() string { + switch runtime.GOOS { + case "windows": + return filepath.Join(os.Getenv("LOCALAPPDATA"), "Ollama", "db.sqlite") + case "darwin": + return filepath.Join(os.Getenv("HOME"), "Library", "Application Support", "Ollama", "db.sqlite") + default: + return filepath.Join(os.Getenv("HOME"), ".ollama", "db.sqlite") + } +}() + +// legacyConfigPath is the path to the old config.json file +var legacyConfigPath = func() string { + switch runtime.GOOS { + case "windows": + return filepath.Join(os.Getenv("LOCALAPPDATA"), "Ollama", "config.json") + case "darwin": + return filepath.Join(os.Getenv("HOME"), "Library", "Application Support", "Ollama", "config.json") + default: + return filepath.Join(os.Getenv("HOME"), ".ollama", "config.json") + } +}() + +// legacyData represents the old config.json structure (only fields we need to migrate) +type legacyData struct { + ID string `json:"id"` + FirstTimeRun bool `json:"first-time-run"` +} + +func (s *Store) ensureDB() error { + // Fast path: check if db is already initialized + if s.db != nil { + return nil + } + + // Slow path: initialize database with lock + s.dbMu.Lock() + defer s.dbMu.Unlock() + + // Double-check after acquiring lock + if s.db != nil { + return nil + } + + dbPath := s.DBPath + if dbPath == "" { + dbPath = defaultDBPath + } + + // Ensure directory exists + if err := os.MkdirAll(filepath.Dir(dbPath), 0o755); err != nil { + return fmt.Errorf("create db directory: %w", err) + } + + database, err := newDatabase(dbPath) + if err != nil { + return fmt.Errorf("open database: %w", err) + } + + // Generate device ID if needed + id, err := database.getID() + if err != nil || id == "" { + // Generate new UUID for device + u, err := uuid.NewV7() + if err == nil { + database.setID(u.String()) + } + } + + s.db = database + + // Check if we need to migrate from config.json + migrated, err := database.isConfigMigrated() + if err != nil || !migrated { + if err := s.migrateFromConfig(database); err != nil { + slog.Warn("failed to migrate from config.json", "error", err) + } + } + + // Run one-time migration from legacy airplane_mode behavior. + if err := s.migrateCloudSetting(database); err != nil { + return fmt.Errorf("migrate cloud setting: %w", err) + } + + return nil +} + +// migrateCloudSetting migrates legacy airplane_mode into server.json exactly once. +// After this, cloud state is sourced from server.json OR OLLAMA_NO_CLOUD. +func (s *Store) migrateCloudSetting(database *database) error { + migrated, err := database.isCloudSettingMigrated() + if err != nil { + return err + } + if migrated { + return nil + } + + airplaneMode, err := database.getAirplaneMode() + if err != nil { + return err + } + + if airplaneMode { + if err := setCloudEnabled(false); err != nil { + return fmt.Errorf("migrate airplane_mode to cloud disabled: %w", err) + } + } + + if err := database.setCloudSettingMigrated(true); err != nil { + return err + } + + return nil +} + +// migrateFromConfig attempts to migrate ID and FirstTimeRun from config.json +func (s *Store) migrateFromConfig(database *database) error { + configPath := legacyConfigPath + + // Check if config.json exists + if _, err := os.Stat(configPath); os.IsNotExist(err) { + // No config to migrate, mark as migrated + return database.setConfigMigrated(true) + } + + // Read the config file + b, err := os.ReadFile(configPath) + if err != nil { + return fmt.Errorf("read legacy config: %w", err) + } + + var legacy legacyData + if err := json.Unmarshal(b, &legacy); err != nil { + // If we can't parse it, just mark as migrated and move on + slog.Warn("failed to parse legacy config.json", "error", err) + return database.setConfigMigrated(true) + } + + // Migrate the ID if present + if legacy.ID != "" { + if err := database.setID(legacy.ID); err != nil { + return fmt.Errorf("migrate device ID: %w", err) + } + slog.Info("migrated device ID from config.json") + } + + hasCompleted := legacy.FirstTimeRun // If old FirstTimeRun is true, it means first run was completed + if err := database.setHasCompletedFirstRun(hasCompleted); err != nil { + return fmt.Errorf("migrate first time run: %w", err) + } + slog.Info("migrated first run status from config.json", "hasCompleted", hasCompleted) + + // Mark as migrated + if err := database.setConfigMigrated(true); err != nil { + return fmt.Errorf("mark config as migrated: %w", err) + } + + slog.Info("successfully migrated settings from config.json") + return nil +} + +func (s *Store) ID() (string, error) { + if err := s.ensureDB(); err != nil { + return "", err + } + + return s.db.getID() +} + +func (s *Store) HasCompletedFirstRun() (bool, error) { + if err := s.ensureDB(); err != nil { + return false, err + } + + return s.db.getHasCompletedFirstRun() +} + +func (s *Store) SetHasCompletedFirstRun(hasCompleted bool) error { + if err := s.ensureDB(); err != nil { + return err + } + + return s.db.setHasCompletedFirstRun(hasCompleted) +} + +func (s *Store) Settings() (Settings, error) { + if err := s.ensureDB(); err != nil { + return Settings{}, fmt.Errorf("load settings: %w", err) + } + + settings, err := s.db.getSettings() + if err != nil { + return Settings{}, err + } + + // Set default models directory if not set + if settings.Models == "" { + dir := os.Getenv("OLLAMA_MODELS") + if dir != "" { + settings.Models = dir + } else { + home, err := os.UserHomeDir() + if err == nil { + settings.Models = filepath.Join(home, ".ollama", "models") + } + } + } + + if settings.LastHomeView == "" { + settings.LastHomeView = "launch" + } + + return settings, nil +} + +func (s *Store) SetSettings(settings Settings) error { + if err := s.ensureDB(); err != nil { + return err + } + + return s.db.setSettings(settings) +} + +func (s *Store) Chats() ([]Chat, error) { + if err := s.ensureDB(); err != nil { + return nil, err + } + + return s.db.getAllChats() +} + +func (s *Store) Chat(id string) (*Chat, error) { + return s.ChatWithOptions(id, true) +} + +func (s *Store) ChatWithOptions(id string, loadAttachmentData bool) (*Chat, error) { + if err := s.ensureDB(); err != nil { + return nil, err + } + + chat, err := s.db.getChatWithOptions(id, loadAttachmentData) + if err != nil { + return nil, fmt.Errorf("%w: chat %s", not.Found, id) + } + + return chat, nil +} + +func (s *Store) SetChat(chat Chat) error { + if err := s.ensureDB(); err != nil { + return err + } + + return s.db.saveChat(chat) +} + +func (s *Store) DeleteChat(id string) error { + if err := s.ensureDB(); err != nil { + return err + } + + // Delete from database + if err := s.db.deleteChat(id); err != nil { + return fmt.Errorf("%w: chat %s", not.Found, id) + } + + // Also delete associated images + chatImgDir := filepath.Join(s.ImgDir(), id) + if err := os.RemoveAll(chatImgDir); err != nil { + // Log error but don't fail the deletion + slog.Warn("failed to delete chat images", "chat_id", id, "error", err) + } + + return nil +} + +func (s *Store) WindowSize() (int, int, error) { + if err := s.ensureDB(); err != nil { + return 0, 0, err + } + + return s.db.getWindowSize() +} + +func (s *Store) SetWindowSize(width, height int) error { + if err := s.ensureDB(); err != nil { + return err + } + + return s.db.setWindowSize(width, height) +} + +func (s *Store) UpdateLastMessage(chatID string, message Message) error { + if err := s.ensureDB(); err != nil { + return err + } + + return s.db.updateLastMessage(chatID, message) +} + +func (s *Store) AppendMessage(chatID string, message Message) error { + if err := s.ensureDB(); err != nil { + return err + } + + return s.db.appendMessage(chatID, message) +} + +func (s *Store) UpdateChatBrowserState(chatID string, state json.RawMessage) error { + if err := s.ensureDB(); err != nil { + return err + } + + return s.db.updateChatBrowserState(chatID, state) +} + +func (s *Store) User() (*User, error) { + if err := s.ensureDB(); err != nil { + return nil, err + } + + return s.db.getUser() +} + +func (s *Store) SetUser(user User) error { + if err := s.ensureDB(); err != nil { + return err + } + + user.CachedAt = time.Now() + return s.db.setUser(user) +} + +func (s *Store) ClearUser() error { + if err := s.ensureDB(); err != nil { + return err + } + + return s.db.clearUser() +} + +func (s *Store) Close() error { + s.dbMu.Lock() + defer s.dbMu.Unlock() + + if s.db != nil { + return s.db.Close() + } + return nil +} diff --git a/app/store/store_test.go b/app/store/store_test.go new file mode 100644 index 0000000..d4a08a8 --- /dev/null +++ b/app/store/store_test.go @@ -0,0 +1,248 @@ +//go:build windows || darwin + +package store + +import ( + "path/filepath" + "testing" +) + +func TestStore(t *testing.T) { + s, cleanup := setupTestStore(t) + defer cleanup() + + t.Run("default id", func(t *testing.T) { + // ID should be automatically generated + id, err := s.ID() + if err != nil { + t.Fatal(err) + } + if id == "" { + t.Error("expected non-empty ID") + } + + // Verify ID is persisted + id2, err := s.ID() + if err != nil { + t.Fatal(err) + } + if id != id2 { + t.Errorf("expected ID %s, got %s", id, id2) + } + }) + + t.Run("has completed first run", func(t *testing.T) { + // Default should be false (hasn't completed first run yet) + hasCompleted, err := s.HasCompletedFirstRun() + if err != nil { + t.Fatal(err) + } + if hasCompleted { + t.Error("expected has completed first run to be false by default") + } + + if err := s.SetHasCompletedFirstRun(true); err != nil { + t.Fatal(err) + } + + hasCompleted, err = s.HasCompletedFirstRun() + if err != nil { + t.Fatal(err) + } + if !hasCompleted { + t.Error("expected has completed first run to be true") + } + }) + + t.Run("settings", func(t *testing.T) { + sc := Settings{ + Expose: true, + Browser: true, + Survey: true, + Models: "/tmp/models", + Agent: true, + Tools: false, + WorkingDir: "/tmp/work", + } + + if err := s.SetSettings(sc); err != nil { + t.Fatal(err) + } + + loaded, err := s.Settings() + if err != nil { + t.Fatal(err) + } + // Compare fields individually since Models might get a default + if loaded.Expose != sc.Expose || loaded.Browser != sc.Browser || + loaded.Agent != sc.Agent || loaded.Survey != sc.Survey || + loaded.Tools != sc.Tools || loaded.WorkingDir != sc.WorkingDir { + t.Errorf("expected %v, got %v", sc, loaded) + } + }) + + t.Run("settings default home view is launch", func(t *testing.T) { + loaded, err := s.Settings() + if err != nil { + t.Fatal(err) + } + + if loaded.LastHomeView != "launch" { + t.Fatalf("expected default LastHomeView to be launch, got %q", loaded.LastHomeView) + } + }) + + t.Run("settings empty home view falls back to launch", func(t *testing.T) { + if err := s.SetSettings(Settings{LastHomeView: ""}); err != nil { + t.Fatal(err) + } + + loaded, err := s.Settings() + if err != nil { + t.Fatal(err) + } + + if loaded.LastHomeView != "launch" { + t.Fatalf("expected empty LastHomeView to fall back to launch, got %q", loaded.LastHomeView) + } + }) + + t.Run("settings disabled home view falls back to launch", func(t *testing.T) { + if err := s.SetSettings(Settings{LastHomeView: "claude-desktop"}); err != nil { + t.Fatal(err) + } + + loaded, err := s.Settings() + if err != nil { + t.Fatal(err) + } + + if loaded.LastHomeView != "launch" { + t.Fatalf("expected disabled LastHomeView to fall back to launch, got %q", loaded.LastHomeView) + } + }) + + t.Run("settings codex app home view is accepted", func(t *testing.T) { + if err := s.SetSettings(Settings{LastHomeView: "codex-app"}); err != nil { + t.Fatal(err) + } + + loaded, err := s.Settings() + if err != nil { + t.Fatal(err) + } + + if loaded.LastHomeView != "codex-app" { + t.Fatalf("expected codex-app LastHomeView to be preserved, got %q", loaded.LastHomeView) + } + }) + + t.Run("window size", func(t *testing.T) { + if err := s.SetWindowSize(1024, 768); err != nil { + t.Fatal(err) + } + + width, height, err := s.WindowSize() + if err != nil { + t.Fatal(err) + } + if width != 1024 || height != 768 { + t.Errorf("expected 1024x768, got %dx%d", width, height) + } + }) + + t.Run("create and retrieve chat", func(t *testing.T) { + chat := NewChat("test-chat-1") + chat.Title = "Test Chat" + + chat.Messages = append(chat.Messages, NewMessage("user", "Hello", nil)) + chat.Messages = append(chat.Messages, NewMessage("assistant", "Hi there!", &MessageOptions{ + Model: "llama4", + })) + + if err := s.SetChat(*chat); err != nil { + t.Fatalf("failed to save chat: %v", err) + } + + retrieved, err := s.Chat("test-chat-1") + if err != nil { + t.Fatalf("failed to retrieve chat: %v", err) + } + + if retrieved.ID != chat.ID { + t.Errorf("expected ID %s, got %s", chat.ID, retrieved.ID) + } + if retrieved.Title != chat.Title { + t.Errorf("expected title %s, got %s", chat.Title, retrieved.Title) + } + if len(retrieved.Messages) != 2 { + t.Fatalf("expected 2 messages, got %d", len(retrieved.Messages)) + } + if retrieved.Messages[0].Content != "Hello" { + t.Errorf("expected first message 'Hello', got %s", retrieved.Messages[0].Content) + } + if retrieved.Messages[1].Content != "Hi there!" { + t.Errorf("expected second message 'Hi there!', got %s", retrieved.Messages[1].Content) + } + }) + + t.Run("list chats", func(t *testing.T) { + chat2 := NewChat("test-chat-2") + chat2.Title = "Another Chat" + chat2.Messages = append(chat2.Messages, NewMessage("user", "Test", nil)) + + if err := s.SetChat(*chat2); err != nil { + t.Fatalf("failed to save chat: %v", err) + } + + chats, err := s.Chats() + if err != nil { + t.Fatalf("failed to list chats: %v", err) + } + + if len(chats) != 2 { + t.Fatalf("expected 2 chats, got %d", len(chats)) + } + }) + + t.Run("delete chat", func(t *testing.T) { + if err := s.DeleteChat("test-chat-1"); err != nil { + t.Fatalf("failed to delete chat: %v", err) + } + + // Verify it's gone + _, err := s.Chat("test-chat-1") + if err == nil { + t.Error("expected error retrieving deleted chat") + } + + // Verify other chat still exists + chats, err := s.Chats() + if err != nil { + t.Fatalf("failed to list chats: %v", err) + } + if len(chats) != 1 { + t.Fatalf("expected 1 chat after deletion, got %d", len(chats)) + } + }) +} + +// setupTestStore creates a temporary store for testing +func setupTestStore(t *testing.T) (*Store, func()) { + t.Helper() + + tmpDir := t.TempDir() + + // Override legacy config path to ensure no migration happens + oldLegacyConfigPath := legacyConfigPath + legacyConfigPath = filepath.Join(tmpDir, "config.json") + + s := &Store{DBPath: filepath.Join(tmpDir, "db.sqlite")} + + cleanup := func() { + s.Close() + legacyConfigPath = oldLegacyConfigPath + } + + return s, cleanup +} diff --git a/app/store/test_home_test.go b/app/store/test_home_test.go new file mode 100644 index 0000000..df2f988 --- /dev/null +++ b/app/store/test_home_test.go @@ -0,0 +1,11 @@ +//go:build windows || darwin + +package store + +import "testing" + +func setTestHome(t *testing.T, home string) { + t.Helper() + t.Setenv("HOME", home) + t.Setenv("USERPROFILE", home) +} diff --git a/app/store/testdata/schema.sql b/app/store/testdata/schema.sql new file mode 100644 index 0000000..9ed23c2 --- /dev/null +++ b/app/store/testdata/schema.sql @@ -0,0 +1,61 @@ +-- This is the version 2 schema for the app database, the first released schema to users. +-- Do not modify this file. It is used to test that the database schema stays in a consistent state between schema migrations. + +CREATE TABLE IF NOT EXISTS settings ( + id INTEGER PRIMARY KEY CHECK (id = 1), + device_id TEXT NOT NULL DEFAULT '', + has_completed_first_run BOOLEAN NOT NULL DEFAULT 0, + expose BOOLEAN NOT NULL DEFAULT 0, + survey BOOLEAN NOT NULL DEFAULT TRUE, + browser BOOLEAN NOT NULL DEFAULT 0, + models TEXT NOT NULL DEFAULT '', + remote TEXT NOT NULL DEFAULT '', + agent BOOLEAN NOT NULL DEFAULT 0, + tools BOOLEAN NOT NULL DEFAULT 0, + working_dir TEXT NOT NULL DEFAULT '', + context_length INTEGER NOT NULL DEFAULT 0, + window_width INTEGER NOT NULL DEFAULT 0, + window_height INTEGER NOT NULL DEFAULT 0, + config_migrated BOOLEAN NOT NULL DEFAULT 0, + schema_version INTEGER NOT NULL DEFAULT 2 +); + +-- Insert default settings row if it doesn't exist +INSERT OR IGNORE INTO settings (id) VALUES (1); + +CREATE TABLE IF NOT EXISTS chats ( + id TEXT PRIMARY KEY, + title TEXT NOT NULL DEFAULT '', + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE TABLE IF NOT EXISTS messages ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + chat_id TEXT NOT NULL, + role TEXT NOT NULL, + content TEXT NOT NULL DEFAULT '', + thinking TEXT NOT NULL DEFAULT '', + stream BOOLEAN NOT NULL DEFAULT 0, + model_name TEXT, + model_cloud BOOLEAN, + model_ollama_host BOOLEAN, + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + thinking_time_start TIMESTAMP, + thinking_time_end TIMESTAMP, + FOREIGN KEY (chat_id) REFERENCES chats(id) ON DELETE CASCADE +); + +CREATE INDEX IF NOT EXISTS idx_messages_chat_id ON messages(chat_id); + +CREATE TABLE IF NOT EXISTS tool_calls ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + message_id INTEGER NOT NULL, + type TEXT NOT NULL, + function_name TEXT NOT NULL, + function_arguments TEXT NOT NULL, + function_result TEXT, + FOREIGN KEY (message_id) REFERENCES messages(id) ON DELETE CASCADE +); + +CREATE INDEX IF NOT EXISTS idx_tool_calls_message_id ON tool_calls(message_id); diff --git a/app/tools/browser.go b/app/tools/browser.go new file mode 100644 index 0000000..b41c079 --- /dev/null +++ b/app/tools/browser.go @@ -0,0 +1,863 @@ +//go:build windows || darwin + +package tools + +import ( + "context" + "fmt" + "net/url" + "regexp" + "strings" + "sync" + "time" + + "github.com/ollama/ollama/app/ui/responses" +) + +type PageType string + +const ( + PageTypeSearchResults PageType = "initial_results" + PageTypeWebpage PageType = "webpage" +) + +// DefaultViewTokens is the number of tokens to show to the model used when calling displayPage +const DefaultViewTokens = 1024 + +/* +The Browser tool provides web browsing capability for gpt-oss. +The model uses the tool by usually doing a search first and then choosing to either open a page, +find a term in a page, or do another search. + +The tool optionally may open a URL directly - especially if one is passed in. + +Each action is saved into an append-only page stack `responses.BrowserStateData` to keep +track of the history of the browsing session. + +Each `Execute()` for a tool returns the full current state of the browser. ui.go manages the +browser state representation between the tool, ui, and db. + +A new Browser object is created per request - the state is reconstructed by ui.go. +The initialization of the browser will receive a `responses.BrowserStateData` with the stitched history. +*/ + +// BrowserState manages the browsing session on a per-chat basis +type BrowserState struct { + mu sync.RWMutex + Data *responses.BrowserStateData +} +type Browser struct { + state *BrowserState +} + +// State is only accessed in a single thread, as each chat has its own browser state +func (b *Browser) State() *responses.BrowserStateData { + b.state.mu.RLock() + defer b.state.mu.RUnlock() + return b.state.Data +} + +func (b *Browser) savePage(page *responses.Page) { + b.state.Data.URLToPage[page.URL] = page + b.state.Data.PageStack = append(b.state.Data.PageStack, page.URL) +} + +func (b *Browser) getPageFromStack(url string) (*responses.Page, error) { + page, ok := b.state.Data.URLToPage[url] + if !ok { + return nil, fmt.Errorf("page not found for url %s", url) + } + return page, nil +} + +func NewBrowser(state *responses.BrowserStateData) *Browser { + if state == nil { + state = &responses.BrowserStateData{ + PageStack: []string{}, + ViewTokens: DefaultViewTokens, + URLToPage: make(map[string]*responses.Page), + } + } + b := &BrowserState{ + Data: state, + } + + return &Browser{ + state: b, + } +} + +type BrowserSearch struct { + Browser + webSearch *BrowserWebSearch +} + +// NewBrowserSearch creates a new browser search instance +func NewBrowserSearch(bb *Browser) *BrowserSearch { + if bb == nil { + bb = &Browser{ + state: &BrowserState{ + Data: &responses.BrowserStateData{ + PageStack: []string{}, + ViewTokens: DefaultViewTokens, + URLToPage: make(map[string]*responses.Page), + }, + }, + } + } + return &BrowserSearch{ + Browser: *bb, + webSearch: &BrowserWebSearch{}, + } +} + +func (b *BrowserSearch) Name() string { + return "browser.search" +} + +func (b *BrowserSearch) Description() string { + return "Search the web for information" +} + +func (b *BrowserSearch) Prompt() string { + return "" +} + +func (b *BrowserSearch) Schema() map[string]any { + return map[string]any{} +} + +func (b *BrowserSearch) Execute(ctx context.Context, args map[string]any) (any, string, error) { + query, ok := args["query"].(string) + if !ok { + return nil, "", fmt.Errorf("query parameter is required") + } + + topn, ok := args["topn"].(int) + if !ok { + topn = 5 + } + + searchArgs := map[string]any{ + "queries": []any{query}, + "max_results": topn, + } + + result, err := b.webSearch.Execute(ctx, searchArgs) + if err != nil { + return nil, "", fmt.Errorf("search error: %w", err) + } + + searchResponse, ok := result.(*WebSearchResponse) + if !ok { + return nil, "", fmt.Errorf("invalid search results format") + } + + // Build main search results page that contains all search results + searchResultsPage := b.buildSearchResultsPageCollection(query, searchResponse) + b.savePage(searchResultsPage) + cursor := len(b.state.Data.PageStack) - 1 + // cache result for each page + for _, queryResults := range searchResponse.Results { + for i, result := range queryResults { + resultPage := b.buildSearchResultsPage(&result, i+1) + // save to global only, do not add to visited stack + b.state.Data.URLToPage[resultPage.URL] = resultPage + } + } + + page := searchResultsPage + + pageText, err := b.displayPage(page, cursor, 0, -1) + if err != nil { + return nil, "", fmt.Errorf("failed to display page: %w", err) + } + + return b.state.Data, pageText, nil +} + +func (b *Browser) buildSearchResultsPageCollection(query string, results *WebSearchResponse) *responses.Page { + page := &responses.Page{ + URL: "search_results_" + query, + Title: query, + Links: make(map[int]string), + FetchedAt: time.Now(), + } + + var textBuilder strings.Builder + linkIdx := 0 + + // Add the header lines to match format + textBuilder.WriteString("\n") // L0: empty + textBuilder.WriteString("URL: \n") // L1: URL: (empty for search) + textBuilder.WriteString("# Search Results\n") // L2: # Search Results + textBuilder.WriteString("\n") // L3: empty + + for _, queryResults := range results.Results { + for _, result := range queryResults { + domain := result.URL + if u, err := url.Parse(result.URL); err == nil && u.Host != "" { + domain = u.Host + domain = strings.TrimPrefix(domain, "www.") + } + + linkFormat := fmt.Sprintf("* 【%d†%s†%s】", linkIdx, result.Title, domain) + textBuilder.WriteString(linkFormat) + + numChars := min(len(result.Content.FullText), 400) + snippet := strings.TrimSpace(result.Content.FullText[:numChars]) + textBuilder.WriteString(snippet) + textBuilder.WriteString("\n") + + page.Links[linkIdx] = result.URL + linkIdx++ + } + } + + page.Text = textBuilder.String() + page.Lines = wrapLines(page.Text, 80) + + return page +} + +func (b *Browser) buildSearchResultsPage(result *WebSearchResult, linkIdx int) *responses.Page { + page := &responses.Page{ + URL: result.URL, + Title: result.Title, + Links: make(map[int]string), + FetchedAt: time.Now(), + } + + var textBuilder strings.Builder + + // Format the individual result page (only used when no full text is available) + linkFormat := fmt.Sprintf("【%d†%s】", linkIdx, result.Title) + textBuilder.WriteString(linkFormat) + textBuilder.WriteString("\n") + textBuilder.WriteString(fmt.Sprintf("URL: %s\n", result.URL)) + numChars := min(len(result.Content.FullText), 300) + textBuilder.WriteString(result.Content.FullText[:numChars]) + textBuilder.WriteString("\n\n") + + // Only store link and snippet if we won't be processing full text later + // (full text processing will handle all links consistently) + if result.Content.FullText == "" { + page.Links[linkIdx] = result.URL + } + + // Use full text if available, otherwise use snippet + if result.Content.FullText != "" { + // Prepend the URL line to the full text + page.Text = fmt.Sprintf("URL: %s\n%s", result.URL, result.Content.FullText) + // Process markdown links in the full text + processedText, processedLinks := processMarkdownLinks(page.Text) + page.Text = processedText + page.Links = processedLinks + } else { + page.Text = textBuilder.String() + } + + page.Lines = wrapLines(page.Text, 80) + + return page +} + +// getEndLoc calculates the end location for viewport based on token limits +func (b *Browser) getEndLoc(loc, numLines, totalLines int, lines []string) int { + if numLines <= 0 { + // Auto-calculate based on viewTokens + txt := b.joinLinesWithNumbers(lines[loc:]) + + // If text is very short, no need to truncate (at least 1 char per token) + if len(txt) > b.state.Data.ViewTokens { + // Simple heuristic: approximate token counting + // Typical token is ~4 characters, but can be up to 128 chars + maxCharsPerToken := 128 + + // upper bound for text to analyze + upperBound := min((b.state.Data.ViewTokens+1)*maxCharsPerToken, len(txt)) + textToAnalyze := txt[:upperBound] + + // Simple approximation: count tokens as ~4 chars each + // This is less accurate than tiktoken but more performant + approxTokens := len(textToAnalyze) / 4 + + if approxTokens > b.state.Data.ViewTokens { + // Find the character position at viewTokens + endIdx := min(b.state.Data.ViewTokens*4, len(txt)) + + // Count newlines up to that position to get line count + numLines = strings.Count(txt[:endIdx], "\n") + 1 + } else { + numLines = totalLines + } + } else { + numLines = totalLines + } + } + + return min(loc+numLines, totalLines) +} + +// joinLinesWithNumbers creates a string with line numbers, matching Python's join_lines +func (b *Browser) joinLinesWithNumbers(lines []string) string { + var builder strings.Builder + var hadZeroLine bool + for i, line := range lines { + if i == 0 { + builder.WriteString("L0:\n") + hadZeroLine = true + } + if hadZeroLine { + builder.WriteString(fmt.Sprintf("L%d: %s\n", i+1, line)) + } else { + builder.WriteString(fmt.Sprintf("L%d: %s\n", i, line)) + } + } + return builder.String() +} + +// processMarkdownLinks finds all markdown links in the text and replaces them with the special format +// Returns the processed text and a map of link IDs to URLs +func processMarkdownLinks(text string) (string, map[int]string) { + links := make(map[int]string) + + // Always start from 0 for consistent numbering across all pages + linkID := 0 + + // First, handle multi-line markdown links by joining them + // This regex finds markdown links that might be split across lines + multiLinePattern := regexp.MustCompile(`\[([^\]]+)\]\s*\n\s*\(([^)]+)\)`) + text = multiLinePattern.ReplaceAllStringFunc(text, func(match string) string { + // Replace newlines with spaces in the match + cleaned := strings.ReplaceAll(match, "\n", " ") + // Remove extra spaces + cleaned = regexp.MustCompile(`\s+`).ReplaceAllString(cleaned, " ") + return cleaned + }) + + // Now process all markdown links (including the cleaned multi-line ones) + linkPattern := regexp.MustCompile(`\[([^\]]+)\]\(([^)]+)\)`) + + processedText := linkPattern.ReplaceAllStringFunc(text, func(match string) string { + matches := linkPattern.FindStringSubmatch(match) + if len(matches) != 3 { + return match + } + + linkText := strings.TrimSpace(matches[1]) + linkURL := strings.TrimSpace(matches[2]) + + // Extract domain from URL + domain := linkURL + if u, err := url.Parse(linkURL); err == nil && u.Host != "" { + domain = u.Host + // Remove www. prefix if present + domain = strings.TrimPrefix(domain, "www.") + } + + // Create the formatted link + formatted := fmt.Sprintf("【%d†%s†%s】", linkID, linkText, domain) + + // Store the link + links[linkID] = linkURL + linkID++ + + return formatted + }) + + return processedText, links +} + +func wrapLines(text string, width int) []string { + if width <= 0 { + width = 80 + } + + lines := strings.Split(text, "\n") + var wrapped []string + + for _, line := range lines { + if line == "" { + // Preserve empty lines + wrapped = append(wrapped, "") + } else if len(line) <= width { + wrapped = append(wrapped, line) + } else { + // Word wrapping while preserving whitespace structure + words := strings.Fields(line) + if len(words) == 0 { + // Line with only whitespace + wrapped = append(wrapped, line) + continue + } + + currentLine := "" + for _, word := range words { + // Check if adding this word would exceed width + testLine := currentLine + if testLine != "" { + testLine += " " + } + testLine += word + + if len(testLine) > width && currentLine != "" { + // Current line would be too long, wrap it + wrapped = append(wrapped, currentLine) + currentLine = word + } else { + // Add word to current line + if currentLine != "" { + currentLine += " " + } + currentLine += word + } + } + + // Add any remaining content + if currentLine != "" { + wrapped = append(wrapped, currentLine) + } + } + } + + return wrapped +} + +// displayPage formats and returns the page display for the model +func (b *Browser) displayPage(page *responses.Page, cursor, loc, numLines int) (string, error) { + totalLines := len(page.Lines) + + if loc >= totalLines { + return "", fmt.Errorf("invalid location: %d (max: %d)", loc, totalLines-1) + } + + // get viewport end location + endLoc := b.getEndLoc(loc, numLines, totalLines, page.Lines) + + var displayBuilder strings.Builder + displayBuilder.WriteString(fmt.Sprintf("[%d] %s", cursor, page.Title)) + if page.URL != "" { + displayBuilder.WriteString(fmt.Sprintf("(%s)\n", page.URL)) + } else { + displayBuilder.WriteString("\n") + } + displayBuilder.WriteString(fmt.Sprintf("**viewing lines [%d - %d] of %d**\n\n", loc, endLoc-1, totalLines-1)) + + // Content with line numbers + var hadZeroLine bool + for i := loc; i < endLoc; i++ { + if i == 0 { + displayBuilder.WriteString("L0:\n") + hadZeroLine = true + } + if hadZeroLine { + displayBuilder.WriteString(fmt.Sprintf("L%d: %s\n", i+1, page.Lines[i])) + } else { + displayBuilder.WriteString(fmt.Sprintf("L%d: %s\n", i, page.Lines[i])) + } + } + + return displayBuilder.String(), nil +} + +type BrowserOpen struct { + Browser + crawlPage *BrowserCrawler +} + +func NewBrowserOpen(bb *Browser) *BrowserOpen { + if bb == nil { + bb = &Browser{ + state: &BrowserState{ + Data: &responses.BrowserStateData{ + PageStack: []string{}, + ViewTokens: DefaultViewTokens, + URLToPage: make(map[string]*responses.Page), + }, + }, + } + } + return &BrowserOpen{ + Browser: *bb, + crawlPage: &BrowserCrawler{}, + } +} + +func (b *BrowserOpen) Name() string { + return "browser.open" +} + +func (b *BrowserOpen) Description() string { + return "Open a link in the browser" +} + +func (b *BrowserOpen) Prompt() string { + return "" +} + +func (b *BrowserOpen) Schema() map[string]any { + return map[string]any{} +} + +func (b *BrowserOpen) Execute(ctx context.Context, args map[string]any) (any, string, error) { + // Get cursor parameter first + cursor := -1 + if c, ok := args["cursor"].(float64); ok { + cursor = int(c) + } else if c, ok := args["cursor"].(int); ok { + cursor = c + } + + // Get loc parameter + loc := 0 + if l, ok := args["loc"].(float64); ok { + loc = int(l) + } else if l, ok := args["loc"].(int); ok { + loc = l + } + + // Get num_lines parameter + numLines := -1 + if n, ok := args["num_lines"].(float64); ok { + numLines = int(n) + } else if n, ok := args["num_lines"].(int); ok { + numLines = n + } + + // get page from cursor + var page *responses.Page + if cursor >= 0 { + if cursor >= len(b.state.Data.PageStack) { + return nil, "", fmt.Errorf("cursor %d is out of range (pageStack length: %d)", cursor, len(b.state.Data.PageStack)) + } + var err error + page, err = b.getPageFromStack(b.state.Data.PageStack[cursor]) + if err != nil { + return nil, "", fmt.Errorf("page not found for cursor %d: %w", cursor, err) + } + } else { + // get last page + if len(b.state.Data.PageStack) != 0 { + pageURL := b.state.Data.PageStack[len(b.state.Data.PageStack)-1] + var err error + page, err = b.getPageFromStack(pageURL) + if err != nil { + return nil, "", fmt.Errorf("page not found for cursor %d: %w", cursor, err) + } + } + } + + // Try to get id as string (URL) first + if url, ok := args["id"].(string); ok { + // Check if we already have this page cached + if existingPage, ok := b.state.Data.URLToPage[url]; ok { + // Use cached page + b.savePage(existingPage) + // Always update cursor to point to the newly added page + cursor = len(b.state.Data.PageStack) - 1 + pageText, err := b.displayPage(existingPage, cursor, loc, numLines) + if err != nil { + return nil, "", fmt.Errorf("failed to display page: %w", err) + } + return b.state.Data, pageText, nil + } + + // Page not in cache, need to crawl it + if b.crawlPage == nil { + b.crawlPage = &BrowserCrawler{} + } + crawlResponse, err := b.crawlPage.Execute(ctx, map[string]any{ + "urls": []any{url}, + "latest": false, + }) + if err != nil { + return nil, "", fmt.Errorf("failed to crawl URL %s: %w", url, err) + } + + newPage, err := b.buildPageFromCrawlResult(url, crawlResponse) + if err != nil { + return nil, "", fmt.Errorf("failed to build page from crawl result: %w", err) + } + + // Need to fall through if first search is directly an open command - no existing page + b.savePage(newPage) + // Always update cursor to point to the newly added page + cursor = len(b.state.Data.PageStack) - 1 + pageText, err := b.displayPage(newPage, cursor, loc, numLines) + if err != nil { + return nil, "", fmt.Errorf("failed to display page: %w", err) + } + return b.state.Data, pageText, nil + } + + // Try to get id as integer (link ID from current page) + if id, ok := args["id"].(float64); ok { + if page == nil { + return nil, "", fmt.Errorf("no current page to resolve link from") + } + idInt := int(id) + pageURL, ok := page.Links[idInt] + if !ok { + return nil, "", fmt.Errorf("invalid link id %d", idInt) + } + + // Check if we have the linked page cached + newPage, ok := b.state.Data.URLToPage[pageURL] + if !ok { + if b.crawlPage == nil { + b.crawlPage = &BrowserCrawler{} + } + crawlResponse, err := b.crawlPage.Execute(ctx, map[string]any{ + "urls": []any{pageURL}, + "latest": false, + }) + if err != nil { + return nil, "", fmt.Errorf("failed to crawl URL %s: %w", pageURL, err) + } + + // Create new page from crawl result + newPage, err = b.buildPageFromCrawlResult(pageURL, crawlResponse) + if err != nil { + return nil, "", fmt.Errorf("failed to build page from crawl result: %w", err) + } + } + + // Add to history stack regardless of cache status + b.savePage(newPage) + + // Always update cursor to point to the newly added page + cursor = len(b.state.Data.PageStack) - 1 + pageText, err := b.displayPage(newPage, cursor, loc, numLines) + if err != nil { + return nil, "", fmt.Errorf("failed to display page: %w", err) + } + return b.state.Data, pageText, nil + } + + // If no id provided, just display current page + if page == nil { + return nil, "", fmt.Errorf("no current page to display") + } + // Only add to PageStack without updating URLToPage + b.state.Data.PageStack = append(b.state.Data.PageStack, page.URL) + cursor = len(b.state.Data.PageStack) - 1 + + pageText, err := b.displayPage(page, cursor, loc, numLines) + if err != nil { + return nil, "", fmt.Errorf("failed to display page: %w", err) + } + return b.state.Data, pageText, nil +} + +// buildPageFromCrawlResult creates a Page from crawl API results +func (b *Browser) buildPageFromCrawlResult(requestedURL string, crawlResponse *CrawlResponse) (*responses.Page, error) { + // Initialize page with defaults + page := &responses.Page{ + URL: requestedURL, + Title: requestedURL, + Text: "", + Links: make(map[int]string), + FetchedAt: time.Now(), + } + + // Process crawl results - the API returns results grouped by URL + for url, urlResults := range crawlResponse.Results { + if len(urlResults) > 0 { + // Get the first result for this URL + result := urlResults[0] + + // Extract content + if result.Content.FullText != "" { + page.Text = result.Content.FullText + } + + // Extract title if available + if result.Title != "" { + page.Title = result.Title + } + + // Update URL to the actual URL from results + page.URL = url + + // Extract links if available from extras + for i, link := range result.Extras.Links { + if link.Href != "" { + page.Links[i] = link.Href + } else if link.URL != "" { + page.Links[i] = link.URL + } + } + + // Only process the first URL's results + break + } + } + + // If no text was extracted, set a default message + if page.Text == "" { + page.Text = "No content could be extracted from this page." + } else { + // Prepend the URL line to match Python implementation + page.Text = fmt.Sprintf("URL: %s\n%s", page.URL, page.Text) + } + + // Process markdown links in the text + processedText, processedLinks := processMarkdownLinks(page.Text) + page.Text = processedText + page.Links = processedLinks + + // Wrap lines for display + page.Lines = wrapLines(page.Text, 80) + + return page, nil +} + +type BrowserFind struct { + Browser +} + +func NewBrowserFind(bb *Browser) *BrowserFind { + return &BrowserFind{ + Browser: *bb, + } +} + +func (b *BrowserFind) Name() string { + return "browser.find" +} + +func (b *BrowserFind) Description() string { + return "Find a term in the browser" +} + +func (b *BrowserFind) Prompt() string { + return "" +} + +func (b *BrowserFind) Schema() map[string]any { + return map[string]any{} +} + +func (b *BrowserFind) Execute(ctx context.Context, args map[string]any) (any, string, error) { + pattern, ok := args["pattern"].(string) + if !ok { + return nil, "", fmt.Errorf("pattern parameter is required") + } + + // Get cursor parameter if provided, default to current page + cursor := -1 + if c, ok := args["cursor"].(float64); ok { + cursor = int(c) + } + + // Get the page to search in + var page *responses.Page + if cursor == -1 { + // Use current page + if len(b.state.Data.PageStack) == 0 { + return nil, "", fmt.Errorf("no pages to search in") + } + var err error + page, err = b.getPageFromStack(b.state.Data.PageStack[len(b.state.Data.PageStack)-1]) + if err != nil { + return nil, "", fmt.Errorf("page not found for cursor %d: %w", cursor, err) + } + } else { + // Use specific cursor + if cursor < 0 || cursor >= len(b.state.Data.PageStack) { + return nil, "", fmt.Errorf("cursor %d is out of range [0-%d]", cursor, len(b.state.Data.PageStack)-1) + } + var err error + page, err = b.getPageFromStack(b.state.Data.PageStack[cursor]) + if err != nil { + return nil, "", fmt.Errorf("page not found for cursor %d: %w", cursor, err) + } + } + + if page == nil { + return nil, "", fmt.Errorf("page not found") + } + + // Create find results page + findPage := b.buildFindResultsPage(pattern, page) + + // Add the find results page to state + b.savePage(findPage) + newCursor := len(b.state.Data.PageStack) - 1 + + pageText, err := b.displayPage(findPage, newCursor, 0, -1) + if err != nil { + return nil, "", fmt.Errorf("failed to display page: %w", err) + } + + return b.state.Data, pageText, nil +} + +func (b *Browser) buildFindResultsPage(pattern string, page *responses.Page) *responses.Page { + findPage := &responses.Page{ + Title: fmt.Sprintf("Find results for text: `%s` in `%s`", pattern, page.Title), + Links: make(map[int]string), + FetchedAt: time.Now(), + } + + findPage.URL = fmt.Sprintf("find_results_%s", pattern) + + var textBuilder strings.Builder + matchIdx := 0 + maxResults := 50 + numShowLines := 4 + patternLower := strings.ToLower(pattern) + + // Search through the page lines following the reference algorithm + var resultChunks []string + lineIdx := 0 + + for lineIdx < len(page.Lines) { + line := page.Lines[lineIdx] + lineLower := strings.ToLower(line) + + if !strings.Contains(lineLower, patternLower) { + lineIdx++ + continue + } + + // Build snippet context + endLine := min(lineIdx+numShowLines, len(page.Lines)) + + var snippetBuilder strings.Builder + for j := lineIdx; j < endLine; j++ { + snippetBuilder.WriteString(page.Lines[j]) + if j < endLine-1 { + snippetBuilder.WriteString("\n") + } + } + snippet := snippetBuilder.String() + + // Format the match + linkFormat := fmt.Sprintf("【%d†match at L%d】", matchIdx, lineIdx) + resultChunk := fmt.Sprintf("%s\n%s", linkFormat, snippet) + resultChunks = append(resultChunks, resultChunk) + + if len(resultChunks) >= maxResults { + break + } + + matchIdx++ + lineIdx += numShowLines + } + + // Build final display text + if len(resultChunks) > 0 { + textBuilder.WriteString(strings.Join(resultChunks, "\n\n")) + } + + if matchIdx == 0 { + findPage.Text = fmt.Sprintf("No `find` results for pattern: `%s`", pattern) + } else { + findPage.Text = textBuilder.String() + } + + findPage.Lines = wrapLines(findPage.Text, 80) + return findPage +} diff --git a/app/tools/browser_crawl.go b/app/tools/browser_crawl.go new file mode 100644 index 0000000..fd9c2bd --- /dev/null +++ b/app/tools/browser_crawl.go @@ -0,0 +1,136 @@ +//go:build windows || darwin + +package tools + +import ( + "context" + "encoding/json" + "fmt" +) + +// CrawlContent represents the content of a crawled page +type CrawlContent struct { + Snippet string `json:"snippet"` + FullText string `json:"full_text"` +} + +// CrawlExtras represents additional data from the crawl API +type CrawlExtras struct { + Links []CrawlLink `json:"links"` +} + +// CrawlLink represents a link found on a crawled page +type CrawlLink struct { + URL string `json:"url"` + Href string `json:"href"` + Text string `json:"text"` +} + +// CrawlResult represents a single crawl result +type CrawlResult struct { + Title string `json:"title"` + URL string `json:"url"` + Content CrawlContent `json:"content"` + Extras CrawlExtras `json:"extras"` +} + +// CrawlResponse represents the complete response from the crawl API +type CrawlResponse struct { + Results map[string][]CrawlResult `json:"results"` +} + +// BrowserCrawler tool for crawling web pages using ollama.com crawl API +type BrowserCrawler struct{} + +func (g *BrowserCrawler) Name() string { + return "get_webpage" +} + +func (g *BrowserCrawler) Description() string { + return "Crawl and extract text content from web pages" +} + +func (g *BrowserCrawler) Prompt() string { + return `When you need to read content from web pages, use the get_webpage tool. Simply provide the URLs you want to read and I'll fetch their content for you. + +For each URL, I'll extract the main text content in a readable format. If you need to discover links within those pages, set extract_links to true. If the user requires the latest information, set livecrawl to true. + +Only use this tool when you need to access current web content. Make sure the URLs are valid and accessible. Do not use this tool for: +- Downloading files or media +- Accessing private/authenticated pages +- Scraping data at high volumes + +Always check the returned content to ensure it's relevant before using it in your response.` +} + +func (g *BrowserCrawler) Schema() map[string]any { + schemaBytes := []byte(`{ + "type": "object", + "properties": { + "urls": { + "type": "array", + "items": { + "type": "string" + }, + "description": "List of URLs to crawl and extract content from" + } + }, + "required": ["urls"] + }`) + var schema map[string]any + if err := json.Unmarshal(schemaBytes, &schema); err != nil { + return nil + } + return schema +} + +func (g *BrowserCrawler) Execute(ctx context.Context, args map[string]any) (*CrawlResponse, error) { + urlsRaw, ok := args["urls"].([]any) + if !ok { + return nil, fmt.Errorf("urls parameter is required and must be an array of strings") + } + + urls := make([]string, 0, len(urlsRaw)) + for _, u := range urlsRaw { + if urlStr, ok := u.(string); ok { + urls = append(urls, urlStr) + } + } + + if len(urls) == 0 { + return nil, fmt.Errorf("at least one URL is required") + } + + return g.performWebCrawl(ctx, urls) +} + +// performWebCrawl handles the actual HTTP request to ollama.com crawl API +func (g *BrowserCrawler) performWebCrawl(ctx context.Context, urls []string) (*CrawlResponse, error) { + result := &CrawlResponse{Results: make(map[string][]CrawlResult, len(urls))} + + for _, targetURL := range urls { + fetchResp, err := performWebFetch(ctx, targetURL) + if err != nil { + return nil, fmt.Errorf("web_fetch failed for %q: %w", targetURL, err) + } + + links := make([]CrawlLink, 0, len(fetchResp.Links)) + for _, link := range fetchResp.Links { + links = append(links, CrawlLink{URL: link, Href: link}) + } + + snippet := truncateString(fetchResp.Content, 400) + + result.Results[targetURL] = []CrawlResult{{ + Title: fetchResp.Title, + URL: targetURL, + Content: CrawlContent{ + Snippet: snippet, + FullText: fetchResp.Content, + }, + Extras: CrawlExtras{Links: links}, + }} + } + + return result, nil +} diff --git a/app/tools/browser_test.go b/app/tools/browser_test.go new file mode 100644 index 0000000..05b5584 --- /dev/null +++ b/app/tools/browser_test.go @@ -0,0 +1,147 @@ +//go:build windows || darwin + +package tools + +import ( + "strings" + "testing" + "time" + + "github.com/ollama/ollama/app/ui/responses" +) + +func makeTestPage(url string) *responses.Page { + return &responses.Page{ + URL: url, + Title: "Title " + url, + Text: "Body for " + url, + Lines: []string{"line1", "line2", "line3"}, + Links: map[int]string{0: url}, + FetchedAt: time.Now(), + } +} + +func TestBrowser_Scroll_AppendsOnlyPageStack(t *testing.T) { + b := NewBrowser(&responses.BrowserStateData{PageStack: []string{}, ViewTokens: 1024, URLToPage: map[string]*responses.Page{}}) + p1 := makeTestPage("https://example.com/1") + b.savePage(p1) + initialStackLen := len(b.state.Data.PageStack) + initialMapLen := len(b.state.Data.URLToPage) + + bo := NewBrowserOpen(b) + // Scroll without id — should push only to PageStack + _, _, err := bo.Execute(t.Context(), map[string]any{"loc": float64(1), "num_lines": float64(1)}) + if err != nil { + t.Fatalf("scroll execute failed: %v", err) + } + + if got, want := len(b.state.Data.PageStack), initialStackLen+1; got != want { + t.Fatalf("page stack length = %d, want %d", got, want) + } + if got, want := len(b.state.Data.URLToPage), initialMapLen; got != want { + t.Fatalf("url_to_page length changed = %d, want %d", got, want) + } +} + +func TestBrowserOpen_UseCacheByURL(t *testing.T) { + b := NewBrowser(&responses.BrowserStateData{PageStack: []string{}, ViewTokens: 1024, URLToPage: map[string]*responses.Page{}}) + bo := NewBrowserOpen(b) + + p := makeTestPage("https://example.com/cached") + b.state.Data.URLToPage[p.URL] = p + initialStackLen := len(b.state.Data.PageStack) + initialMapLen := len(b.state.Data.URLToPage) + + _, _, err := bo.Execute(t.Context(), map[string]any{"id": p.URL}) + if err != nil { + t.Fatalf("open cached execute failed: %v", err) + } + + if got, want := len(b.state.Data.PageStack), initialStackLen+1; got != want { + t.Fatalf("page stack length = %d, want %d", got, want) + } + if got, want := len(b.state.Data.URLToPage), initialMapLen; got != want { + t.Fatalf("url_to_page length changed = %d, want %d", got, want) + } +} + +func TestDisplayPage_InvalidLoc(t *testing.T) { + b := NewBrowser(&responses.BrowserStateData{PageStack: []string{}, ViewTokens: 1024, URLToPage: map[string]*responses.Page{}}) + p := makeTestPage("https://example.com/x") + // ensure lines are set + p.Lines = []string{"a", "b"} + _, err := b.displayPage(p, 0, 10, -1) + if err == nil || !strings.Contains(err.Error(), "invalid location") { + t.Fatalf("expected invalid location error, got %v", err) + } +} + +func TestBrowserOpen_LinkId_UsesCacheAndAppends(t *testing.T) { + b := NewBrowser(&responses.BrowserStateData{PageStack: []string{}, ViewTokens: 1024, URLToPage: map[string]*responses.Page{}}) + // Seed a main page with a link id 0 to a linked URL + main := makeTestPage("https://example.com/main") + linked := makeTestPage("https://example.com/linked") + main.Links = map[int]string{0: linked.URL} + // Save the main page (adds to PageStack and URLToPage) + b.savePage(main) + // Pre-cache the linked page so open by id avoids network + b.state.Data.URLToPage[linked.URL] = linked + + initialStackLen := len(b.state.Data.PageStack) + initialMapLen := len(b.state.Data.URLToPage) + + bo := NewBrowserOpen(b) + _, _, err := bo.Execute(t.Context(), map[string]any{"id": float64(0)}) + if err != nil { + t.Fatalf("open by link id failed: %v", err) + } + + if got, want := len(b.state.Data.PageStack), initialStackLen+1; got != want { + t.Fatalf("page stack length = %d, want %d", got, want) + } + if got, want := len(b.state.Data.URLToPage), initialMapLen; got != want { + t.Fatalf("url_to_page length changed = %d, want %d", got, want) + } + if last := b.state.Data.PageStack[len(b.state.Data.PageStack)-1]; last != linked.URL { + t.Fatalf("last page in stack = %s, want %s", last, linked.URL) + } +} + +func TestWrapLines_PreserveAndWidth(t *testing.T) { + long := strings.Repeat("word ", 50) + text := "Line1\n\n" + long + "\nLine3" + lines := wrapLines(text, 40) + + // Ensure empty line preserved at index 1 + if lines[1] != "" { + t.Fatalf("expected preserved empty line at index 1, got %q", lines[1]) + } + // All lines should be <= 40 chars + for i, l := range lines { + if len(l) > 40 { + t.Fatalf("line %d exceeds width: %d > 40", i, len(l)) + } + } +} + +func TestDisplayPage_FormatHeaderAndLines(t *testing.T) { + b := NewBrowser(&responses.BrowserStateData{PageStack: []string{}, ViewTokens: 1024, URLToPage: map[string]*responses.Page{}}) + p := &responses.Page{ + URL: "https://example.com/x", + Title: "Example", + Lines: []string{"URL: https://example.com/x", "A", "B", "C"}, + } + out, err := b.displayPage(p, 3, 0, 2) + if err != nil { + t.Fatalf("displayPage failed: %v", err) + } + if !strings.HasPrefix(out, "[3] Example(") { + t.Fatalf("header not formatted as expected: %q", out) + } + if !strings.Contains(out, "L0:\n") { + t.Fatalf("missing L0 label: %q", out) + } + if !strings.Contains(out, "L1: URL: https://example.com/x\n") || !strings.Contains(out, "L2: A\n") { + t.Fatalf("missing expected line numbers/content: %q", out) + } +} diff --git a/app/tools/browser_websearch.go b/app/tools/browser_websearch.go new file mode 100644 index 0000000..dd47fb8 --- /dev/null +++ b/app/tools/browser_websearch.go @@ -0,0 +1,143 @@ +//go:build windows || darwin + +package tools + +import ( + "context" + "encoding/json" + "fmt" + "strconv" + "time" +) + +// WebSearchContent represents the content of a search result +type WebSearchContent struct { + Snippet string `json:"snippet"` + FullText string `json:"full_text"` +} + +// WebSearchMetadata represents metadata for a search result +type WebSearchMetadata struct { + PublishedDate *time.Time `json:"published_date,omitempty"` +} + +// WebSearchResult represents a single search result +type WebSearchResult struct { + Title string `json:"title"` + URL string `json:"url"` + Content WebSearchContent `json:"content"` + Metadata WebSearchMetadata `json:"metadata"` +} + +// WebSearchResponse represents the complete response from the websearch API +type WebSearchResponse struct { + Results map[string][]WebSearchResult `json:"results"` +} + +// BrowserWebSearch tool for searching the web using ollama.com search API +type BrowserWebSearch struct{} + +func (w *BrowserWebSearch) Name() string { + return "gpt_oss_web_search" +} + +func (w *BrowserWebSearch) Description() string { + return "Search the web for real-time information using ollama.com search API." +} + +func (w *BrowserWebSearch) Prompt() string { + return `Use the gpt_oss_web_search tool to search the web. +1. Come up with a list of search queries to get comprehensive information (typically 2-3 related queries work well) +2. Use the gpt_oss_web_search tool with multiple queries to get results organized by query +3. Use the search results to provide current up to date, accurate information + +Today's date is ` + time.Now().Format("January 2, 2006") + ` +Add "` + time.Now().Format("January 2, 2006") + `" for news queries and ` + strconv.Itoa(time.Now().Year()+1) + ` for other queries that need current information.` +} + +func (w *BrowserWebSearch) Schema() map[string]any { + schemaBytes := []byte(`{ + "type": "object", + "properties": { + "queries": { + "type": "array", + "items": { + "type": "string" + }, + "description": "List of search queries to look up" + }, + "max_results": { + "type": "integer", + "description": "Maximum number of results to return per query (default: 2) up to 5", + "default": 2 + } + }, + "required": ["queries"] + }`) + var schema map[string]any + if err := json.Unmarshal(schemaBytes, &schema); err != nil { + return nil + } + return schema +} + +func (w *BrowserWebSearch) Execute(ctx context.Context, args map[string]any) (any, error) { + queriesRaw, ok := args["queries"].([]any) + if !ok { + return nil, fmt.Errorf("queries parameter is required and must be an array of strings") + } + + queries := make([]string, 0, len(queriesRaw)) + for _, q := range queriesRaw { + if query, ok := q.(string); ok { + queries = append(queries, query) + } + } + + if len(queries) == 0 { + return nil, fmt.Errorf("at least one query is required") + } + + maxResults := 5 + if mr, ok := args["max_results"].(int); ok { + maxResults = mr + } + + return w.performWebSearch(ctx, queries, maxResults) +} + +// performWebSearch handles the actual HTTP request to ollama.com search API +func (w *BrowserWebSearch) performWebSearch(ctx context.Context, queries []string, maxResults int) (*WebSearchResponse, error) { + response := &WebSearchResponse{Results: make(map[string][]WebSearchResult, len(queries))} + + for _, query := range queries { + searchResp, err := performWebSearch(ctx, query, maxResults) + if err != nil { + return nil, fmt.Errorf("web_search failed for %q: %w", query, err) + } + + converted := make([]WebSearchResult, 0, len(searchResp.Results)) + for _, item := range searchResp.Results { + converted = append(converted, WebSearchResult{ + Title: item.Title, + URL: item.URL, + Content: WebSearchContent{ + Snippet: truncateString(item.Content, 400), + FullText: item.Content, + }, + Metadata: WebSearchMetadata{}, + }) + } + + response.Results[query] = converted + } + + return response, nil +} + +func truncateString(input string, limit int) string { + if limit <= 0 || len(input) <= limit { + return input + } + return input[:limit] +} diff --git a/app/tools/cloud_policy.go b/app/tools/cloud_policy.go new file mode 100644 index 0000000..3b05577 --- /dev/null +++ b/app/tools/cloud_policy.go @@ -0,0 +1,35 @@ +//go:build windows || darwin + +package tools + +import ( + "context" + "errors" + + "github.com/ollama/ollama/api" + internalcloud "github.com/ollama/ollama/internal/cloud" +) + +// ensureCloudEnabledForTool checks cloud policy from the connected Ollama server. +// If policy cannot be determined, this fails closed and blocks the operation. +func ensureCloudEnabledForTool(ctx context.Context, operation string) error { + // Reuse shared message formatting; policy evaluation is still done via + // the connected server's /api/status endpoint below. + disabledMessage := internalcloud.DisabledError(operation) + + client, err := api.ClientFromEnvironment() + if err != nil { + return errors.New(disabledMessage + " (unable to verify server cloud policy)") + } + + status, err := client.CloudStatusExperimental(ctx) + if err != nil { + return errors.New(disabledMessage + " (unable to verify server cloud policy)") + } + + if status.Cloud.Disabled { + return errors.New(disabledMessage) + } + + return nil +} diff --git a/app/tools/cloud_policy_test.go b/app/tools/cloud_policy_test.go new file mode 100644 index 0000000..5bd83ca --- /dev/null +++ b/app/tools/cloud_policy_test.go @@ -0,0 +1,73 @@ +//go:build windows || darwin + +package tools + +import ( + "context" + "net/http" + "net/http/httptest" + "strings" + "testing" +) + +func TestEnsureCloudEnabledForTool(t *testing.T) { + const op = "web search is unavailable" + const disabledPrefix = "ollama cloud is disabled: web search is unavailable" + + t.Run("enabled allows tool execution", func(t *testing.T) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.URL.Path != "/api/status" { + http.NotFound(w, r) + return + } + w.Header().Set("Content-Type", "application/json") + _, _ = w.Write([]byte(`{"cloud":{"disabled":false,"source":"none"}}`)) + })) + t.Cleanup(ts.Close) + t.Setenv("OLLAMA_HOST", ts.URL) + + if err := ensureCloudEnabledForTool(context.Background(), op); err != nil { + t.Fatalf("expected nil error, got %v", err) + } + }) + + t.Run("disabled blocks tool execution", func(t *testing.T) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.URL.Path != "/api/status" { + http.NotFound(w, r) + return + } + w.Header().Set("Content-Type", "application/json") + _, _ = w.Write([]byte(`{"cloud":{"disabled":true,"source":"config"}}`)) + })) + t.Cleanup(ts.Close) + t.Setenv("OLLAMA_HOST", ts.URL) + + err := ensureCloudEnabledForTool(context.Background(), op) + if err == nil { + t.Fatal("expected error, got nil") + } + if got := err.Error(); got != disabledPrefix { + t.Fatalf("unexpected error: %q", got) + } + }) + + t.Run("status unavailable fails closed", func(t *testing.T) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + http.NotFound(w, r) + })) + t.Cleanup(ts.Close) + t.Setenv("OLLAMA_HOST", ts.URL) + + err := ensureCloudEnabledForTool(context.Background(), op) + if err == nil { + t.Fatal("expected error, got nil") + } + if got := err.Error(); !strings.Contains(got, disabledPrefix) { + t.Fatalf("expected disabled prefix, got %q", got) + } + if got := err.Error(); !strings.Contains(got, "unable to verify server cloud policy") { + t.Fatalf("expected verification failure detail, got %q", got) + } + }) +} diff --git a/app/tools/tools.go b/app/tools/tools.go new file mode 100644 index 0000000..b367278 --- /dev/null +++ b/app/tools/tools.go @@ -0,0 +1,122 @@ +//go:build windows || darwin + +package tools + +import ( + "context" + "encoding/json" + "fmt" +) + +// Tool defines the interface that all tools must implement +type Tool interface { + // Name returns the unique identifier for the tool + Name() string + + // Description returns a human-readable description of what the tool does + Description() string + + // Schema returns the JSON schema for the tool's parameters + Schema() map[string]any + + // Execute runs the tool with the given arguments and returns result to store in db, and a string result for the model + Execute(ctx context.Context, args map[string]any) (any, string, error) + + // Prompt returns a prompt for the tool + Prompt() string +} + +// Registry manages the available tools and their execution +type Registry struct { + tools map[string]Tool + workingDir string // Working directory for all tool operations +} + +// NewRegistry creates a new tool registry with no tools +func NewRegistry() *Registry { + return &Registry{ + tools: make(map[string]Tool), + } +} + +// Register adds a tool to the registry +func (r *Registry) Register(tool Tool) { + r.tools[tool.Name()] = tool +} + +// Get retrieves a tool by name +func (r *Registry) Get(name string) (Tool, bool) { + tool, exists := r.tools[name] + return tool, exists +} + +// List returns all available tools +func (r *Registry) List() []Tool { + tools := make([]Tool, 0, len(r.tools)) + for _, tool := range r.tools { + tools = append(tools, tool) + } + return tools +} + +// SetWorkingDir sets the working directory for all tool operations +func (r *Registry) SetWorkingDir(dir string) { + r.workingDir = dir +} + +// Execute runs a tool with the given name and arguments +func (r *Registry) Execute(ctx context.Context, name string, args map[string]any) (any, string, error) { + tool, ok := r.tools[name] + if !ok { + return nil, "", fmt.Errorf("unknown tool: %s", name) + } + + result, text, err := tool.Execute(ctx, args) + if err != nil { + return nil, "", err + } + return result, text, nil +} + +// ToolCall represents a request to execute a tool +type ToolCall struct { + ID string `json:"id"` + Type string `json:"type"` + Function ToolFunction `json:"function"` +} + +// ToolFunction represents the function call details +type ToolFunction struct { + Name string `json:"name"` + Arguments json.RawMessage `json:"arguments"` +} + +// ToolResult represents the result of a tool execution +type ToolResult struct { + ToolCallID string `json:"tool_call_id"` + Content any `json:"content"` + Error string `json:"error,omitempty"` +} + +// ToolSchemas returns all tools as schema maps suitable for API calls +func (r *Registry) AvailableTools() []map[string]any { + schemas := make([]map[string]any, 0, len(r.tools)) + for _, tool := range r.tools { + schema := map[string]any{ + "name": tool.Name(), + "description": tool.Description(), + "schema": tool.Schema(), + } + schemas = append(schemas, schema) + } + return schemas +} + +// ToolNames returns a list of all tool names +func (r *Registry) ToolNames() []string { + names := make([]string, 0, len(r.tools)) + for name := range r.tools { + names = append(names, name) + } + return names +} diff --git a/app/tools/web_fetch.go b/app/tools/web_fetch.go new file mode 100644 index 0000000..15e2778 --- /dev/null +++ b/app/tools/web_fetch.go @@ -0,0 +1,132 @@ +//go:build windows || darwin + +package tools + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "net/http" + "net/url" + "strconv" + "strings" + "time" + + "github.com/ollama/ollama/auth" +) + +type WebFetch struct{} + +type FetchRequest struct { + URL string `json:"url"` +} + +type FetchResponse struct { + Title string `json:"title"` + Content string `json:"content"` + Links []string `json:"links"` +} + +func (w *WebFetch) Name() string { + return "web_fetch" +} + +func (w *WebFetch) Description() string { + return "Crawl and extract text content from web pages" +} + +func (g *WebFetch) Schema() map[string]any { + schemaBytes := []byte(`{ + "type": "object", + "properties": { + "url": { + "type": "string", + "description": "URL to crawl and extract content from" + } + }, + "required": ["url"] + }`) + var schema map[string]any + if err := json.Unmarshal(schemaBytes, &schema); err != nil { + return nil + } + return schema +} + +func (w *WebFetch) Prompt() string { + return "" +} + +func (w *WebFetch) Execute(ctx context.Context, args map[string]any) (any, string, error) { + urlRaw, ok := args["url"] + if !ok { + return nil, "", fmt.Errorf("url parameter is required") + } + urlStr, ok := urlRaw.(string) + if !ok || strings.TrimSpace(urlStr) == "" { + return nil, "", fmt.Errorf("url must be a non-empty string") + } + + result, err := performWebFetch(ctx, urlStr) + if err != nil { + return nil, "", err + } + + return result, "", nil +} + +func performWebFetch(ctx context.Context, targetURL string) (*FetchResponse, error) { + if err := ensureCloudEnabledForTool(ctx, "web fetch is unavailable"); err != nil { + return nil, err + } + + reqBody := FetchRequest{URL: targetURL} + jsonBody, err := json.Marshal(reqBody) + if err != nil { + return nil, fmt.Errorf("failed to marshal request body: %w", err) + } + + crawlURL, err := url.Parse("https://ollama.com/api/web_fetch") + if err != nil { + return nil, fmt.Errorf("failed to parse fetch URL: %w", err) + } + + query := crawlURL.Query() + query.Add("ts", strconv.FormatInt(time.Now().Unix(), 10)) + crawlURL.RawQuery = query.Encode() + + data := fmt.Appendf(nil, "%s,%s", http.MethodPost, crawlURL.RequestURI()) + signature, err := auth.Sign(ctx, data) + if err != nil { + return nil, fmt.Errorf("failed to sign request: %w", err) + } + + req, err := http.NewRequestWithContext(ctx, http.MethodPost, crawlURL.String(), bytes.NewBuffer(jsonBody)) + if err != nil { + return nil, fmt.Errorf("failed to create request: %w", err) + } + + req.Header.Set("Content-Type", "application/json") + if signature != "" { + req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", signature)) + } + + client := &http.Client{Timeout: 30 * time.Second} + resp, err := client.Do(req) + if err != nil { + return nil, fmt.Errorf("failed to execute fetch request: %w", err) + } + defer resp.Body.Close() + + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("fetch API error (status %d)", resp.StatusCode) + } + + var result FetchResponse + if err := json.NewDecoder(resp.Body).Decode(&result); err != nil { + return nil, fmt.Errorf("failed to decode response: %w", err) + } + + return &result, nil +} diff --git a/app/tools/web_search.go b/app/tools/web_search.go new file mode 100644 index 0000000..fd37835 --- /dev/null +++ b/app/tools/web_search.go @@ -0,0 +1,149 @@ +//go:build windows || darwin + +package tools + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "net/http" + "net/url" + "strconv" + "strings" + "time" + + "github.com/ollama/ollama/auth" +) + +type WebSearch struct{} + +type SearchRequest struct { + Query string `json:"query"` + MaxResults int `json:"max_results,omitempty"` +} + +type SearchResult struct { + Title string `json:"title"` + URL string `json:"url"` + Content string `json:"content"` +} + +type SearchResponse struct { + Results []SearchResult `json:"results"` +} + +func (w *WebSearch) Name() string { + return "web_search" +} + +func (w *WebSearch) Description() string { + return "Search the web for real-time information using ollama.com web search API." +} + +func (w *WebSearch) Prompt() string { + return "" +} + +func (g *WebSearch) Schema() map[string]any { + schemaBytes := []byte(`{ + "type": "object", + "properties": { + "query": { + "type": "string", + "description": "The search query to execute" + }, + "max_results": { + "type": "integer", + "description": "Maximum number of search results to return", + "default": 3 + } + }, + "required": ["query"] + }`) + var schema map[string]any + if err := json.Unmarshal(schemaBytes, &schema); err != nil { + return nil + } + return schema +} + +func (w *WebSearch) Execute(ctx context.Context, args map[string]any) (any, string, error) { + rawQuery, ok := args["query"] + if !ok { + return nil, "", fmt.Errorf("query parameter is required") + } + + queryStr, ok := rawQuery.(string) + if !ok || strings.TrimSpace(queryStr) == "" { + return nil, "", fmt.Errorf("query must be a non-empty string") + } + + maxResults := 5 + if v, ok := args["max_results"].(float64); ok && int(v) > 0 { + maxResults = int(v) + } + + result, err := performWebSearch(ctx, queryStr, maxResults) + if err != nil { + return nil, "", err + } + + return result, "", nil +} + +func performWebSearch(ctx context.Context, query string, maxResults int) (*SearchResponse, error) { + if err := ensureCloudEnabledForTool(ctx, "web search is unavailable"); err != nil { + return nil, err + } + + reqBody := SearchRequest{Query: query, MaxResults: maxResults} + + jsonBody, err := json.Marshal(reqBody) + if err != nil { + return nil, fmt.Errorf("failed to marshal request body: %w", err) + } + + searchURL, err := url.Parse("https://ollama.com/api/web_search") + if err != nil { + return nil, fmt.Errorf("failed to parse search URL: %w", err) + } + + q := searchURL.Query() + q.Add("ts", strconv.FormatInt(time.Now().Unix(), 10)) + searchURL.RawQuery = q.Encode() + + data := fmt.Appendf(nil, "%s,%s", http.MethodPost, searchURL.RequestURI()) + signature, err := auth.Sign(ctx, data) + if err != nil { + return nil, fmt.Errorf("failed to sign request: %w", err) + } + + req, err := http.NewRequestWithContext(ctx, http.MethodPost, searchURL.String(), bytes.NewBuffer(jsonBody)) + if err != nil { + return nil, fmt.Errorf("failed to create request: %w", err) + } + + req.Header.Set("Content-Type", "application/json") + if signature != "" { + req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", signature)) + } + + client := &http.Client{Timeout: 10 * time.Second} + resp, err := client.Do(req) + if err != nil { + return nil, fmt.Errorf("failed to execute search request: %w", err) + } + defer resp.Body.Close() + + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("search API error (status %d)", resp.StatusCode) + } + + var result SearchResponse + if err := json.NewDecoder(resp.Body).Decode(&result); err != nil { + return nil, fmt.Errorf("failed to decode response: %w", err) + } + + return &result, nil +} diff --git a/app/types/not/found.go b/app/types/not/found.go new file mode 100644 index 0000000..9294e01 --- /dev/null +++ b/app/types/not/found.go @@ -0,0 +1,28 @@ +//go:build windows || darwin + +package not + +import ( + "errors" +) + +// Found is an error that indicates that a value was not found. It +// may be used by low-level packages to signal to higher-level +// packages that a value was not found. +// +// It exists to avoid using errors.New("not found") in multiple +// packages to mean the same thing. +// +// Found should not be used directly. Instead it should be wrapped +// or joined using errors.Join or fmt.Errorf, etc. +// +// Errors wrapping Found should provide additional context, e.g. +// fmt.Errorf("%w: %s", not.Found, key) +// +//lint:ignore ST1012 This is a sentinel error intended to be read like not.Found. +var Found = errors.New("not found") + +// Available is an error that indicates that a value is not available. +// +//lint:ignore ST1012 This is a sentinel error intended to be read like not.Available. +var Available = errors.New("not available") diff --git a/app/types/not/valids.go b/app/types/not/valids.go new file mode 100644 index 0000000..d198942 --- /dev/null +++ b/app/types/not/valids.go @@ -0,0 +1,55 @@ +//go:build windows || darwin + +package not + +import ( + "fmt" +) + +type ValidError struct { + name string + msg string + args []any +} + +// Valid returns a new validation error with the given name and message. +func Valid(name, message string, args ...any) error { + return ValidError{name, message, args} +} + +// Message returns the formatted message for the validation error. +func (e *ValidError) Message() string { + return fmt.Sprintf(e.msg, e.args...) +} + +// Error implements the error interface. +func (e ValidError) Error() string { + return fmt.Sprintf("invalid %s: %s", e.name, e.Message()) +} + +func (e ValidError) Field() string { + return e.name +} + +// Valids is for building a list of validation errors. +type Valids []ValidError + +// Addf adds a validation error to the list with a formatted message using fmt.Sprintf. +func (b *Valids) Add(name, message string, args ...any) { + *b = append(*b, ValidError{name, message, args}) +} + +func (b Valids) Error() string { + if len(b) == 0 { + return "" + } + + var result string + for i, err := range b { + if i > 0 { + result += "; " + } + result += err.Error() + } + return result +} diff --git a/app/types/not/valids_test.go b/app/types/not/valids_test.go new file mode 100644 index 0000000..4a64822 --- /dev/null +++ b/app/types/not/valids_test.go @@ -0,0 +1,43 @@ +//go:build windows || darwin + +package not_test + +import ( + "errors" + "fmt" + + "github.com/ollama/ollama/app/types/not" +) + +func ExampleValids() { + // This example demonstrates how to use the Valids type to create + // a list of validation errors. + // + // The Valids type is a slice of ValidError values. Each ValidError + // value represents a validation error. + // + // The Valids type has an Error method that returns a single error + // value that represents all of the validation errors in the list. + // + // The Valids type is useful for collecting multiple validation errors + // and returning them as a single error value. + + validate := func() error { + var b not.Valids + b.Add("name", "must be a valid name") + b.Add("email", "%q: must be a valid email address", "invalid.email") + return b + } + + err := validate() + var nv not.Valids + if errors.As(err, &nv) { + for _, v := range nv { + fmt.Println(v) + } + } + + // Output: + // invalid name: must be a valid name + // invalid email: "invalid.email": must be a valid email address +} diff --git a/app/ui/app.go b/app/ui/app.go new file mode 100644 index 0000000..d73df2c --- /dev/null +++ b/app/ui/app.go @@ -0,0 +1,44 @@ +//go:build windows || darwin + +package ui + +import ( + "bytes" + "embed" + "errors" + "io/fs" + "net/http" + "strings" + "time" +) + +//go:embed app/dist +var appFS embed.FS + +// appHandler returns an HTTP handler that serves the React SPA. +// It tries to serve real files first, then falls back to index.html for React Router. +func (s *Server) appHandler() http.Handler { + // Strip the dist prefix so URLs look clean + fsys, _ := fs.Sub(appFS, "app/dist") + fileServer := http.FileServer(http.FS(fsys)) + + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + p := strings.TrimPrefix(r.URL.Path, "/") + if _, err := fsys.Open(p); err == nil { + // Serve the file directly + fileServer.ServeHTTP(w, r) + return + } + // Fallback – serve index.html for unknown paths so React Router works + data, err := fs.ReadFile(fsys, "index.html") + if err != nil { + if errors.Is(err, fs.ErrNotExist) { + http.NotFound(w, r) + } else { + http.Error(w, "Internal Server Error", http.StatusInternalServerError) + } + return + } + http.ServeContent(w, r, "index.html", time.Time{}, bytes.NewReader(data)) + }) +} diff --git a/app/ui/app/.gitignore b/app/ui/app/.gitignore new file mode 100644 index 0000000..9705d1e --- /dev/null +++ b/app/ui/app/.gitignore @@ -0,0 +1,30 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? + +.vite/ +.claude/ + +*storybook.log +storybook-static diff --git a/app/ui/app/.prettierignore b/app/ui/app/.prettierignore new file mode 100644 index 0000000..21c55e2 --- /dev/null +++ b/app/ui/app/.prettierignore @@ -0,0 +1 @@ +*.gen.ts \ No newline at end of file diff --git a/app/ui/app/.prettierrc b/app/ui/app/.prettierrc new file mode 100644 index 0000000..1957463 --- /dev/null +++ b/app/ui/app/.prettierrc @@ -0,0 +1,6 @@ +{ + "trailingComma": "all", + "semi": true, + "singleQuote": false, + "printWidth": 80 +} diff --git a/app/ui/app/codegen/gotypes.gen.ts b/app/ui/app/codegen/gotypes.gen.ts new file mode 100644 index 0000000..7356984 --- /dev/null +++ b/app/ui/app/codegen/gotypes.gen.ts @@ -0,0 +1,611 @@ +/* Do not change, this code is generated from Golang structs */ + + +export class ChatInfo { + id: string; + title: string; + userExcerpt: string; + createdAt: Date; + updatedAt: Date; + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.id = source["id"]; + this.title = source["title"]; + this.userExcerpt = source["userExcerpt"]; + this.createdAt = new Date(source["createdAt"]); + this.updatedAt = new Date(source["updatedAt"]); + } +} +export class ChatsResponse { + chatInfos: ChatInfo[]; + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.chatInfos = this.convertValues(source["chatInfos"], ChatInfo); + } + + convertValues(a: any, classs: any, asMap: boolean = false): any { + if (!a) { + return a; + } + if (Array.isArray(a)) { + return (a as any[]).map(elem => this.convertValues(elem, classs)); + } else if ("object" === typeof a) { + if (asMap) { + for (const key of Object.keys(a)) { + a[key] = new classs(a[key]); + } + return a; + } + return new classs(a); + } + return a; + } +} +export class Time { + + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + + } +} +export class ToolFunction { + name: string; + arguments: string; + result?: any; + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.name = source["name"]; + this.arguments = source["arguments"]; + this.result = source["result"]; + } +} +export class ToolCall { + type: string; + function: ToolFunction; + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.type = source["type"]; + this.function = this.convertValues(source["function"], ToolFunction); + } + + convertValues(a: any, classs: any, asMap: boolean = false): any { + if (!a) { + return a; + } + if (Array.isArray(a)) { + return (a as any[]).map(elem => this.convertValues(elem, classs)); + } else if ("object" === typeof a) { + if (asMap) { + for (const key of Object.keys(a)) { + a[key] = new classs(a[key]); + } + return a; + } + return new classs(a); + } + return a; + } +} +export class File { + filename: string; + data: number[]; + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.filename = source["filename"]; + this.data = source["data"]; + } +} +export class Message { + role: string; + content: string; + thinking: string; + stream: boolean; + model?: string; + attachments?: File[]; + tool_calls?: ToolCall[]; + tool_call?: ToolCall; + tool_name?: string; + tool_result?: number[]; + created_at: Time; + updated_at: Time; + thinkingTimeStart?: Date | undefined; + thinkingTimeEnd?: Date | undefined; + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.role = source["role"]; + this.content = source["content"]; + this.thinking = source["thinking"]; + this.stream = source["stream"]; + this.model = source["model"]; + this.attachments = this.convertValues(source["attachments"], File); + this.tool_calls = this.convertValues(source["tool_calls"], ToolCall); + this.tool_call = this.convertValues(source["tool_call"], ToolCall); + this.tool_name = source["tool_name"]; + this.tool_result = source["tool_result"]; + this.created_at = this.convertValues(source["created_at"], Time); + this.updated_at = this.convertValues(source["updated_at"], Time); + this.thinkingTimeStart = source["thinkingTimeStart"] && new Date(source["thinkingTimeStart"]); + this.thinkingTimeEnd = source["thinkingTimeEnd"] && new Date(source["thinkingTimeEnd"]); + } + + convertValues(a: any, classs: any, asMap: boolean = false): any { + if (!a) { + return a; + } + if (Array.isArray(a)) { + return (a as any[]).map(elem => this.convertValues(elem, classs)); + } else if ("object" === typeof a) { + if (asMap) { + for (const key of Object.keys(a)) { + a[key] = new classs(a[key]); + } + return a; + } + return new classs(a); + } + return a; + } +} +export class Chat { + id: string; + messages: Message[]; + title: string; + created_at: Time; + browser_state?: BrowserStateData; + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.id = source["id"]; + this.messages = this.convertValues(source["messages"], Message); + this.title = source["title"]; + this.created_at = this.convertValues(source["created_at"], Time); + this.browser_state = source["browser_state"]; + } + + convertValues(a: any, classs: any, asMap: boolean = false): any { + if (!a) { + return a; + } + if (Array.isArray(a)) { + return (a as any[]).map(elem => this.convertValues(elem, classs)); + } else if ("object" === typeof a) { + if (asMap) { + for (const key of Object.keys(a)) { + a[key] = new classs(a[key]); + } + return a; + } + return new classs(a); + } + return a; + } +} +export class ChatResponse { + chat: Chat; + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.chat = this.convertValues(source["chat"], Chat); + } + + convertValues(a: any, classs: any, asMap: boolean = false): any { + if (!a) { + return a; + } + if (Array.isArray(a)) { + return (a as any[]).map(elem => this.convertValues(elem, classs)); + } else if ("object" === typeof a) { + if (asMap) { + for (const key of Object.keys(a)) { + a[key] = new classs(a[key]); + } + return a; + } + return new classs(a); + } + return a; + } +} +export class Model { + model: string; + digest?: string; + modified_at?: Time; + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.model = source["model"]; + this.digest = source["digest"]; + this.modified_at = this.convertValues(source["modified_at"], Time); + } + + convertValues(a: any, classs: any, asMap: boolean = false): any { + if (!a) { + return a; + } + if (Array.isArray(a)) { + return (a as any[]).map(elem => this.convertValues(elem, classs)); + } else if ("object" === typeof a) { + if (asMap) { + for (const key of Object.keys(a)) { + a[key] = new classs(a[key]); + } + return a; + } + return new classs(a); + } + return a; + } +} +export class ModelsResponse { + models: Model[]; + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.models = this.convertValues(source["models"], Model); + } + + convertValues(a: any, classs: any, asMap: boolean = false): any { + if (!a) { + return a; + } + if (Array.isArray(a)) { + return (a as any[]).map(elem => this.convertValues(elem, classs)); + } else if ("object" === typeof a) { + if (asMap) { + for (const key of Object.keys(a)) { + a[key] = new classs(a[key]); + } + return a; + } + return new classs(a); + } + return a; + } +} +export class InferenceCompute { + library: string; + variant: string; + compute: string; + driver: string; + name: string; + vram: string; + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.library = source["library"]; + this.variant = source["variant"]; + this.compute = source["compute"]; + this.driver = source["driver"]; + this.name = source["name"]; + this.vram = source["vram"]; + } +} +export class InferenceComputeResponse { + inferenceComputes: InferenceCompute[]; + defaultContextLength: number; + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.inferenceComputes = this.convertValues(source["inferenceComputes"], InferenceCompute); + this.defaultContextLength = source["defaultContextLength"]; + } + + convertValues(a: any, classs: any, asMap: boolean = false): any { + if (!a) { + return a; + } + if (Array.isArray(a)) { + return (a as any[]).map(elem => this.convertValues(elem, classs)); + } else if ("object" === typeof a) { + if (asMap) { + for (const key of Object.keys(a)) { + a[key] = new classs(a[key]); + } + return a; + } + return new classs(a); + } + return a; + } +} +export class ModelCapabilitiesResponse { + capabilities: string[]; + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.capabilities = source["capabilities"]; + } +} +export class ChatEvent { + eventName: "chat" | "thinking" | "assistant_with_tools" | "tool_call" | "tool" | "tool_result" | "done" | "chat_created"; + content?: string; + thinking?: string; + thinkingTimeStart?: Date | undefined; + thinkingTimeEnd?: Date | undefined; + toolCalls?: ToolCall[]; + toolCall?: ToolCall; + toolName?: string; + toolResult?: boolean; + toolResultData?: any; + chatId?: string; + toolState?: any; + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.eventName = source["eventName"]; + this.content = source["content"]; + this.thinking = source["thinking"]; + this.thinkingTimeStart = source["thinkingTimeStart"] && new Date(source["thinkingTimeStart"]); + this.thinkingTimeEnd = source["thinkingTimeEnd"] && new Date(source["thinkingTimeEnd"]); + this.toolCalls = this.convertValues(source["toolCalls"], ToolCall); + this.toolCall = this.convertValues(source["toolCall"], ToolCall); + this.toolName = source["toolName"]; + this.toolResult = source["toolResult"]; + this.toolResultData = source["toolResultData"]; + this.chatId = source["chatId"]; + this.toolState = source["toolState"]; + } + + convertValues(a: any, classs: any, asMap: boolean = false): any { + if (!a) { + return a; + } + if (Array.isArray(a)) { + return (a as any[]).map(elem => this.convertValues(elem, classs)); + } else if ("object" === typeof a) { + if (asMap) { + for (const key of Object.keys(a)) { + a[key] = new classs(a[key]); + } + return a; + } + return new classs(a); + } + return a; + } +} +export class DownloadEvent { + eventName: "download"; + total: number; + completed: number; + done: boolean; + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.eventName = source["eventName"]; + this.total = source["total"]; + this.completed = source["completed"]; + this.done = source["done"]; + } +} +export class ErrorEvent { + eventName: "error"; + error: string; + code?: string; + details?: string; + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.eventName = source["eventName"]; + this.error = source["error"]; + this.code = source["code"]; + this.details = source["details"]; + } +} +export class Settings { + Expose: boolean; + Browser: boolean; + Survey: boolean; + Models: string; + Agent: boolean; + Tools: boolean; + WorkingDir: string; + ContextLength: number; + TurboEnabled: boolean; + WebSearchEnabled: boolean; + ThinkEnabled: boolean; + ThinkLevel: string; + SelectedModel: string; + SidebarOpen: boolean; + LastHomeView: string; + AutoUpdateEnabled: boolean; + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.Expose = source["Expose"]; + this.Browser = source["Browser"]; + this.Survey = source["Survey"]; + this.Models = source["Models"]; + this.Agent = source["Agent"]; + this.Tools = source["Tools"]; + this.WorkingDir = source["WorkingDir"]; + this.ContextLength = source["ContextLength"]; + this.TurboEnabled = source["TurboEnabled"]; + this.WebSearchEnabled = source["WebSearchEnabled"]; + this.ThinkEnabled = source["ThinkEnabled"]; + this.ThinkLevel = source["ThinkLevel"]; + this.SelectedModel = source["SelectedModel"]; + this.SidebarOpen = source["SidebarOpen"]; + this.LastHomeView = source["LastHomeView"]; + this.AutoUpdateEnabled = source["AutoUpdateEnabled"]; + } +} +export class SettingsResponse { + settings: Settings; + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.settings = this.convertValues(source["settings"], Settings); + } + + convertValues(a: any, classs: any, asMap: boolean = false): any { + if (!a) { + return a; + } + if (Array.isArray(a)) { + return (a as any[]).map(elem => this.convertValues(elem, classs)); + } else if ("object" === typeof a) { + if (asMap) { + for (const key of Object.keys(a)) { + a[key] = new classs(a[key]); + } + return a; + } + return new classs(a); + } + return a; + } +} +export class HealthResponse { + healthy: boolean; + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.healthy = source["healthy"]; + } +} +export class User { + id: string; + email: string; + name: string; + bio?: string; + avatarurl?: string; + firstname?: string; + lastname?: string; + plan?: string; + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.id = source["id"]; + this.email = source["email"]; + this.name = source["name"]; + this.bio = source["bio"]; + this.avatarurl = source["avatarurl"]; + this.firstname = source["firstname"]; + this.lastname = source["lastname"]; + this.plan = source["plan"]; + } +} +export class Attachment { + filename: string; + data?: string; + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.filename = source["filename"]; + this.data = source["data"]; + } +} +export class ChatRequest { + model: string; + prompt: string; + index?: number; + attachments?: Attachment[]; + web_search?: boolean; + file_tools?: boolean; + forceUpdate?: boolean; + think?: any; + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.model = source["model"]; + this.prompt = source["prompt"]; + this.index = source["index"]; + this.attachments = this.convertValues(source["attachments"], Attachment); + this.web_search = source["web_search"]; + this.file_tools = source["file_tools"]; + this.forceUpdate = source["forceUpdate"]; + this.think = source["think"]; + } + + convertValues(a: any, classs: any, asMap: boolean = false): any { + if (!a) { + return a; + } + if (Array.isArray(a)) { + return (a as any[]).map(elem => this.convertValues(elem, classs)); + } else if ("object" === typeof a) { + if (asMap) { + for (const key of Object.keys(a)) { + a[key] = new classs(a[key]); + } + return a; + } + return new classs(a); + } + return a; + } +} +export class Error { + error: string; + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.error = source["error"]; + } +} +export class ModelUpstreamResponse { + stale: boolean; + error?: string; + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.stale = source["stale"]; + this.error = source["error"]; + } +} +export class Page { + url: string; + title: string; + text: string; + lines: string[]; + links?: Record; + fetched_at: Time; + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.url = source["url"]; + this.title = source["title"]; + this.text = source["text"]; + this.lines = source["lines"]; + this.links = source["links"]; + this.fetched_at = this.convertValues(source["fetched_at"], Time); + } + + convertValues(a: any, classs: any, asMap: boolean = false): any { + if (!a) { + return a; + } + if (Array.isArray(a)) { + return (a as any[]).map(elem => this.convertValues(elem, classs)); + } else if ("object" === typeof a) { + if (asMap) { + for (const key of Object.keys(a)) { + a[key] = new classs(a[key]); + } + return a; + } + return new classs(a); + } + return a; + } +} +export class BrowserStateData { + page_stack: string[]; + view_tokens: number; + url_to_page: {[key: string]: Page}; + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.page_stack = source["page_stack"]; + this.view_tokens = source["view_tokens"]; + this.url_to_page = source["url_to_page"]; + } +} diff --git a/app/ui/app/eslint.config.js b/app/ui/app/eslint.config.js new file mode 100644 index 0000000..691c8a4 --- /dev/null +++ b/app/ui/app/eslint.config.js @@ -0,0 +1,32 @@ +// For more info, see https://github.com/storybookjs/eslint-plugin-storybook#configuration-flat-config-format +import storybook from "eslint-plugin-storybook"; + +import js from "@eslint/js"; +import globals from "globals"; +import reactHooks from "eslint-plugin-react-hooks"; +import reactRefresh from "eslint-plugin-react-refresh"; +import tseslint from "typescript-eslint"; + +export default tseslint.config( + { ignores: ["dist"] }, + { + extends: [js.configs.recommended, ...tseslint.configs.recommended], + files: ["**/*.{ts,tsx}"], + languageOptions: { + ecmaVersion: 2020, + globals: globals.browser, + }, + plugins: { + "react-hooks": reactHooks, + "react-refresh": reactRefresh, + }, + rules: { + ...reactHooks.configs.recommended.rules, + "react-refresh/only-export-components": [ + "warn", + { allowConstantExport: true }, + ], + }, + }, + storybook.configs["flat/recommended"], +); diff --git a/app/ui/app/index.html b/app/ui/app/index.html new file mode 100644 index 0000000..9e74109 --- /dev/null +++ b/app/ui/app/index.html @@ -0,0 +1,189 @@ + + + + + + + + Ollama + + +
+ + + + diff --git a/app/ui/app/package-lock.json b/app/ui/app/package-lock.json new file mode 100644 index 0000000..0dcd91a --- /dev/null +++ b/app/ui/app/package-lock.json @@ -0,0 +1,13308 @@ +{ + "name": "app", + "version": "0.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "app", + "version": "0.0.0", + "dependencies": { + "@headlessui/react": "^2.2.4", + "@heroicons/react": "^2.2.0", + "@tanstack/react-query": "^5.80.7", + "@tanstack/react-router": "^1.120.20", + "@tanstack/react-router-devtools": "^1.120.20", + "clsx": "^2.1.1", + "framer-motion": "^12.17.0", + "katex": "^0.16.22", + "micromark-extension-llm-math": "^3.1.0", + "ollama": "^0.6.0", + "react": "^19.1.0", + "react-dom": "^19.1.0", + "rehype-katex": "^7.0.1", + "rehype-prism-plus": "^2.0.1", + "rehype-raw": "^7.0.0", + "rehype-sanitize": "^6.0.0", + "remark-math": "^6.0.0", + "streamdown": "^1.4.0", + "unist-builder": "^4.0.0", + "unist-util-parents": "^3.0.0" + }, + "devDependencies": { + "@chromatic-com/storybook": "^4.0.1", + "@eslint/js": "^9.25.0", + "@storybook/addon-a11y": "^9.0.14", + "@storybook/addon-docs": "^9.0.14", + "@storybook/addon-onboarding": "^9.0.14", + "@storybook/addon-vitest": "^9.0.14", + "@storybook/react-vite": "^9.0.14", + "@tailwindcss/typography": "^0.5.16", + "@tailwindcss/vite": "^4.1.11", + "@tanstack/router-plugin": "^1.120.20", + "@types/node": "^24.7.2", + "@types/react": "^19.1.2", + "@types/react-dom": "^19.1.2", + "@vitejs/plugin-react": "^4.4.1", + "@vitest/browser": "^3.2.4", + "@vitest/coverage-v8": "^3.2.4", + "@vitest/ui": "^3.2.4", + "autoprefixer": "^10.4.21", + "eslint": "^9.25.0", + "eslint-plugin-react-hooks": "^5.2.0", + "eslint-plugin-react-refresh": "^0.4.19", + "eslint-plugin-storybook": "^9.0.14", + "globals": "^16.0.0", + "playwright": "^1.53.2", + "postcss-preset-env": "^10.2.4", + "react-markdown": "^10.1.0", + "remark": "^15.0.1", + "remark-gfm": "^4.0.1", + "remark-stringify": "^11.0.0", + "storybook": "^9.0.14", + "tailwindcss": "^4.1.9", + "typescript": "~5.8.3", + "typescript-eslint": "^8.30.1", + "vite": "^6.3.5", + "vite-tsconfig-paths": "^5.1.4", + "vitest": "^3.2.4" + } + }, + "node_modules/@adobe/css-tools": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/@adobe/css-tools/-/css-tools-4.4.3.tgz", + "integrity": "sha512-VQKMkwriZbaOgVCby1UDY/LDk5fIjhQicCvVPFqfe+69fWaPWydbWJ3wRt59/YzIwda1I81loas3oCoHxnqvdA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@ampproject/remapping": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz", + "integrity": "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@antfu/install-pkg": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@antfu/install-pkg/-/install-pkg-1.1.0.tgz", + "integrity": "sha512-MGQsmw10ZyI+EJo45CdSER4zEb+p31LpDAFp2Z3gkSd1yqVZGi0Ebx++YTEMonJy4oChEMLsxZ64j8FH6sSqtQ==", + "license": "MIT", + "dependencies": { + "package-manager-detector": "^1.3.0", + "tinyexec": "^1.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/@antfu/install-pkg/node_modules/tinyexec": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.0.2.tgz", + "integrity": "sha512-W/KYk+NFhkmsYpuHq5JykngiOCnxeVL8v8dFnqxSD8qEEdRfXk1SDM6JzNqcERbcGYj9tMrDQBYV9cjgnunFIg==", + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/@antfu/utils": { + "version": "9.3.0", + "resolved": "https://registry.npmjs.org/@antfu/utils/-/utils-9.3.0.tgz", + "integrity": "sha512-9hFT4RauhcUzqOE4f1+frMKLZrgNog5b06I7VmZQV1BkvwvqrbC8EBZf3L1eEL2AKb6rNKjER0sEvJiSP1FXEA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/@babel/code-frame": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.27.1.tgz", + "integrity": "sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-validator-identifier": "^7.27.1", + "js-tokens": "^4.0.0", + "picocolors": "^1.1.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/compat-data": { + "version": "7.27.5", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.27.5.tgz", + "integrity": "sha512-KiRAp/VoJaWkkte84TvUd9qjdbZAdiqyvMxrGl1N6vzFogKmaLgoM3L1kgtLicp2HP5fBJS8JrZKLVIZGVJAVg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/core": { + "version": "7.27.4", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.27.4.tgz", + "integrity": "sha512-bXYxrXFubeYdvB0NhD/NBB3Qi6aZeV20GOWVI47t2dkecCEoneR4NPVcb7abpXDEvejgrUfFtG6vG/zxAKmg+g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@ampproject/remapping": "^2.2.0", + "@babel/code-frame": "^7.27.1", + "@babel/generator": "^7.27.3", + "@babel/helper-compilation-targets": "^7.27.2", + "@babel/helper-module-transforms": "^7.27.3", + "@babel/helpers": "^7.27.4", + "@babel/parser": "^7.27.4", + "@babel/template": "^7.27.2", + "@babel/traverse": "^7.27.4", + "@babel/types": "^7.27.3", + "convert-source-map": "^2.0.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.3", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + } + }, + "node_modules/@babel/generator": { + "version": "7.27.5", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.27.5.tgz", + "integrity": "sha512-ZGhA37l0e/g2s1Cnzdix0O3aLYm66eF8aufiVteOgnwxgnRP8GoyMj7VWsgWnQbVKXyge7hqrFh2K2TQM6t1Hw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.27.5", + "@babel/types": "^7.27.3", + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.25", + "jsesc": "^3.0.2" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-compilation-targets": { + "version": "7.27.2", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.27.2.tgz", + "integrity": "sha512-2+1thGUUWWjLTYTHZWK1n8Yga0ijBz1XAhUXcKy81rd5g6yh7hGqMp45v7cadSbEHc9G3OTv45SyneRN3ps4DQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/compat-data": "^7.27.2", + "@babel/helper-validator-option": "^7.27.1", + "browserslist": "^4.24.0", + "lru-cache": "^5.1.1", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-imports": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.27.1.tgz", + "integrity": "sha512-0gSFWUPNXNopqtIPQvlD5WgXYI5GY2kP2cCvoT8kczjbfcfuIljTbcWrulD1CIPIX2gt1wghbDy08yE1p+/r3w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/traverse": "^7.27.1", + "@babel/types": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-transforms": { + "version": "7.27.3", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.27.3.tgz", + "integrity": "sha512-dSOvYwvyLsWBeIRyOeHXp5vPj5l1I011r52FM1+r1jCERv+aFXYk4whgQccYEGYxK2H3ZAIA8nuPkQ0HaUo3qg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-module-imports": "^7.27.1", + "@babel/helper-validator-identifier": "^7.27.1", + "@babel/traverse": "^7.27.3" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-plugin-utils": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.27.1.tgz", + "integrity": "sha512-1gn1Up5YXka3YYAHGKpbideQ5Yjf1tDa9qYcgysz+cNCXukyLl6DjPXhD3VRwSb8c0J9tA4b2+rHEZtc6R0tlw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz", + "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.27.1.tgz", + "integrity": "sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-option": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.27.1.tgz", + "integrity": "sha512-YvjJow9FxbhFFKDSuFnVCe2WxXk1zWc22fFePVNEaWJEu8IrZVlda6N0uHwzZrUM1il7NC9Mlp4MaJYbYd9JSg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helpers": { + "version": "7.27.6", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.27.6.tgz", + "integrity": "sha512-muE8Tt8M22638HU31A3CgfSUciwz1fhATfoVai05aPXGor//CdWDCbnlY1yvBPo07njuVOCNGCSp/GTt12lIug==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/template": "^7.27.2", + "@babel/types": "^7.27.6" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.27.5", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.27.5.tgz", + "integrity": "sha512-OsQd175SxWkGlzbny8J3K8TnnDD0N3lrIUtB92xwyRpzaenGZhxDvxN/JgU00U3CDZNj9tPuDJ5H0WS4Nt3vKg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.27.3" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/plugin-syntax-jsx": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.27.1.tgz", + "integrity": "sha512-y8YTNIeKoyhGd9O0Jiyzyyqk8gdjnumGTQPsz0xOZOQ2RmkVJeZ1vmmfIvFEKqucBG6axJGBZDE/7iI5suUI/w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-typescript": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.27.1.tgz", + "integrity": "sha512-xfYCBMxveHrRMnAWl1ZlPXOZjzkN82THFvLhQhFXFt81Z5HnN+EtUkZhv/zcKpmT3fzmWZB0ywiBrbC3vogbwQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-react-jsx-self": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx-self/-/plugin-transform-react-jsx-self-7.27.1.tgz", + "integrity": "sha512-6UzkCs+ejGdZ5mFFC/OCUrv028ab2fp1znZmCZjAOBKiBK2jXD1O+BPSfX8X2qjJ75fZBMSnQn3Rq2mrBJK2mw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-react-jsx-source": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx-source/-/plugin-transform-react-jsx-source-7.27.1.tgz", + "integrity": "sha512-zbwoTsBruTeKB9hSq73ha66iFeJHuaFkUbwvqElnygoNbj/jHRsSeokowZFN3CZ64IvEqcmmkVe89OPXc7ldAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/runtime": { + "version": "7.27.6", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.27.6.tgz", + "integrity": "sha512-vbavdySgbTTrmFE+EsiqUTzlOr5bzlnJtUv9PynGCAKvfQqjIXbvFdumPM/GxMDfyuGMJaJAU6TO4zc1Jf1i8Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/template": { + "version": "7.27.2", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.27.2.tgz", + "integrity": "sha512-LPDZ85aEJyYSd18/DkjNh4/y1ntkE5KwUHWTiqgRxruuZL2F1yuHligVHLvcHY2vMHXttKFpJn6LwfI7cw7ODw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.27.1", + "@babel/parser": "^7.27.2", + "@babel/types": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse": { + "version": "7.27.4", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.27.4.tgz", + "integrity": "sha512-oNcu2QbHqts9BtOWJosOVJapWjBDSxGCpFvikNR5TGDYDQf3JwpIoMzIKrvfoti93cLfPJEG4tH9SPVeyCGgdA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.27.1", + "@babel/generator": "^7.27.3", + "@babel/parser": "^7.27.4", + "@babel/template": "^7.27.2", + "@babel/types": "^7.27.3", + "debug": "^4.3.1", + "globals": "^11.1.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse/node_modules/globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/types": { + "version": "7.27.6", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.27.6.tgz", + "integrity": "sha512-ETyHEk2VHHvl9b9jZP5IHPavHYk57EhanlRRuae9XCpb/j5bDCbPPMOBfCWhnl/7EDJz0jEMCi/RhccCE8r1+Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.27.1", + "@babel/helper-validator-identifier": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@bcoe/v8-coverage": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-1.0.2.tgz", + "integrity": "sha512-6zABk/ECA/QYSCQ1NGiVwwbQerUCZ+TQbp64Q3AgmfNvurHH0j8TtXa1qbShXA6qqkpAj4V5W8pP6mLe1mcMqA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/@braintree/sanitize-url": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@braintree/sanitize-url/-/sanitize-url-7.1.1.tgz", + "integrity": "sha512-i1L7noDNxtFyL5DmZafWy1wRVhGehQmzZaz1HiN5e7iylJMSZR7ekOV7NsIqa5qBldlLrsKv4HbgFUVlQrz8Mw==", + "license": "MIT" + }, + "node_modules/@chevrotain/cst-dts-gen": { + "version": "11.0.3", + "resolved": "https://registry.npmjs.org/@chevrotain/cst-dts-gen/-/cst-dts-gen-11.0.3.tgz", + "integrity": "sha512-BvIKpRLeS/8UbfxXxgC33xOumsacaeCKAjAeLyOn7Pcp95HiRbrpl14S+9vaZLolnbssPIUuiUd8IvgkRyt6NQ==", + "license": "Apache-2.0", + "dependencies": { + "@chevrotain/gast": "11.0.3", + "@chevrotain/types": "11.0.3", + "lodash-es": "4.17.21" + } + }, + "node_modules/@chevrotain/gast": { + "version": "11.0.3", + "resolved": "https://registry.npmjs.org/@chevrotain/gast/-/gast-11.0.3.tgz", + "integrity": "sha512-+qNfcoNk70PyS/uxmj3li5NiECO+2YKZZQMbmjTqRI3Qchu8Hig/Q9vgkHpI3alNjr7M+a2St5pw5w5F6NL5/Q==", + "license": "Apache-2.0", + "dependencies": { + "@chevrotain/types": "11.0.3", + "lodash-es": "4.17.21" + } + }, + "node_modules/@chevrotain/regexp-to-ast": { + "version": "11.0.3", + "resolved": "https://registry.npmjs.org/@chevrotain/regexp-to-ast/-/regexp-to-ast-11.0.3.tgz", + "integrity": "sha512-1fMHaBZxLFvWI067AVbGJav1eRY7N8DDvYCTwGBiE/ytKBgP8azTdgyrKyWZ9Mfh09eHWb5PgTSO8wi7U824RA==", + "license": "Apache-2.0" + }, + "node_modules/@chevrotain/types": { + "version": "11.0.3", + "resolved": "https://registry.npmjs.org/@chevrotain/types/-/types-11.0.3.tgz", + "integrity": "sha512-gsiM3G8b58kZC2HaWR50gu6Y1440cHiJ+i3JUvcp/35JchYejb2+5MVeJK0iKThYpAa/P2PYFV4hoi44HD+aHQ==", + "license": "Apache-2.0" + }, + "node_modules/@chevrotain/utils": { + "version": "11.0.3", + "resolved": "https://registry.npmjs.org/@chevrotain/utils/-/utils-11.0.3.tgz", + "integrity": "sha512-YslZMgtJUyuMbZ+aKvfF3x1f5liK4mWNxghFRv7jqRR9C3R3fAOGTTKvxXDa2Y1s9zSbcpuO0cAxDYsc9SrXoQ==", + "license": "Apache-2.0" + }, + "node_modules/@chromatic-com/storybook": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@chromatic-com/storybook/-/storybook-4.0.1.tgz", + "integrity": "sha512-GQXe5lyZl3yLewLJQyFXEpOp2h+mfN2bPrzYaOFNCJjO4Js9deKbRHTOSaiP2FRwZqDLdQwy2+SEGeXPZ94yYw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@neoconfetti/react": "^1.0.0", + "chromatic": "^12.0.0", + "filesize": "^10.0.12", + "jsonfile": "^6.1.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=20.0.0", + "yarn": ">=1.22.18" + }, + "peerDependencies": { + "storybook": "^0.0.0-0 || ^9.0.0 || ^9.1.0-0" + } + }, + "node_modules/@csstools/cascade-layer-name-parser": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@csstools/cascade-layer-name-parser/-/cascade-layer-name-parser-2.0.5.tgz", + "integrity": "sha512-p1ko5eHgV+MgXFVa4STPKpvPxr6ReS8oS2jzTukjR74i5zJNyWO1ZM1m8YKBXnzDKWfBN1ztLYlHxbVemDD88A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4" + } + }, + "node_modules/@csstools/color-helpers": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@csstools/color-helpers/-/color-helpers-5.0.2.tgz", + "integrity": "sha512-JqWH1vsgdGcw2RR6VliXXdA0/59LttzlU8UlRT/iUUsEeWfYq8I+K0yhihEUTTHLRm1EXvpsCx3083EU15ecsA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "engines": { + "node": ">=18" + } + }, + "node_modules/@csstools/css-calc": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@csstools/css-calc/-/css-calc-2.1.4.tgz", + "integrity": "sha512-3N8oaj+0juUw/1H3YwmDDJXCgTB1gKU6Hc/bB502u9zR0q2vd786XJH9QfrKIEgFlZmhZiq6epXl4rHqhzsIgQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4" + } + }, + "node_modules/@csstools/css-color-parser": { + "version": "3.0.10", + "resolved": "https://registry.npmjs.org/@csstools/css-color-parser/-/css-color-parser-3.0.10.tgz", + "integrity": "sha512-TiJ5Ajr6WRd1r8HSiwJvZBiJOqtH86aHpUjq5aEKWHiII2Qfjqd/HCWKPOW8EP4vcspXbHnXrwIDlu5savQipg==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "dependencies": { + "@csstools/color-helpers": "^5.0.2", + "@csstools/css-calc": "^2.1.4" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4" + } + }, + "node_modules/@csstools/css-parser-algorithms": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/@csstools/css-parser-algorithms/-/css-parser-algorithms-3.0.5.tgz", + "integrity": "sha512-DaDeUkXZKjdGhgYaHNJTV9pV7Y9B3b644jCLs9Upc3VeNGg6LWARAT6O+Q+/COo+2gg/bM5rhpMAtf70WqfBdQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@csstools/css-tokenizer": "^3.0.4" + } + }, + "node_modules/@csstools/css-tokenizer": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@csstools/css-tokenizer/-/css-tokenizer-3.0.4.tgz", + "integrity": "sha512-Vd/9EVDiu6PPJt9yAh6roZP6El1xHrdvIVGjyBsHR0RYwNHgL7FJPyIIW4fANJNG6FtyZfvlRPpFI4ZM/lubvw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/@csstools/media-query-list-parser": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@csstools/media-query-list-parser/-/media-query-list-parser-4.0.3.tgz", + "integrity": "sha512-HAYH7d3TLRHDOUQK4mZKf9k9Ph/m8Akstg66ywKR4SFAigjs3yBiUeZtFxywiTm5moZMAp/5W/ZuFnNXXYLuuQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4" + } + }, + "node_modules/@csstools/postcss-cascade-layers": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@csstools/postcss-cascade-layers/-/postcss-cascade-layers-5.0.2.tgz", + "integrity": "sha512-nWBE08nhO8uWl6kSAeCx4im7QfVko3zLrtgWZY4/bP87zrSPpSyN/3W3TDqz1jJuH+kbKOHXg5rJnK+ZVYcFFg==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "@csstools/selector-specificity": "^5.0.0", + "postcss-selector-parser": "^7.0.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/@csstools/postcss-cascade-layers/node_modules/@csstools/selector-specificity": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@csstools/selector-specificity/-/selector-specificity-5.0.0.tgz", + "integrity": "sha512-PCqQV3c4CoVm3kdPhyeZ07VmBRdH2EpMFA/pd9OASpOEC3aXNGoqPDAZ80D0cLpMBxnmk0+yNhGsEx31hq7Gtw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss-selector-parser": "^7.0.0" + } + }, + "node_modules/@csstools/postcss-cascade-layers/node_modules/postcss-selector-parser": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.0.tgz", + "integrity": "sha512-8sLjZwK0R+JlxlYcTuVnyT2v+htpdrjDOKuMcOVdYjt52Lh8hWRYpxBPoKx/Zg+bcjc3wx6fmQevMmUztS/ccA==", + "dev": true, + "license": "MIT", + "dependencies": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@csstools/postcss-color-function": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/@csstools/postcss-color-function/-/postcss-color-function-4.0.10.tgz", + "integrity": "sha512-4dY0NBu7NVIpzxZRgh/Q/0GPSz/jLSw0i/u3LTUor0BkQcz/fNhN10mSWBDsL0p9nDb0Ky1PD6/dcGbhACuFTQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "@csstools/css-color-parser": "^3.0.10", + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4", + "@csstools/postcss-progressive-custom-properties": "^4.1.0", + "@csstools/utilities": "^2.0.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/@csstools/postcss-color-mix-function": { + "version": "3.0.10", + "resolved": "https://registry.npmjs.org/@csstools/postcss-color-mix-function/-/postcss-color-mix-function-3.0.10.tgz", + "integrity": "sha512-P0lIbQW9I4ShE7uBgZRib/lMTf9XMjJkFl/d6w4EMNHu2qvQ6zljJGEcBkw/NsBtq/6q3WrmgxSS8kHtPMkK4Q==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "@csstools/css-color-parser": "^3.0.10", + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4", + "@csstools/postcss-progressive-custom-properties": "^4.1.0", + "@csstools/utilities": "^2.0.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/@csstools/postcss-color-mix-variadic-function-arguments": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@csstools/postcss-color-mix-variadic-function-arguments/-/postcss-color-mix-variadic-function-arguments-1.0.0.tgz", + "integrity": "sha512-Z5WhouTyD74dPFPrVE7KydgNS9VvnjB8qcdes9ARpCOItb4jTnm7cHp4FhxCRUoyhabD0WVv43wbkJ4p8hLAlQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "@csstools/css-color-parser": "^3.0.10", + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4", + "@csstools/postcss-progressive-custom-properties": "^4.1.0", + "@csstools/utilities": "^2.0.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/@csstools/postcss-content-alt-text": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/@csstools/postcss-content-alt-text/-/postcss-content-alt-text-2.0.6.tgz", + "integrity": "sha512-eRjLbOjblXq+byyaedQRSrAejKGNAFued+LcbzT+LCL78fabxHkxYjBbxkroONxHHYu2qxhFK2dBStTLPG3jpQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4", + "@csstools/postcss-progressive-custom-properties": "^4.1.0", + "@csstools/utilities": "^2.0.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/@csstools/postcss-exponential-functions": { + "version": "2.0.9", + "resolved": "https://registry.npmjs.org/@csstools/postcss-exponential-functions/-/postcss-exponential-functions-2.0.9.tgz", + "integrity": "sha512-abg2W/PI3HXwS/CZshSa79kNWNZHdJPMBXeZNyPQFbbj8sKO3jXxOt/wF7juJVjyDTc6JrvaUZYFcSBZBhaxjw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "@csstools/css-calc": "^2.1.4", + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/@csstools/postcss-font-format-keywords": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@csstools/postcss-font-format-keywords/-/postcss-font-format-keywords-4.0.0.tgz", + "integrity": "sha512-usBzw9aCRDvchpok6C+4TXC57btc4bJtmKQWOHQxOVKen1ZfVqBUuCZ/wuqdX5GHsD0NRSr9XTP+5ID1ZZQBXw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "@csstools/utilities": "^2.0.0", + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/@csstools/postcss-gamut-mapping": { + "version": "2.0.10", + "resolved": "https://registry.npmjs.org/@csstools/postcss-gamut-mapping/-/postcss-gamut-mapping-2.0.10.tgz", + "integrity": "sha512-QDGqhJlvFnDlaPAfCYPsnwVA6ze+8hhrwevYWlnUeSjkkZfBpcCO42SaUD8jiLlq7niouyLgvup5lh+f1qessg==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "@csstools/css-color-parser": "^3.0.10", + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/@csstools/postcss-gradients-interpolation-method": { + "version": "5.0.10", + "resolved": "https://registry.npmjs.org/@csstools/postcss-gradients-interpolation-method/-/postcss-gradients-interpolation-method-5.0.10.tgz", + "integrity": "sha512-HHPauB2k7Oits02tKFUeVFEU2ox/H3OQVrP3fSOKDxvloOikSal+3dzlyTZmYsb9FlY9p5EUpBtz0//XBmy+aw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "@csstools/css-color-parser": "^3.0.10", + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4", + "@csstools/postcss-progressive-custom-properties": "^4.1.0", + "@csstools/utilities": "^2.0.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/@csstools/postcss-hwb-function": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/@csstools/postcss-hwb-function/-/postcss-hwb-function-4.0.10.tgz", + "integrity": "sha512-nOKKfp14SWcdEQ++S9/4TgRKchooLZL0TUFdun3nI4KPwCjETmhjta1QT4ICQcGVWQTvrsgMM/aLB5We+kMHhQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "@csstools/css-color-parser": "^3.0.10", + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4", + "@csstools/postcss-progressive-custom-properties": "^4.1.0", + "@csstools/utilities": "^2.0.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/@csstools/postcss-ic-unit": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@csstools/postcss-ic-unit/-/postcss-ic-unit-4.0.2.tgz", + "integrity": "sha512-lrK2jjyZwh7DbxaNnIUjkeDmU8Y6KyzRBk91ZkI5h8nb1ykEfZrtIVArdIjX4DHMIBGpdHrgP0n4qXDr7OHaKA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "@csstools/postcss-progressive-custom-properties": "^4.1.0", + "@csstools/utilities": "^2.0.0", + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/@csstools/postcss-initial": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@csstools/postcss-initial/-/postcss-initial-2.0.1.tgz", + "integrity": "sha512-L1wLVMSAZ4wovznquK0xmC7QSctzO4D0Is590bxpGqhqjboLXYA16dWZpfwImkdOgACdQ9PqXsuRroW6qPlEsg==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/@csstools/postcss-is-pseudo-class": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/@csstools/postcss-is-pseudo-class/-/postcss-is-pseudo-class-5.0.3.tgz", + "integrity": "sha512-jS/TY4SpG4gszAtIg7Qnf3AS2pjcUM5SzxpApOrlndMeGhIbaTzWBzzP/IApXoNWEW7OhcjkRT48jnAUIFXhAQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "@csstools/selector-specificity": "^5.0.0", + "postcss-selector-parser": "^7.0.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/@csstools/postcss-is-pseudo-class/node_modules/@csstools/selector-specificity": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@csstools/selector-specificity/-/selector-specificity-5.0.0.tgz", + "integrity": "sha512-PCqQV3c4CoVm3kdPhyeZ07VmBRdH2EpMFA/pd9OASpOEC3aXNGoqPDAZ80D0cLpMBxnmk0+yNhGsEx31hq7Gtw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss-selector-parser": "^7.0.0" + } + }, + "node_modules/@csstools/postcss-is-pseudo-class/node_modules/postcss-selector-parser": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.0.tgz", + "integrity": "sha512-8sLjZwK0R+JlxlYcTuVnyT2v+htpdrjDOKuMcOVdYjt52Lh8hWRYpxBPoKx/Zg+bcjc3wx6fmQevMmUztS/ccA==", + "dev": true, + "license": "MIT", + "dependencies": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@csstools/postcss-light-dark-function": { + "version": "2.0.9", + "resolved": "https://registry.npmjs.org/@csstools/postcss-light-dark-function/-/postcss-light-dark-function-2.0.9.tgz", + "integrity": "sha512-1tCZH5bla0EAkFAI2r0H33CDnIBeLUaJh1p+hvvsylJ4svsv2wOmJjJn+OXwUZLXef37GYbRIVKX+X+g6m+3CQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4", + "@csstools/postcss-progressive-custom-properties": "^4.1.0", + "@csstools/utilities": "^2.0.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/@csstools/postcss-logical-float-and-clear": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@csstools/postcss-logical-float-and-clear/-/postcss-logical-float-and-clear-3.0.0.tgz", + "integrity": "sha512-SEmaHMszwakI2rqKRJgE+8rpotFfne1ZS6bZqBoQIicFyV+xT1UF42eORPxJkVJVrH9C0ctUgwMSn3BLOIZldQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/@csstools/postcss-logical-overflow": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@csstools/postcss-logical-overflow/-/postcss-logical-overflow-2.0.0.tgz", + "integrity": "sha512-spzR1MInxPuXKEX2csMamshR4LRaSZ3UXVaRGjeQxl70ySxOhMpP2252RAFsg8QyyBXBzuVOOdx1+bVO5bPIzA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/@csstools/postcss-logical-overscroll-behavior": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@csstools/postcss-logical-overscroll-behavior/-/postcss-logical-overscroll-behavior-2.0.0.tgz", + "integrity": "sha512-e/webMjoGOSYfqLunyzByZj5KKe5oyVg/YSbie99VEaSDE2kimFm0q1f6t/6Jo+VVCQ/jbe2Xy+uX+C4xzWs4w==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/@csstools/postcss-logical-resize": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@csstools/postcss-logical-resize/-/postcss-logical-resize-3.0.0.tgz", + "integrity": "sha512-DFbHQOFW/+I+MY4Ycd/QN6Dg4Hcbb50elIJCfnwkRTCX05G11SwViI5BbBlg9iHRl4ytB7pmY5ieAFk3ws7yyg==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/@csstools/postcss-logical-viewport-units": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@csstools/postcss-logical-viewport-units/-/postcss-logical-viewport-units-3.0.4.tgz", + "integrity": "sha512-q+eHV1haXA4w9xBwZLKjVKAWn3W2CMqmpNpZUk5kRprvSiBEGMgrNH3/sJZ8UA3JgyHaOt3jwT9uFa4wLX4EqQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "@csstools/css-tokenizer": "^3.0.4", + "@csstools/utilities": "^2.0.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/@csstools/postcss-media-minmax": { + "version": "2.0.9", + "resolved": "https://registry.npmjs.org/@csstools/postcss-media-minmax/-/postcss-media-minmax-2.0.9.tgz", + "integrity": "sha512-af9Qw3uS3JhYLnCbqtZ9crTvvkR+0Se+bBqSr7ykAnl9yKhk6895z9rf+2F4dClIDJWxgn0iZZ1PSdkhrbs2ig==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "dependencies": { + "@csstools/css-calc": "^2.1.4", + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4", + "@csstools/media-query-list-parser": "^4.0.3" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/@csstools/postcss-media-queries-aspect-ratio-number-values": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/@csstools/postcss-media-queries-aspect-ratio-number-values/-/postcss-media-queries-aspect-ratio-number-values-3.0.5.tgz", + "integrity": "sha512-zhAe31xaaXOY2Px8IYfoVTB3wglbJUVigGphFLj6exb7cjZRH9A6adyE22XfFK3P2PzwRk0VDeTJmaxpluyrDg==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4", + "@csstools/media-query-list-parser": "^4.0.3" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/@csstools/postcss-nested-calc": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@csstools/postcss-nested-calc/-/postcss-nested-calc-4.0.0.tgz", + "integrity": "sha512-jMYDdqrQQxE7k9+KjstC3NbsmC063n1FTPLCgCRS2/qHUbHM0mNy9pIn4QIiQGs9I/Bg98vMqw7mJXBxa0N88A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "@csstools/utilities": "^2.0.0", + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/@csstools/postcss-normalize-display-values": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@csstools/postcss-normalize-display-values/-/postcss-normalize-display-values-4.0.0.tgz", + "integrity": "sha512-HlEoG0IDRoHXzXnkV4in47dzsxdsjdz6+j7MLjaACABX2NfvjFS6XVAnpaDyGesz9gK2SC7MbNwdCHusObKJ9Q==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/@csstools/postcss-oklab-function": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/@csstools/postcss-oklab-function/-/postcss-oklab-function-4.0.10.tgz", + "integrity": "sha512-ZzZUTDd0fgNdhv8UUjGCtObPD8LYxMH+MJsW9xlZaWTV8Ppr4PtxlHYNMmF4vVWGl0T6f8tyWAKjoI6vePSgAg==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "@csstools/css-color-parser": "^3.0.10", + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4", + "@csstools/postcss-progressive-custom-properties": "^4.1.0", + "@csstools/utilities": "^2.0.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/@csstools/postcss-progressive-custom-properties": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@csstools/postcss-progressive-custom-properties/-/postcss-progressive-custom-properties-4.1.0.tgz", + "integrity": "sha512-YrkI9dx8U4R8Sz2EJaoeD9fI7s7kmeEBfmO+UURNeL6lQI7VxF6sBE+rSqdCBn4onwqmxFdBU3lTwyYb/lCmxA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/@csstools/postcss-random-function": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@csstools/postcss-random-function/-/postcss-random-function-2.0.1.tgz", + "integrity": "sha512-q+FQaNiRBhnoSNo+GzqGOIBKoHQ43lYz0ICrV+UudfWnEF6ksS6DsBIJSISKQT2Bvu3g4k6r7t0zYrk5pDlo8w==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "@csstools/css-calc": "^2.1.4", + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/@csstools/postcss-relative-color-syntax": { + "version": "3.0.10", + "resolved": "https://registry.npmjs.org/@csstools/postcss-relative-color-syntax/-/postcss-relative-color-syntax-3.0.10.tgz", + "integrity": "sha512-8+0kQbQGg9yYG8hv0dtEpOMLwB9M+P7PhacgIzVzJpixxV4Eq9AUQtQw8adMmAJU1RBBmIlpmtmm3XTRd/T00g==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "@csstools/css-color-parser": "^3.0.10", + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4", + "@csstools/postcss-progressive-custom-properties": "^4.1.0", + "@csstools/utilities": "^2.0.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/@csstools/postcss-scope-pseudo-class": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@csstools/postcss-scope-pseudo-class/-/postcss-scope-pseudo-class-4.0.1.tgz", + "integrity": "sha512-IMi9FwtH6LMNuLea1bjVMQAsUhFxJnyLSgOp/cpv5hrzWmrUYU5fm0EguNDIIOHUqzXode8F/1qkC/tEo/qN8Q==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "postcss-selector-parser": "^7.0.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/@csstools/postcss-scope-pseudo-class/node_modules/postcss-selector-parser": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.0.tgz", + "integrity": "sha512-8sLjZwK0R+JlxlYcTuVnyT2v+htpdrjDOKuMcOVdYjt52Lh8hWRYpxBPoKx/Zg+bcjc3wx6fmQevMmUztS/ccA==", + "dev": true, + "license": "MIT", + "dependencies": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@csstools/postcss-sign-functions": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@csstools/postcss-sign-functions/-/postcss-sign-functions-1.1.4.tgz", + "integrity": "sha512-P97h1XqRPcfcJndFdG95Gv/6ZzxUBBISem0IDqPZ7WMvc/wlO+yU0c5D/OCpZ5TJoTt63Ok3knGk64N+o6L2Pg==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "@csstools/css-calc": "^2.1.4", + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/@csstools/postcss-stepped-value-functions": { + "version": "4.0.9", + "resolved": "https://registry.npmjs.org/@csstools/postcss-stepped-value-functions/-/postcss-stepped-value-functions-4.0.9.tgz", + "integrity": "sha512-h9btycWrsex4dNLeQfyU3y3w40LMQooJWFMm/SK9lrKguHDcFl4VMkncKKoXi2z5rM9YGWbUQABI8BT2UydIcA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "@csstools/css-calc": "^2.1.4", + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/@csstools/postcss-text-decoration-shorthand": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@csstools/postcss-text-decoration-shorthand/-/postcss-text-decoration-shorthand-4.0.2.tgz", + "integrity": "sha512-8XvCRrFNseBSAGxeaVTaNijAu+FzUvjwFXtcrynmazGb/9WUdsPCpBX+mHEHShVRq47Gy4peYAoxYs8ltUnmzA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "@csstools/color-helpers": "^5.0.2", + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/@csstools/postcss-trigonometric-functions": { + "version": "4.0.9", + "resolved": "https://registry.npmjs.org/@csstools/postcss-trigonometric-functions/-/postcss-trigonometric-functions-4.0.9.tgz", + "integrity": "sha512-Hnh5zJUdpNrJqK9v1/E3BbrQhaDTj5YiX7P61TOvUhoDHnUmsNNxcDAgkQ32RrcWx9GVUvfUNPcUkn8R3vIX6A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "@csstools/css-calc": "^2.1.4", + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/@csstools/postcss-unset-value": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@csstools/postcss-unset-value/-/postcss-unset-value-4.0.0.tgz", + "integrity": "sha512-cBz3tOCI5Fw6NIFEwU3RiwK6mn3nKegjpJuzCndoGq3BZPkUjnsq7uQmIeMNeMbMk7YD2MfKcgCpZwX5jyXqCA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/@csstools/utilities": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@csstools/utilities/-/utilities-2.0.0.tgz", + "integrity": "sha512-5VdOr0Z71u+Yp3ozOx8T11N703wIFGVRgOWbOZMKgglPJsWA54MRIoMNVMa7shUToIhx5J8vX4sOZgD2XiihiQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.5.tgz", + "integrity": "sha512-9o3TMmpmftaCMepOdA5k/yDw8SfInyzWWTjYTFCX3kPSDJMROQTb8jg+h9Cnwnmm1vOzvxN7gIfB5V2ewpjtGA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.5.tgz", + "integrity": "sha512-AdJKSPeEHgi7/ZhuIPtcQKr5RQdo6OO2IL87JkianiMYMPbCtot9fxPbrMiBADOWWm3T2si9stAiVsGbTQFkbA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.5.tgz", + "integrity": "sha512-VGzGhj4lJO+TVGV1v8ntCZWJktV7SGCs3Pn1GRWI1SBFtRALoomm8k5E9Pmwg3HOAal2VDc2F9+PM/rEY6oIDg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.5.tgz", + "integrity": "sha512-D2GyJT1kjvO//drbRT3Hib9XPwQeWd9vZoBJn+bu/lVsOZ13cqNdDeqIF/xQ5/VmWvMduP6AmXvylO/PIc2isw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.5.tgz", + "integrity": "sha512-GtaBgammVvdF7aPIgH2jxMDdivezgFu6iKpmT+48+F8Hhg5J/sfnDieg0aeG/jfSvkYQU2/pceFPDKlqZzwnfQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.5.tgz", + "integrity": "sha512-1iT4FVL0dJ76/q1wd7XDsXrSW+oLoquptvh4CLR4kITDtqi2e/xwXwdCVH8hVHU43wgJdsq7Gxuzcs6Iq/7bxQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.5.tgz", + "integrity": "sha512-nk4tGP3JThz4La38Uy/gzyXtpkPW8zSAmoUhK9xKKXdBCzKODMc2adkB2+8om9BDYugz+uGV7sLmpTYzvmz6Sw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.5.tgz", + "integrity": "sha512-PrikaNjiXdR2laW6OIjlbeuCPrPaAl0IwPIaRv+SMV8CiM8i2LqVUHFC1+8eORgWyY7yhQY+2U2fA55mBzReaw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.5.tgz", + "integrity": "sha512-cPzojwW2okgh7ZlRpcBEtsX7WBuqbLrNXqLU89GxWbNt6uIg78ET82qifUy3W6OVww6ZWobWub5oqZOVtwolfw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.5.tgz", + "integrity": "sha512-Z9kfb1v6ZlGbWj8EJk9T6czVEjjq2ntSYLY2cw6pAZl4oKtfgQuS4HOq41M/BcoLPzrUbNd+R4BXFyH//nHxVg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.5.tgz", + "integrity": "sha512-sQ7l00M8bSv36GLV95BVAdhJ2QsIbCuCjh/uYrWiMQSUuV+LpXwIqhgJDcvMTj+VsQmqAHL2yYaasENvJ7CDKA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.5.tgz", + "integrity": "sha512-0ur7ae16hDUC4OL5iEnDb0tZHDxYmuQyhKhsPBV8f99f6Z9KQM02g33f93rNH5A30agMS46u2HP6qTdEt6Q1kg==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.5.tgz", + "integrity": "sha512-kB/66P1OsHO5zLz0i6X0RxlQ+3cu0mkxS3TKFvkb5lin6uwZ/ttOkP3Z8lfR9mJOBk14ZwZ9182SIIWFGNmqmg==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.5.tgz", + "integrity": "sha512-UZCmJ7r9X2fe2D6jBmkLBMQetXPXIsZjQJCjgwpVDz+YMcS6oFR27alkgGv3Oqkv07bxdvw7fyB71/olceJhkQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.5.tgz", + "integrity": "sha512-kTxwu4mLyeOlsVIFPfQo+fQJAV9mh24xL+y+Bm6ej067sYANjyEw1dNHmvoqxJUCMnkBdKpvOn0Ahql6+4VyeA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.5.tgz", + "integrity": "sha512-K2dSKTKfmdh78uJ3NcWFiqyRrimfdinS5ErLSn3vluHNeHVnBAFWC8a4X5N+7FgVE1EjXS1QDZbpqZBjfrqMTQ==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.5.tgz", + "integrity": "sha512-uhj8N2obKTE6pSZ+aMUbqq+1nXxNjZIIjCjGLfsWvVpy7gKCOL6rsY1MhRh9zLtUtAI7vpgLMK6DxjO8Qm9lJw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.5.tgz", + "integrity": "sha512-pwHtMP9viAy1oHPvgxtOv+OkduK5ugofNTVDilIzBLpoWAM16r7b/mxBvfpuQDpRQFMfuVr5aLcn4yveGvBZvw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.5.tgz", + "integrity": "sha512-WOb5fKrvVTRMfWFNCroYWWklbnXH0Q5rZppjq0vQIdlsQKuw6mdSihwSo4RV/YdQ5UCKKvBy7/0ZZYLBZKIbwQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.5.tgz", + "integrity": "sha512-7A208+uQKgTxHd0G0uqZO8UjK2R0DDb4fDmERtARjSHWxqMTye4Erz4zZafx7Di9Cv+lNHYuncAkiGFySoD+Mw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.5.tgz", + "integrity": "sha512-G4hE405ErTWraiZ8UiSoesH8DaCsMm0Cay4fsFWOOUcz8b8rC6uCvnagr+gnioEjWn0wC+o1/TAHt+It+MpIMg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.5.tgz", + "integrity": "sha512-l+azKShMy7FxzY0Rj4RCt5VD/q8mG/e+mDivgspo+yL8zW7qEwctQ6YqKX34DTEleFAvCIUviCFX1SDZRSyMQA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.5.tgz", + "integrity": "sha512-O2S7SNZzdcFG7eFKgvwUEZ2VG9D/sn/eIiz8XRZ1Q/DO5a3s76Xv0mdBzVM5j5R639lXQmPmSo0iRpHqUUrsxw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.5.tgz", + "integrity": "sha512-onOJ02pqs9h1iMJ1PQphR+VZv8qBMQ77Klcsqv9CNW2w6yLqoURLcgERAIurY6QE63bbLuqgP9ATqajFLK5AMQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.5.tgz", + "integrity": "sha512-TXv6YnJ8ZMVdX+SXWVBo/0p8LTcrUYngpWjvm91TMjjBQii7Oz11Lw5lbDV5Y0TzuhSJHwiH4hEtC1I42mMS0g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.7.0.tgz", + "integrity": "sha512-dyybb3AcajC7uha6CvhdVRJqaKyn7w2YKqKyAN37NKYgZT36w+iRb0Dymmc5qEJ549c/S31cMMSFd75bteCpCw==", + "dev": true, + "license": "MIT", + "dependencies": { + "eslint-visitor-keys": "^3.4.3" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.12.1", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.1.tgz", + "integrity": "sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, + "node_modules/@eslint/config-array": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.20.0.tgz", + "integrity": "sha512-fxlS1kkIjx8+vy2SjuCB94q3htSNrufYTXubwiBFeaQHbH6Ipi43gFJq2zCMt6PHhImH3Xmr0NksKDvchWlpQQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/object-schema": "^2.1.6", + "debug": "^4.3.1", + "minimatch": "^3.1.2" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/config-helpers": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.2.2.tgz", + "integrity": "sha512-+GPzk8PlG0sPpzdU5ZvIRMPidzAnZDl/s9L+y13iodqvb8leL53bTannOrQ/Im7UkpsmFU5Ily5U60LWixnmLg==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/core": { + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.14.0.tgz", + "integrity": "sha512-qIbV0/JZr7iSDjqAc60IqbLdsj9GDt16xQtWD+B78d/HAlvysGdZZ6rpJHGAc2T0FQx1X6thsSPdnoiGKdNtdg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@types/json-schema": "^7.0.15" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/eslintrc": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.3.1.tgz", + "integrity": "sha512-gtF186CXhIl1p4pJNGZw8Yc6RlshoePRvE0X91oPGb3vZ8pM3qOS9W9NGPat9LziaBV7XrJWGylNQXkGcnM3IQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^10.0.1", + "globals": "^14.0.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint/eslintrc/node_modules/globals": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", + "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@eslint/js": { + "version": "9.28.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.28.0.tgz", + "integrity": "sha512-fnqSjGWd/CoIp4EXIxWVK/sHA6DOHN4+8Ix2cX5ycOY7LG0UY8nHCU5pIp2eaE1Mc7Qd8kHspYNzYXT2ojPLzg==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://eslint.org/donate" + } + }, + "node_modules/@eslint/object-schema": { + "version": "2.1.6", + "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.6.tgz", + "integrity": "sha512-RBMg5FRL0I0gs51M/guSAj5/e14VQ4tpZnQNWwuDT66P14I43ItmPfIZRhO9fUVIPOAQXU47atlywZ/czoqFPA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/plugin-kit": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.3.3.tgz", + "integrity": "sha512-1+WqvgNMhmlAambTvT3KPtCl/Ibr68VldY2XY40SL1CE0ZXiakFR/cbTspaF5HsnpDMvcYYoJHfl4980NBjGag==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/core": "^0.15.1", + "levn": "^0.4.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/plugin-kit/node_modules/@eslint/core": { + "version": "0.15.1", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.15.1.tgz", + "integrity": "sha512-bkOp+iumZCCbt1K1CmWf0R9pM5yKpDv+ZXtvSyQpudrI9kuFLp+bM2WOPXImuD/ceQuaa8f5pj93Y7zyECIGNA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@types/json-schema": "^7.0.15" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@floating-ui/core": { + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.7.1.tgz", + "integrity": "sha512-azI0DrjMMfIug/ExbBaeDVJXcY0a7EPvPjb2xAJPa4HeimBX+Z18HK8QQR3jb6356SnDDdxx+hinMLcJEDdOjw==", + "dependencies": { + "@floating-ui/utils": "^0.2.9" + } + }, + "node_modules/@floating-ui/dom": { + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.7.1.tgz", + "integrity": "sha512-cwsmW/zyw5ltYTUeeYJ60CnQuPqmGwuGVhG9w0PRaRKkAyi38BT5CKrpIbb+jtahSwUl04cWzSx9ZOIxeS6RsQ==", + "dependencies": { + "@floating-ui/core": "^1.7.1", + "@floating-ui/utils": "^0.2.9" + } + }, + "node_modules/@floating-ui/react": { + "version": "0.26.28", + "resolved": "https://registry.npmjs.org/@floating-ui/react/-/react-0.26.28.tgz", + "integrity": "sha512-yORQuuAtVpiRjpMhdc0wJj06b9JFjrYF4qp96j++v2NBpbi6SEGF7donUJ3TMieerQ6qVkAv1tgr7L4r5roTqw==", + "dependencies": { + "@floating-ui/react-dom": "^2.1.2", + "@floating-ui/utils": "^0.2.8", + "tabbable": "^6.0.0" + }, + "peerDependencies": { + "react": ">=16.8.0", + "react-dom": ">=16.8.0" + } + }, + "node_modules/@floating-ui/react-dom": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-2.1.3.tgz", + "integrity": "sha512-huMBfiU9UnQ2oBwIhgzyIiSpVgvlDstU8CX0AF+wS+KzmYMs0J2a3GwuFHV1Lz+jlrQGeC1fF+Nv0QoumyV0bA==", + "dependencies": { + "@floating-ui/dom": "^1.0.0" + }, + "peerDependencies": { + "react": ">=16.8.0", + "react-dom": ">=16.8.0" + } + }, + "node_modules/@floating-ui/utils": { + "version": "0.2.9", + "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.9.tgz", + "integrity": "sha512-MDWhGtE+eHw5JW7lq4qhc5yRLS11ERl1c7Z6Xd0a58DozHES6EnNNwUWbMiG4J9Cgj053Bhk8zvlhFYKVhULwg==" + }, + "node_modules/@headlessui/react": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/@headlessui/react/-/react-2.2.4.tgz", + "integrity": "sha512-lz+OGcAH1dK93rgSMzXmm1qKOJkBUqZf1L4M8TWLNplftQD3IkoEDdUFNfAn4ylsN6WOTVtWaLmvmaHOUk1dTA==", + "dependencies": { + "@floating-ui/react": "^0.26.16", + "@react-aria/focus": "^3.20.2", + "@react-aria/interactions": "^3.25.0", + "@tanstack/react-virtual": "^3.13.9", + "use-sync-external-store": "^1.5.0" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "react": "^18 || ^19 || ^19.0.0-rc", + "react-dom": "^18 || ^19 || ^19.0.0-rc" + } + }, + "node_modules/@heroicons/react": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@heroicons/react/-/react-2.2.0.tgz", + "integrity": "sha512-LMcepvRaS9LYHJGsF0zzmgKCUim/X3N/DQKc4jepAXJ7l8QxJ1PmxJzqplF2Z3FE4PqBAIGyJAQ/w4B5dsqbtQ==", + "license": "MIT", + "peerDependencies": { + "react": ">= 16 || ^19.0.0-rc" + } + }, + "node_modules/@humanfs/core": { + "version": "0.19.1", + "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.1.tgz", + "integrity": "sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanfs/node": { + "version": "0.16.6", + "resolved": "https://registry.npmjs.org/@humanfs/node/-/node-0.16.6.tgz", + "integrity": "sha512-YuI2ZHQL78Q5HbhDiBA1X4LmYdXCKCMQIfw0pw7piHJwyREFebJUvrQN4cMssyES6x+vfUbx1CIpaQUKYdQZOw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@humanfs/core": "^0.19.1", + "@humanwhocodes/retry": "^0.3.0" + }, + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanfs/node/node_modules/@humanwhocodes/retry": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.3.1.tgz", + "integrity": "sha512-JBxkERygn7Bv/GbN5Rv8Ul6LVknS+5Bp6RgDC/O8gEBU/yeH5Ui5C/OlWrTb6qct7LjjfT6Re2NxB0ln0yYybA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/retry": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.4.3.tgz", + "integrity": "sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@iconify/types": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@iconify/types/-/types-2.0.0.tgz", + "integrity": "sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg==", + "license": "MIT" + }, + "node_modules/@iconify/utils": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@iconify/utils/-/utils-3.0.2.tgz", + "integrity": "sha512-EfJS0rLfVuRuJRn4psJHtK2A9TqVnkxPpHY6lYHiB9+8eSuudsxbwMiavocG45ujOo6FJ+CIRlRnlOGinzkaGQ==", + "license": "MIT", + "dependencies": { + "@antfu/install-pkg": "^1.1.0", + "@antfu/utils": "^9.2.0", + "@iconify/types": "^2.0.0", + "debug": "^4.4.1", + "globals": "^15.15.0", + "kolorist": "^1.8.0", + "local-pkg": "^1.1.1", + "mlly": "^1.7.4" + } + }, + "node_modules/@iconify/utils/node_modules/globals": { + "version": "15.15.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-15.15.0.tgz", + "integrity": "sha512-7ACyT3wmyp3I61S4fG682L0VA2RGD9otkqGJIwNUMF1SWUombIIk+af1unuDYgMm082aHYwD+mzJvv9Iu8dsgg==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@isaacs/cliui": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", + "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", + "dev": true, + "license": "ISC", + "dependencies": { + "string-width": "^5.1.2", + "string-width-cjs": "npm:string-width@^4.2.0", + "strip-ansi": "^7.0.1", + "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", + "wrap-ansi": "^8.1.0", + "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@isaacs/fs-minipass": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@isaacs/fs-minipass/-/fs-minipass-4.0.1.tgz", + "integrity": "sha512-wgm9Ehl2jpeqP3zw/7mo3kRHFp5MEDhqAdwy1fTGkHAwnkGOVsgpvQhL8B5n1qlb01jV3n/bI0ZfZp5lWA1k4w==", + "dev": true, + "license": "ISC", + "dependencies": { + "minipass": "^7.0.4" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@istanbuljs/schema": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", + "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/@joshwooding/vite-plugin-react-docgen-typescript": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/@joshwooding/vite-plugin-react-docgen-typescript/-/vite-plugin-react-docgen-typescript-0.6.0.tgz", + "integrity": "sha512-dPo6SE4dm8UKcgGg4LsV9iw6f5HkIeJwzMA2M2Lb+mhl5vxesbDvb3ENTzNTkGnOxS6PqJig2pfXdtYaW3S9fg==", + "dev": true, + "license": "MIT", + "dependencies": { + "glob": "^10.0.0", + "magic-string": "^0.30.0", + "react-docgen-typescript": "^2.2.2" + }, + "peerDependencies": { + "typescript": ">= 4.3.x", + "vite": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.8", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.8.tgz", + "integrity": "sha512-imAbBGkb+ebQyxKgzv5Hu2nmROxoDOXHh80evxdoXNOrvAnVx7zimzc1Oo5h9RlfV4vPXaE2iM5pOFbvOCClWA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/set-array": "^1.2.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.24" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/set-array": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz", + "integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", + "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.25", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", + "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@mdx-js/react": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@mdx-js/react/-/react-3.1.0.tgz", + "integrity": "sha512-QjHtSaoameoalGnKDT3FoIl4+9RwyTmo9ZJGBdLOks/YOiWHoRDI3PUwEzOE7kEmGcV3AFcp9K6dYu9rEuKLAQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/mdx": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + }, + "peerDependencies": { + "@types/react": ">=16", + "react": ">=16" + } + }, + "node_modules/@mermaid-js/parser": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/@mermaid-js/parser/-/parser-0.6.3.tgz", + "integrity": "sha512-lnjOhe7zyHjc+If7yT4zoedx2vo4sHaTmtkl1+or8BRTnCtDmcTpAjpzDSfCZrshM5bCoz0GyidzadJAH1xobA==", + "license": "MIT", + "dependencies": { + "langium": "3.3.1" + } + }, + "node_modules/@neoconfetti/react": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@neoconfetti/react/-/react-1.0.0.tgz", + "integrity": "sha512-klcSooChXXOzIm+SE5IISIAn3bYzYfPjbX7D7HoqZL84oAfgREeSg5vSIaSFH+DaGzzvImTyWe1OyrJ67vik4A==", + "dev": true, + "license": "MIT" + }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@pkgjs/parseargs": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", + "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=14" + } + }, + "node_modules/@polka/url": { + "version": "1.0.0-next.29", + "resolved": "https://registry.npmjs.org/@polka/url/-/url-1.0.0-next.29.tgz", + "integrity": "sha512-wwQAWhWSuHaag8c4q/KN/vCoeOJYshAIvMQwD4GpSb3OiZklFfvAgmj0VCBBImRpuF/aFgIRzllXlVX93Jevww==", + "dev": true, + "license": "MIT" + }, + "node_modules/@react-aria/focus": { + "version": "3.20.5", + "resolved": "https://registry.npmjs.org/@react-aria/focus/-/focus-3.20.5.tgz", + "integrity": "sha512-JpFtXmWQ0Oca7FcvkqgjSyo6xEP7v3oQOLUId6o0xTvm4AD5W0mU2r3lYrbhsJ+XxdUUX4AVR5473sZZ85kU4A==", + "dependencies": { + "@react-aria/interactions": "^3.25.3", + "@react-aria/utils": "^3.29.1", + "@react-types/shared": "^3.30.0", + "@swc/helpers": "^0.5.0", + "clsx": "^2.0.0" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1", + "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" + } + }, + "node_modules/@react-aria/interactions": { + "version": "3.25.3", + "resolved": "https://registry.npmjs.org/@react-aria/interactions/-/interactions-3.25.3.tgz", + "integrity": "sha512-J1bhlrNtjPS/fe5uJQ+0c7/jiXniwa4RQlP+Emjfc/iuqpW2RhbF9ou5vROcLzWIyaW8tVMZ468J68rAs/aZ5A==", + "dependencies": { + "@react-aria/ssr": "^3.9.9", + "@react-aria/utils": "^3.29.1", + "@react-stately/flags": "^3.1.2", + "@react-types/shared": "^3.30.0", + "@swc/helpers": "^0.5.0" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1", + "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" + } + }, + "node_modules/@react-aria/ssr": { + "version": "3.9.9", + "resolved": "https://registry.npmjs.org/@react-aria/ssr/-/ssr-3.9.9.tgz", + "integrity": "sha512-2P5thfjfPy/np18e5wD4WPt8ydNXhij1jwA8oehxZTFqlgVMGXzcWKxTb4RtJrLFsqPO7RUQTiY8QJk0M4Vy2g==", + "dependencies": { + "@swc/helpers": "^0.5.0" + }, + "engines": { + "node": ">= 12" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" + } + }, + "node_modules/@react-aria/utils": { + "version": "3.29.1", + "resolved": "https://registry.npmjs.org/@react-aria/utils/-/utils-3.29.1.tgz", + "integrity": "sha512-yXMFVJ73rbQ/yYE/49n5Uidjw7kh192WNN9PNQGV0Xoc7EJUlSOxqhnpHmYTyO0EotJ8fdM1fMH8durHjUSI8g==", + "dependencies": { + "@react-aria/ssr": "^3.9.9", + "@react-stately/flags": "^3.1.2", + "@react-stately/utils": "^3.10.7", + "@react-types/shared": "^3.30.0", + "@swc/helpers": "^0.5.0", + "clsx": "^2.0.0" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1", + "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" + } + }, + "node_modules/@react-stately/flags": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@react-stately/flags/-/flags-3.1.2.tgz", + "integrity": "sha512-2HjFcZx1MyQXoPqcBGALwWWmgFVUk2TuKVIQxCbRq7fPyWXIl6VHcakCLurdtYC2Iks7zizvz0Idv48MQ38DWg==", + "dependencies": { + "@swc/helpers": "^0.5.0" + } + }, + "node_modules/@react-stately/utils": { + "version": "3.10.7", + "resolved": "https://registry.npmjs.org/@react-stately/utils/-/utils-3.10.7.tgz", + "integrity": "sha512-cWvjGAocvy4abO9zbr6PW6taHgF24Mwy/LbQ4TC4Aq3tKdKDntxyD+sh7AkSRfJRT2ccMVaHVv2+FfHThd3PKQ==", + "dependencies": { + "@swc/helpers": "^0.5.0" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" + } + }, + "node_modules/@react-types/shared": { + "version": "3.30.0", + "resolved": "https://registry.npmjs.org/@react-types/shared/-/shared-3.30.0.tgz", + "integrity": "sha512-COIazDAx1ncDg046cTJ8SFYsX8aS3lB/08LDnbkH/SkdYrFPWDlXMrO/sUam8j1WWM+PJ+4d1mj7tODIKNiFog==", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" + } + }, + "node_modules/@rolldown/pluginutils": { + "version": "1.0.0-beta.9", + "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-beta.9.tgz", + "integrity": "sha512-e9MeMtVWo186sgvFFJOPGy7/d2j2mZhLJIdVW0C/xDluuOvymEATqz6zKsP0ZmXGzQtqlyjz5sC1sYQUoJG98w==", + "dev": true, + "license": "MIT" + }, + "node_modules/@rollup/pluginutils": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.2.0.tgz", + "integrity": "sha512-qWJ2ZTbmumwiLFomfzTyt5Kng4hwPi9rwCYN4SHb6eaRU1KNO4ccxINHr/VhH4GgPlt1XfSTLX2LBTme8ne4Zw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^4.0.2" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/pluginutils/node_modules/picomatch": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", + "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.42.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.42.0.tgz", + "integrity": "sha512-gldmAyS9hpj+H6LpRNlcjQWbuKUtb94lodB9uCz71Jm+7BxK1VIOo7y62tZZwxhA7j1ylv/yQz080L5WkS+LoQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.42.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.42.0.tgz", + "integrity": "sha512-bpRipfTgmGFdCZDFLRvIkSNO1/3RGS74aWkJJTFJBH7h3MRV4UijkaEUeOMbi9wxtxYmtAbVcnMtHTPBhLEkaw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.42.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.42.0.tgz", + "integrity": "sha512-JxHtA081izPBVCHLKnl6GEA0w3920mlJPLh89NojpU2GsBSB6ypu4erFg/Wx1qbpUbepn0jY4dVWMGZM8gplgA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.42.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.42.0.tgz", + "integrity": "sha512-rv5UZaWVIJTDMyQ3dCEK+m0SAn6G7H3PRc2AZmExvbDvtaDc+qXkei0knQWcI3+c9tEs7iL/4I4pTQoPbNL2SA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.42.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.42.0.tgz", + "integrity": "sha512-fJcN4uSGPWdpVmvLuMtALUFwCHgb2XiQjuECkHT3lWLZhSQ3MBQ9pq+WoWeJq2PrNxr9rPM1Qx+IjyGj8/c6zQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.42.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.42.0.tgz", + "integrity": "sha512-CziHfyzpp8hJpCVE/ZdTizw58gr+m7Y2Xq5VOuCSrZR++th2xWAz4Nqk52MoIIrV3JHtVBhbBsJcAxs6NammOQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.42.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.42.0.tgz", + "integrity": "sha512-UsQD5fyLWm2Fe5CDM7VPYAo+UC7+2Px4Y+N3AcPh/LdZu23YcuGPegQly++XEVaC8XUTFVPscl5y5Cl1twEI4A==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.42.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.42.0.tgz", + "integrity": "sha512-/i8NIrlgc/+4n1lnoWl1zgH7Uo0XK5xK3EDqVTf38KvyYgCU/Rm04+o1VvvzJZnVS5/cWSd07owkzcVasgfIkQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.42.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.42.0.tgz", + "integrity": "sha512-eoujJFOvoIBjZEi9hJnXAbWg+Vo1Ov8n/0IKZZcPZ7JhBzxh2A+2NFyeMZIRkY9iwBvSjloKgcvnjTbGKHE44Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.42.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.42.0.tgz", + "integrity": "sha512-/3NrcOWFSR7RQUQIuZQChLND36aTU9IYE4j+TB40VU78S+RA0IiqHR30oSh6P1S9f9/wVOenHQnacs/Byb824g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loongarch64-gnu": { + "version": "4.42.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.42.0.tgz", + "integrity": "sha512-O8AplvIeavK5ABmZlKBq9/STdZlnQo7Sle0LLhVA7QT+CiGpNVe197/t8Aph9bhJqbDVGCHpY2i7QyfEDDStDg==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { + "version": "4.42.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.42.0.tgz", + "integrity": "sha512-6Qb66tbKVN7VyQrekhEzbHRxXXFFD8QKiFAwX5v9Xt6FiJ3BnCVBuyBxa2fkFGqxOCSGGYNejxd8ht+q5SnmtA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.42.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.42.0.tgz", + "integrity": "sha512-KQETDSEBamQFvg/d8jajtRwLNBlGc3aKpaGiP/LvEbnmVUKlFta1vqJqTrvPtsYsfbE/DLg5CC9zyXRX3fnBiA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.42.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.42.0.tgz", + "integrity": "sha512-qMvnyjcU37sCo/tuC+JqeDKSuukGAd+pVlRl/oyDbkvPJ3awk6G6ua7tyum02O3lI+fio+eM5wsVd66X0jQtxw==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.42.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.42.0.tgz", + "integrity": "sha512-I2Y1ZUgTgU2RLddUHXTIgyrdOwljjkmcZ/VilvaEumtS3Fkuhbw4p4hgHc39Ypwvo2o7sBFNl2MquNvGCa55Iw==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.42.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.42.0.tgz", + "integrity": "sha512-Gfm6cV6mj3hCUY8TqWa63DB8Mx3NADoFwiJrMpoZ1uESbK8FQV3LXkhfry+8bOniq9pqY1OdsjFWNsSbfjPugw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.42.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.42.0.tgz", + "integrity": "sha512-g86PF8YZ9GRqkdi0VoGlcDUb4rYtQKyTD1IVtxxN4Hpe7YqLBShA7oHMKU6oKTCi3uxwW4VkIGnOaH/El8de3w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.42.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.42.0.tgz", + "integrity": "sha512-+axkdyDGSp6hjyzQ5m1pgcvQScfHnMCcsXkx8pTgy/6qBmWVhtRVlgxjWwDp67wEXXUr0x+vD6tp5W4x6V7u1A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.42.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.42.0.tgz", + "integrity": "sha512-F+5J9pelstXKwRSDq92J0TEBXn2nfUrQGg+HK1+Tk7VOL09e0gBqUHugZv7SW4MGrYj41oNCUe3IKCDGVlis2g==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.42.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.42.0.tgz", + "integrity": "sha512-LpHiJRwkaVz/LqjHjK8LCi8osq7elmpwujwbXKNW88bM8eeGxavJIKKjkjpMHAh/2xfnrt1ZSnhTv41WYUHYmA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@shikijs/core": { + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-3.14.0.tgz", + "integrity": "sha512-qRSeuP5vlYHCNUIrpEBQFO7vSkR7jn7Kv+5X3FO/zBKVDGQbcnlScD3XhkrHi/R8Ltz0kEjvFR9Szp/XMRbFMw==", + "license": "MIT", + "dependencies": { + "@shikijs/types": "3.14.0", + "@shikijs/vscode-textmate": "^10.0.2", + "@types/hast": "^3.0.4", + "hast-util-to-html": "^9.0.5" + } + }, + "node_modules/@shikijs/engine-javascript": { + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/@shikijs/engine-javascript/-/engine-javascript-3.14.0.tgz", + "integrity": "sha512-3v1kAXI2TsWQuwv86cREH/+FK9Pjw3dorVEykzQDhwrZj0lwsHYlfyARaKmn6vr5Gasf8aeVpb8JkzeWspxOLQ==", + "license": "MIT", + "dependencies": { + "@shikijs/types": "3.14.0", + "@shikijs/vscode-textmate": "^10.0.2", + "oniguruma-to-es": "^4.3.3" + } + }, + "node_modules/@shikijs/engine-oniguruma": { + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-3.14.0.tgz", + "integrity": "sha512-TNcYTYMbJyy+ZjzWtt0bG5y4YyMIWC2nyePz+CFMWqm+HnZZyy9SWMgo8Z6KBJVIZnx8XUXS8U2afO6Y0g1Oug==", + "license": "MIT", + "dependencies": { + "@shikijs/types": "3.14.0", + "@shikijs/vscode-textmate": "^10.0.2" + } + }, + "node_modules/@shikijs/langs": { + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/@shikijs/langs/-/langs-3.14.0.tgz", + "integrity": "sha512-DIB2EQY7yPX1/ZH7lMcwrK5pl+ZkP/xoSpUzg9YC8R+evRCCiSQ7yyrvEyBsMnfZq4eBzLzBlugMyTAf13+pzg==", + "license": "MIT", + "dependencies": { + "@shikijs/types": "3.14.0" + } + }, + "node_modules/@shikijs/themes": { + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/@shikijs/themes/-/themes-3.14.0.tgz", + "integrity": "sha512-fAo/OnfWckNmv4uBoUu6dSlkcBc+SA1xzj5oUSaz5z3KqHtEbUypg/9xxgJARtM6+7RVm0Q6Xnty41xA1ma1IA==", + "license": "MIT", + "dependencies": { + "@shikijs/types": "3.14.0" + } + }, + "node_modules/@shikijs/types": { + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/@shikijs/types/-/types-3.14.0.tgz", + "integrity": "sha512-bQGgC6vrY8U/9ObG1Z/vTro+uclbjjD/uG58RvfxKZVD5p9Yc1ka3tVyEFy7BNJLzxuWyHH5NWynP9zZZS59eQ==", + "license": "MIT", + "dependencies": { + "@shikijs/vscode-textmate": "^10.0.2", + "@types/hast": "^3.0.4" + } + }, + "node_modules/@shikijs/vscode-textmate": { + "version": "10.0.2", + "resolved": "https://registry.npmjs.org/@shikijs/vscode-textmate/-/vscode-textmate-10.0.2.tgz", + "integrity": "sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg==", + "license": "MIT" + }, + "node_modules/@storybook/addon-a11y": { + "version": "9.0.14", + "resolved": "https://registry.npmjs.org/@storybook/addon-a11y/-/addon-a11y-9.0.14.tgz", + "integrity": "sha512-xDtzD89lyyq706yynJ8iAUjBfNebb7F5OoJXSAPYPnUiHoNHAcRT9ia2HrC6Yjp3f3JX2PRIEMjD5Myz3sL04A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@storybook/global": "^5.0.0", + "axe-core": "^4.2.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/storybook" + }, + "peerDependencies": { + "storybook": "^9.0.14" + } + }, + "node_modules/@storybook/addon-docs": { + "version": "9.0.14", + "resolved": "https://registry.npmjs.org/@storybook/addon-docs/-/addon-docs-9.0.14.tgz", + "integrity": "sha512-vjWH2FamLzoPZXitecbhRSUvQDj27q/dDaCKXSwCIwEVziIQrqHBGDmuJPCWoroCkKxLo8s8gwMi6wk5Minaqg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@mdx-js/react": "^3.0.0", + "@storybook/csf-plugin": "9.0.14", + "@storybook/icons": "^1.2.12", + "@storybook/react-dom-shim": "9.0.14", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", + "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", + "ts-dedent": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/storybook" + }, + "peerDependencies": { + "storybook": "^9.0.14" + } + }, + "node_modules/@storybook/addon-onboarding": { + "version": "9.0.14", + "resolved": "https://registry.npmjs.org/@storybook/addon-onboarding/-/addon-onboarding-9.0.14.tgz", + "integrity": "sha512-oJdRbOp8OkmDit8KpvkcOccN7Xczqznz55WH2oxaSLg0pWqn493BQGaRvq7Tn8qxTomNg9ibqr0rsHRZQKGlbQ==", + "dev": true, + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/storybook" + }, + "peerDependencies": { + "storybook": "^9.0.14" + } + }, + "node_modules/@storybook/addon-vitest": { + "version": "9.0.14", + "resolved": "https://registry.npmjs.org/@storybook/addon-vitest/-/addon-vitest-9.0.14.tgz", + "integrity": "sha512-pWovuulbQiLCf/hT1FiBnEvH3x+yfi6iYtJt7SMY+WF8LllKQskJXOPNW5mZ+OF6YnJiaI9SHncFVur4B2y+LA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@storybook/global": "^5.0.0", + "@storybook/icons": "^1.4.0", + "prompts": "^2.4.0", + "ts-dedent": "^2.2.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/storybook" + }, + "peerDependencies": { + "@vitest/browser": "^3.0.0", + "@vitest/runner": "^3.0.0", + "storybook": "^9.0.14", + "vitest": "^3.0.0" + }, + "peerDependenciesMeta": { + "@vitest/browser": { + "optional": true + }, + "@vitest/runner": { + "optional": true + }, + "vitest": { + "optional": true + } + } + }, + "node_modules/@storybook/builder-vite": { + "version": "9.0.14", + "resolved": "https://registry.npmjs.org/@storybook/builder-vite/-/builder-vite-9.0.14.tgz", + "integrity": "sha512-pMe/RmiC98SMRNVDvfvISW/rEVbKwKLuLm3KilHSKkW1187S/BkxBQx/o61avAEnZR2AC+JgwWZC18PJGRH/pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@storybook/csf-plugin": "9.0.14", + "ts-dedent": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/storybook" + }, + "peerDependencies": { + "storybook": "^9.0.14", + "vite": "^5.0.0 || ^6.0.0 || ^7.0.0" + } + }, + "node_modules/@storybook/csf-plugin": { + "version": "9.0.14", + "resolved": "https://registry.npmjs.org/@storybook/csf-plugin/-/csf-plugin-9.0.14.tgz", + "integrity": "sha512-PKUmF5y/SfPOifC2bRo79YwfGv6TYISM5JK6r6FHVKMwV1nWLmj7Xx2t5aHa/5JggdBz/iGganTP7oo7QOn+0A==", + "dev": true, + "license": "MIT", + "dependencies": { + "unplugin": "^1.3.1" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/storybook" + }, + "peerDependencies": { + "storybook": "^9.0.14" + } + }, + "node_modules/@storybook/csf-plugin/node_modules/unplugin": { + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/unplugin/-/unplugin-1.16.1.tgz", + "integrity": "sha512-4/u/j4FrCKdi17jaxuJA0jClGxB1AvU2hw/IuayPc4ay1XGaJs/rbb4v5WKwAjNifjmXK9PIFyuPiaK8azyR9w==", + "dev": true, + "license": "MIT", + "dependencies": { + "acorn": "^8.14.0", + "webpack-virtual-modules": "^0.6.2" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@storybook/global": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@storybook/global/-/global-5.0.0.tgz", + "integrity": "sha512-FcOqPAXACP0I3oJ/ws6/rrPT9WGhu915Cg8D02a9YxLo0DE9zI+a9A5gRGvmQ09fiWPukqI8ZAEoQEdWUKMQdQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@storybook/icons": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@storybook/icons/-/icons-1.4.0.tgz", + "integrity": "sha512-Td73IeJxOyalzvjQL+JXx72jlIYHgs+REaHiREOqfpo3A2AYYG71AUbcv+lg7mEDIweKVCxsMQ0UKo634c8XeA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0-beta", + "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0-beta" + } + }, + "node_modules/@storybook/react": { + "version": "9.0.14", + "resolved": "https://registry.npmjs.org/@storybook/react/-/react-9.0.14.tgz", + "integrity": "sha512-Ig4Y1xUOMcOWtQ/H73JZa4MeE0GJvYOcK16AhbfvPZMotdXCFyPbb1/pWhS209HuGwfNTVvWGz9rk7KrHmKsNw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@storybook/global": "^5.0.0", + "@storybook/react-dom-shim": "9.0.14" + }, + "engines": { + "node": ">=20.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/storybook" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0-beta", + "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0-beta", + "storybook": "^9.0.14", + "typescript": ">= 4.9.x" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@storybook/react-dom-shim": { + "version": "9.0.14", + "resolved": "https://registry.npmjs.org/@storybook/react-dom-shim/-/react-dom-shim-9.0.14.tgz", + "integrity": "sha512-fXMzhgFMnGZUhWm9zWiR8qOB90OykPhkB/qiebFbD/wUedPyp3H1+NAzX1/UWV2SYqr+aFK9vH1PokAYbpTRsw==", + "dev": true, + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/storybook" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0-beta", + "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0-beta", + "storybook": "^9.0.14" + } + }, + "node_modules/@storybook/react-vite": { + "version": "9.0.14", + "resolved": "https://registry.npmjs.org/@storybook/react-vite/-/react-vite-9.0.14.tgz", + "integrity": "sha512-Qz231WFDcfRiB61P9zBv12GxX/V0CO0YiuIFNDoCNroVRAzGaBK8IYR2KKRd5V/1UGJl35YyyEIZUcA4Zt5xEQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@joshwooding/vite-plugin-react-docgen-typescript": "0.6.0", + "@rollup/pluginutils": "^5.0.2", + "@storybook/builder-vite": "9.0.14", + "@storybook/react": "9.0.14", + "find-up": "^7.0.0", + "magic-string": "^0.30.0", + "react-docgen": "^8.0.0", + "resolve": "^1.22.8", + "tsconfig-paths": "^4.2.0" + }, + "engines": { + "node": ">=20.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/storybook" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0-beta", + "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0-beta", + "storybook": "^9.0.14", + "vite": "^5.0.0 || ^6.0.0 || ^7.0.0" + } + }, + "node_modules/@storybook/react-vite/node_modules/find-up": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-7.0.0.tgz", + "integrity": "sha512-YyZM99iHrqLKjmt4LJDj58KI+fYyufRLBSYcqycxf//KpBk9FoewoGX0450m9nB44qrZnovzC2oeP5hUibxc/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^7.2.0", + "path-exists": "^5.0.0", + "unicorn-magic": "^0.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@storybook/react-vite/node_modules/locate-path": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-7.2.0.tgz", + "integrity": "sha512-gvVijfZvn7R+2qyPX8mAuKcFGDf6Nc61GdvGafQsHL0sBIxfKzA+usWn4GFC/bk+QdwPUD4kWFJLhElipq+0VA==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^6.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@storybook/react-vite/node_modules/p-limit": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-4.0.0.tgz", + "integrity": "sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "yocto-queue": "^1.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@storybook/react-vite/node_modules/p-locate": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-6.0.0.tgz", + "integrity": "sha512-wPrq66Llhl7/4AGC6I+cqxT07LhXvWL08LNXz1fENOw0Ap4sRZZ/gZpTTJ5jpurzzzfS2W/Ge9BY3LgLjCShcw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^4.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@storybook/react-vite/node_modules/path-exists": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-5.0.0.tgz", + "integrity": "sha512-RjhtfwJOxzcFmNOi6ltcbcu4Iu+FL3zEj83dk4kAS+fVpTxXLO1b38RvJgT/0QwvV/L3aY9TAnyv0EOqW4GoMQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + } + }, + "node_modules/@storybook/react-vite/node_modules/yocto-queue": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.2.1.tgz", + "integrity": "sha512-AyeEbWOu/TAXdxlV9wmGcR0+yh2j3vYPGOECcIj2S7MkrLyC7ne+oye2BKTItt0ii2PHk4cDy+95+LshzbXnGg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@swc/helpers": { + "version": "0.5.17", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.17.tgz", + "integrity": "sha512-5IKx/Y13RsYd+sauPb2x+U/xZikHjolzfuDgTAl/Tdf3Q8rslRvC19NKDLgAJQ6wsqADk10ntlv08nPFw/gO/A==", + "dependencies": { + "tslib": "^2.8.0" + } + }, + "node_modules/@tailwindcss/node": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@tailwindcss/node/-/node-4.1.11.tgz", + "integrity": "sha512-yzhzuGRmv5QyU9qLNg4GTlYI6STedBWRE7NjxP45CsFYYq9taI0zJXZBMqIC/c8fViNLhmrbpSFS57EoxUmD6Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@ampproject/remapping": "^2.3.0", + "enhanced-resolve": "^5.18.1", + "jiti": "^2.4.2", + "lightningcss": "1.30.1", + "magic-string": "^0.30.17", + "source-map-js": "^1.2.1", + "tailwindcss": "4.1.11" + } + }, + "node_modules/@tailwindcss/oxide": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide/-/oxide-4.1.11.tgz", + "integrity": "sha512-Q69XzrtAhuyfHo+5/HMgr1lAiPP/G40OMFAnws7xcFEYqcypZmdW8eGXaOUIeOl1dzPJBPENXgbjsOyhg2nkrg==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "dependencies": { + "detect-libc": "^2.0.4", + "tar": "^7.4.3" + }, + "engines": { + "node": ">= 10" + }, + "optionalDependencies": { + "@tailwindcss/oxide-android-arm64": "4.1.11", + "@tailwindcss/oxide-darwin-arm64": "4.1.11", + "@tailwindcss/oxide-darwin-x64": "4.1.11", + "@tailwindcss/oxide-freebsd-x64": "4.1.11", + "@tailwindcss/oxide-linux-arm-gnueabihf": "4.1.11", + "@tailwindcss/oxide-linux-arm64-gnu": "4.1.11", + "@tailwindcss/oxide-linux-arm64-musl": "4.1.11", + "@tailwindcss/oxide-linux-x64-gnu": "4.1.11", + "@tailwindcss/oxide-linux-x64-musl": "4.1.11", + "@tailwindcss/oxide-wasm32-wasi": "4.1.11", + "@tailwindcss/oxide-win32-arm64-msvc": "4.1.11", + "@tailwindcss/oxide-win32-x64-msvc": "4.1.11" + } + }, + "node_modules/@tailwindcss/oxide-android-arm64": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-android-arm64/-/oxide-android-arm64-4.1.11.tgz", + "integrity": "sha512-3IfFuATVRUMZZprEIx9OGDjG3Ou3jG4xQzNTvjDoKmU9JdmoCohQJ83MYd0GPnQIu89YoJqvMM0G3uqLRFtetg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tailwindcss/oxide-darwin-arm64": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-darwin-arm64/-/oxide-darwin-arm64-4.1.11.tgz", + "integrity": "sha512-ESgStEOEsyg8J5YcMb1xl8WFOXfeBmrhAwGsFxxB2CxY9evy63+AtpbDLAyRkJnxLy2WsD1qF13E97uQyP1lfQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tailwindcss/oxide-darwin-x64": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-darwin-x64/-/oxide-darwin-x64-4.1.11.tgz", + "integrity": "sha512-EgnK8kRchgmgzG6jE10UQNaH9Mwi2n+yw1jWmof9Vyg2lpKNX2ioe7CJdf9M5f8V9uaQxInenZkOxnTVL3fhAw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tailwindcss/oxide-freebsd-x64": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-freebsd-x64/-/oxide-freebsd-x64-4.1.11.tgz", + "integrity": "sha512-xdqKtbpHs7pQhIKmqVpxStnY1skuNh4CtbcyOHeX1YBE0hArj2romsFGb6yUmzkq/6M24nkxDqU8GYrKrz+UcA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tailwindcss/oxide-linux-arm-gnueabihf": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm-gnueabihf/-/oxide-linux-arm-gnueabihf-4.1.11.tgz", + "integrity": "sha512-ryHQK2eyDYYMwB5wZL46uoxz2zzDZsFBwfjssgB7pzytAeCCa6glsiJGjhTEddq/4OsIjsLNMAiMlHNYnkEEeg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tailwindcss/oxide-linux-arm64-gnu": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm64-gnu/-/oxide-linux-arm64-gnu-4.1.11.tgz", + "integrity": "sha512-mYwqheq4BXF83j/w75ewkPJmPZIqqP1nhoghS9D57CLjsh3Nfq0m4ftTotRYtGnZd3eCztgbSPJ9QhfC91gDZQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tailwindcss/oxide-linux-arm64-musl": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm64-musl/-/oxide-linux-arm64-musl-4.1.11.tgz", + "integrity": "sha512-m/NVRFNGlEHJrNVk3O6I9ggVuNjXHIPoD6bqay/pubtYC9QIdAMpS+cswZQPBLvVvEF6GtSNONbDkZrjWZXYNQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tailwindcss/oxide-linux-x64-gnu": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-x64-gnu/-/oxide-linux-x64-gnu-4.1.11.tgz", + "integrity": "sha512-YW6sblI7xukSD2TdbbaeQVDysIm/UPJtObHJHKxDEcW2exAtY47j52f8jZXkqE1krdnkhCMGqP3dbniu1Te2Fg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tailwindcss/oxide-linux-x64-musl": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-x64-musl/-/oxide-linux-x64-musl-4.1.11.tgz", + "integrity": "sha512-e3C/RRhGunWYNC3aSF7exsQkdXzQ/M+aYuZHKnw4U7KQwTJotnWsGOIVih0s2qQzmEzOFIJ3+xt7iq67K/p56Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tailwindcss/oxide-wasm32-wasi": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-wasm32-wasi/-/oxide-wasm32-wasi-4.1.11.tgz", + "integrity": "sha512-Xo1+/GU0JEN/C/dvcammKHzeM6NqKovG+6921MR6oadee5XPBaKOumrJCXvopJ/Qb5TH7LX/UAywbqrP4lax0g==", + "bundleDependencies": [ + "@napi-rs/wasm-runtime", + "@emnapi/core", + "@emnapi/runtime", + "@tybys/wasm-util", + "@emnapi/wasi-threads", + "tslib" + ], + "cpu": [ + "wasm32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/core": "^1.4.3", + "@emnapi/runtime": "^1.4.3", + "@emnapi/wasi-threads": "^1.0.2", + "@napi-rs/wasm-runtime": "^0.2.11", + "@tybys/wasm-util": "^0.9.0", + "tslib": "^2.8.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@tailwindcss/oxide-win32-arm64-msvc": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-arm64-msvc/-/oxide-win32-arm64-msvc-4.1.11.tgz", + "integrity": "sha512-UgKYx5PwEKrac3GPNPf6HVMNhUIGuUh4wlDFR2jYYdkX6pL/rn73zTq/4pzUm8fOjAn5L8zDeHp9iXmUGOXZ+w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tailwindcss/oxide-win32-x64-msvc": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-x64-msvc/-/oxide-win32-x64-msvc-4.1.11.tgz", + "integrity": "sha512-YfHoggn1j0LK7wR82TOucWc5LDCguHnoS879idHekmmiR7g9HUtMw9MI0NHatS28u/Xlkfi9w5RJWgz2Dl+5Qg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@tailwindcss/typography": { + "version": "0.5.16", + "resolved": "https://registry.npmjs.org/@tailwindcss/typography/-/typography-0.5.16.tgz", + "integrity": "sha512-0wDLwCVF5V3x3b1SGXPCDcdsbDHMBe+lkFzBRaHeLvNi+nrrnZ1lA18u+OTWO8iSWU2GxUOCvlXtDuqftc1oiA==", + "dev": true, + "license": "MIT", + "dependencies": { + "lodash.castarray": "^4.4.0", + "lodash.isplainobject": "^4.0.6", + "lodash.merge": "^4.6.2", + "postcss-selector-parser": "6.0.10" + }, + "peerDependencies": { + "tailwindcss": ">=3.0.0 || insiders || >=4.0.0-alpha.20 || >=4.0.0-beta.1" + } + }, + "node_modules/@tailwindcss/vite": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@tailwindcss/vite/-/vite-4.1.11.tgz", + "integrity": "sha512-RHYhrR3hku0MJFRV+fN2gNbDNEh3dwKvY8XJvTxCSXeMOsCRSr+uKvDWQcbizrHgjML6ZmTE5OwMrl5wKcujCw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@tailwindcss/node": "4.1.11", + "@tailwindcss/oxide": "4.1.11", + "tailwindcss": "4.1.11" + }, + "peerDependencies": { + "vite": "^5.2.0 || ^6 || ^7" + } + }, + "node_modules/@tanstack/history": { + "version": "1.120.17", + "resolved": "https://registry.npmjs.org/@tanstack/history/-/history-1.120.17.tgz", + "integrity": "sha512-k07LFI4Qo074IIaWzT/XjD0KlkGx2w1V3fnNtclKx0oAl8z4O9kCh6za+FPEIRe98xLgNFEiddDbJeAYGSlPtw==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + } + }, + "node_modules/@tanstack/query-core": { + "version": "5.80.7", + "resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-5.80.7.tgz", + "integrity": "sha512-s09l5zeUKC8q7DCCCIkVSns8zZrK4ZDT6ryEjxNBFi68G4z2EBobBS7rdOY3r6W1WbUDpc1fe5oY+YO/+2UVUg==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + } + }, + "node_modules/@tanstack/react-query": { + "version": "5.80.7", + "resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.80.7.tgz", + "integrity": "sha512-u2F0VK6+anItoEvB3+rfvTO9GEh2vb00Je05OwlUe/A0lkJBgW1HckiY3f9YZa+jx6IOe4dHPh10dyp9aY3iRQ==", + "license": "MIT", + "dependencies": { + "@tanstack/query-core": "5.80.7" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + }, + "peerDependencies": { + "react": "^18 || ^19" + } + }, + "node_modules/@tanstack/react-router": { + "version": "1.120.20", + "resolved": "https://registry.npmjs.org/@tanstack/react-router/-/react-router-1.120.20.tgz", + "integrity": "sha512-+zNruUE9NsfGm9cHd22Xs7FRtBrBhDZe94pB69BEIjqjrEPZct6f5VhTV9WQ+bDZ6fRz8tUuxNFAgm/3Lm4AIg==", + "license": "MIT", + "dependencies": { + "@tanstack/history": "1.120.17", + "@tanstack/react-store": "^0.7.0", + "@tanstack/router-core": "1.120.19", + "jsesc": "^3.1.0", + "tiny-invariant": "^1.3.3", + "tiny-warning": "^1.0.3" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + }, + "peerDependencies": { + "react": ">=18.0.0 || >=19.0.0", + "react-dom": ">=18.0.0 || >=19.0.0" + } + }, + "node_modules/@tanstack/react-router-devtools": { + "version": "1.120.20", + "resolved": "https://registry.npmjs.org/@tanstack/react-router-devtools/-/react-router-devtools-1.120.20.tgz", + "integrity": "sha512-8wYUBdhaMQLo+f5GlJ31WK3T5gpQWetIG7bEGbhrgmd8Z6nZbUYfq10BtVnIwhJwiQa/39Fi9778/09N13l00A==", + "license": "MIT", + "dependencies": { + "@tanstack/router-devtools-core": "^1.120.19", + "solid-js": "^1.9.5" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + }, + "peerDependencies": { + "@tanstack/react-router": "^1.120.20", + "react": ">=18.0.0 || >=19.0.0", + "react-dom": ">=18.0.0 || >=19.0.0" + } + }, + "node_modules/@tanstack/react-store": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/@tanstack/react-store/-/react-store-0.7.1.tgz", + "integrity": "sha512-qUTEKdId6QPWGiWyKAPf/gkN29scEsz6EUSJ0C3HgLMgaqTAyBsQ2sMCfGVcqb+kkhEXAdjleCgH6LAPD6f2sA==", + "license": "MIT", + "dependencies": { + "@tanstack/store": "0.7.1", + "use-sync-external-store": "^1.5.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", + "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" + } + }, + "node_modules/@tanstack/react-virtual": { + "version": "3.13.10", + "resolved": "https://registry.npmjs.org/@tanstack/react-virtual/-/react-virtual-3.13.10.tgz", + "integrity": "sha512-nvrzk4E9mWB4124YdJ7/yzwou7IfHxlSef6ugCFcBfRmsnsma3heciiiV97sBNxyc3VuwtZvmwXd0aB5BpucVw==", + "dependencies": { + "@tanstack/virtual-core": "3.13.10" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", + "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" + } + }, + "node_modules/@tanstack/router-core": { + "version": "1.120.19", + "resolved": "https://registry.npmjs.org/@tanstack/router-core/-/router-core-1.120.19.tgz", + "integrity": "sha512-5JUVgkxnIM3NxMwzKt0tfz2UopZVxwq6Kl7Rp33zlFJaPjpiRs46VuRjVeAvkpJd6samo1gcH1rWqmnPUmtGcw==", + "license": "MIT", + "dependencies": { + "@tanstack/history": "1.120.17", + "@tanstack/store": "^0.7.0", + "tiny-invariant": "^1.3.3" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + } + }, + "node_modules/@tanstack/router-devtools-core": { + "version": "1.120.19", + "resolved": "https://registry.npmjs.org/@tanstack/router-devtools-core/-/router-devtools-core-1.120.19.tgz", + "integrity": "sha512-B/8riYIxs5z+6BmkycfkllhZzRV0/jt8MEqlVHU/HDyAi+00luhi+4xwqQNxiAIUpFa6+0twmGPj4SI3SPA6nQ==", + "license": "MIT", + "dependencies": { + "clsx": "^2.1.1", + "goober": "^2.1.16" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + }, + "peerDependencies": { + "@tanstack/router-core": "^1.120.19", + "csstype": "^3.0.10", + "solid-js": ">=1.9.5", + "tiny-invariant": "^1.3.3" + }, + "peerDependenciesMeta": { + "csstype": { + "optional": true + } + } + }, + "node_modules/@tanstack/router-generator": { + "version": "1.120.20", + "resolved": "https://registry.npmjs.org/@tanstack/router-generator/-/router-generator-1.120.20.tgz", + "integrity": "sha512-tv8uOjteyMnUUDepjknkiTQ90EL6sNuDGsfeUz0wXFQ6dy/cqYqV0pXzJuBRN79ToteWFdq5sJeypqUdzOC8+w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@tanstack/virtual-file-routes": "^1.120.17", + "prettier": "^3.5.0", + "tsx": "^4.19.2", + "zod": "^3.24.2" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + }, + "peerDependencies": { + "@tanstack/react-router": "^1.120.20" + }, + "peerDependenciesMeta": { + "@tanstack/react-router": { + "optional": true + } + } + }, + "node_modules/@tanstack/router-plugin": { + "version": "1.120.20", + "resolved": "https://registry.npmjs.org/@tanstack/router-plugin/-/router-plugin-1.120.20.tgz", + "integrity": "sha512-GaDcIZSVaMoLvG6pu0yRLz8C8jtFo1avV23Q1UbZzv+1i66Uk0twcfTPy/eJbB8pgRA2P5Eu7xo7L3g5HvkGRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/core": "^7.26.8", + "@babel/plugin-syntax-jsx": "^7.25.9", + "@babel/plugin-syntax-typescript": "^7.25.9", + "@babel/template": "^7.26.8", + "@babel/traverse": "^7.26.8", + "@babel/types": "^7.26.8", + "@tanstack/router-core": "^1.120.19", + "@tanstack/router-generator": "^1.120.20", + "@tanstack/router-utils": "^1.120.17", + "@tanstack/virtual-file-routes": "^1.120.17", + "@types/babel__core": "^7.20.5", + "@types/babel__template": "^7.4.4", + "@types/babel__traverse": "^7.20.6", + "babel-dead-code-elimination": "^1.0.10", + "chokidar": "^3.6.0", + "unplugin": "^2.1.2", + "zod": "^3.24.2" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + }, + "peerDependencies": { + "@rsbuild/core": ">=1.0.2", + "@tanstack/react-router": "^1.120.20", + "vite": ">=5.0.0 || >=6.0.0", + "vite-plugin-solid": "^2.11.2", + "webpack": ">=5.92.0" + }, + "peerDependenciesMeta": { + "@rsbuild/core": { + "optional": true + }, + "@tanstack/react-router": { + "optional": true + }, + "vite": { + "optional": true + }, + "vite-plugin-solid": { + "optional": true + }, + "webpack": { + "optional": true + } + } + }, + "node_modules/@tanstack/router-utils": { + "version": "1.120.17", + "resolved": "https://registry.npmjs.org/@tanstack/router-utils/-/router-utils-1.120.17.tgz", + "integrity": "sha512-emgT4FthaGtTRaRg9bsr0uaq3EHdl/flS4bKLuFaetiFTt8wk8EVU2a7EZlkaaAfLLDPaiGbP1S2DDaZQ7ci+Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/generator": "^7.26.8", + "@babel/parser": "^7.26.8", + "ansis": "^3.11.0", + "diff": "^7.0.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + } + }, + "node_modules/@tanstack/store": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/@tanstack/store/-/store-0.7.1.tgz", + "integrity": "sha512-PjUQKXEXhLYj2X5/6c1Xn/0/qKY0IVFxTJweopRfF26xfjVyb14yALydJrHupDh3/d+1WKmfEgZPBVCmDkzzwg==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + } + }, + "node_modules/@tanstack/virtual-core": { + "version": "3.13.10", + "resolved": "https://registry.npmjs.org/@tanstack/virtual-core/-/virtual-core-3.13.10.tgz", + "integrity": "sha512-sPEDhXREou5HyZYqSWIqdU580rsF6FGeN7vpzijmP3KTiOGjOMZASz4Y6+QKjiFQwhWrR58OP8izYaNGVxvViA==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + } + }, + "node_modules/@tanstack/virtual-file-routes": { + "version": "1.120.17", + "resolved": "https://registry.npmjs.org/@tanstack/virtual-file-routes/-/virtual-file-routes-1.120.17.tgz", + "integrity": "sha512-Ssi+yKcjG9ru02ieCpUBF7QQBEKGB7WQS1R9va3GHu+Oq9WjzmJ4rifzdugjTeKD3yfT7d1I+pOxRhoWog6CHw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + } + }, + "node_modules/@testing-library/dom": { + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.4.0.tgz", + "integrity": "sha512-pemlzrSESWbdAloYml3bAJMEfNh1Z7EduzqPKprCH5S341frlpYnUEW0H72dLxa6IsYr+mPno20GiSm+h9dEdQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.10.4", + "@babel/runtime": "^7.12.5", + "@types/aria-query": "^5.0.1", + "aria-query": "5.3.0", + "chalk": "^4.1.0", + "dom-accessibility-api": "^0.5.9", + "lz-string": "^1.5.0", + "pretty-format": "^27.0.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@testing-library/jest-dom": { + "version": "6.6.3", + "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-6.6.3.tgz", + "integrity": "sha512-IteBhl4XqYNkM54f4ejhLRJiZNqcSCoXUOG2CPK7qbD322KjQozM4kHQOfkG2oln9b9HTYqs+Sae8vBATubxxA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@adobe/css-tools": "^4.4.0", + "aria-query": "^5.0.0", + "chalk": "^3.0.0", + "css.escape": "^1.5.1", + "dom-accessibility-api": "^0.6.3", + "lodash": "^4.17.21", + "redent": "^3.0.0" + }, + "engines": { + "node": ">=14", + "npm": ">=6", + "yarn": ">=1" + } + }, + "node_modules/@testing-library/jest-dom/node_modules/chalk": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", + "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@testing-library/jest-dom/node_modules/dom-accessibility-api": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.6.3.tgz", + "integrity": "sha512-7ZgogeTnjuHbo+ct10G9Ffp0mif17idi0IyWNVA/wcwcm7NPOD/WEHVP3n7n3MhXqxoIYm8d6MuZohYWIZ4T3w==", + "dev": true, + "license": "MIT" + }, + "node_modules/@testing-library/user-event": { + "version": "14.6.1", + "resolved": "https://registry.npmjs.org/@testing-library/user-event/-/user-event-14.6.1.tgz", + "integrity": "sha512-vq7fv0rnt+QTXgPxr5Hjc210p6YKq2kmdziLgnsZGgLJ9e6VAShx1pACLuRjd/AS/sr7phAR58OIIpf0LlmQNw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12", + "npm": ">=6" + }, + "peerDependencies": { + "@testing-library/dom": ">=7.21.4" + } + }, + "node_modules/@types/aria-query": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.4.tgz", + "integrity": "sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/babel__core": { + "version": "7.20.5", + "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", + "integrity": "sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.20.7", + "@babel/types": "^7.20.7", + "@types/babel__generator": "*", + "@types/babel__template": "*", + "@types/babel__traverse": "*" + } + }, + "node_modules/@types/babel__generator": { + "version": "7.27.0", + "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.27.0.tgz", + "integrity": "sha512-ufFd2Xi92OAVPYsy+P4n7/U7e68fex0+Ee8gSG9KX7eo084CWiQ4sdxktvdl0bOPupXtVJPY19zk6EwWqUQ8lg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.0.0" + } + }, + "node_modules/@types/babel__template": { + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.4.tgz", + "integrity": "sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "node_modules/@types/babel__traverse": { + "version": "7.20.7", + "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.20.7.tgz", + "integrity": "sha512-dkO5fhS7+/oos4ciWxyEyjWe48zmG6wbCheo/G2ZnHx4fs3EU6YC6UM8rk56gAjNJ9P3MTH2jo5jb92/K6wbng==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.20.7" + } + }, + "node_modules/@types/chai": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.2.tgz", + "integrity": "sha512-8kB30R7Hwqf40JPiKhVzodJs2Qc1ZJ5zuT3uzw5Hq/dhNCl3G3l83jfpdI1e20BP348+fV7VIL/+FxaXkqBmWg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/deep-eql": "*" + } + }, + "node_modules/@types/d3": { + "version": "7.4.3", + "resolved": "https://registry.npmjs.org/@types/d3/-/d3-7.4.3.tgz", + "integrity": "sha512-lZXZ9ckh5R8uiFVt8ogUNf+pIrK4EsWrx2Np75WvF/eTpJ0FMHNhjXk8CKEx/+gpHbNQyJWehbFaTvqmHWB3ww==", + "license": "MIT", + "dependencies": { + "@types/d3-array": "*", + "@types/d3-axis": "*", + "@types/d3-brush": "*", + "@types/d3-chord": "*", + "@types/d3-color": "*", + "@types/d3-contour": "*", + "@types/d3-delaunay": "*", + "@types/d3-dispatch": "*", + "@types/d3-drag": "*", + "@types/d3-dsv": "*", + "@types/d3-ease": "*", + "@types/d3-fetch": "*", + "@types/d3-force": "*", + "@types/d3-format": "*", + "@types/d3-geo": "*", + "@types/d3-hierarchy": "*", + "@types/d3-interpolate": "*", + "@types/d3-path": "*", + "@types/d3-polygon": "*", + "@types/d3-quadtree": "*", + "@types/d3-random": "*", + "@types/d3-scale": "*", + "@types/d3-scale-chromatic": "*", + "@types/d3-selection": "*", + "@types/d3-shape": "*", + "@types/d3-time": "*", + "@types/d3-time-format": "*", + "@types/d3-timer": "*", + "@types/d3-transition": "*", + "@types/d3-zoom": "*" + } + }, + "node_modules/@types/d3-array": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/@types/d3-array/-/d3-array-3.2.2.tgz", + "integrity": "sha512-hOLWVbm7uRza0BYXpIIW5pxfrKe0W+D5lrFiAEYR+pb6w3N2SwSMaJbXdUfSEv+dT4MfHBLtn5js0LAWaO6otw==", + "license": "MIT" + }, + "node_modules/@types/d3-axis": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/@types/d3-axis/-/d3-axis-3.0.6.tgz", + "integrity": "sha512-pYeijfZuBd87T0hGn0FO1vQ/cgLk6E1ALJjfkC0oJ8cbwkZl3TpgS8bVBLZN+2jjGgg38epgxb2zmoGtSfvgMw==", + "license": "MIT", + "dependencies": { + "@types/d3-selection": "*" + } + }, + "node_modules/@types/d3-brush": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/@types/d3-brush/-/d3-brush-3.0.6.tgz", + "integrity": "sha512-nH60IZNNxEcrh6L1ZSMNA28rj27ut/2ZmI3r96Zd+1jrZD++zD3LsMIjWlvg4AYrHn/Pqz4CF3veCxGjtbqt7A==", + "license": "MIT", + "dependencies": { + "@types/d3-selection": "*" + } + }, + "node_modules/@types/d3-chord": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/@types/d3-chord/-/d3-chord-3.0.6.tgz", + "integrity": "sha512-LFYWWd8nwfwEmTZG9PfQxd17HbNPksHBiJHaKuY1XeqscXacsS2tyoo6OdRsjf+NQYeB6XrNL3a25E3gH69lcg==", + "license": "MIT" + }, + "node_modules/@types/d3-color": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/@types/d3-color/-/d3-color-3.1.3.tgz", + "integrity": "sha512-iO90scth9WAbmgv7ogoq57O9YpKmFBbmoEoCHDB2xMBY0+/KVrqAaCDyCE16dUspeOvIxFFRI+0sEtqDqy2b4A==", + "license": "MIT" + }, + "node_modules/@types/d3-contour": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/@types/d3-contour/-/d3-contour-3.0.6.tgz", + "integrity": "sha512-BjzLgXGnCWjUSYGfH1cpdo41/hgdWETu4YxpezoztawmqsvCeep+8QGfiY6YbDvfgHz/DkjeIkkZVJavB4a3rg==", + "license": "MIT", + "dependencies": { + "@types/d3-array": "*", + "@types/geojson": "*" + } + }, + "node_modules/@types/d3-delaunay": { + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/@types/d3-delaunay/-/d3-delaunay-6.0.4.tgz", + "integrity": "sha512-ZMaSKu4THYCU6sV64Lhg6qjf1orxBthaC161plr5KuPHo3CNm8DTHiLw/5Eq2b6TsNP0W0iJrUOFscY6Q450Hw==", + "license": "MIT" + }, + "node_modules/@types/d3-dispatch": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/@types/d3-dispatch/-/d3-dispatch-3.0.7.tgz", + "integrity": "sha512-5o9OIAdKkhN1QItV2oqaE5KMIiXAvDWBDPrD85e58Qlz1c1kI/J0NcqbEG88CoTwJrYe7ntUCVfeUl2UJKbWgA==", + "license": "MIT" + }, + "node_modules/@types/d3-drag": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/@types/d3-drag/-/d3-drag-3.0.7.tgz", + "integrity": "sha512-HE3jVKlzU9AaMazNufooRJ5ZpWmLIoc90A37WU2JMmeq28w1FQqCZswHZ3xR+SuxYftzHq6WU6KJHvqxKzTxxQ==", + "license": "MIT", + "dependencies": { + "@types/d3-selection": "*" + } + }, + "node_modules/@types/d3-dsv": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/@types/d3-dsv/-/d3-dsv-3.0.7.tgz", + "integrity": "sha512-n6QBF9/+XASqcKK6waudgL0pf/S5XHPPI8APyMLLUHd8NqouBGLsU8MgtO7NINGtPBtk9Kko/W4ea0oAspwh9g==", + "license": "MIT" + }, + "node_modules/@types/d3-ease": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@types/d3-ease/-/d3-ease-3.0.2.tgz", + "integrity": "sha512-NcV1JjO5oDzoK26oMzbILE6HW7uVXOHLQvHshBUW4UMdZGfiY6v5BeQwh9a9tCzv+CeefZQHJt5SRgK154RtiA==", + "license": "MIT" + }, + "node_modules/@types/d3-fetch": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/@types/d3-fetch/-/d3-fetch-3.0.7.tgz", + "integrity": "sha512-fTAfNmxSb9SOWNB9IoG5c8Hg6R+AzUHDRlsXsDZsNp6sxAEOP0tkP3gKkNSO/qmHPoBFTxNrjDprVHDQDvo5aA==", + "license": "MIT", + "dependencies": { + "@types/d3-dsv": "*" + } + }, + "node_modules/@types/d3-force": { + "version": "3.0.10", + "resolved": "https://registry.npmjs.org/@types/d3-force/-/d3-force-3.0.10.tgz", + "integrity": "sha512-ZYeSaCF3p73RdOKcjj+swRlZfnYpK1EbaDiYICEEp5Q6sUiqFaFQ9qgoshp5CzIyyb/yD09kD9o2zEltCexlgw==", + "license": "MIT" + }, + "node_modules/@types/d3-format": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@types/d3-format/-/d3-format-3.0.4.tgz", + "integrity": "sha512-fALi2aI6shfg7vM5KiR1wNJnZ7r6UuggVqtDA+xiEdPZQwy/trcQaHnwShLuLdta2rTymCNpxYTiMZX/e09F4g==", + "license": "MIT" + }, + "node_modules/@types/d3-geo": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@types/d3-geo/-/d3-geo-3.1.0.tgz", + "integrity": "sha512-856sckF0oP/diXtS4jNsiQw/UuK5fQG8l/a9VVLeSouf1/PPbBE1i1W852zVwKwYCBkFJJB7nCFTbk6UMEXBOQ==", + "license": "MIT", + "dependencies": { + "@types/geojson": "*" + } + }, + "node_modules/@types/d3-hierarchy": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/@types/d3-hierarchy/-/d3-hierarchy-3.1.7.tgz", + "integrity": "sha512-tJFtNoYBtRtkNysX1Xq4sxtjK8YgoWUNpIiUee0/jHGRwqvzYxkq0hGVbbOGSz+JgFxxRu4K8nb3YpG3CMARtg==", + "license": "MIT" + }, + "node_modules/@types/d3-interpolate": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@types/d3-interpolate/-/d3-interpolate-3.0.4.tgz", + "integrity": "sha512-mgLPETlrpVV1YRJIglr4Ez47g7Yxjl1lj7YKsiMCb27VJH9W8NVM6Bb9d8kkpG/uAQS5AmbA48q2IAolKKo1MA==", + "license": "MIT", + "dependencies": { + "@types/d3-color": "*" + } + }, + "node_modules/@types/d3-path": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@types/d3-path/-/d3-path-3.1.1.tgz", + "integrity": "sha512-VMZBYyQvbGmWyWVea0EHs/BwLgxc+MKi1zLDCONksozI4YJMcTt8ZEuIR4Sb1MMTE8MMW49v0IwI5+b7RmfWlg==", + "license": "MIT" + }, + "node_modules/@types/d3-polygon": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@types/d3-polygon/-/d3-polygon-3.0.2.tgz", + "integrity": "sha512-ZuWOtMaHCkN9xoeEMr1ubW2nGWsp4nIql+OPQRstu4ypeZ+zk3YKqQT0CXVe/PYqrKpZAi+J9mTs05TKwjXSRA==", + "license": "MIT" + }, + "node_modules/@types/d3-quadtree": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/@types/d3-quadtree/-/d3-quadtree-3.0.6.tgz", + "integrity": "sha512-oUzyO1/Zm6rsxKRHA1vH0NEDG58HrT5icx/azi9MF1TWdtttWl0UIUsjEQBBh+SIkrpd21ZjEv7ptxWys1ncsg==", + "license": "MIT" + }, + "node_modules/@types/d3-random": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/d3-random/-/d3-random-3.0.3.tgz", + "integrity": "sha512-Imagg1vJ3y76Y2ea0871wpabqp613+8/r0mCLEBfdtqC7xMSfj9idOnmBYyMoULfHePJyxMAw3nWhJxzc+LFwQ==", + "license": "MIT" + }, + "node_modules/@types/d3-scale": { + "version": "4.0.9", + "resolved": "https://registry.npmjs.org/@types/d3-scale/-/d3-scale-4.0.9.tgz", + "integrity": "sha512-dLmtwB8zkAeO/juAMfnV+sItKjlsw2lKdZVVy6LRr0cBmegxSABiLEpGVmSJJ8O08i4+sGR6qQtb6WtuwJdvVw==", + "license": "MIT", + "dependencies": { + "@types/d3-time": "*" + } + }, + "node_modules/@types/d3-scale-chromatic": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@types/d3-scale-chromatic/-/d3-scale-chromatic-3.1.0.tgz", + "integrity": "sha512-iWMJgwkK7yTRmWqRB5plb1kadXyQ5Sj8V/zYlFGMUBbIPKQScw+Dku9cAAMgJG+z5GYDoMjWGLVOvjghDEFnKQ==", + "license": "MIT" + }, + "node_modules/@types/d3-selection": { + "version": "3.0.11", + "resolved": "https://registry.npmjs.org/@types/d3-selection/-/d3-selection-3.0.11.tgz", + "integrity": "sha512-bhAXu23DJWsrI45xafYpkQ4NtcKMwWnAC/vKrd2l+nxMFuvOT3XMYTIj2opv8vq8AO5Yh7Qac/nSeP/3zjTK0w==", + "license": "MIT" + }, + "node_modules/@types/d3-shape": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/@types/d3-shape/-/d3-shape-3.1.7.tgz", + "integrity": "sha512-VLvUQ33C+3J+8p+Daf+nYSOsjB4GXp19/S/aGo60m9h1v6XaxjiT82lKVWJCfzhtuZ3yD7i/TPeC/fuKLLOSmg==", + "license": "MIT", + "dependencies": { + "@types/d3-path": "*" + } + }, + "node_modules/@types/d3-time": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@types/d3-time/-/d3-time-3.0.4.tgz", + "integrity": "sha512-yuzZug1nkAAaBlBBikKZTgzCeA+k1uy4ZFwWANOfKw5z5LRhV0gNA7gNkKm7HoK+HRN0wX3EkxGk0fpbWhmB7g==", + "license": "MIT" + }, + "node_modules/@types/d3-time-format": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@types/d3-time-format/-/d3-time-format-4.0.3.tgz", + "integrity": "sha512-5xg9rC+wWL8kdDj153qZcsJ0FWiFt0J5RB6LYUNZjwSnesfblqrI/bJ1wBdJ8OQfncgbJG5+2F+qfqnqyzYxyg==", + "license": "MIT" + }, + "node_modules/@types/d3-timer": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@types/d3-timer/-/d3-timer-3.0.2.tgz", + "integrity": "sha512-Ps3T8E8dZDam6fUyNiMkekK3XUsaUEik+idO9/YjPtfj2qruF8tFBXS7XhtE4iIXBLxhmLjP3SXpLhVf21I9Lw==", + "license": "MIT" + }, + "node_modules/@types/d3-transition": { + "version": "3.0.9", + "resolved": "https://registry.npmjs.org/@types/d3-transition/-/d3-transition-3.0.9.tgz", + "integrity": "sha512-uZS5shfxzO3rGlu0cC3bjmMFKsXv+SmZZcgp0KD22ts4uGXp5EVYGzu/0YdwZeKmddhcAccYtREJKkPfXkZuCg==", + "license": "MIT", + "dependencies": { + "@types/d3-selection": "*" + } + }, + "node_modules/@types/d3-zoom": { + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/@types/d3-zoom/-/d3-zoom-3.0.8.tgz", + "integrity": "sha512-iqMC4/YlFCSlO8+2Ii1GGGliCAY4XdeG748w5vQUbevlbDu0zSjH/+jojorQVBK/se0j6DUFNPBGSqD3YWYnDw==", + "license": "MIT", + "dependencies": { + "@types/d3-interpolate": "*", + "@types/d3-selection": "*" + } + }, + "node_modules/@types/debug": { + "version": "4.1.12", + "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.12.tgz", + "integrity": "sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ==", + "license": "MIT", + "dependencies": { + "@types/ms": "*" + } + }, + "node_modules/@types/deep-eql": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz", + "integrity": "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/doctrine": { + "version": "0.0.9", + "resolved": "https://registry.npmjs.org/@types/doctrine/-/doctrine-0.0.9.tgz", + "integrity": "sha512-eOIHzCUSH7SMfonMG1LsC2f8vxBFtho6NGBznK41R84YzPuvSBzrhEps33IsQiOW9+VL6NQ9DbjQJznk/S4uRA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/estree": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", + "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==", + "license": "MIT" + }, + "node_modules/@types/estree-jsx": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@types/estree-jsx/-/estree-jsx-1.0.5.tgz", + "integrity": "sha512-52CcUVNFyfb1A2ALocQw/Dd1BQFNmSdkuC3BkZ6iqhdMfQz7JWOFRuJFloOzjk+6WijU56m9oKXFAXc7o3Towg==", + "license": "MIT", + "dependencies": { + "@types/estree": "*" + } + }, + "node_modules/@types/geojson": { + "version": "7946.0.16", + "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.16.tgz", + "integrity": "sha512-6C8nqWur3j98U6+lXDfTUWIfgvZU+EumvpHKcYjujKH7woYyLj2sUmff0tRhrqM7BohUw7Pz3ZB1jj2gW9Fvmg==", + "license": "MIT" + }, + "node_modules/@types/hast": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.4.tgz", + "integrity": "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==", + "license": "MIT", + "dependencies": { + "@types/unist": "*" + } + }, + "node_modules/@types/json-schema": { + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/katex": { + "version": "0.16.7", + "resolved": "https://registry.npmjs.org/@types/katex/-/katex-0.16.7.tgz", + "integrity": "sha512-HMwFiRujE5PjrgwHQ25+bsLJgowjGjm5Z8FVSf0N6PwgJrwxH0QxzHYDcKsTfV3wva0vzrpqMTJS2jXPr5BMEQ==", + "license": "MIT" + }, + "node_modules/@types/mdast": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz", + "integrity": "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==", + "license": "MIT", + "dependencies": { + "@types/unist": "*" + } + }, + "node_modules/@types/mdx": { + "version": "2.0.13", + "resolved": "https://registry.npmjs.org/@types/mdx/-/mdx-2.0.13.tgz", + "integrity": "sha512-+OWZQfAYyio6YkJb3HLxDrvnx6SWWDbC0zVPfBRzUk0/nqoDyf6dNxQi3eArPe8rJ473nobTMQ/8Zk+LxJ+Yuw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/ms": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@types/ms/-/ms-2.1.0.tgz", + "integrity": "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==", + "license": "MIT" + }, + "node_modules/@types/node": { + "version": "24.7.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.7.2.tgz", + "integrity": "sha512-/NbVmcGTP+lj5oa4yiYxxeBjRivKQ5Ns1eSZeB99ExsEQ6rX5XYU1Zy/gGxY/ilqtD4Etx9mKyrPxZRetiahhA==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~7.14.0" + } + }, + "node_modules/@types/prismjs": { + "version": "1.26.5", + "resolved": "https://registry.npmjs.org/@types/prismjs/-/prismjs-1.26.5.tgz", + "integrity": "sha512-AUZTa7hQ2KY5L7AmtSiqxlhWxb4ina0yd8hNbl4TWuqnv/pFP0nDMb3YrfSBf4hJVGLh2YEIBfKaBW/9UEl6IQ==", + "license": "MIT" + }, + "node_modules/@types/react": { + "version": "19.1.7", + "resolved": "https://registry.npmjs.org/@types/react/-/react-19.1.7.tgz", + "integrity": "sha512-BnsPLV43ddr05N71gaGzyZ5hzkCmGwhMvYc8zmvI8Ci1bRkkDSzDDVfAXfN2tk748OwI7ediiPX6PfT9p0QGVg==", + "license": "MIT", + "dependencies": { + "csstype": "^3.0.2" + } + }, + "node_modules/@types/react-dom": { + "version": "19.1.6", + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.1.6.tgz", + "integrity": "sha512-4hOiT/dwO8Ko0gV1m/TJZYk3y0KBnY9vzDh7W+DH17b2HFSOGgdj33dhihPeuy3l0q23+4e+hoXHV6hCC4dCXw==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@types/react": "^19.0.0" + } + }, + "node_modules/@types/resolve": { + "version": "1.20.6", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.20.6.tgz", + "integrity": "sha512-A4STmOXPhMUtHH+S6ymgE2GiBSMqf4oTvcQZMcHzokuTLVYzXTB8ttjcgxOVaAp2lGwEdzZ0J+cRbbeevQj1UQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/trusted-types": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz", + "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==", + "license": "MIT", + "optional": true + }, + "node_modules/@types/unist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", + "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", + "license": "MIT" + }, + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "8.34.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.34.0.tgz", + "integrity": "sha512-QXwAlHlbcAwNlEEMKQS2RCgJsgXrTJdjXT08xEgbPFa2yYQgVjBymxP5DrfrE7X7iodSzd9qBUHUycdyVJTW1w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/regexpp": "^4.10.0", + "@typescript-eslint/scope-manager": "8.34.0", + "@typescript-eslint/type-utils": "8.34.0", + "@typescript-eslint/utils": "8.34.0", + "@typescript-eslint/visitor-keys": "8.34.0", + "graphemer": "^1.4.0", + "ignore": "^7.0.0", + "natural-compare": "^1.4.0", + "ts-api-utils": "^2.1.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^8.34.0", + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.9.0" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/ignore": { + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.5.tgz", + "integrity": "sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/@typescript-eslint/parser": { + "version": "8.34.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.34.0.tgz", + "integrity": "sha512-vxXJV1hVFx3IXz/oy2sICsJukaBrtDEQSBiV48/YIV5KWjX1dO+bcIr/kCPrW6weKXvsaGKFNlwH0v2eYdRRbA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/scope-manager": "8.34.0", + "@typescript-eslint/types": "8.34.0", + "@typescript-eslint/typescript-estree": "8.34.0", + "@typescript-eslint/visitor-keys": "8.34.0", + "debug": "^4.3.4" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.9.0" + } + }, + "node_modules/@typescript-eslint/project-service": { + "version": "8.34.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.34.0.tgz", + "integrity": "sha512-iEgDALRf970/B2YExmtPMPF54NenZUf4xpL3wsCRx/lgjz6ul/l13R81ozP/ZNuXfnLCS+oPmG7JIxfdNYKELw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/tsconfig-utils": "^8.34.0", + "@typescript-eslint/types": "^8.34.0", + "debug": "^4.3.4" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <5.9.0" + } + }, + "node_modules/@typescript-eslint/scope-manager": { + "version": "8.34.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.34.0.tgz", + "integrity": "sha512-9Ac0X8WiLykl0aj1oYQNcLZjHgBojT6cW68yAgZ19letYu+Hxd0rE0veI1XznSSst1X5lwnxhPbVdwjDRIomRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.34.0", + "@typescript-eslint/visitor-keys": "8.34.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/tsconfig-utils": { + "version": "8.34.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.34.0.tgz", + "integrity": "sha512-+W9VYHKFIzA5cBeooqQxqNriAP0QeQ7xTiDuIOr71hzgffm3EL2hxwWBIIj4GuofIbKxGNarpKqIq6Q6YrShOA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <5.9.0" + } + }, + "node_modules/@typescript-eslint/type-utils": { + "version": "8.34.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.34.0.tgz", + "integrity": "sha512-n7zSmOcUVhcRYC75W2pnPpbO1iwhJY3NLoHEtbJwJSNlVAZuwqu05zY3f3s2SDWWDSo9FdN5szqc73DCtDObAg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/typescript-estree": "8.34.0", + "@typescript-eslint/utils": "8.34.0", + "debug": "^4.3.4", + "ts-api-utils": "^2.1.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.9.0" + } + }, + "node_modules/@typescript-eslint/types": { + "version": "8.34.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.34.0.tgz", + "integrity": "sha512-9V24k/paICYPniajHfJ4cuAWETnt7Ssy+R0Rbcqo5sSFr3QEZ/8TSoUi9XeXVBGXCaLtwTOKSLGcInCAvyZeMA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/typescript-estree": { + "version": "8.34.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.34.0.tgz", + "integrity": "sha512-rOi4KZxI7E0+BMqG7emPSK1bB4RICCpF7QD3KCLXn9ZvWoESsOMlHyZPAHyG04ujVplPaHbmEvs34m+wjgtVtg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/project-service": "8.34.0", + "@typescript-eslint/tsconfig-utils": "8.34.0", + "@typescript-eslint/types": "8.34.0", + "@typescript-eslint/visitor-keys": "8.34.0", + "debug": "^4.3.4", + "fast-glob": "^3.3.2", + "is-glob": "^4.0.3", + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^2.1.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <5.9.0" + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", + "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/semver": { + "version": "7.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz", + "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@typescript-eslint/utils": { + "version": "8.34.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.34.0.tgz", + "integrity": "sha512-8L4tWatGchV9A1cKbjaavS6mwYwp39jql8xUmIIKJdm+qiaeHy5KMKlBrf30akXAWBzn2SqKsNOtSENWUwg7XQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.7.0", + "@typescript-eslint/scope-manager": "8.34.0", + "@typescript-eslint/types": "8.34.0", + "@typescript-eslint/typescript-estree": "8.34.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.9.0" + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "8.34.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.34.0.tgz", + "integrity": "sha512-qHV7pW7E85A0x6qyrFn+O+q1k1p3tQCsqIZ1KZ5ESLXY57aTvUd3/a4rdPTeXisvhXn2VQG0VSKUqs8KHF2zcA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.34.0", + "eslint-visitor-keys": "^4.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@ungap/structured-clone": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.3.0.tgz", + "integrity": "sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g==", + "license": "ISC" + }, + "node_modules/@vitejs/plugin-react": { + "version": "4.5.1", + "resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-4.5.1.tgz", + "integrity": "sha512-uPZBqSI0YD4lpkIru6M35sIfylLGTyhGHvDZbNLuMA73lMlwJKz5xweH7FajfcCAc2HnINciejA9qTz0dr0M7A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/core": "^7.26.10", + "@babel/plugin-transform-react-jsx-self": "^7.25.9", + "@babel/plugin-transform-react-jsx-source": "^7.25.9", + "@rolldown/pluginutils": "1.0.0-beta.9", + "@types/babel__core": "^7.20.5", + "react-refresh": "^0.17.0" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "peerDependencies": { + "vite": "^4.2.0 || ^5.0.0 || ^6.0.0" + } + }, + "node_modules/@vitest/browser": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@vitest/browser/-/browser-3.2.4.tgz", + "integrity": "sha512-tJxiPrWmzH8a+w9nLKlQMzAKX/7VjFs50MWgcAj7p9XQ7AQ9/35fByFYptgPELyLw+0aixTnC4pUWV+APcZ/kw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@testing-library/dom": "^10.4.0", + "@testing-library/user-event": "^14.6.1", + "@vitest/mocker": "3.2.4", + "@vitest/utils": "3.2.4", + "magic-string": "^0.30.17", + "sirv": "^3.0.1", + "tinyrainbow": "^2.0.0", + "ws": "^8.18.2" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "playwright": "*", + "vitest": "3.2.4", + "webdriverio": "^7.0.0 || ^8.0.0 || ^9.0.0" + }, + "peerDependenciesMeta": { + "playwright": { + "optional": true + }, + "safaridriver": { + "optional": true + }, + "webdriverio": { + "optional": true + } + } + }, + "node_modules/@vitest/coverage-v8": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-3.2.4.tgz", + "integrity": "sha512-EyF9SXU6kS5Ku/U82E259WSnvg6c8KTjppUncuNdm5QHpe17mwREHnjDzozC8x9MZ0xfBUFSaLkRv4TMA75ALQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@ampproject/remapping": "^2.3.0", + "@bcoe/v8-coverage": "^1.0.2", + "ast-v8-to-istanbul": "^0.3.3", + "debug": "^4.4.1", + "istanbul-lib-coverage": "^3.2.2", + "istanbul-lib-report": "^3.0.1", + "istanbul-lib-source-maps": "^5.0.6", + "istanbul-reports": "^3.1.7", + "magic-string": "^0.30.17", + "magicast": "^0.3.5", + "std-env": "^3.9.0", + "test-exclude": "^7.0.1", + "tinyrainbow": "^2.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@vitest/browser": "3.2.4", + "vitest": "3.2.4" + }, + "peerDependenciesMeta": { + "@vitest/browser": { + "optional": true + } + } + }, + "node_modules/@vitest/expect": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-3.2.4.tgz", + "integrity": "sha512-Io0yyORnB6sikFlt8QW5K7slY4OjqNX9jmJQ02QDda8lyM6B5oNgVWoSoKPac8/kgnCUzuHQKrSLtu/uOqqrig==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/chai": "^5.2.2", + "@vitest/spy": "3.2.4", + "@vitest/utils": "3.2.4", + "chai": "^5.2.0", + "tinyrainbow": "^2.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/mocker": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-3.2.4.tgz", + "integrity": "sha512-46ryTE9RZO/rfDd7pEqFl7etuyzekzEhUbTW3BvmeO/BcCMEgq59BKhek3dXDWgAj4oMK6OZi+vRr1wPW6qjEQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/spy": "3.2.4", + "estree-walker": "^3.0.3", + "magic-string": "^0.30.17" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "msw": "^2.4.9", + "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0" + }, + "peerDependenciesMeta": { + "msw": { + "optional": true + }, + "vite": { + "optional": true + } + } + }, + "node_modules/@vitest/mocker/node_modules/estree-walker": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", + "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0" + } + }, + "node_modules/@vitest/pretty-format": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-3.2.4.tgz", + "integrity": "sha512-IVNZik8IVRJRTr9fxlitMKeJeXFFFN0JaB9PHPGQ8NKQbGpfjlTx9zO4RefN8gp7eqjNy8nyK3NZmBzOPeIxtA==", + "dev": true, + "license": "MIT", + "dependencies": { + "tinyrainbow": "^2.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/runner": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-3.2.4.tgz", + "integrity": "sha512-oukfKT9Mk41LreEW09vt45f8wx7DordoWUZMYdY/cyAk7w5TWkTRCNZYF7sX7n2wB7jyGAl74OxgwhPgKaqDMQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/utils": "3.2.4", + "pathe": "^2.0.3", + "strip-literal": "^3.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/snapshot": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-3.2.4.tgz", + "integrity": "sha512-dEYtS7qQP2CjU27QBC5oUOxLE/v5eLkGqPE0ZKEIDGMs4vKWe7IjgLOeauHsR0D5YuuycGRO5oSRXnwnmA78fQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "3.2.4", + "magic-string": "^0.30.17", + "pathe": "^2.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/spy": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-3.2.4.tgz", + "integrity": "sha512-vAfasCOe6AIK70iP5UD11Ac4siNUNJ9i/9PZ3NKx07sG6sUxeag1LWdNrMWeKKYBLlzuK+Gn65Yd5nyL6ds+nw==", + "dev": true, + "license": "MIT", + "dependencies": { + "tinyspy": "^4.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/ui": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@vitest/ui/-/ui-3.2.4.tgz", + "integrity": "sha512-hGISOaP18plkzbWEcP/QvtRW1xDXF2+96HbEX6byqQhAUbiS5oH6/9JwW+QsQCIYON2bI6QZBF+2PvOmrRZ9wA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/utils": "3.2.4", + "fflate": "^0.8.2", + "flatted": "^3.3.3", + "pathe": "^2.0.3", + "sirv": "^3.0.1", + "tinyglobby": "^0.2.14", + "tinyrainbow": "^2.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "vitest": "3.2.4" + } + }, + "node_modules/@vitest/utils": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-3.2.4.tgz", + "integrity": "sha512-fB2V0JFrQSMsCo9HiSq3Ezpdv4iYaXRG1Sx8edX3MwxfyNn83mKiGzOcH+Fkxt4MHxr3y42fQi1oeAInqgX2QA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "3.2.4", + "loupe": "^3.1.4", + "tinyrainbow": "^2.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/acorn": { + "version": "8.15.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz", + "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", + "license": "MIT", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/ansis": { + "version": "3.17.0", + "resolved": "https://registry.npmjs.org/ansis/-/ansis-3.17.0.tgz", + "integrity": "sha512-0qWUglt9JEqLFr3w1I1pbrChn1grhaiAR2ocX1PP/flRmxgtwTzPFFFnfIlD6aMOLQZgSuCRlidD70lvx8yhzg==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=14" + } + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "license": "ISC", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true, + "license": "Python-2.0" + }, + "node_modules/aria-query": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz", + "integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "dequal": "^2.0.3" + } + }, + "node_modules/assertion-error": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", + "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + } + }, + "node_modules/ast-types": { + "version": "0.16.1", + "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.16.1.tgz", + "integrity": "sha512-6t10qk83GOG8p0vKmaCr8eiilZwO171AvbROMtvvNiwrTly62t+7XkA8RdIIVbpMhCASAsxgAzdRSwh6nw/5Dg==", + "dev": true, + "license": "MIT", + "dependencies": { + "tslib": "^2.0.1" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/ast-v8-to-istanbul": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/ast-v8-to-istanbul/-/ast-v8-to-istanbul-0.3.3.tgz", + "integrity": "sha512-MuXMrSLVVoA6sYN/6Hke18vMzrT4TZNbZIj/hvh0fnYFpO+/kFXcLIaiPwXXWaQUPg4yJD8fj+lfJ7/1EBconw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.25", + "estree-walker": "^3.0.3", + "js-tokens": "^9.0.1" + } + }, + "node_modules/ast-v8-to-istanbul/node_modules/estree-walker": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", + "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0" + } + }, + "node_modules/ast-v8-to-istanbul/node_modules/js-tokens": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-9.0.1.tgz", + "integrity": "sha512-mxa9E9ITFOt0ban3j6L5MpjwegGz6lBQmM1IJkWeBZGcMxto50+eWdjC/52xDbS2vy0k7vIMK0Fe2wfL9OQSpQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/autoprefixer": { + "version": "10.4.21", + "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.21.tgz", + "integrity": "sha512-O+A6LWV5LDHSJD3LjHYoNi4VLsj/Whi7k6zG12xTYaU4cQ8oxQGckXNX8cRHK5yOZ/ppVHe0ZBXGzSV9jXdVbQ==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/autoprefixer" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "browserslist": "^4.24.4", + "caniuse-lite": "^1.0.30001702", + "fraction.js": "^4.3.7", + "normalize-range": "^0.1.2", + "picocolors": "^1.1.1", + "postcss-value-parser": "^4.2.0" + }, + "bin": { + "autoprefixer": "bin/autoprefixer" + }, + "engines": { + "node": "^10 || ^12 || >=14" + }, + "peerDependencies": { + "postcss": "^8.1.0" + } + }, + "node_modules/axe-core": { + "version": "4.10.3", + "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.10.3.tgz", + "integrity": "sha512-Xm7bpRXnDSX2YE2YFfBk2FnF0ep6tmG7xPh8iHee8MIcrgq762Nkce856dYtJYLkuIoYZvGfTs/PbZhideTcEg==", + "dev": true, + "license": "MPL-2.0", + "engines": { + "node": ">=4" + } + }, + "node_modules/babel-dead-code-elimination": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/babel-dead-code-elimination/-/babel-dead-code-elimination-1.0.10.tgz", + "integrity": "sha512-DV5bdJZTzZ0zn0DC24v3jD7Mnidh6xhKa4GfKCbq3sfW8kaWhDdZjP3i81geA8T33tdYqWKw4D3fVv0CwEgKVA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/core": "^7.23.7", + "@babel/parser": "^7.23.6", + "@babel/traverse": "^7.23.7", + "@babel/types": "^7.23.6" + } + }, + "node_modules/bail": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/bail/-/bail-2.0.2.tgz", + "integrity": "sha512-0xO6mYd7JB2YesxDKplafRpsiOzPt9V02ddPCLbY1xYGPOX24NTyN50qnUxgCPcSoYMhKpAuBTjQoRZCAkUDRw==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/better-opn": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/better-opn/-/better-opn-3.0.2.tgz", + "integrity": "sha512-aVNobHnJqLiUelTaHat9DZ1qM2w0C0Eym4LPI/3JxOnSokGVdsl1T1kN7TFvsEAD8G47A6VKQ0TVHqbBnYMJlQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "open": "^8.0.4" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/brace-expansion": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", + "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/browserslist": { + "version": "4.25.0", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.25.0.tgz", + "integrity": "sha512-PJ8gYKeS5e/whHBh8xrwYK+dAvEj7JXtz6uTucnMRB8OiGTsKccFekoRrjajPBHV8oOY+2tI4uxeceSimKwMFA==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "caniuse-lite": "^1.0.30001718", + "electron-to-chromium": "^1.5.160", + "node-releases": "^2.0.19", + "update-browserslist-db": "^1.1.3" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/cac": { + "version": "6.7.14", + "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", + "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001721", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001721.tgz", + "integrity": "sha512-cOuvmUVtKrtEaoKiO0rSc29jcjwMwX5tOHDy4MgVFEWiUXj4uBMJkwI8MDySkgXidpMiHUcviogAvFi4pA2hDQ==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "CC-BY-4.0" + }, + "node_modules/ccount": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/ccount/-/ccount-2.0.1.tgz", + "integrity": "sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/chai": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-5.2.0.tgz", + "integrity": "sha512-mCuXncKXk5iCLhfhwTc0izo0gtEmpz5CtG2y8GiOINBlMVS6v8TMRc5TaLWKS6692m9+dVVfzgeVxR5UxWHTYw==", + "dev": true, + "license": "MIT", + "dependencies": { + "assertion-error": "^2.0.1", + "check-error": "^2.1.1", + "deep-eql": "^5.0.1", + "loupe": "^3.1.0", + "pathval": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/character-entities": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/character-entities/-/character-entities-2.0.2.tgz", + "integrity": "sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/character-entities-html4": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/character-entities-html4/-/character-entities-html4-2.1.0.tgz", + "integrity": "sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/character-entities-legacy": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-3.0.0.tgz", + "integrity": "sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/character-reference-invalid": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/character-reference-invalid/-/character-reference-invalid-2.0.1.tgz", + "integrity": "sha512-iBZ4F4wRbyORVsu0jPV7gXkOsGYjGHPmAyv+HiHG8gi5PtC9KI2j1+v8/tlibRvjoWX027ypmG/n0HtO5t7unw==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/check-error": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-2.1.1.tgz", + "integrity": "sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 16" + } + }, + "node_modules/chevrotain": { + "version": "11.0.3", + "resolved": "https://registry.npmjs.org/chevrotain/-/chevrotain-11.0.3.tgz", + "integrity": "sha512-ci2iJH6LeIkvP9eJW6gpueU8cnZhv85ELY8w8WiFtNjMHA5ad6pQLaJo9mEly/9qUyCpvqX8/POVUTf18/HFdw==", + "license": "Apache-2.0", + "dependencies": { + "@chevrotain/cst-dts-gen": "11.0.3", + "@chevrotain/gast": "11.0.3", + "@chevrotain/regexp-to-ast": "11.0.3", + "@chevrotain/types": "11.0.3", + "@chevrotain/utils": "11.0.3", + "lodash-es": "4.17.21" + } + }, + "node_modules/chevrotain-allstar": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/chevrotain-allstar/-/chevrotain-allstar-0.3.1.tgz", + "integrity": "sha512-b7g+y9A0v4mxCW1qUhf3BSVPg+/NvGErk/dOkrDaHA0nQIQGAtrOjlX//9OQtRlSCy+x9rfB5N8yC71lH1nvMw==", + "license": "MIT", + "dependencies": { + "lodash-es": "^4.17.21" + }, + "peerDependencies": { + "chevrotain": "^11.0.0" + } + }, + "node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/chokidar/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/chownr": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-3.0.0.tgz", + "integrity": "sha512-+IxzY9BZOQd/XuYPRmrvEVjF/nqj5kgT4kEq7VofrDoM1MxoRjEWkrCC3EtLi59TVawxTAn+orJwFQcrqEN1+g==", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": ">=18" + } + }, + "node_modules/chromatic": { + "version": "12.2.0", + "resolved": "https://registry.npmjs.org/chromatic/-/chromatic-12.2.0.tgz", + "integrity": "sha512-GswmBW9ZptAoTns1BMyjbm55Z7EsIJnUvYKdQqXIBZIKbGErmpA+p4c0BYA+nzw5B0M+rb3Iqp1IaH8TFwIQew==", + "dev": true, + "license": "MIT", + "bin": { + "chroma": "dist/bin.js", + "chromatic": "dist/bin.js", + "chromatic-cli": "dist/bin.js" + }, + "peerDependencies": { + "@chromatic-com/cypress": "^0.*.* || ^1.0.0", + "@chromatic-com/playwright": "^0.*.* || ^1.0.0" + }, + "peerDependenciesMeta": { + "@chromatic-com/cypress": { + "optional": true + }, + "@chromatic-com/playwright": { + "optional": true + } + } + }, + "node_modules/clsx": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", + "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==", + "engines": { + "node": ">=6" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" + }, + "node_modules/comma-separated-tokens": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-2.0.3.tgz", + "integrity": "sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/commander": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz", + "integrity": "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==", + "license": "MIT", + "engines": { + "node": ">= 12" + } + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true, + "license": "MIT" + }, + "node_modules/confbox": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/confbox/-/confbox-0.2.2.tgz", + "integrity": "sha512-1NB+BKqhtNipMsov4xI/NnhCKp9XG9NamYp5PVm9klAT0fsrNPjaFICsCFhNhwZJKNh7zB/3q8qXz0E9oaMNtQ==", + "license": "MIT" + }, + "node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true, + "license": "MIT" + }, + "node_modules/cose-base": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/cose-base/-/cose-base-1.0.3.tgz", + "integrity": "sha512-s9whTXInMSgAp/NVXVNuVxVKzGH2qck3aQlVHxDCdAEPgtMKwc4Wq6/QKhgdEdgbLSi9rBTAcPoRa6JpiG4ksg==", + "license": "MIT", + "dependencies": { + "layout-base": "^1.0.0" + } + }, + "node_modules/cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/css-blank-pseudo": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/css-blank-pseudo/-/css-blank-pseudo-7.0.1.tgz", + "integrity": "sha512-jf+twWGDf6LDoXDUode+nc7ZlrqfaNphrBIBrcmeP3D8yw1uPaix1gCC8LUQUGQ6CycuK2opkbFFWFuq/a94ag==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "postcss-selector-parser": "^7.0.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/css-blank-pseudo/node_modules/postcss-selector-parser": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.0.tgz", + "integrity": "sha512-8sLjZwK0R+JlxlYcTuVnyT2v+htpdrjDOKuMcOVdYjt52Lh8hWRYpxBPoKx/Zg+bcjc3wx6fmQevMmUztS/ccA==", + "dev": true, + "license": "MIT", + "dependencies": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/css-has-pseudo": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/css-has-pseudo/-/css-has-pseudo-7.0.2.tgz", + "integrity": "sha512-nzol/h+E0bId46Kn2dQH5VElaknX2Sr0hFuB/1EomdC7j+OISt2ZzK7EHX9DZDY53WbIVAR7FYKSO2XnSf07MQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "@csstools/selector-specificity": "^5.0.0", + "postcss-selector-parser": "^7.0.0", + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/css-has-pseudo/node_modules/@csstools/selector-specificity": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@csstools/selector-specificity/-/selector-specificity-5.0.0.tgz", + "integrity": "sha512-PCqQV3c4CoVm3kdPhyeZ07VmBRdH2EpMFA/pd9OASpOEC3aXNGoqPDAZ80D0cLpMBxnmk0+yNhGsEx31hq7Gtw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss-selector-parser": "^7.0.0" + } + }, + "node_modules/css-has-pseudo/node_modules/postcss-selector-parser": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.0.tgz", + "integrity": "sha512-8sLjZwK0R+JlxlYcTuVnyT2v+htpdrjDOKuMcOVdYjt52Lh8hWRYpxBPoKx/Zg+bcjc3wx6fmQevMmUztS/ccA==", + "dev": true, + "license": "MIT", + "dependencies": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/css-prefers-color-scheme": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/css-prefers-color-scheme/-/css-prefers-color-scheme-10.0.0.tgz", + "integrity": "sha512-VCtXZAWivRglTZditUfB4StnsWr6YVZ2PRtuxQLKTNRdtAf8tpzaVPE9zXIF3VaSc7O70iK/j1+NXxyQCqdPjQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/css.escape": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/css.escape/-/css.escape-1.5.1.tgz", + "integrity": "sha512-YUifsXXuknHlUsmlgyY0PKzgPOr7/FjCePfHNt0jxm83wHZi44VDMQ7/fGNkjY3/jV1MC+1CmZbaHzugyeRtpg==", + "dev": true, + "license": "MIT" + }, + "node_modules/cssdb": { + "version": "8.3.1", + "resolved": "https://registry.npmjs.org/cssdb/-/cssdb-8.3.1.tgz", + "integrity": "sha512-XnDRQMXucLueX92yDe0LPKupXetWoFOgawr4O4X41l5TltgK2NVbJJVDnnOywDYfW1sTJ28AcXGKOqdRKwCcmQ==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + }, + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + } + ], + "license": "MIT-0" + }, + "node_modules/cssesc": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz", + "integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==", + "dev": true, + "license": "MIT", + "bin": { + "cssesc": "bin/cssesc" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/csstype": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", + "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==", + "license": "MIT" + }, + "node_modules/cytoscape": { + "version": "3.33.1", + "resolved": "https://registry.npmjs.org/cytoscape/-/cytoscape-3.33.1.tgz", + "integrity": "sha512-iJc4TwyANnOGR1OmWhsS9ayRS3s+XQ185FmuHObThD+5AeJCakAAbWv8KimMTt08xCCLNgneQwFp+JRJOr9qGQ==", + "license": "MIT", + "engines": { + "node": ">=0.10" + } + }, + "node_modules/cytoscape-cose-bilkent": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/cytoscape-cose-bilkent/-/cytoscape-cose-bilkent-4.1.0.tgz", + "integrity": "sha512-wgQlVIUJF13Quxiv5e1gstZ08rnZj2XaLHGoFMYXz7SkNfCDOOteKBE6SYRfA9WxxI/iBc3ajfDoc6hb/MRAHQ==", + "license": "MIT", + "dependencies": { + "cose-base": "^1.0.0" + }, + "peerDependencies": { + "cytoscape": "^3.2.0" + } + }, + "node_modules/cytoscape-fcose": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/cytoscape-fcose/-/cytoscape-fcose-2.2.0.tgz", + "integrity": "sha512-ki1/VuRIHFCzxWNrsshHYPs6L7TvLu3DL+TyIGEsRcvVERmxokbf5Gdk7mFxZnTdiGtnA4cfSmjZJMviqSuZrQ==", + "license": "MIT", + "dependencies": { + "cose-base": "^2.2.0" + }, + "peerDependencies": { + "cytoscape": "^3.2.0" + } + }, + "node_modules/cytoscape-fcose/node_modules/cose-base": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/cose-base/-/cose-base-2.2.0.tgz", + "integrity": "sha512-AzlgcsCbUMymkADOJtQm3wO9S3ltPfYOFD5033keQn9NJzIbtnZj+UdBJe7DYml/8TdbtHJW3j58SOnKhWY/5g==", + "license": "MIT", + "dependencies": { + "layout-base": "^2.0.0" + } + }, + "node_modules/cytoscape-fcose/node_modules/layout-base": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/layout-base/-/layout-base-2.0.1.tgz", + "integrity": "sha512-dp3s92+uNI1hWIpPGH3jK2kxE2lMjdXdr+DH8ynZHpd6PUlH6x6cbuXnoMmiNumznqaNO31xu9e79F0uuZ0JFg==", + "license": "MIT" + }, + "node_modules/d3": { + "version": "7.9.0", + "resolved": "https://registry.npmjs.org/d3/-/d3-7.9.0.tgz", + "integrity": "sha512-e1U46jVP+w7Iut8Jt8ri1YsPOvFpg46k+K8TpCb0P+zjCkjkPnV7WzfDJzMHy1LnA+wj5pLT1wjO901gLXeEhA==", + "license": "ISC", + "dependencies": { + "d3-array": "3", + "d3-axis": "3", + "d3-brush": "3", + "d3-chord": "3", + "d3-color": "3", + "d3-contour": "4", + "d3-delaunay": "6", + "d3-dispatch": "3", + "d3-drag": "3", + "d3-dsv": "3", + "d3-ease": "3", + "d3-fetch": "3", + "d3-force": "3", + "d3-format": "3", + "d3-geo": "3", + "d3-hierarchy": "3", + "d3-interpolate": "3", + "d3-path": "3", + "d3-polygon": "3", + "d3-quadtree": "3", + "d3-random": "3", + "d3-scale": "4", + "d3-scale-chromatic": "3", + "d3-selection": "3", + "d3-shape": "3", + "d3-time": "3", + "d3-time-format": "4", + "d3-timer": "3", + "d3-transition": "3", + "d3-zoom": "3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-array": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/d3-array/-/d3-array-3.2.4.tgz", + "integrity": "sha512-tdQAmyA18i4J7wprpYq8ClcxZy3SC31QMeByyCFyRt7BVHdREQZ5lpzoe5mFEYZUWe+oq8HBvk9JjpibyEV4Jg==", + "license": "ISC", + "dependencies": { + "internmap": "1 - 2" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-axis": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-axis/-/d3-axis-3.0.0.tgz", + "integrity": "sha512-IH5tgjV4jE/GhHkRV0HiVYPDtvfjHQlQfJHs0usq7M30XcSBvOotpmH1IgkcXsO/5gEQZD43B//fc7SRT5S+xw==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-brush": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-brush/-/d3-brush-3.0.0.tgz", + "integrity": "sha512-ALnjWlVYkXsVIGlOsuWH1+3udkYFI48Ljihfnh8FZPF2QS9o+PzGLBslO0PjzVoHLZ2KCVgAM8NVkXPJB2aNnQ==", + "license": "ISC", + "dependencies": { + "d3-dispatch": "1 - 3", + "d3-drag": "2 - 3", + "d3-interpolate": "1 - 3", + "d3-selection": "3", + "d3-transition": "3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-chord": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-chord/-/d3-chord-3.0.1.tgz", + "integrity": "sha512-VE5S6TNa+j8msksl7HwjxMHDM2yNK3XCkusIlpX5kwauBfXuyLAtNg9jCp/iHH61tgI4sb6R/EIMWCqEIdjT/g==", + "license": "ISC", + "dependencies": { + "d3-path": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-color": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/d3-color/-/d3-color-3.1.0.tgz", + "integrity": "sha512-zg/chbXyeBtMQ1LbD/WSoW2DpC3I0mpmPdW+ynRTj/x2DAWYrIY7qeZIHidozwV24m4iavr15lNwIwLxRmOxhA==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-contour": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/d3-contour/-/d3-contour-4.0.2.tgz", + "integrity": "sha512-4EzFTRIikzs47RGmdxbeUvLWtGedDUNkTcmzoeyg4sP/dvCexO47AaQL7VKy/gul85TOxw+IBgA8US2xwbToNA==", + "license": "ISC", + "dependencies": { + "d3-array": "^3.2.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-delaunay": { + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/d3-delaunay/-/d3-delaunay-6.0.4.tgz", + "integrity": "sha512-mdjtIZ1XLAM8bm/hx3WwjfHt6Sggek7qH043O8KEjDXN40xi3vx/6pYSVTwLjEgiXQTbvaouWKynLBiUZ6SK6A==", + "license": "ISC", + "dependencies": { + "delaunator": "5" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-dispatch": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-dispatch/-/d3-dispatch-3.0.1.tgz", + "integrity": "sha512-rzUyPU/S7rwUflMyLc1ETDeBj0NRuHKKAcvukozwhshr6g6c5d8zh4c2gQjY2bZ0dXeGLWc1PF174P2tVvKhfg==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-drag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-drag/-/d3-drag-3.0.0.tgz", + "integrity": "sha512-pWbUJLdETVA8lQNJecMxoXfH6x+mO2UQo8rSmZ+QqxcbyA3hfeprFgIT//HW2nlHChWeIIMwS2Fq+gEARkhTkg==", + "license": "ISC", + "dependencies": { + "d3-dispatch": "1 - 3", + "d3-selection": "3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-dsv": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-dsv/-/d3-dsv-3.0.1.tgz", + "integrity": "sha512-UG6OvdI5afDIFP9w4G0mNq50dSOsXHJaRE8arAS5o9ApWnIElp8GZw1Dun8vP8OyHOZ/QJUKUJwxiiCCnUwm+Q==", + "license": "ISC", + "dependencies": { + "commander": "7", + "iconv-lite": "0.6", + "rw": "1" + }, + "bin": { + "csv2json": "bin/dsv2json.js", + "csv2tsv": "bin/dsv2dsv.js", + "dsv2dsv": "bin/dsv2dsv.js", + "dsv2json": "bin/dsv2json.js", + "json2csv": "bin/json2dsv.js", + "json2dsv": "bin/json2dsv.js", + "json2tsv": "bin/json2dsv.js", + "tsv2csv": "bin/dsv2dsv.js", + "tsv2json": "bin/dsv2json.js" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-dsv/node_modules/commander": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz", + "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==", + "license": "MIT", + "engines": { + "node": ">= 10" + } + }, + "node_modules/d3-ease": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-ease/-/d3-ease-3.0.1.tgz", + "integrity": "sha512-wR/XK3D3XcLIZwpbvQwQ5fK+8Ykds1ip7A2Txe0yxncXSdq1L9skcG7blcedkOX+ZcgxGAmLX1FrRGbADwzi0w==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-fetch": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-fetch/-/d3-fetch-3.0.1.tgz", + "integrity": "sha512-kpkQIM20n3oLVBKGg6oHrUchHM3xODkTzjMoj7aWQFq5QEM+R6E4WkzT5+tojDY7yjez8KgCBRoj4aEr99Fdqw==", + "license": "ISC", + "dependencies": { + "d3-dsv": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-force": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-force/-/d3-force-3.0.0.tgz", + "integrity": "sha512-zxV/SsA+U4yte8051P4ECydjD/S+qeYtnaIyAs9tgHCqfguma/aAQDjo85A9Z6EKhBirHRJHXIgJUlffT4wdLg==", + "license": "ISC", + "dependencies": { + "d3-dispatch": "1 - 3", + "d3-quadtree": "1 - 3", + "d3-timer": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-format": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/d3-format/-/d3-format-3.1.0.tgz", + "integrity": "sha512-YyUI6AEuY/Wpt8KWLgZHsIU86atmikuoOmCfommt0LYHiQSPjvX2AcFc38PX0CBpr2RCyZhjex+NS/LPOv6YqA==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-geo": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/d3-geo/-/d3-geo-3.1.1.tgz", + "integrity": "sha512-637ln3gXKXOwhalDzinUgY83KzNWZRKbYubaG+fGVuc/dxO64RRljtCTnf5ecMyE1RIdtqpkVcq0IbtU2S8j2Q==", + "license": "ISC", + "dependencies": { + "d3-array": "2.5.0 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-hierarchy": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/d3-hierarchy/-/d3-hierarchy-3.1.2.tgz", + "integrity": "sha512-FX/9frcub54beBdugHjDCdikxThEqjnR93Qt7PvQTOHxyiNCAlvMrHhclk3cD5VeAaq9fxmfRp+CnWw9rEMBuA==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-interpolate": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-interpolate/-/d3-interpolate-3.0.1.tgz", + "integrity": "sha512-3bYs1rOD33uo8aqJfKP3JWPAibgw8Zm2+L9vBKEHJ2Rg+viTR7o5Mmv5mZcieN+FRYaAOWX5SJATX6k1PWz72g==", + "license": "ISC", + "dependencies": { + "d3-color": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-path": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/d3-path/-/d3-path-3.1.0.tgz", + "integrity": "sha512-p3KP5HCf/bvjBSSKuXid6Zqijx7wIfNW+J/maPs+iwR35at5JCbLUT0LzF1cnjbCHWhqzQTIN2Jpe8pRebIEFQ==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-polygon": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-polygon/-/d3-polygon-3.0.1.tgz", + "integrity": "sha512-3vbA7vXYwfe1SYhED++fPUQlWSYTTGmFmQiany/gdbiWgU/iEyQzyymwL9SkJjFFuCS4902BSzewVGsHHmHtXg==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-quadtree": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-quadtree/-/d3-quadtree-3.0.1.tgz", + "integrity": "sha512-04xDrxQTDTCFwP5H6hRhsRcb9xxv2RzkcsygFzmkSIOJy3PeRJP7sNk3VRIbKXcog561P9oU0/rVH6vDROAgUw==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-random": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-random/-/d3-random-3.0.1.tgz", + "integrity": "sha512-FXMe9GfxTxqd5D6jFsQ+DJ8BJS4E/fT5mqqdjovykEB2oFbTMDVdg1MGFxfQW+FBOGoB++k8swBrgwSHT1cUXQ==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-sankey": { + "version": "0.12.3", + "resolved": "https://registry.npmjs.org/d3-sankey/-/d3-sankey-0.12.3.tgz", + "integrity": "sha512-nQhsBRmM19Ax5xEIPLMY9ZmJ/cDvd1BG3UVvt5h3WRxKg5zGRbvnteTyWAbzeSvlh3tW7ZEmq4VwR5mB3tutmQ==", + "license": "BSD-3-Clause", + "dependencies": { + "d3-array": "1 - 2", + "d3-shape": "^1.2.0" + } + }, + "node_modules/d3-sankey/node_modules/d3-array": { + "version": "2.12.1", + "resolved": "https://registry.npmjs.org/d3-array/-/d3-array-2.12.1.tgz", + "integrity": "sha512-B0ErZK/66mHtEsR1TkPEEkwdy+WDesimkM5gpZr5Dsg54BiTA5RXtYW5qTLIAcekaS9xfZrzBLF/OAkB3Qn1YQ==", + "license": "BSD-3-Clause", + "dependencies": { + "internmap": "^1.0.0" + } + }, + "node_modules/d3-sankey/node_modules/d3-path": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/d3-path/-/d3-path-1.0.9.tgz", + "integrity": "sha512-VLaYcn81dtHVTjEHd8B+pbe9yHWpXKZUC87PzoFmsFrJqgFwDe/qxfp5MlfsfM1V5E/iVt0MmEbWQ7FVIXh/bg==", + "license": "BSD-3-Clause" + }, + "node_modules/d3-sankey/node_modules/d3-shape": { + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/d3-shape/-/d3-shape-1.3.7.tgz", + "integrity": "sha512-EUkvKjqPFUAZyOlhY5gzCxCeI0Aep04LwIRpsZ/mLFelJiUfnK56jo5JMDSE7yyP2kLSb6LtF+S5chMk7uqPqw==", + "license": "BSD-3-Clause", + "dependencies": { + "d3-path": "1" + } + }, + "node_modules/d3-sankey/node_modules/internmap": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/internmap/-/internmap-1.0.1.tgz", + "integrity": "sha512-lDB5YccMydFBtasVtxnZ3MRBHuaoE8GKsppq+EchKL2U4nK/DmEpPHNH8MZe5HkMtpSiTSOZwfN0tzYjO/lJEw==", + "license": "ISC" + }, + "node_modules/d3-scale": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/d3-scale/-/d3-scale-4.0.2.tgz", + "integrity": "sha512-GZW464g1SH7ag3Y7hXjf8RoUuAFIqklOAq3MRl4OaWabTFJY9PN/E1YklhXLh+OQ3fM9yS2nOkCoS+WLZ6kvxQ==", + "license": "ISC", + "dependencies": { + "d3-array": "2.10.0 - 3", + "d3-format": "1 - 3", + "d3-interpolate": "1.2.0 - 3", + "d3-time": "2.1.1 - 3", + "d3-time-format": "2 - 4" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-scale-chromatic": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/d3-scale-chromatic/-/d3-scale-chromatic-3.1.0.tgz", + "integrity": "sha512-A3s5PWiZ9YCXFye1o246KoscMWqf8BsD9eRiJ3He7C9OBaxKhAd5TFCdEx/7VbKtxxTsu//1mMJFrEt572cEyQ==", + "license": "ISC", + "dependencies": { + "d3-color": "1 - 3", + "d3-interpolate": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-selection": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-selection/-/d3-selection-3.0.0.tgz", + "integrity": "sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-shape": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/d3-shape/-/d3-shape-3.2.0.tgz", + "integrity": "sha512-SaLBuwGm3MOViRq2ABk3eLoxwZELpH6zhl3FbAoJ7Vm1gofKx6El1Ib5z23NUEhF9AsGl7y+dzLe5Cw2AArGTA==", + "license": "ISC", + "dependencies": { + "d3-path": "^3.1.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-time": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/d3-time/-/d3-time-3.1.0.tgz", + "integrity": "sha512-VqKjzBLejbSMT4IgbmVgDjpkYrNWUYJnbCGo874u7MMKIWsILRX+OpX/gTk8MqjpT1A/c6HY2dCA77ZN0lkQ2Q==", + "license": "ISC", + "dependencies": { + "d3-array": "2 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-time-format": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/d3-time-format/-/d3-time-format-4.1.0.tgz", + "integrity": "sha512-dJxPBlzC7NugB2PDLwo9Q8JiTR3M3e4/XANkreKSUxF8vvXKqm1Yfq4Q5dl8budlunRVlUUaDUgFt7eA8D6NLg==", + "license": "ISC", + "dependencies": { + "d3-time": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-timer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-timer/-/d3-timer-3.0.1.tgz", + "integrity": "sha512-ndfJ/JxxMd3nw31uyKoY2naivF+r29V+Lc0svZxe1JvvIRmi8hUsrMvdOwgS1o6uBHmiz91geQ0ylPP0aj1VUA==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/d3-transition": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/d3-transition/-/d3-transition-3.0.1.tgz", + "integrity": "sha512-ApKvfjsSR6tg06xrL434C0WydLr7JewBB3V+/39RMHsaXTOG0zmt/OAXeng5M5LBm0ojmxJrpomQVZ1aPvBL4w==", + "license": "ISC", + "dependencies": { + "d3-color": "1 - 3", + "d3-dispatch": "1 - 3", + "d3-ease": "1 - 3", + "d3-interpolate": "1 - 3", + "d3-timer": "1 - 3" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "d3-selection": "2 - 3" + } + }, + "node_modules/d3-zoom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-zoom/-/d3-zoom-3.0.0.tgz", + "integrity": "sha512-b8AmV3kfQaqWAuacbPuNbL6vahnOJflOhexLzMMNLga62+/nh0JzvJ0aO/5a5MVgUFGS7Hu1P9P03o3fJkDCyw==", + "license": "ISC", + "dependencies": { + "d3-dispatch": "1 - 3", + "d3-drag": "2 - 3", + "d3-interpolate": "1 - 3", + "d3-selection": "2 - 3", + "d3-transition": "2 - 3" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/dagre-d3-es": { + "version": "7.0.13", + "resolved": "https://registry.npmjs.org/dagre-d3-es/-/dagre-d3-es-7.0.13.tgz", + "integrity": "sha512-efEhnxpSuwpYOKRm/L5KbqoZmNNukHa/Flty4Wp62JRvgH2ojwVgPgdYyr4twpieZnyRDdIH7PY2mopX26+j2Q==", + "license": "MIT", + "dependencies": { + "d3": "^7.9.0", + "lodash-es": "^4.17.21" + } + }, + "node_modules/dayjs": { + "version": "1.11.19", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.19.tgz", + "integrity": "sha512-t5EcLVS6QPBNqM2z8fakk/NKel+Xzshgt8FFKAn+qwlD1pzZWxh0nVCrvFK7ZDb6XucZeF9z8C7CBWTRIVApAw==", + "license": "MIT" + }, + "node_modules/debug": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz", + "integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/decode-named-character-reference": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/decode-named-character-reference/-/decode-named-character-reference-1.1.0.tgz", + "integrity": "sha512-Wy+JTSbFThEOXQIR2L6mxJvEs+veIzpmqD7ynWxMXGpnk3smkHQOp6forLdHsKpAMW9iJpaBBIxz285t1n1C3w==", + "license": "MIT", + "dependencies": { + "character-entities": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/deep-eql": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.2.tgz", + "integrity": "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/define-lazy-prop": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz", + "integrity": "sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/delaunator": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/delaunator/-/delaunator-5.0.1.tgz", + "integrity": "sha512-8nvh+XBe96aCESrGOqMp/84b13H9cdKbG5P2ejQCh4d4sK9RL4371qou9drQjMhvnPmhWl5hnmqbEE0fXr9Xnw==", + "license": "ISC", + "dependencies": { + "robust-predicates": "^3.0.2" + } + }, + "node_modules/dequal": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", + "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/detect-libc": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.4.tgz", + "integrity": "sha512-3UDv+G9CsCKO1WKMGw9fwq/SWJYbI0c5Y7LU1AXYoDdbhE2AHQ6N6Nb34sG8Fj7T5APy8qXDCKuuIHd1BR0tVA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=8" + } + }, + "node_modules/devlop": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/devlop/-/devlop-1.1.0.tgz", + "integrity": "sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==", + "license": "MIT", + "dependencies": { + "dequal": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/diff": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-7.0.0.tgz", + "integrity": "sha512-PJWHUb1RFevKCwaFA9RlG5tCd+FO5iRh9A8HEtkmBH2Li03iJriB6m6JIN4rGz3K3JLawI7/veA1xzRKP6ISBw==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/doctrine": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "esutils": "^2.0.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/dom-accessibility-api": { + "version": "0.5.16", + "resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.5.16.tgz", + "integrity": "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==", + "dev": true, + "license": "MIT" + }, + "node_modules/dompurify": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.3.0.tgz", + "integrity": "sha512-r+f6MYR1gGN1eJv0TVQbhA7if/U7P87cdPl3HN5rikqaBSBxLiCb/b9O+2eG0cxz0ghyU+mU1QkbsOwERMYlWQ==", + "license": "(MPL-2.0 OR Apache-2.0)", + "optionalDependencies": { + "@types/trusted-types": "^2.0.7" + } + }, + "node_modules/eastasianwidth": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", + "dev": true, + "license": "MIT" + }, + "node_modules/electron-to-chromium": { + "version": "1.5.166", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.166.tgz", + "integrity": "sha512-QPWqHL0BglzPYyJJ1zSSmwFFL6MFXhbACOCcsCdUMCkzPdS9/OIBVxg516X/Ado2qwAq8k0nJJ7phQPCqiaFAw==", + "dev": true, + "license": "ISC" + }, + "node_modules/emoji-regex": { + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", + "dev": true, + "license": "MIT" + }, + "node_modules/enhanced-resolve": { + "version": "5.18.2", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.18.2.tgz", + "integrity": "sha512-6Jw4sE1maoRJo3q8MsSIn2onJFbLTOjY9hlx4DZXmOKvLRd1Ok2kXmAGXaafL2+ijsJZ1ClYbl/pmqr9+k4iUQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.4", + "tapable": "^2.2.0" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/entities": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/entities/-/entities-6.0.1.tgz", + "integrity": "sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/es-module-lexer": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.7.0.tgz", + "integrity": "sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA==", + "dev": true, + "license": "MIT" + }, + "node_modules/esbuild": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.5.tgz", + "integrity": "sha512-P8OtKZRv/5J5hhz0cUAdu/cLuPIKXpQl1R9pZtvmHWQvrAUVd0UNIPT4IB4W3rNOqVO0rlqHmCIbSwxh/c9yUQ==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.25.5", + "@esbuild/android-arm": "0.25.5", + "@esbuild/android-arm64": "0.25.5", + "@esbuild/android-x64": "0.25.5", + "@esbuild/darwin-arm64": "0.25.5", + "@esbuild/darwin-x64": "0.25.5", + "@esbuild/freebsd-arm64": "0.25.5", + "@esbuild/freebsd-x64": "0.25.5", + "@esbuild/linux-arm": "0.25.5", + "@esbuild/linux-arm64": "0.25.5", + "@esbuild/linux-ia32": "0.25.5", + "@esbuild/linux-loong64": "0.25.5", + "@esbuild/linux-mips64el": "0.25.5", + "@esbuild/linux-ppc64": "0.25.5", + "@esbuild/linux-riscv64": "0.25.5", + "@esbuild/linux-s390x": "0.25.5", + "@esbuild/linux-x64": "0.25.5", + "@esbuild/netbsd-arm64": "0.25.5", + "@esbuild/netbsd-x64": "0.25.5", + "@esbuild/openbsd-arm64": "0.25.5", + "@esbuild/openbsd-x64": "0.25.5", + "@esbuild/sunos-x64": "0.25.5", + "@esbuild/win32-arm64": "0.25.5", + "@esbuild/win32-ia32": "0.25.5", + "@esbuild/win32-x64": "0.25.5" + } + }, + "node_modules/esbuild-register": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/esbuild-register/-/esbuild-register-3.6.0.tgz", + "integrity": "sha512-H2/S7Pm8a9CL1uhp9OvjwrBh5Pvx0H8qVOxNu8Wed9Y7qv56MPtq+GGM8RJpq6glYJn9Wspr8uw7l55uyinNeg==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^4.3.4" + }, + "peerDependencies": { + "esbuild": ">=0.12 <1" + } + }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint": { + "version": "9.28.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.28.0.tgz", + "integrity": "sha512-ocgh41VhRlf9+fVpe7QKzwLj9c92fDiqOj8Y3Sd4/ZmVA4Btx4PlUYPq4pp9JDyupkf1upbEXecxL2mwNV7jPQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.12.1", + "@eslint/config-array": "^0.20.0", + "@eslint/config-helpers": "^0.2.1", + "@eslint/core": "^0.14.0", + "@eslint/eslintrc": "^3.3.1", + "@eslint/js": "9.28.0", + "@eslint/plugin-kit": "^0.3.1", + "@humanfs/node": "^0.16.6", + "@humanwhocodes/module-importer": "^1.0.1", + "@humanwhocodes/retry": "^0.4.2", + "@types/estree": "^1.0.6", + "@types/json-schema": "^7.0.15", + "ajv": "^6.12.4", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.6", + "debug": "^4.3.2", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^8.3.0", + "eslint-visitor-keys": "^4.2.0", + "espree": "^10.3.0", + "esquery": "^1.5.0", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^8.0.0", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "ignore": "^5.2.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.2", + "natural-compare": "^1.4.0", + "optionator": "^0.9.3" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://eslint.org/donate" + }, + "peerDependencies": { + "jiti": "*" + }, + "peerDependenciesMeta": { + "jiti": { + "optional": true + } + } + }, + "node_modules/eslint-plugin-react-hooks": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-5.2.0.tgz", + "integrity": "sha512-+f15FfK64YQwZdJNELETdn5ibXEUQmW1DZL6KXhNnc2heoy/sg9VJJeT7n8TlMWouzWqSWavFkIhHyIbIAEapg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 || ^9.0.0" + } + }, + "node_modules/eslint-plugin-react-refresh": { + "version": "0.4.20", + "resolved": "https://registry.npmjs.org/eslint-plugin-react-refresh/-/eslint-plugin-react-refresh-0.4.20.tgz", + "integrity": "sha512-XpbHQ2q5gUF8BGOX4dHe+71qoirYMhApEPZ7sfhF/dNnOF1UXnCMGZf79SFTBO7Bz5YEIT4TMieSlJBWhP9WBA==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "eslint": ">=8.40" + } + }, + "node_modules/eslint-plugin-storybook": { + "version": "9.0.14", + "resolved": "https://registry.npmjs.org/eslint-plugin-storybook/-/eslint-plugin-storybook-9.0.14.tgz", + "integrity": "sha512-YZsDhyFgVfeFPdvd7Xcl9ZusY7Jniq7AOAWN/cdg0a2Y+ywKKNYrQ+EfyuhXsiMjh58plYKMpJYxKVxeUwW9jw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/utils": "^8.8.1" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "eslint": ">=8", + "storybook": "^9.0.14" + } + }, + "node_modules/eslint-scope": { + "version": "8.4.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.4.0.tgz", + "integrity": "sha512-sNXOfKCn74rt8RICKMvJS7XKV/Xk9kA7DyJr8mJik3S7Cwgy3qlkkmyS2uQB3jiJg6VNdZd/pDBJu0nvG2NlTg==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-visitor-keys": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz", + "integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/espree": { + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.4.0.tgz", + "integrity": "sha512-j6PAQ2uUr79PZhBjP5C5fhl8e39FmRnOjsD5lGnWrFU8i2G776tBK7+nP8KuQUTTyAZUwfQqXAgrVH5MbH9CYQ==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "acorn": "^8.15.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^4.2.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true, + "license": "BSD-2-Clause", + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/esquery": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.6.0.tgz", + "integrity": "sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "estraverse": "^5.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "estraverse": "^5.2.0" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estree-util-is-identifier-name": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/estree-util-is-identifier-name/-/estree-util-is-identifier-name-3.0.0.tgz", + "integrity": "sha512-hFtqIDZTIUZ9BXLb8y4pYGyk6+wekIivNVTcmvk8NoOh+VeRn5y6cEHzbURrWbfp1fIqdVipilzj+lfaadNZmg==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "dev": true, + "license": "MIT" + }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/expect-type": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.2.1.tgz", + "integrity": "sha512-/kP8CAwxzLVEeFrMm4kMmy4CCDlpipyA7MYLVrdJIkV0fYF0UaigQHRsxHiuY/GEea+bh4KSv3TIlgr+2UL6bw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/exsolve": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/exsolve/-/exsolve-1.0.7.tgz", + "integrity": "sha512-VO5fQUzZtI6C+vx4w/4BWJpg3s/5l+6pRQEHzFRM8WFi4XffSP1Z+4qi7GbjWbvRQEbdIco5mIMq+zX4rPuLrw==", + "license": "MIT" + }, + "node_modules/extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", + "license": "MIT" + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-glob": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz", + "integrity": "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.8" + }, + "engines": { + "node": ">=8.6.0" + } + }, + "node_modules/fast-glob/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", + "dev": true, + "license": "MIT" + }, + "node_modules/fastq": { + "version": "1.19.1", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.19.1.tgz", + "integrity": "sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "reusify": "^1.0.4" + } + }, + "node_modules/fflate": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.2.tgz", + "integrity": "sha512-cPJU47OaAoCbg0pBvzsgpTPhmhqI5eJjh/JIu8tPj5q+T7iLvW/JAYUqmE7KOB4R1ZyEhzBaIQpQpardBF5z8A==", + "dev": true, + "license": "MIT" + }, + "node_modules/file-entry-cache": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", + "integrity": "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "flat-cache": "^4.0.0" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/filesize": { + "version": "10.1.6", + "resolved": "https://registry.npmjs.org/filesize/-/filesize-10.1.6.tgz", + "integrity": "sha512-sJslQKU2uM33qH5nqewAwVB2QgR6w1aMNsYUp3aN5rMRyXEwJGmZvaWzeJFNTOXWlHQyBFCWrdj3fV/fsTOX8w==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">= 10.4.0" + } + }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "license": "MIT", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/flat-cache": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz", + "integrity": "sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==", + "dev": true, + "license": "MIT", + "dependencies": { + "flatted": "^3.2.9", + "keyv": "^4.5.4" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/flatted": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.3.tgz", + "integrity": "sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg==", + "dev": true, + "license": "ISC" + }, + "node_modules/foreground-child": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.1.tgz", + "integrity": "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==", + "dev": true, + "license": "ISC", + "dependencies": { + "cross-spawn": "^7.0.6", + "signal-exit": "^4.0.1" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/fraction.js": { + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.3.7.tgz", + "integrity": "sha512-ZsDfxO51wGAXREY55a7la9LScWpwv9RxIrYABrlvOFBlH/ShPnrtsXeuUIfXKKOVicNxQ+o8JTbJvjS4M89yew==", + "dev": true, + "license": "MIT", + "engines": { + "node": "*" + }, + "funding": { + "type": "patreon", + "url": "https://github.com/sponsors/rawify" + } + }, + "node_modules/framer-motion": { + "version": "12.17.0", + "resolved": "https://registry.npmjs.org/framer-motion/-/framer-motion-12.17.0.tgz", + "integrity": "sha512-2hISKgDk49yCLStwG1wf4Kdy/D6eBw9/eRNaWFIYoI9vMQ/Mqd1Fz+gzVlEtxJmtQ9y4IWnXm19/+UXD3dAYAA==", + "dependencies": { + "motion-dom": "^12.17.0", + "motion-utils": "^12.12.1", + "tslib": "^2.4.0" + }, + "peerDependencies": { + "@emotion/is-prop-valid": "*", + "react": "^18.0.0 || ^19.0.0", + "react-dom": "^18.0.0 || ^19.0.0" + }, + "peerDependenciesMeta": { + "@emotion/is-prop-valid": { + "optional": true + }, + "react": { + "optional": true + }, + "react-dom": { + "optional": true + } + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/gensync": { + "version": "1.0.0-beta.2", + "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", + "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/get-tsconfig": { + "version": "4.10.1", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.10.1.tgz", + "integrity": "sha512-auHyJ4AgMz7vgS8Hp3N6HXSmlMdUyhSUrfBF16w153rxtLIEOE+HGqaBppczZvnHLqQJfiHotCYpNhl0lUROFQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "resolve-pkg-maps": "^1.0.0" + }, + "funding": { + "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" + } + }, + "node_modules/glob": { + "version": "10.4.5", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", + "integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==", + "dev": true, + "license": "ISC", + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^3.1.2", + "minimatch": "^9.0.4", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^1.11.1" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/glob/node_modules/brace-expansion": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", + "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/glob/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/globals": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-16.2.0.tgz", + "integrity": "sha512-O+7l9tPdHCU320IigZZPj5zmRCFG9xHmx9cU8FqU2Rp+JN714seHV+2S9+JslCpY4gJwU2vOGox0wzgae/MCEg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/globrex": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/globrex/-/globrex-0.1.2.tgz", + "integrity": "sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==", + "dev": true, + "license": "MIT" + }, + "node_modules/goober": { + "version": "2.1.16", + "resolved": "https://registry.npmjs.org/goober/-/goober-2.1.16.tgz", + "integrity": "sha512-erjk19y1U33+XAMe1VTvIONHYoSqE4iS7BYUZfHaqeohLmnC0FdxEh7rQU+6MZ4OajItzjZFSRtVANrQwNq6/g==", + "license": "MIT", + "peerDependencies": { + "csstype": "^3.0.10" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/graphemer": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", + "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", + "dev": true, + "license": "MIT" + }, + "node_modules/hachure-fill": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/hachure-fill/-/hachure-fill-0.5.2.tgz", + "integrity": "sha512-3GKBOn+m2LX9iq+JC1064cSFprJY4jL1jCXTcpnfER5HYE2l/4EfWSGzkPa/ZDBmYI0ZOEj5VHV/eKnPGkHuOg==", + "license": "MIT" + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/hast-util-from-dom": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/hast-util-from-dom/-/hast-util-from-dom-5.0.1.tgz", + "integrity": "sha512-N+LqofjR2zuzTjCPzyDUdSshy4Ma6li7p/c3pA78uTwzFgENbgbUrm2ugwsOdcjI1muO+o6Dgzp9p8WHtn/39Q==", + "license": "ISC", + "dependencies": { + "@types/hast": "^3.0.0", + "hastscript": "^9.0.0", + "web-namespaces": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/hast-util-from-html": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/hast-util-from-html/-/hast-util-from-html-2.0.3.tgz", + "integrity": "sha512-CUSRHXyKjzHov8yKsQjGOElXy/3EKpyX56ELnkHH34vDVw1N1XSQ1ZcAvTyAPtGqLTuKP/uxM+aLkSPqF/EtMw==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "devlop": "^1.1.0", + "hast-util-from-parse5": "^8.0.0", + "parse5": "^7.0.0", + "vfile": "^6.0.0", + "vfile-message": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/hast-util-from-html-isomorphic": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/hast-util-from-html-isomorphic/-/hast-util-from-html-isomorphic-2.0.0.tgz", + "integrity": "sha512-zJfpXq44yff2hmE0XmwEOzdWin5xwH+QIhMLOScpX91e/NSGPsAzNCvLQDIEPyO2TXi+lBmU6hjLIhV8MwP2kw==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "hast-util-from-dom": "^5.0.0", + "hast-util-from-html": "^2.0.0", + "unist-util-remove-position": "^5.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/hast-util-from-parse5": { + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/hast-util-from-parse5/-/hast-util-from-parse5-8.0.3.tgz", + "integrity": "sha512-3kxEVkEKt0zvcZ3hCRYI8rqrgwtlIOFMWkbclACvjlDw8Li9S2hk/d51OI0nr/gIpdMHNepwgOKqZ/sy0Clpyg==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "@types/unist": "^3.0.0", + "devlop": "^1.0.0", + "hastscript": "^9.0.0", + "property-information": "^7.0.0", + "vfile": "^6.0.0", + "vfile-location": "^5.0.0", + "web-namespaces": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/hast-util-is-element": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/hast-util-is-element/-/hast-util-is-element-3.0.0.tgz", + "integrity": "sha512-Val9mnv2IWpLbNPqc/pUem+a7Ipj2aHacCwgNfTiK0vJKl0LF+4Ba4+v1oPHFpf3bLYmreq0/l3Gud9S5OH42g==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/hast-util-parse-selector": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/hast-util-parse-selector/-/hast-util-parse-selector-4.0.0.tgz", + "integrity": "sha512-wkQCkSYoOGCRKERFWcxMVMOcYE2K1AaNLU8DXS9arxnLOUEWbOXKXiJUNzEpqZ3JOKpnha3jkFrumEjVliDe7A==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/hast-util-raw": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/hast-util-raw/-/hast-util-raw-9.1.0.tgz", + "integrity": "sha512-Y8/SBAHkZGoNkpzqqfCldijcuUKh7/su31kEBp67cFY09Wy0mTRgtsLYsiIxMJxlu0f6AA5SUTbDR8K0rxnbUw==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "@types/unist": "^3.0.0", + "@ungap/structured-clone": "^1.0.0", + "hast-util-from-parse5": "^8.0.0", + "hast-util-to-parse5": "^8.0.0", + "html-void-elements": "^3.0.0", + "mdast-util-to-hast": "^13.0.0", + "parse5": "^7.0.0", + "unist-util-position": "^5.0.0", + "unist-util-visit": "^5.0.0", + "vfile": "^6.0.0", + "web-namespaces": "^2.0.0", + "zwitch": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/hast-util-sanitize": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/hast-util-sanitize/-/hast-util-sanitize-5.0.2.tgz", + "integrity": "sha512-3yTWghByc50aGS7JlGhk61SPenfE/p1oaFeNwkOOyrscaOkMGrcW9+Cy/QAIOBpZxP1yqDIzFMR0+Np0i0+usg==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "@ungap/structured-clone": "^1.0.0", + "unist-util-position": "^5.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/hast-util-to-html": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/hast-util-to-html/-/hast-util-to-html-9.0.5.tgz", + "integrity": "sha512-OguPdidb+fbHQSU4Q4ZiLKnzWo8Wwsf5bZfbvu7//a9oTYoqD/fWpe96NuHkoS9h0ccGOTe0C4NGXdtS0iObOw==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "@types/unist": "^3.0.0", + "ccount": "^2.0.0", + "comma-separated-tokens": "^2.0.0", + "hast-util-whitespace": "^3.0.0", + "html-void-elements": "^3.0.0", + "mdast-util-to-hast": "^13.0.0", + "property-information": "^7.0.0", + "space-separated-tokens": "^2.0.0", + "stringify-entities": "^4.0.0", + "zwitch": "^2.0.4" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/hast-util-to-jsx-runtime": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/hast-util-to-jsx-runtime/-/hast-util-to-jsx-runtime-2.3.6.tgz", + "integrity": "sha512-zl6s8LwNyo1P9uw+XJGvZtdFF1GdAkOg8ujOw+4Pyb76874fLps4ueHXDhXWdk6YHQ6OgUtinliG7RsYvCbbBg==", + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0", + "@types/hast": "^3.0.0", + "@types/unist": "^3.0.0", + "comma-separated-tokens": "^2.0.0", + "devlop": "^1.0.0", + "estree-util-is-identifier-name": "^3.0.0", + "hast-util-whitespace": "^3.0.0", + "mdast-util-mdx-expression": "^2.0.0", + "mdast-util-mdx-jsx": "^3.0.0", + "mdast-util-mdxjs-esm": "^2.0.0", + "property-information": "^7.0.0", + "space-separated-tokens": "^2.0.0", + "style-to-js": "^1.0.0", + "unist-util-position": "^5.0.0", + "vfile-message": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/hast-util-to-parse5": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/hast-util-to-parse5/-/hast-util-to-parse5-8.0.0.tgz", + "integrity": "sha512-3KKrV5ZVI8if87DVSi1vDeByYrkGzg4mEfeu4alwgmmIeARiBLKCZS2uw5Gb6nU9x9Yufyj3iudm6i7nl52PFw==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "comma-separated-tokens": "^2.0.0", + "devlop": "^1.0.0", + "property-information": "^6.0.0", + "space-separated-tokens": "^2.0.0", + "web-namespaces": "^2.0.0", + "zwitch": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/hast-util-to-parse5/node_modules/property-information": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/property-information/-/property-information-6.5.0.tgz", + "integrity": "sha512-PgTgs/BlvHxOu8QuEN7wi5A0OmXaBcHpmCSTehcs6Uuu9IkDIEo13Hy7n898RHfrQ49vKCoGeWZSaAK01nwVig==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/hast-util-to-string": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/hast-util-to-string/-/hast-util-to-string-3.0.1.tgz", + "integrity": "sha512-XelQVTDWvqcl3axRfI0xSeoVKzyIFPwsAGSLIsKdJKQMXDYJS4WYrBNF/8J7RdhIcFI2BOHgAifggsvsxp/3+A==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/hast-util-to-text": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/hast-util-to-text/-/hast-util-to-text-4.0.2.tgz", + "integrity": "sha512-KK6y/BN8lbaq654j7JgBydev7wuNMcID54lkRav1P0CaE1e47P72AWWPiGKXTJU271ooYzcvTAn/Zt0REnvc7A==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "@types/unist": "^3.0.0", + "hast-util-is-element": "^3.0.0", + "unist-util-find-after": "^5.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/hast-util-whitespace": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/hast-util-whitespace/-/hast-util-whitespace-3.0.0.tgz", + "integrity": "sha512-88JUN06ipLwsnv+dVn+OIYOvAuvBMy/Qoi6O7mQHxdPXpjy+Cd6xRkWwux7DKO+4sYILtLBRIKgsdpS2gQc7qw==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/hastscript": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/hastscript/-/hastscript-9.0.1.tgz", + "integrity": "sha512-g7df9rMFX/SPi34tyGCyUBREQoKkapwdY/T04Qn9TDWfHhAYt4/I0gMVirzK5wEzeUqIjEB+LXC/ypb7Aqno5w==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "comma-separated-tokens": "^2.0.0", + "hast-util-parse-selector": "^4.0.0", + "property-information": "^7.0.0", + "space-separated-tokens": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true, + "license": "MIT" + }, + "node_modules/html-url-attributes": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/html-url-attributes/-/html-url-attributes-3.0.1.tgz", + "integrity": "sha512-ol6UPyBWqsrO6EJySPz2O7ZSr856WDrEzM5zMqp+FJJLGMW35cLYmmZnl0vztAZxRUoNZJFTCohfjuIJ8I4QBQ==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/html-void-elements": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/html-void-elements/-/html-void-elements-3.0.0.tgz", + "integrity": "sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/ignore": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", + "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/import-fresh": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz", + "integrity": "sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8.19" + } + }, + "node_modules/indent-string": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", + "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/inline-style-parser": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/inline-style-parser/-/inline-style-parser-0.2.4.tgz", + "integrity": "sha512-0aO8FkhNZlj/ZIbNi7Lxxr12obT7cL1moPfE4tg1LkX7LlLfC6DeX4l2ZEud1ukP9jNQyNnfzQVqwbwmAATY4Q==", + "license": "MIT" + }, + "node_modules/internmap": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/internmap/-/internmap-2.0.3.tgz", + "integrity": "sha512-5Hh7Y1wQbvY5ooGgPbDaL5iYLAPzMTUrjMulskHLH6wnv/A+1q5rgEaiuqEjB+oxGXIVZs1FF+R/KPN3ZSQYYg==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/is-alphabetical": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-2.0.1.tgz", + "integrity": "sha512-FWyyY60MeTNyeSRpkM2Iry0G9hpr7/9kD40mD/cGQEuilcZYS4okz8SN2Q6rLCJ8gbCt6fN+rC+6tMGS99LaxQ==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/is-alphanumerical": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-alphanumerical/-/is-alphanumerical-2.0.1.tgz", + "integrity": "sha512-hmbYhX/9MUMF5uh7tOXyK/n0ZvWpad5caBA17GsC6vyuCqaWliRG5K1qS9inmUhEMaOBIW7/whAnSwveW/LtZw==", + "license": "MIT", + "dependencies": { + "is-alphabetical": "^2.0.0", + "is-decimal": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "license": "MIT", + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-core-module": { + "version": "2.16.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.1.tgz", + "integrity": "sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==", + "dev": true, + "license": "MIT", + "dependencies": { + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-decimal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-decimal/-/is-decimal-2.0.1.tgz", + "integrity": "sha512-AAB9hiomQs5DXWcRB1rqsxGUstbRroFOPPVAomNk/3XHR5JyEZChOyTWe2oayKnsSsr/kcGqF+z6yuH6HHpN0A==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/is-docker": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", + "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==", + "dev": true, + "license": "MIT", + "bin": { + "is-docker": "cli.js" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-hexadecimal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-hexadecimal/-/is-hexadecimal-2.0.1.tgz", + "integrity": "sha512-DgZQp241c8oO6cA1SbTEWiXeoxV42vlcJxgH+B3hi1AiqqKruZR3ZGF8In3fj4+/y/7rHvlOZLZtgJ/4ttYGZg==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-plain-obj": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-4.1.0.tgz", + "integrity": "sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-wsl": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", + "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-docker": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true, + "license": "ISC" + }, + "node_modules/istanbul-lib-coverage": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz", + "integrity": "sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-report": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", + "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^4.0.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-source-maps": { + "version": "5.0.6", + "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-5.0.6.tgz", + "integrity": "sha512-yg2d+Em4KizZC5niWhQaIomgf5WlL4vOOjZ5xGCmF8SnPE/mDWWXgvRExdcpCgh9lLRRa1/fSYp2ymmbJ1pI+A==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.23", + "debug": "^4.1.1", + "istanbul-lib-coverage": "^3.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-reports": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.7.tgz", + "integrity": "sha512-BewmUXImeuRk2YY0PVbxgKAysvhRPUQE0h5QRM++nVWyubKGV0l8qQ5op8+B2DOmwSe63Jivj0BjkPQVf8fP5g==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/jackspeak": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz", + "integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "@isaacs/cliui": "^8.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + }, + "optionalDependencies": { + "@pkgjs/parseargs": "^0.11.0" + } + }, + "node_modules/jiti": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.4.2.tgz", + "integrity": "sha512-rg9zJN+G4n2nfJl5MW3BMygZX56zKPNVEYYqq7adpmMh4Jn2QNEwhvQlFy6jPVdcod7txZtKHWnyZiA3a0zP7A==", + "dev": true, + "license": "MIT", + "bin": { + "jiti": "lib/jiti-cli.mjs" + } + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/jsesc": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz", + "integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==", + "license": "MIT", + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/json-buffer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", + "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true, + "license": "MIT" + }, + "node_modules/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/json5": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "dev": true, + "license": "MIT", + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/jsonfile": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "universalify": "^2.0.0" + }, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/katex": { + "version": "0.16.22", + "resolved": "https://registry.npmjs.org/katex/-/katex-0.16.22.tgz", + "integrity": "sha512-XCHRdUw4lf3SKBaJe4EvgqIuWwkPSo9XoeO8GjQW94Bp7TWv9hNhzZjZ+OH9yf1UmLygb7DIT5GSFQiyt16zYg==", + "funding": [ + "https://opencollective.com/katex", + "https://github.com/sponsors/katex" + ], + "license": "MIT", + "dependencies": { + "commander": "^8.3.0" + }, + "bin": { + "katex": "cli.js" + } + }, + "node_modules/keyv": { + "version": "4.5.4", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", + "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", + "dev": true, + "license": "MIT", + "dependencies": { + "json-buffer": "3.0.1" + } + }, + "node_modules/khroma": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/khroma/-/khroma-2.1.0.tgz", + "integrity": "sha512-Ls993zuzfayK269Svk9hzpeGUKob/sIgZzyHYdjQoAdQetRKpOLj+k/QQQ/6Qi0Yz65mlROrfd+Ev+1+7dz9Kw==" + }, + "node_modules/kleur": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", + "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/kolorist": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/kolorist/-/kolorist-1.8.0.tgz", + "integrity": "sha512-Y+60/zizpJ3HRH8DCss+q95yr6145JXZo46OTpFvDZWLfRCE4qChOyk1b26nMaNpfHHgxagk9dXT5OP0Tfe+dQ==", + "license": "MIT" + }, + "node_modules/langium": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/langium/-/langium-3.3.1.tgz", + "integrity": "sha512-QJv/h939gDpvT+9SiLVlY7tZC3xB2qK57v0J04Sh9wpMb6MP1q8gB21L3WIo8T5P1MSMg3Ep14L7KkDCFG3y4w==", + "license": "MIT", + "dependencies": { + "chevrotain": "~11.0.3", + "chevrotain-allstar": "~0.3.0", + "vscode-languageserver": "~9.0.1", + "vscode-languageserver-textdocument": "~1.0.11", + "vscode-uri": "~3.0.8" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/layout-base": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/layout-base/-/layout-base-1.0.2.tgz", + "integrity": "sha512-8h2oVEZNktL4BH2JCOI90iD1yXwL6iNW7KcCKT2QZgQJR2vbqDsldCTPRU9NifTCqHZci57XvQQ15YTu+sTYPg==", + "license": "MIT" + }, + "node_modules/levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/lightningcss": { + "version": "1.30.1", + "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.30.1.tgz", + "integrity": "sha512-xi6IyHML+c9+Q3W0S4fCQJOym42pyurFiJUHEcEyHS0CeKzia4yZDEsLlqOFykxOdHpNy0NmvVO31vcSqAxJCg==", + "dev": true, + "license": "MPL-2.0", + "dependencies": { + "detect-libc": "^2.0.3" + }, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + }, + "optionalDependencies": { + "lightningcss-darwin-arm64": "1.30.1", + "lightningcss-darwin-x64": "1.30.1", + "lightningcss-freebsd-x64": "1.30.1", + "lightningcss-linux-arm-gnueabihf": "1.30.1", + "lightningcss-linux-arm64-gnu": "1.30.1", + "lightningcss-linux-arm64-musl": "1.30.1", + "lightningcss-linux-x64-gnu": "1.30.1", + "lightningcss-linux-x64-musl": "1.30.1", + "lightningcss-win32-arm64-msvc": "1.30.1", + "lightningcss-win32-x64-msvc": "1.30.1" + } + }, + "node_modules/lightningcss-darwin-arm64": { + "version": "1.30.1", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.30.1.tgz", + "integrity": "sha512-c8JK7hyE65X1MHMN+Viq9n11RRC7hgin3HhYKhrMyaXflk5GVplZ60IxyoVtzILeKr+xAJwg6zK6sjTBJ0FKYQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-x64": { + "version": "1.30.1", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.30.1.tgz", + "integrity": "sha512-k1EvjakfumAQoTfcXUcHQZhSpLlkAuEkdMBsI/ivWw9hL+7FtilQc0Cy3hrx0AAQrVtQAbMI7YjCgYgvn37PzA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-freebsd-x64": { + "version": "1.30.1", + "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.30.1.tgz", + "integrity": "sha512-kmW6UGCGg2PcyUE59K5r0kWfKPAVy4SltVeut+umLCFoJ53RdCUWxcRDzO1eTaxf/7Q2H7LTquFHPL5R+Gjyig==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm-gnueabihf": { + "version": "1.30.1", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.30.1.tgz", + "integrity": "sha512-MjxUShl1v8pit+6D/zSPq9S9dQ2NPFSQwGvxBCYaBYLPlCWuPh9/t1MRS8iUaR8i+a6w7aps+B4N0S1TYP/R+Q==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-gnu": { + "version": "1.30.1", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.30.1.tgz", + "integrity": "sha512-gB72maP8rmrKsnKYy8XUuXi/4OctJiuQjcuqWNlJQ6jZiWqtPvqFziskH3hnajfvKB27ynbVCucKSm2rkQp4Bw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-musl": { + "version": "1.30.1", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.30.1.tgz", + "integrity": "sha512-jmUQVx4331m6LIX+0wUhBbmMX7TCfjF5FoOH6SD1CttzuYlGNVpA7QnrmLxrsub43ClTINfGSYyHe2HWeLl5CQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-gnu": { + "version": "1.30.1", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.30.1.tgz", + "integrity": "sha512-piWx3z4wN8J8z3+O5kO74+yr6ze/dKmPnI7vLqfSqI8bccaTGY5xiSGVIJBDd5K5BHlvVLpUB3S2YCfelyJ1bw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-musl": { + "version": "1.30.1", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.30.1.tgz", + "integrity": "sha512-rRomAK7eIkL+tHY0YPxbc5Dra2gXlI63HL+v1Pdi1a3sC+tJTcFrHX+E86sulgAXeI7rSzDYhPSeHHjqFhqfeQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-arm64-msvc": { + "version": "1.30.1", + "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.30.1.tgz", + "integrity": "sha512-mSL4rqPi4iXq5YVqzSsJgMVFENoa4nGTT/GjO2c0Yl9OuQfPsIfncvLrEW6RbbB24WtZ3xP/2CCmI3tNkNV4oA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-x64-msvc": { + "version": "1.30.1", + "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.30.1.tgz", + "integrity": "sha512-PVqXh48wh4T53F/1CCu8PIPCxLzWyCnn/9T5W1Jpmdy5h9Cwd+0YQS6/LwhHXSafuc61/xg9Lv5OrCby6a++jg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/local-pkg": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/local-pkg/-/local-pkg-1.1.2.tgz", + "integrity": "sha512-arhlxbFRmoQHl33a0Zkle/YWlmNwoyt6QNZEIJcqNbdrsix5Lvc4HyyI3EnwxTYlZYc32EbYrQ8SzEZ7dqgg9A==", + "license": "MIT", + "dependencies": { + "mlly": "^1.7.4", + "pkg-types": "^2.3.0", + "quansync": "^0.2.11" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash-es": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz", + "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==", + "license": "MIT" + }, + "node_modules/lodash.castarray": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/lodash.castarray/-/lodash.castarray-4.4.0.tgz", + "integrity": "sha512-aVx8ztPv7/2ULbArGJ2Y42bG1mEQ5mGjpdvrbJcJFU3TbYybe+QlLS4pst9zV52ymy2in1KpFPiZnAOATxD4+Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/longest-streak": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/longest-streak/-/longest-streak-3.1.0.tgz", + "integrity": "sha512-9Ri+o0JYgehTaVBBDoMqIl8GXtbWg711O3srftcHhZ0dqnETqLaoIK0x17fUw9rFSlK/0NlsKe0Ahhyl5pXE2g==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/loupe": { + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.1.4.tgz", + "integrity": "sha512-wJzkKwJrheKtknCOKNEtDK4iqg/MxmZheEMtSTYvnzRdEYaZzmgH976nenp8WdJRdx5Vc1X/9MO0Oszl6ezeXg==", + "dev": true, + "license": "MIT" + }, + "node_modules/lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "dev": true, + "license": "ISC", + "dependencies": { + "yallist": "^3.0.2" + } + }, + "node_modules/lucide-react": { + "version": "0.542.0", + "resolved": "https://registry.npmjs.org/lucide-react/-/lucide-react-0.542.0.tgz", + "integrity": "sha512-w3hD8/SQB7+lzU2r4VdFyzzOzKnUjTZIF/MQJGSSvni7Llewni4vuViRppfRAa2guOsY5k4jZyxw/i9DQHv+dw==", + "license": "ISC", + "peerDependencies": { + "react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0" + } + }, + "node_modules/lz-string": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.5.0.tgz", + "integrity": "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==", + "dev": true, + "license": "MIT", + "bin": { + "lz-string": "bin/bin.js" + } + }, + "node_modules/magic-string": { + "version": "0.30.17", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.17.tgz", + "integrity": "sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0" + } + }, + "node_modules/magicast": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/magicast/-/magicast-0.3.5.tgz", + "integrity": "sha512-L0WhttDl+2BOsybvEOLK7fW3UA0OQ0IQ2d6Zl2x/a6vVRs3bAY0ECOSHHeL5jD+SbOpOCUEi0y1DgHEn9Qn1AQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.25.4", + "@babel/types": "^7.25.4", + "source-map-js": "^1.2.0" + } + }, + "node_modules/make-dir": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", + "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/make-dir/node_modules/semver": { + "version": "7.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz", + "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/markdown-table": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/markdown-table/-/markdown-table-3.0.4.tgz", + "integrity": "sha512-wiYz4+JrLyb/DqW2hkFJxP7Vd7JuTDm77fvbM8VfEQdmSMqcImWeeRbHwZjBjIFki/VaMK2BhFi7oUUZeM5bqw==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/marked": { + "version": "16.4.1", + "resolved": "https://registry.npmjs.org/marked/-/marked-16.4.1.tgz", + "integrity": "sha512-ntROs7RaN3EvWfy3EZi14H4YxmT6A5YvywfhO+0pm+cH/dnSQRmdAmoFIc3B9aiwTehyk7pESH4ofyBY+V5hZg==", + "license": "MIT", + "bin": { + "marked": "bin/marked.js" + }, + "engines": { + "node": ">= 20" + } + }, + "node_modules/mdast-util-find-and-replace": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/mdast-util-find-and-replace/-/mdast-util-find-and-replace-3.0.2.tgz", + "integrity": "sha512-Tmd1Vg/m3Xz43afeNxDIhWRtFZgM2VLyaf4vSTYwudTyeuTneoL3qtWMA5jeLyz/O1vDJmmV4QuScFCA2tBPwg==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "escape-string-regexp": "^5.0.0", + "unist-util-is": "^6.0.0", + "unist-util-visit-parents": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-find-and-replace/node_modules/escape-string-regexp": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz", + "integrity": "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/mdast-util-from-markdown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-2.0.2.tgz", + "integrity": "sha512-uZhTV/8NBuw0WHkPTrCqDOl0zVe1BIng5ZtHoDk49ME1qqcjYmmLmOf0gELgcRMxN4w2iuIeVso5/6QymSrgmA==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "@types/unist": "^3.0.0", + "decode-named-character-reference": "^1.0.0", + "devlop": "^1.0.0", + "mdast-util-to-string": "^4.0.0", + "micromark": "^4.0.0", + "micromark-util-decode-numeric-character-reference": "^2.0.0", + "micromark-util-decode-string": "^2.0.0", + "micromark-util-normalize-identifier": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0", + "unist-util-stringify-position": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-gfm": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-gfm/-/mdast-util-gfm-3.1.0.tgz", + "integrity": "sha512-0ulfdQOM3ysHhCJ1p06l0b0VKlhU0wuQs3thxZQagjcjPrlFRqY215uZGHHJan9GEAXd9MbfPjFJz+qMkVR6zQ==", + "license": "MIT", + "dependencies": { + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-gfm-autolink-literal": "^2.0.0", + "mdast-util-gfm-footnote": "^2.0.0", + "mdast-util-gfm-strikethrough": "^2.0.0", + "mdast-util-gfm-table": "^2.0.0", + "mdast-util-gfm-task-list-item": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-gfm-footnote": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-footnote/-/mdast-util-gfm-footnote-2.1.0.tgz", + "integrity": "sha512-sqpDWlsHn7Ac9GNZQMeUzPQSMzR6Wv0WKRNvQRg0KqHh02fpTz69Qc1QSseNX29bhz1ROIyNyxExfawVKTm1GQ==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "devlop": "^1.1.0", + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0", + "micromark-util-normalize-identifier": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-gfm-strikethrough": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-strikethrough/-/mdast-util-gfm-strikethrough-2.0.0.tgz", + "integrity": "sha512-mKKb915TF+OC5ptj5bJ7WFRPdYtuHv0yTRxK2tJvi+BDqbkiG7h7u/9SI89nRAYcmap2xHQL9D+QG/6wSrTtXg==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-gfm-table": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-table/-/mdast-util-gfm-table-2.0.0.tgz", + "integrity": "sha512-78UEvebzz/rJIxLvE7ZtDd/vIQ0RHv+3Mh5DR96p7cS7HsBhYIICDBCu8csTNWNO6tBWfqXPWekRuj2FNOGOZg==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "devlop": "^1.0.0", + "markdown-table": "^3.0.0", + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-gfm-task-list-item": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-task-list-item/-/mdast-util-gfm-task-list-item-2.0.0.tgz", + "integrity": "sha512-IrtvNvjxC1o06taBAVJznEnkiHxLFTzgonUdy8hzFVeDun0uTjxxrRGVaNFqkU1wJR3RBPEfsxmU6jDWPofrTQ==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "devlop": "^1.0.0", + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-gfm/node_modules/mdast-util-gfm-autolink-literal": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-autolink-literal/-/mdast-util-gfm-autolink-literal-2.0.0.tgz", + "integrity": "sha512-FyzMsduZZHSc3i0Px3PQcBT4WJY/X/RCtEJKuybiC6sjPqLv7h1yqAkmILZtuxMSsUyaLUWNp71+vQH2zqp5cg==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "ccount": "^2.0.0", + "devlop": "^1.0.0", + "mdast-util-find-and-replace": "^3.0.0", + "micromark-util-character": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-math": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/mdast-util-math/-/mdast-util-math-3.0.0.tgz", + "integrity": "sha512-Tl9GBNeG/AhJnQM221bJR2HPvLOSnLE/T9cJI9tlc6zwQk2nPk/4f0cHkOdEixQPC/j8UtKDdITswvLAy1OZ1w==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "@types/mdast": "^4.0.0", + "devlop": "^1.0.0", + "longest-streak": "^3.0.0", + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-to-markdown": "^2.1.0", + "unist-util-remove-position": "^5.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-mdx-expression": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/mdast-util-mdx-expression/-/mdast-util-mdx-expression-2.0.1.tgz", + "integrity": "sha512-J6f+9hUp+ldTZqKRSg7Vw5V6MqjATc+3E4gf3CFNcuZNWD8XdyI6zQ8GqH7f8169MM6P7hMBRDVGnn7oHB9kXQ==", + "license": "MIT", + "dependencies": { + "@types/estree-jsx": "^1.0.0", + "@types/hast": "^3.0.0", + "@types/mdast": "^4.0.0", + "devlop": "^1.0.0", + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-mdx-jsx": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/mdast-util-mdx-jsx/-/mdast-util-mdx-jsx-3.2.0.tgz", + "integrity": "sha512-lj/z8v0r6ZtsN/cGNNtemmmfoLAFZnjMbNyLzBafjzikOM+glrjNHPlf6lQDOTccj9n5b0PPihEBbhneMyGs1Q==", + "license": "MIT", + "dependencies": { + "@types/estree-jsx": "^1.0.0", + "@types/hast": "^3.0.0", + "@types/mdast": "^4.0.0", + "@types/unist": "^3.0.0", + "ccount": "^2.0.0", + "devlop": "^1.1.0", + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0", + "parse-entities": "^4.0.0", + "stringify-entities": "^4.0.0", + "unist-util-stringify-position": "^4.0.0", + "vfile-message": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-mdxjs-esm": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/mdast-util-mdxjs-esm/-/mdast-util-mdxjs-esm-2.0.1.tgz", + "integrity": "sha512-EcmOpxsZ96CvlP03NghtH1EsLtr0n9Tm4lPUJUBccV9RwUOneqSycg19n5HGzCf+10LozMRSObtVr3ee1WoHtg==", + "license": "MIT", + "dependencies": { + "@types/estree-jsx": "^1.0.0", + "@types/hast": "^3.0.0", + "@types/mdast": "^4.0.0", + "devlop": "^1.0.0", + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-phrasing": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-phrasing/-/mdast-util-phrasing-4.1.0.tgz", + "integrity": "sha512-TqICwyvJJpBwvGAMZjj4J2n0X8QWp21b9l0o7eXyVJ25YNWYbJDVIyD1bZXE6WtV6RmKJVYmQAKWa0zWOABz2w==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "unist-util-is": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-to-hast": { + "version": "13.2.0", + "resolved": "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-13.2.0.tgz", + "integrity": "sha512-QGYKEuUsYT9ykKBCMOEDLsU5JRObWQusAolFMeko/tYPufNkRffBAQjIE+99jbA87xv6FgmjLtwjh9wBWajwAA==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "@types/mdast": "^4.0.0", + "@ungap/structured-clone": "^1.0.0", + "devlop": "^1.0.0", + "micromark-util-sanitize-uri": "^2.0.0", + "trim-lines": "^3.0.0", + "unist-util-position": "^5.0.0", + "unist-util-visit": "^5.0.0", + "vfile": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-to-markdown": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-2.1.2.tgz", + "integrity": "sha512-xj68wMTvGXVOKonmog6LwyJKrYXZPvlwabaryTjLh9LuvovB/KAH+kvi8Gjj+7rJjsFi23nkUxRQv1KqSroMqA==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "@types/unist": "^3.0.0", + "longest-streak": "^3.0.0", + "mdast-util-phrasing": "^4.0.0", + "mdast-util-to-string": "^4.0.0", + "micromark-util-classify-character": "^2.0.0", + "micromark-util-decode-string": "^2.0.0", + "unist-util-visit": "^5.0.0", + "zwitch": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-to-string": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-4.0.0.tgz", + "integrity": "sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/mermaid": { + "version": "11.12.1", + "resolved": "https://registry.npmjs.org/mermaid/-/mermaid-11.12.1.tgz", + "integrity": "sha512-UlIZrRariB11TY1RtTgUWp65tphtBv4CSq7vyS2ZZ2TgoMjs2nloq+wFqxiwcxlhHUvs7DPGgMjs2aeQxz5h9g==", + "license": "MIT", + "dependencies": { + "@braintree/sanitize-url": "^7.1.1", + "@iconify/utils": "^3.0.1", + "@mermaid-js/parser": "^0.6.3", + "@types/d3": "^7.4.3", + "cytoscape": "^3.29.3", + "cytoscape-cose-bilkent": "^4.1.0", + "cytoscape-fcose": "^2.2.0", + "d3": "^7.9.0", + "d3-sankey": "^0.12.3", + "dagre-d3-es": "7.0.13", + "dayjs": "^1.11.18", + "dompurify": "^3.2.5", + "katex": "^0.16.22", + "khroma": "^2.1.0", + "lodash-es": "^4.17.21", + "marked": "^16.2.1", + "roughjs": "^4.6.6", + "stylis": "^4.3.6", + "ts-dedent": "^2.2.0", + "uuid": "^11.1.0" + } + }, + "node_modules/micromark": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/micromark/-/micromark-4.0.2.tgz", + "integrity": "sha512-zpe98Q6kvavpCr1NPVSCMebCKfD7CA2NqZ+rykeNhONIJBpc1tFKt9hucLGwha3jNTNI8lHpctWJWoimVF4PfA==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "@types/debug": "^4.0.0", + "debug": "^4.0.0", + "decode-named-character-reference": "^1.0.0", + "devlop": "^1.0.0", + "micromark-core-commonmark": "^2.0.0", + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-chunked": "^2.0.0", + "micromark-util-combine-extensions": "^2.0.0", + "micromark-util-decode-numeric-character-reference": "^2.0.0", + "micromark-util-encode": "^2.0.0", + "micromark-util-normalize-identifier": "^2.0.0", + "micromark-util-resolve-all": "^2.0.0", + "micromark-util-sanitize-uri": "^2.0.0", + "micromark-util-subtokenize": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-core-commonmark": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/micromark-core-commonmark/-/micromark-core-commonmark-2.0.3.tgz", + "integrity": "sha512-RDBrHEMSxVFLg6xvnXmb1Ayr2WzLAWjeSATAoxwKYJV94TeNavgoIdA0a9ytzDSVzBy2YKFK+emCPOEibLeCrg==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "decode-named-character-reference": "^1.0.0", + "devlop": "^1.0.0", + "micromark-factory-destination": "^2.0.0", + "micromark-factory-label": "^2.0.0", + "micromark-factory-space": "^2.0.0", + "micromark-factory-title": "^2.0.0", + "micromark-factory-whitespace": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-chunked": "^2.0.0", + "micromark-util-classify-character": "^2.0.0", + "micromark-util-html-tag-name": "^2.0.0", + "micromark-util-normalize-identifier": "^2.0.0", + "micromark-util-resolve-all": "^2.0.0", + "micromark-util-subtokenize": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-extension-gfm": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm/-/micromark-extension-gfm-3.0.0.tgz", + "integrity": "sha512-vsKArQsicm7t0z2GugkCKtZehqUm31oeGBV/KVSorWSy8ZlNAv7ytjFhvaryUiCUJYqs+NoE6AFhpQvBTM6Q4w==", + "license": "MIT", + "dependencies": { + "micromark-extension-gfm-autolink-literal": "^2.0.0", + "micromark-extension-gfm-footnote": "^2.0.0", + "micromark-extension-gfm-strikethrough": "^2.0.0", + "micromark-extension-gfm-table": "^2.0.0", + "micromark-extension-gfm-tagfilter": "^2.0.0", + "micromark-extension-gfm-task-list-item": "^2.0.0", + "micromark-util-combine-extensions": "^2.0.0", + "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark-extension-gfm-autolink-literal": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-autolink-literal/-/micromark-extension-gfm-autolink-literal-2.1.0.tgz", + "integrity": "sha512-oOg7knzhicgQ3t4QCjCWgTmfNhvQbDDnJeVu9v81r7NltNCVmhPy1fJRX27pISafdjL+SVc4d3l48Gb6pbRypw==", + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-sanitize-uri": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark-extension-gfm-footnote": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-footnote/-/micromark-extension-gfm-footnote-2.1.0.tgz", + "integrity": "sha512-/yPhxI1ntnDNsiHtzLKYnE3vf9JZ6cAisqVDauhp4CEHxlb4uoOTxOCJ+9s51bIB8U1N1FJ1RXOKTIlD5B/gqw==", + "license": "MIT", + "dependencies": { + "devlop": "^1.0.0", + "micromark-core-commonmark": "^2.0.0", + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-normalize-identifier": "^2.0.0", + "micromark-util-sanitize-uri": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark-extension-gfm-strikethrough": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-strikethrough/-/micromark-extension-gfm-strikethrough-2.1.0.tgz", + "integrity": "sha512-ADVjpOOkjz1hhkZLlBiYA9cR2Anf8F4HqZUO6e5eDcPQd0Txw5fxLzzxnEkSkfnD0wziSGiv7sYhk/ktvbf1uw==", + "license": "MIT", + "dependencies": { + "devlop": "^1.0.0", + "micromark-util-chunked": "^2.0.0", + "micromark-util-classify-character": "^2.0.0", + "micromark-util-resolve-all": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark-extension-gfm-table": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-table/-/micromark-extension-gfm-table-2.1.1.tgz", + "integrity": "sha512-t2OU/dXXioARrC6yWfJ4hqB7rct14e8f7m0cbI5hUmDyyIlwv5vEtooptH8INkbLzOatzKuVbQmAYcbWoyz6Dg==", + "license": "MIT", + "dependencies": { + "devlop": "^1.0.0", + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark-extension-gfm-tagfilter": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-tagfilter/-/micromark-extension-gfm-tagfilter-2.0.0.tgz", + "integrity": "sha512-xHlTOmuCSotIA8TW1mDIM6X2O1SiX5P9IuDtqGonFhEK0qgRI4yeC6vMxEV2dgyr2TiD+2PQ10o+cOhdVAcwfg==", + "license": "MIT", + "dependencies": { + "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark-extension-gfm-task-list-item": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-task-list-item/-/micromark-extension-gfm-task-list-item-2.1.0.tgz", + "integrity": "sha512-qIBZhqxqI6fjLDYFTBIa4eivDMnP+OZqsNwmQ3xNLE4Cxwc+zfQEfbs6tzAo2Hjq+bh6q5F+Z8/cksrLFYWQQw==", + "license": "MIT", + "dependencies": { + "devlop": "^1.0.0", + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark-extension-llm-math": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/micromark-extension-llm-math/-/micromark-extension-llm-math-3.1.0.tgz", + "integrity": "sha512-VIYHuIEk0gpHrojEtNGaxGwdpSLtdWYlLL2vu9PM4M1ilEtak10S8F9zzbNAPBNRoWFs/bjs+J7R3yUBoIQUEA==", + "license": "MIT", + "dependencies": { + "@types/katex": "^0.16.0", + "devlop": "^1.0.0", + "katex": "^0.16.0", + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark-extension-math": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/micromark-extension-math/-/micromark-extension-math-3.1.0.tgz", + "integrity": "sha512-lvEqd+fHjATVs+2v/8kg9i5Q0AP2k85H0WUOwpIVvUML8BapsMvh1XAogmQjOCsLpoKRCVQqEkQBB3NhVBcsOg==", + "license": "MIT", + "dependencies": { + "@types/katex": "^0.16.0", + "devlop": "^1.0.0", + "katex": "^0.16.0", + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark-factory-destination": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-2.0.1.tgz", + "integrity": "sha512-Xe6rDdJlkmbFRExpTOmRj9N3MaWmbAgdpSrBQvCFqhezUn4AHqJHbaEnfbVYYiexVSs//tqOdY/DxhjdCiJnIA==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-label": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-label/-/micromark-factory-label-2.0.1.tgz", + "integrity": "sha512-VFMekyQExqIW7xIChcXn4ok29YE3rnuyveW3wZQWWqF4Nv9Wk5rgJ99KzPvHjkmPXF93FXIbBp6YdW3t71/7Vg==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "devlop": "^1.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-space": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.1.tgz", + "integrity": "sha512-zRkxjtBxxLd2Sc0d+fbnEunsTj46SWXgXciZmHq0kDYGnck/ZSGj9/wULTV95uoeYiK5hRXP2mJ98Uo4cq/LQg==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-title": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-title/-/micromark-factory-title-2.0.1.tgz", + "integrity": "sha512-5bZ+3CjhAd9eChYTHsjy6TGxpOFSKgKKJPJxr293jTbfry2KDoWkhBb6TcPVB4NmzaPhMs1Frm9AZH7OD4Cjzw==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-whitespace": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-whitespace/-/micromark-factory-whitespace-2.0.1.tgz", + "integrity": "sha512-Ob0nuZ3PKt/n0hORHyvoD9uZhr+Za8sFoP+OnMcnWK5lngSzALgQYKMr9RJVOWLqQYuyn6ulqGWSXdwf6F80lQ==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-character": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", + "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-chunked": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-chunked/-/micromark-util-chunked-2.0.1.tgz", + "integrity": "sha512-QUNFEOPELfmvv+4xiNg2sRYeS/P84pTW0TCgP5zc9FpXetHY0ab7SxKyAQCNCc1eK0459uoLI1y5oO5Vc1dbhA==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-classify-character": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-classify-character/-/micromark-util-classify-character-2.0.1.tgz", + "integrity": "sha512-K0kHzM6afW/MbeWYWLjoHQv1sgg2Q9EccHEDzSkxiP/EaagNzCm7T/WMKZ3rjMbvIpvBiZgwR3dKMygtA4mG1Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-combine-extensions": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-combine-extensions/-/micromark-util-combine-extensions-2.0.1.tgz", + "integrity": "sha512-OnAnH8Ujmy59JcyZw8JSbK9cGpdVY44NKgSM7E9Eh7DiLS2E9RNQf0dONaGDzEG9yjEl5hcqeIsj4hfRkLH/Bg==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-chunked": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-decode-numeric-character-reference": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-decode-numeric-character-reference/-/micromark-util-decode-numeric-character-reference-2.0.2.tgz", + "integrity": "sha512-ccUbYk6CwVdkmCQMyr64dXz42EfHGkPQlBj5p7YVGzq8I7CtjXZJrubAYezf7Rp+bjPseiROqe7G6foFd+lEuw==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-decode-string": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-decode-string/-/micromark-util-decode-string-2.0.1.tgz", + "integrity": "sha512-nDV/77Fj6eH1ynwscYTOsbK7rR//Uj0bZXBwJZRfaLEJ1iGBR6kIfNmlNqaqJf649EP0F3NWNdeJi03elllNUQ==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "decode-named-character-reference": "^1.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-decode-numeric-character-reference": "^2.0.0", + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-encode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.1.tgz", + "integrity": "sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-util-html-tag-name": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-html-tag-name/-/micromark-util-html-tag-name-2.0.1.tgz", + "integrity": "sha512-2cNEiYDhCWKI+Gs9T0Tiysk136SnR13hhO8yW6BGNyhOC4qYFnwF1nKfD3HFAIXA5c45RrIG1ub11GiXeYd1xA==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-util-normalize-identifier": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-normalize-identifier/-/micromark-util-normalize-identifier-2.0.1.tgz", + "integrity": "sha512-sxPqmo70LyARJs0w2UclACPUUEqltCkJ6PhKdMIDuJ3gSf/Q+/GIe3WKl0Ijb/GyH9lOpUkRAO2wp0GVkLvS9Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-resolve-all": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-resolve-all/-/micromark-util-resolve-all-2.0.1.tgz", + "integrity": "sha512-VdQyxFWFT2/FGJgwQnJYbe1jjQoNTS4RjglmSjTUlpUMa95Htx9NHeYW4rGDJzbjvCsl9eLjMQwGeElsqmzcHg==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-sanitize-uri": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-2.0.1.tgz", + "integrity": "sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-encode": "^2.0.0", + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-subtokenize": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/micromark-util-subtokenize/-/micromark-util-subtokenize-2.1.0.tgz", + "integrity": "sha512-XQLu552iSctvnEcgXw6+Sx75GflAPNED1qx7eBJ+wydBb2KCbRZe+NwvIEEMM83uml1+2WSXpBAcp9IUCgCYWA==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "devlop": "^1.0.0", + "micromark-util-chunked": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-symbol": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", + "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-util-types": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", + "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromatch": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", + "dev": true, + "license": "MIT", + "dependencies": { + "braces": "^3.0.3", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/min-indent": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", + "integrity": "sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/minipass": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", + "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/minizlib": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-3.0.2.tgz", + "integrity": "sha512-oG62iEk+CYt5Xj2YqI5Xi9xWUeZhDI8jjQmC5oThVH5JGCTgIjr7ciJDzC7MBzYd//WvR1OTmP5Q38Q8ShQtVA==", + "dev": true, + "license": "MIT", + "dependencies": { + "minipass": "^7.1.2" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/mkdirp": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-3.0.1.tgz", + "integrity": "sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==", + "dev": true, + "license": "MIT", + "bin": { + "mkdirp": "dist/cjs/src/bin.js" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/mlly": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.8.0.tgz", + "integrity": "sha512-l8D9ODSRWLe2KHJSifWGwBqpTZXIXTeo8mlKjY+E2HAakaTeNpqAyBZ8GSqLzHgw4XmHmC8whvpjJNMbFZN7/g==", + "license": "MIT", + "dependencies": { + "acorn": "^8.15.0", + "pathe": "^2.0.3", + "pkg-types": "^1.3.1", + "ufo": "^1.6.1" + } + }, + "node_modules/mlly/node_modules/confbox": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/confbox/-/confbox-0.1.8.tgz", + "integrity": "sha512-RMtmw0iFkeR4YV+fUOSucriAQNb9g8zFR52MWCtl+cCZOFRNL6zeB395vPzFhEjjn4fMxXudmELnl/KF/WrK6w==", + "license": "MIT" + }, + "node_modules/mlly/node_modules/pkg-types": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-1.3.1.tgz", + "integrity": "sha512-/Jm5M4RvtBFVkKWRu2BLUTNP8/M2a+UwuAX+ae4770q1qVGtfjG+WTCupoZixokjmHiry8uI+dlY8KXYV5HVVQ==", + "license": "MIT", + "dependencies": { + "confbox": "^0.1.8", + "mlly": "^1.7.4", + "pathe": "^2.0.1" + } + }, + "node_modules/motion-dom": { + "version": "12.17.0", + "resolved": "https://registry.npmjs.org/motion-dom/-/motion-dom-12.17.0.tgz", + "integrity": "sha512-FA6/c70R9NKs3g41XDVONzmUUrEmyaifLVGCWtAmHP0usDnX9W+RN/tmbC4EUl0w6yLGvMTOwnWCFVgA5luhRg==", + "dependencies": { + "motion-utils": "^12.12.1" + } + }, + "node_modules/motion-utils": { + "version": "12.12.1", + "resolved": "https://registry.npmjs.org/motion-utils/-/motion-utils-12.12.1.tgz", + "integrity": "sha512-f9qiqUHm7hWSLlNW8gS9pisnsN7CRFRD58vNjptKdsqFLpkVnX00TNeD6Q0d27V9KzT7ySFyK1TZ/DShfVOv6w==" + }, + "node_modules/mrmime": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/mrmime/-/mrmime-2.0.1.tgz", + "integrity": "sha512-Y3wQdFg2Va6etvQ5I82yUhGdsKrcYox6p7FfL1LbK2J4V01F9TGlepTIhnK24t7koZibmg82KGglhA1XK5IsLQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/nanoid": { + "version": "3.3.11", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", + "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true, + "license": "MIT" + }, + "node_modules/node-releases": { + "version": "2.0.19", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.19.tgz", + "integrity": "sha512-xxOWJsBKtzAq7DY0J+DTzuz58K8e7sJbdgwkbMWQe8UYB6ekmsQ45q0M/tJDsGaZmbC+l7n57UV8Hl5tHxO9uw==", + "dev": true, + "license": "MIT" + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/normalize-range": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/normalize-range/-/normalize-range-0.1.2.tgz", + "integrity": "sha512-bdok/XvKII3nUpklnV6P2hxtMNrCboOjAcyBuQnWEhO665FwrSNRxU+AqpsyvO6LgGYPspN+lu5CLtw4jPRKNA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/ollama": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/ollama/-/ollama-0.6.0.tgz", + "integrity": "sha512-FHjdU2Ok5x2HZsxPui/MBJZ5J+HzmxoWYa/p9wk736eT+uAhS8nvIICar5YgwlG5MFNjDR6UA5F3RSKq+JseOA==", + "license": "MIT", + "dependencies": { + "whatwg-fetch": "^3.6.20" + } + }, + "node_modules/oniguruma-parser": { + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/oniguruma-parser/-/oniguruma-parser-0.12.1.tgz", + "integrity": "sha512-8Unqkvk1RYc6yq2WBYRj4hdnsAxVze8i7iPfQr8e4uSP3tRv0rpZcbGUDvxfQQcdwHt/e9PrMvGCsa8OqG9X3w==", + "license": "MIT" + }, + "node_modules/oniguruma-to-es": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/oniguruma-to-es/-/oniguruma-to-es-4.3.3.tgz", + "integrity": "sha512-rPiZhzC3wXwE59YQMRDodUwwT9FZ9nNBwQQfsd1wfdtlKEyCdRV0avrTcSZ5xlIvGRVPd/cx6ZN45ECmS39xvg==", + "license": "MIT", + "dependencies": { + "oniguruma-parser": "^0.12.1", + "regex": "^6.0.1", + "regex-recursion": "^6.0.2" + } + }, + "node_modules/open": { + "version": "8.4.2", + "resolved": "https://registry.npmjs.org/open/-/open-8.4.2.tgz", + "integrity": "sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "define-lazy-prop": "^2.0.0", + "is-docker": "^2.1.1", + "is-wsl": "^2.2.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/optionator": { + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", + "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.5" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/package-json-from-dist": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", + "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", + "dev": true, + "license": "BlueOak-1.0.0" + }, + "node_modules/package-manager-detector": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/package-manager-detector/-/package-manager-detector-1.5.0.tgz", + "integrity": "sha512-uBj69dVlYe/+wxj8JOpr97XfsxH/eumMt6HqjNTmJDf/6NO9s+0uxeOneIz3AsPt2m6y9PqzDzd3ATcU17MNfw==", + "license": "MIT" + }, + "node_modules/parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "license": "MIT", + "dependencies": { + "callsites": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/parse-entities": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/parse-entities/-/parse-entities-4.0.2.tgz", + "integrity": "sha512-GG2AQYWoLgL877gQIKeRPGO1xF9+eG1ujIb5soS5gPvLQ1y2o8FL90w2QWNdf9I361Mpp7726c+lj3U0qK1uGw==", + "license": "MIT", + "dependencies": { + "@types/unist": "^2.0.0", + "character-entities-legacy": "^3.0.0", + "character-reference-invalid": "^2.0.0", + "decode-named-character-reference": "^1.0.0", + "is-alphanumerical": "^2.0.0", + "is-decimal": "^2.0.0", + "is-hexadecimal": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/parse-entities/node_modules/@types/unist": { + "version": "2.0.11", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.11.tgz", + "integrity": "sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA==", + "license": "MIT" + }, + "node_modules/parse-numeric-range": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/parse-numeric-range/-/parse-numeric-range-1.3.0.tgz", + "integrity": "sha512-twN+njEipszzlMJd4ONUYgSfZPDxgHhT9Ahed5uTigpQn90FggW4SA/AIPq/6a149fTbE9qBEcSwE3FAEp6wQQ==", + "license": "ISC" + }, + "node_modules/parse5": { + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.3.0.tgz", + "integrity": "sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw==", + "license": "MIT", + "dependencies": { + "entities": "^6.0.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, + "node_modules/path-data-parser": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/path-data-parser/-/path-data-parser-0.1.0.tgz", + "integrity": "sha512-NOnmBpt5Y2RWbuv0LMzsayp3lVylAHLPUTut412ZA3l+C4uw4ZVkQbjShYCQ8TCpUMdPapr4YjUqLYD6v68j+w==", + "license": "MIT" + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true, + "license": "MIT" + }, + "node_modules/path-scurry": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", + "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "lru-cache": "^10.2.0", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" + }, + "engines": { + "node": ">=16 || 14 >=14.18" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/path-scurry/node_modules/lru-cache": { + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", + "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/pathe": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz", + "integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==", + "license": "MIT" + }, + "node_modules/pathval": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.1.tgz", + "integrity": "sha512-//nshmD55c46FuFw26xV/xFAaB5HF9Xdap7HJBBnrKdAd6/GxDBaNA1870O79+9ueg61cZLSVc+OaFlfmObYVQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 14.16" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/pkg-types": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-2.3.0.tgz", + "integrity": "sha512-SIqCzDRg0s9npO5XQ3tNZioRY1uK06lA41ynBC1YmFTmnY6FjUjVt6s4LoADmwoig1qqD0oK8h1p/8mlMx8Oig==", + "license": "MIT", + "dependencies": { + "confbox": "^0.2.2", + "exsolve": "^1.0.7", + "pathe": "^2.0.3" + } + }, + "node_modules/playwright": { + "version": "1.53.2", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.53.2.tgz", + "integrity": "sha512-6K/qQxVFuVQhRQhFsVZ9fGeatxirtrpPgxzBYWyZLEXJzqYwuL4fuNmfOfD5et1tJE4GScKyPNeLhZeRwuTU3A==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright-core": "1.53.2" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "fsevents": "2.3.2" + } + }, + "node_modules/playwright-core": { + "version": "1.53.2", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.53.2.tgz", + "integrity": "sha512-ox/OytMy+2w1jcYEYlOo1Hhp8hZkLCximMTUTMBXjGUA1KoFfiSZ+DU+3a739jsPY0yoKH2TFy9S2fsJas8yAw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/playwright/node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/points-on-curve": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/points-on-curve/-/points-on-curve-0.2.0.tgz", + "integrity": "sha512-0mYKnYYe9ZcqMCWhUjItv/oHjvgEsfKvnUTg8sAtnHr3GVy7rGkXCb6d5cSyqrWqL4k81b9CPg3urd+T7aop3A==", + "license": "MIT" + }, + "node_modules/points-on-path": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/points-on-path/-/points-on-path-0.2.1.tgz", + "integrity": "sha512-25ClnWWuw7JbWZcgqY/gJ4FQWadKxGWk+3kR/7kD0tCaDtPPMj7oHu2ToLaVhfpnHrZzYby2w6tUA0eOIuUg8g==", + "license": "MIT", + "dependencies": { + "path-data-parser": "0.1.0", + "points-on-curve": "0.2.0" + } + }, + "node_modules/postcss": { + "version": "8.5.4", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.4.tgz", + "integrity": "sha512-QSa9EBe+uwlGTFmHsPKokv3B/oEMQZxfqW0QqNCyhpa6mB1afzulwn8hihglqAb2pOw+BJgNlmXQ8la2VeHB7w==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.11", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/postcss-attribute-case-insensitive": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/postcss-attribute-case-insensitive/-/postcss-attribute-case-insensitive-7.0.1.tgz", + "integrity": "sha512-Uai+SupNSqzlschRyNx3kbCTWgY/2hcwtHEI/ej2LJWc9JJ77qKgGptd8DHwY1mXtZ7Aoh4z4yxfwMBue9eNgw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "dependencies": { + "postcss-selector-parser": "^7.0.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/postcss-attribute-case-insensitive/node_modules/postcss-selector-parser": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.0.tgz", + "integrity": "sha512-8sLjZwK0R+JlxlYcTuVnyT2v+htpdrjDOKuMcOVdYjt52Lh8hWRYpxBPoKx/Zg+bcjc3wx6fmQevMmUztS/ccA==", + "dev": true, + "license": "MIT", + "dependencies": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/postcss-clamp": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/postcss-clamp/-/postcss-clamp-4.1.0.tgz", + "integrity": "sha512-ry4b1Llo/9zz+PKC+030KUnPITTJAHeOwjfAyyB60eT0AorGLdzp52s31OsPRHRf8NchkgFoG2y6fCfn1IV1Ow==", + "dev": true, + "license": "MIT", + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": ">=7.6.0" + }, + "peerDependencies": { + "postcss": "^8.4.6" + } + }, + "node_modules/postcss-color-functional-notation": { + "version": "7.0.10", + "resolved": "https://registry.npmjs.org/postcss-color-functional-notation/-/postcss-color-functional-notation-7.0.10.tgz", + "integrity": "sha512-k9qX+aXHBiLTRrWoCJuUFI6F1iF6QJQUXNVWJVSbqZgj57jDhBlOvD8gNUGl35tgqDivbGLhZeW3Ongz4feuKA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "@csstools/css-color-parser": "^3.0.10", + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4", + "@csstools/postcss-progressive-custom-properties": "^4.1.0", + "@csstools/utilities": "^2.0.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/postcss-color-hex-alpha": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/postcss-color-hex-alpha/-/postcss-color-hex-alpha-10.0.0.tgz", + "integrity": "sha512-1kervM2cnlgPs2a8Vt/Qbe5cQ++N7rkYo/2rz2BkqJZIHQwaVuJgQH38REHrAi4uM0b1fqxMkWYmese94iMp3w==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "dependencies": { + "@csstools/utilities": "^2.0.0", + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/postcss-color-rebeccapurple": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/postcss-color-rebeccapurple/-/postcss-color-rebeccapurple-10.0.0.tgz", + "integrity": "sha512-JFta737jSP+hdAIEhk1Vs0q0YF5P8fFcj+09pweS8ktuGuZ8pPlykHsk6mPxZ8awDl4TrcxUqJo9l1IhVr/OjQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "@csstools/utilities": "^2.0.0", + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/postcss-custom-media": { + "version": "11.0.6", + "resolved": "https://registry.npmjs.org/postcss-custom-media/-/postcss-custom-media-11.0.6.tgz", + "integrity": "sha512-C4lD4b7mUIw+RZhtY7qUbf4eADmb7Ey8BFA2px9jUbwg7pjTZDl4KY4bvlUV+/vXQvzQRfiGEVJyAbtOsCMInw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "dependencies": { + "@csstools/cascade-layer-name-parser": "^2.0.5", + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4", + "@csstools/media-query-list-parser": "^4.0.3" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/postcss-custom-properties": { + "version": "14.0.6", + "resolved": "https://registry.npmjs.org/postcss-custom-properties/-/postcss-custom-properties-14.0.6.tgz", + "integrity": "sha512-fTYSp3xuk4BUeVhxCSJdIPhDLpJfNakZKoiTDx7yRGCdlZrSJR7mWKVOBS4sBF+5poPQFMj2YdXx1VHItBGihQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "dependencies": { + "@csstools/cascade-layer-name-parser": "^2.0.5", + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4", + "@csstools/utilities": "^2.0.0", + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/postcss-custom-selectors": { + "version": "8.0.5", + "resolved": "https://registry.npmjs.org/postcss-custom-selectors/-/postcss-custom-selectors-8.0.5.tgz", + "integrity": "sha512-9PGmckHQswiB2usSO6XMSswO2yFWVoCAuih1yl9FVcwkscLjRKjwsjM3t+NIWpSU2Jx3eOiK2+t4vVTQaoCHHg==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "dependencies": { + "@csstools/cascade-layer-name-parser": "^2.0.5", + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4", + "postcss-selector-parser": "^7.0.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/postcss-custom-selectors/node_modules/postcss-selector-parser": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.0.tgz", + "integrity": "sha512-8sLjZwK0R+JlxlYcTuVnyT2v+htpdrjDOKuMcOVdYjt52Lh8hWRYpxBPoKx/Zg+bcjc3wx6fmQevMmUztS/ccA==", + "dev": true, + "license": "MIT", + "dependencies": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/postcss-dir-pseudo-class": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/postcss-dir-pseudo-class/-/postcss-dir-pseudo-class-9.0.1.tgz", + "integrity": "sha512-tRBEK0MHYvcMUrAuYMEOa0zg9APqirBcgzi6P21OhxtJyJADo/SWBwY1CAwEohQ/6HDaa9jCjLRG7K3PVQYHEA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "postcss-selector-parser": "^7.0.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/postcss-dir-pseudo-class/node_modules/postcss-selector-parser": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.0.tgz", + "integrity": "sha512-8sLjZwK0R+JlxlYcTuVnyT2v+htpdrjDOKuMcOVdYjt52Lh8hWRYpxBPoKx/Zg+bcjc3wx6fmQevMmUztS/ccA==", + "dev": true, + "license": "MIT", + "dependencies": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/postcss-double-position-gradients": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/postcss-double-position-gradients/-/postcss-double-position-gradients-6.0.2.tgz", + "integrity": "sha512-7qTqnL7nfLRyJK/AHSVrrXOuvDDzettC+wGoienURV8v2svNbu6zJC52ruZtHaO6mfcagFmuTGFdzRsJKB3k5Q==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "@csstools/postcss-progressive-custom-properties": "^4.1.0", + "@csstools/utilities": "^2.0.0", + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/postcss-focus-visible": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/postcss-focus-visible/-/postcss-focus-visible-10.0.1.tgz", + "integrity": "sha512-U58wyjS/I1GZgjRok33aE8juW9qQgQUNwTSdxQGuShHzwuYdcklnvK/+qOWX1Q9kr7ysbraQ6ht6r+udansalA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "postcss-selector-parser": "^7.0.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/postcss-focus-visible/node_modules/postcss-selector-parser": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.0.tgz", + "integrity": "sha512-8sLjZwK0R+JlxlYcTuVnyT2v+htpdrjDOKuMcOVdYjt52Lh8hWRYpxBPoKx/Zg+bcjc3wx6fmQevMmUztS/ccA==", + "dev": true, + "license": "MIT", + "dependencies": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/postcss-focus-within": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/postcss-focus-within/-/postcss-focus-within-9.0.1.tgz", + "integrity": "sha512-fzNUyS1yOYa7mOjpci/bR+u+ESvdar6hk8XNK/TRR0fiGTp2QT5N+ducP0n3rfH/m9I7H/EQU6lsa2BrgxkEjw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "postcss-selector-parser": "^7.0.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/postcss-focus-within/node_modules/postcss-selector-parser": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.0.tgz", + "integrity": "sha512-8sLjZwK0R+JlxlYcTuVnyT2v+htpdrjDOKuMcOVdYjt52Lh8hWRYpxBPoKx/Zg+bcjc3wx6fmQevMmUztS/ccA==", + "dev": true, + "license": "MIT", + "dependencies": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/postcss-font-variant": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/postcss-font-variant/-/postcss-font-variant-5.0.0.tgz", + "integrity": "sha512-1fmkBaCALD72CK2a9i468mA/+tr9/1cBxRRMXOUaZqO43oWPR5imcyPjXwuv7PXbCid4ndlP5zWhidQVVa3hmA==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "postcss": "^8.1.0" + } + }, + "node_modules/postcss-gap-properties": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/postcss-gap-properties/-/postcss-gap-properties-6.0.0.tgz", + "integrity": "sha512-Om0WPjEwiM9Ru+VhfEDPZJAKWUd0mV1HmNXqp2C29z80aQ2uP9UVhLc7e3aYMIor/S5cVhoPgYQ7RtfeZpYTRw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/postcss-image-set-function": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/postcss-image-set-function/-/postcss-image-set-function-7.0.0.tgz", + "integrity": "sha512-QL7W7QNlZuzOwBTeXEmbVckNt1FSmhQtbMRvGGqqU4Nf4xk6KUEQhAoWuMzwbSv5jxiRiSZ5Tv7eiDB9U87znA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "@csstools/utilities": "^2.0.0", + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/postcss-lab-function": { + "version": "7.0.10", + "resolved": "https://registry.npmjs.org/postcss-lab-function/-/postcss-lab-function-7.0.10.tgz", + "integrity": "sha512-tqs6TCEv9tC1Riq6fOzHuHcZyhg4k3gIAMB8GGY/zA1ssGdm6puHMVE7t75aOSoFg7UD2wyrFFhbldiCMyyFTQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "@csstools/css-color-parser": "^3.0.10", + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4", + "@csstools/postcss-progressive-custom-properties": "^4.1.0", + "@csstools/utilities": "^2.0.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/postcss-logical": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/postcss-logical/-/postcss-logical-8.1.0.tgz", + "integrity": "sha512-pL1hXFQ2fEXNKiNiAgtfA005T9FBxky5zkX6s4GZM2D8RkVgRqz3f4g1JUoq925zXv495qk8UNldDwh8uGEDoA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/postcss-nesting": { + "version": "13.0.2", + "resolved": "https://registry.npmjs.org/postcss-nesting/-/postcss-nesting-13.0.2.tgz", + "integrity": "sha512-1YCI290TX+VP0U/K/aFxzHzQWHWURL+CtHMSbex1lCdpXD1SoR2sYuxDu5aNI9lPoXpKTCggFZiDJbwylU0LEQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "@csstools/selector-resolve-nested": "^3.1.0", + "@csstools/selector-specificity": "^5.0.0", + "postcss-selector-parser": "^7.0.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/postcss-nesting/node_modules/@csstools/selector-resolve-nested": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@csstools/selector-resolve-nested/-/selector-resolve-nested-3.1.0.tgz", + "integrity": "sha512-mf1LEW0tJLKfWyvn5KdDrhpxHyuxpbNwTIwOYLIvsTffeyOf85j5oIzfG0yosxDgx/sswlqBnESYUcQH0vgZ0g==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss-selector-parser": "^7.0.0" + } + }, + "node_modules/postcss-nesting/node_modules/@csstools/selector-specificity": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@csstools/selector-specificity/-/selector-specificity-5.0.0.tgz", + "integrity": "sha512-PCqQV3c4CoVm3kdPhyeZ07VmBRdH2EpMFA/pd9OASpOEC3aXNGoqPDAZ80D0cLpMBxnmk0+yNhGsEx31hq7Gtw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss-selector-parser": "^7.0.0" + } + }, + "node_modules/postcss-nesting/node_modules/postcss-selector-parser": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.0.tgz", + "integrity": "sha512-8sLjZwK0R+JlxlYcTuVnyT2v+htpdrjDOKuMcOVdYjt52Lh8hWRYpxBPoKx/Zg+bcjc3wx6fmQevMmUztS/ccA==", + "dev": true, + "license": "MIT", + "dependencies": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/postcss-opacity-percentage": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/postcss-opacity-percentage/-/postcss-opacity-percentage-3.0.0.tgz", + "integrity": "sha512-K6HGVzyxUxd/VgZdX04DCtdwWJ4NGLG212US4/LA1TLAbHgmAsTWVR86o+gGIbFtnTkfOpb9sCRBx8K7HO66qQ==", + "dev": true, + "funding": [ + { + "type": "kofi", + "url": "https://ko-fi.com/mrcgrtz" + }, + { + "type": "liberapay", + "url": "https://liberapay.com/mrcgrtz" + } + ], + "license": "MIT", + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/postcss-overflow-shorthand": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/postcss-overflow-shorthand/-/postcss-overflow-shorthand-6.0.0.tgz", + "integrity": "sha512-BdDl/AbVkDjoTofzDQnwDdm/Ym6oS9KgmO7Gr+LHYjNWJ6ExORe4+3pcLQsLA9gIROMkiGVjjwZNoL/mpXHd5Q==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/postcss-page-break": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/postcss-page-break/-/postcss-page-break-3.0.4.tgz", + "integrity": "sha512-1JGu8oCjVXLa9q9rFTo4MbeeA5FMe00/9C7lN4va606Rdb+HkxXtXsmEDrIraQ11fGz/WvKWa8gMuCKkrXpTsQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "postcss": "^8" + } + }, + "node_modules/postcss-place": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/postcss-place/-/postcss-place-10.0.0.tgz", + "integrity": "sha512-5EBrMzat2pPAxQNWYavwAfoKfYcTADJ8AXGVPcUZ2UkNloUTWzJQExgrzrDkh3EKzmAx1evfTAzF9I8NGcc+qw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/postcss-preset-env": { + "version": "10.2.4", + "resolved": "https://registry.npmjs.org/postcss-preset-env/-/postcss-preset-env-10.2.4.tgz", + "integrity": "sha512-q+lXgqmTMdB0Ty+EQ31SuodhdfZetUlwCA/F0zRcd/XdxjzI+Rl2JhZNz5US2n/7t9ePsvuhCnEN4Bmu86zXlA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "@csstools/postcss-cascade-layers": "^5.0.2", + "@csstools/postcss-color-function": "^4.0.10", + "@csstools/postcss-color-mix-function": "^3.0.10", + "@csstools/postcss-color-mix-variadic-function-arguments": "^1.0.0", + "@csstools/postcss-content-alt-text": "^2.0.6", + "@csstools/postcss-exponential-functions": "^2.0.9", + "@csstools/postcss-font-format-keywords": "^4.0.0", + "@csstools/postcss-gamut-mapping": "^2.0.10", + "@csstools/postcss-gradients-interpolation-method": "^5.0.10", + "@csstools/postcss-hwb-function": "^4.0.10", + "@csstools/postcss-ic-unit": "^4.0.2", + "@csstools/postcss-initial": "^2.0.1", + "@csstools/postcss-is-pseudo-class": "^5.0.3", + "@csstools/postcss-light-dark-function": "^2.0.9", + "@csstools/postcss-logical-float-and-clear": "^3.0.0", + "@csstools/postcss-logical-overflow": "^2.0.0", + "@csstools/postcss-logical-overscroll-behavior": "^2.0.0", + "@csstools/postcss-logical-resize": "^3.0.0", + "@csstools/postcss-logical-viewport-units": "^3.0.4", + "@csstools/postcss-media-minmax": "^2.0.9", + "@csstools/postcss-media-queries-aspect-ratio-number-values": "^3.0.5", + "@csstools/postcss-nested-calc": "^4.0.0", + "@csstools/postcss-normalize-display-values": "^4.0.0", + "@csstools/postcss-oklab-function": "^4.0.10", + "@csstools/postcss-progressive-custom-properties": "^4.1.0", + "@csstools/postcss-random-function": "^2.0.1", + "@csstools/postcss-relative-color-syntax": "^3.0.10", + "@csstools/postcss-scope-pseudo-class": "^4.0.1", + "@csstools/postcss-sign-functions": "^1.1.4", + "@csstools/postcss-stepped-value-functions": "^4.0.9", + "@csstools/postcss-text-decoration-shorthand": "^4.0.2", + "@csstools/postcss-trigonometric-functions": "^4.0.9", + "@csstools/postcss-unset-value": "^4.0.0", + "autoprefixer": "^10.4.21", + "browserslist": "^4.25.0", + "css-blank-pseudo": "^7.0.1", + "css-has-pseudo": "^7.0.2", + "css-prefers-color-scheme": "^10.0.0", + "cssdb": "^8.3.0", + "postcss-attribute-case-insensitive": "^7.0.1", + "postcss-clamp": "^4.1.0", + "postcss-color-functional-notation": "^7.0.10", + "postcss-color-hex-alpha": "^10.0.0", + "postcss-color-rebeccapurple": "^10.0.0", + "postcss-custom-media": "^11.0.6", + "postcss-custom-properties": "^14.0.6", + "postcss-custom-selectors": "^8.0.5", + "postcss-dir-pseudo-class": "^9.0.1", + "postcss-double-position-gradients": "^6.0.2", + "postcss-focus-visible": "^10.0.1", + "postcss-focus-within": "^9.0.1", + "postcss-font-variant": "^5.0.0", + "postcss-gap-properties": "^6.0.0", + "postcss-image-set-function": "^7.0.0", + "postcss-lab-function": "^7.0.10", + "postcss-logical": "^8.1.0", + "postcss-nesting": "^13.0.2", + "postcss-opacity-percentage": "^3.0.0", + "postcss-overflow-shorthand": "^6.0.0", + "postcss-page-break": "^3.0.4", + "postcss-place": "^10.0.0", + "postcss-pseudo-class-any-link": "^10.0.1", + "postcss-replace-overflow-wrap": "^4.0.0", + "postcss-selector-not": "^8.0.1" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/postcss-pseudo-class-any-link": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/postcss-pseudo-class-any-link/-/postcss-pseudo-class-any-link-10.0.1.tgz", + "integrity": "sha512-3el9rXlBOqTFaMFkWDOkHUTQekFIYnaQY55Rsp8As8QQkpiSgIYEcF/6Ond93oHiDsGb4kad8zjt+NPlOC1H0Q==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "dependencies": { + "postcss-selector-parser": "^7.0.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/postcss-pseudo-class-any-link/node_modules/postcss-selector-parser": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.0.tgz", + "integrity": "sha512-8sLjZwK0R+JlxlYcTuVnyT2v+htpdrjDOKuMcOVdYjt52Lh8hWRYpxBPoKx/Zg+bcjc3wx6fmQevMmUztS/ccA==", + "dev": true, + "license": "MIT", + "dependencies": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/postcss-replace-overflow-wrap": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/postcss-replace-overflow-wrap/-/postcss-replace-overflow-wrap-4.0.0.tgz", + "integrity": "sha512-KmF7SBPphT4gPPcKZc7aDkweHiKEEO8cla/GjcBK+ckKxiZslIu3C4GCRW3DNfL0o7yW7kMQu9xlZ1kXRXLXtw==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "postcss": "^8.0.3" + } + }, + "node_modules/postcss-selector-not": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/postcss-selector-not/-/postcss-selector-not-8.0.1.tgz", + "integrity": "sha512-kmVy/5PYVb2UOhy0+LqUYAhKj7DUGDpSWa5LZqlkWJaaAV+dxxsOG3+St0yNLu6vsKD7Dmqx+nWQt0iil89+WA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "dependencies": { + "postcss-selector-parser": "^7.0.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss": "^8.4" + } + }, + "node_modules/postcss-selector-not/node_modules/postcss-selector-parser": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.0.tgz", + "integrity": "sha512-8sLjZwK0R+JlxlYcTuVnyT2v+htpdrjDOKuMcOVdYjt52Lh8hWRYpxBPoKx/Zg+bcjc3wx6fmQevMmUztS/ccA==", + "dev": true, + "license": "MIT", + "dependencies": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/postcss-selector-parser": { + "version": "6.0.10", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.10.tgz", + "integrity": "sha512-IQ7TZdoaqbT+LCpShg46jnZVlhWD2w6iQYAcYXfHARZ7X1t/UGhhceQDs5X0cGqKvYlHNOuv7Oa1xmb0oQuA3w==", + "dev": true, + "license": "MIT", + "dependencies": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/postcss-value-parser": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz", + "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/prettier": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.5.3.tgz", + "integrity": "sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==", + "dev": true, + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/pretty-format": { + "version": "27.5.1", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz", + "integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1", + "ansi-styles": "^5.0.0", + "react-is": "^17.0.1" + }, + "engines": { + "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + } + }, + "node_modules/pretty-format/node_modules/ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/prompts": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", + "integrity": "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "kleur": "^3.0.3", + "sisteransi": "^1.0.5" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/property-information": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/property-information/-/property-information-7.1.0.tgz", + "integrity": "sha512-TwEZ+X+yCJmYfL7TPUOcvBZ4QfoT5YenQiJuX//0th53DE6w0xxLEtfK3iyryQFddXuvkIk51EEgrJQ0WJkOmQ==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/quansync": { + "version": "0.2.11", + "resolved": "https://registry.npmjs.org/quansync/-/quansync-0.2.11.tgz", + "integrity": "sha512-AifT7QEbW9Nri4tAwR5M/uzpBuqfZf+zwaEM/QkzEjj7NBuFD2rBuy0K3dE+8wltbezDV7JMA0WfnCPYRSYbXA==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/antfu" + }, + { + "type": "individual", + "url": "https://github.com/sponsors/sxzz" + } + ], + "license": "MIT" + }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/react": { + "version": "19.1.0", + "resolved": "https://registry.npmjs.org/react/-/react-19.1.0.tgz", + "integrity": "sha512-FS+XFBNvn3GTAWq26joslQgWNoFu08F4kl0J4CgdNKADkdSGXQyTCnKteIAJy96Br6YbpEU1LSzV5dYtjMkMDg==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react-docgen": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/react-docgen/-/react-docgen-8.0.0.tgz", + "integrity": "sha512-kmob/FOTwep7DUWf9KjuenKX0vyvChr3oTdvvPt09V60Iz75FJp+T/0ZeHMbAfJj2WaVWqAPP5Hmm3PYzSPPKg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/core": "^7.18.9", + "@babel/traverse": "^7.18.9", + "@babel/types": "^7.18.9", + "@types/babel__core": "^7.18.0", + "@types/babel__traverse": "^7.18.0", + "@types/doctrine": "^0.0.9", + "@types/resolve": "^1.20.2", + "doctrine": "^3.0.0", + "resolve": "^1.22.1", + "strip-indent": "^4.0.0" + }, + "engines": { + "node": "^20.9.0 || >=22" + } + }, + "node_modules/react-docgen-typescript": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/react-docgen-typescript/-/react-docgen-typescript-2.4.0.tgz", + "integrity": "sha512-ZtAp5XTO5HRzQctjPU0ybY0RRCQO19X/8fxn3w7y2VVTUbGHDKULPTL4ky3vB05euSgG5NpALhEhDPvQ56wvXg==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "typescript": ">= 4.3.x" + } + }, + "node_modules/react-dom": { + "version": "19.1.0", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.1.0.tgz", + "integrity": "sha512-Xs1hdnE+DyKgeHJeJznQmYMIBG3TKIHJJT95Q58nHLSrElKlGQqDTR2HQ9fx5CN/Gk6Vh/kupBTDLU11/nDk/g==", + "license": "MIT", + "dependencies": { + "scheduler": "^0.26.0" + }, + "peerDependencies": { + "react": "^19.1.0" + } + }, + "node_modules/react-is": { + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", + "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==", + "dev": true, + "license": "MIT" + }, + "node_modules/react-markdown": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/react-markdown/-/react-markdown-10.1.0.tgz", + "integrity": "sha512-qKxVopLT/TyA6BX3Ue5NwabOsAzm0Q7kAPwq6L+wWDwisYs7R8vZ0nRXqq6rkueboxpkjvLGU9fWifiX/ZZFxQ==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "@types/mdast": "^4.0.0", + "devlop": "^1.0.0", + "hast-util-to-jsx-runtime": "^2.0.0", + "html-url-attributes": "^3.0.0", + "mdast-util-to-hast": "^13.0.0", + "remark-parse": "^11.0.0", + "remark-rehype": "^11.0.0", + "unified": "^11.0.0", + "unist-util-visit": "^5.0.0", + "vfile": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + }, + "peerDependencies": { + "@types/react": ">=18", + "react": ">=18" + } + }, + "node_modules/react-refresh": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.17.0.tgz", + "integrity": "sha512-z6F7K9bV85EfseRCp2bzrpyQ0Gkw1uLoCel9XBVWPg/TjRj94SkJzUTGfOa4bs7iJvBWtQG0Wq7wnI0syw3EBQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "license": "MIT", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/recast": { + "version": "0.23.11", + "resolved": "https://registry.npmjs.org/recast/-/recast-0.23.11.tgz", + "integrity": "sha512-YTUo+Flmw4ZXiWfQKGcwwc11KnoRAYgzAE2E7mXKCjSviTKShtxBsN6YUUBB2gtaBzKzeKunxhUwNHQuRryhWA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ast-types": "^0.16.1", + "esprima": "~4.0.0", + "source-map": "~0.6.1", + "tiny-invariant": "^1.3.3", + "tslib": "^2.0.1" + }, + "engines": { + "node": ">= 4" + } + }, + "node_modules/redent": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/redent/-/redent-3.0.0.tgz", + "integrity": "sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==", + "dev": true, + "license": "MIT", + "dependencies": { + "indent-string": "^4.0.0", + "strip-indent": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/redent/node_modules/strip-indent": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-3.0.0.tgz", + "integrity": "sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "min-indent": "^1.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/refractor": { + "version": "4.9.0", + "resolved": "https://registry.npmjs.org/refractor/-/refractor-4.9.0.tgz", + "integrity": "sha512-nEG1SPXFoGGx+dcjftjv8cAjEusIh6ED1xhf5DG3C0x/k+rmZ2duKnc3QLpt6qeHv5fPb8uwN3VWN2BT7fr3Og==", + "license": "MIT", + "dependencies": { + "@types/hast": "^2.0.0", + "@types/prismjs": "^1.0.0", + "hastscript": "^7.0.0", + "parse-entities": "^4.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/refractor/node_modules/@types/hast": { + "version": "2.3.10", + "resolved": "https://registry.npmjs.org/@types/hast/-/hast-2.3.10.tgz", + "integrity": "sha512-McWspRw8xx8J9HurkVBfYj0xKoE25tOFlHGdx4MJ5xORQrMGZNqJhVQWaIbm6Oyla5kYOXtDiopzKRJzEOkwJw==", + "license": "MIT", + "dependencies": { + "@types/unist": "^2" + } + }, + "node_modules/refractor/node_modules/@types/unist": { + "version": "2.0.11", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.11.tgz", + "integrity": "sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA==", + "license": "MIT" + }, + "node_modules/refractor/node_modules/hast-util-parse-selector": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/hast-util-parse-selector/-/hast-util-parse-selector-3.1.1.tgz", + "integrity": "sha512-jdlwBjEexy1oGz0aJ2f4GKMaVKkA9jwjr4MjAAI22E5fM/TXVZHuS5OpONtdeIkRKqAaryQ2E9xNQxijoThSZA==", + "license": "MIT", + "dependencies": { + "@types/hast": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/refractor/node_modules/hastscript": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/hastscript/-/hastscript-7.2.0.tgz", + "integrity": "sha512-TtYPq24IldU8iKoJQqvZOuhi5CyCQRAbvDOX0x1eW6rsHSxa/1i2CCiptNTotGHJ3VoHRGmqiv6/D3q113ikkw==", + "license": "MIT", + "dependencies": { + "@types/hast": "^2.0.0", + "comma-separated-tokens": "^2.0.0", + "hast-util-parse-selector": "^3.0.0", + "property-information": "^6.0.0", + "space-separated-tokens": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/refractor/node_modules/property-information": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/property-information/-/property-information-6.5.0.tgz", + "integrity": "sha512-PgTgs/BlvHxOu8QuEN7wi5A0OmXaBcHpmCSTehcs6Uuu9IkDIEo13Hy7n898RHfrQ49vKCoGeWZSaAK01nwVig==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/regex": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/regex/-/regex-6.0.1.tgz", + "integrity": "sha512-uorlqlzAKjKQZ5P+kTJr3eeJGSVroLKoHmquUj4zHWuR+hEyNqlXsSKlYYF5F4NI6nl7tWCs0apKJ0lmfsXAPA==", + "license": "MIT", + "dependencies": { + "regex-utilities": "^2.3.0" + } + }, + "node_modules/regex-recursion": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/regex-recursion/-/regex-recursion-6.0.2.tgz", + "integrity": "sha512-0YCaSCq2VRIebiaUviZNs0cBz1kg5kVS2UKUfNIx8YVs1cN3AV7NTctO5FOKBA+UT2BPJIWZauYHPqJODG50cg==", + "license": "MIT", + "dependencies": { + "regex-utilities": "^2.3.0" + } + }, + "node_modules/regex-utilities": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/regex-utilities/-/regex-utilities-2.3.0.tgz", + "integrity": "sha512-8VhliFJAWRaUiVvREIiW2NXXTmHs4vMNnSzuJVhscgmGav3g9VDxLrQndI3dZZVVdp0ZO/5v0xmX516/7M9cng==", + "license": "MIT" + }, + "node_modules/rehype-harden": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/rehype-harden/-/rehype-harden-1.1.5.tgz", + "integrity": "sha512-JrtBj5BVd/5vf3H3/blyJatXJbzQfRT9pJBmjafbTaPouQCAKxHwRyCc7dle9BXQKxv4z1OzZylz/tNamoiG3A==", + "license": "MIT" + }, + "node_modules/rehype-katex": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/rehype-katex/-/rehype-katex-7.0.1.tgz", + "integrity": "sha512-OiM2wrZ/wuhKkigASodFoo8wimG3H12LWQaH8qSPVJn9apWKFSH3YOCtbKpBorTVw/eI7cuT21XBbvwEswbIOA==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "@types/katex": "^0.16.0", + "hast-util-from-html-isomorphic": "^2.0.0", + "hast-util-to-text": "^4.0.0", + "katex": "^0.16.0", + "unist-util-visit-parents": "^6.0.0", + "vfile": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/rehype-parse": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/rehype-parse/-/rehype-parse-9.0.1.tgz", + "integrity": "sha512-ksCzCD0Fgfh7trPDxr2rSylbwq9iYDkSn8TCDmEJ49ljEUBxDVCzCHv7QNzZOfODanX4+bWQ4WZqLCRWYLfhag==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "hast-util-from-html": "^2.0.0", + "unified": "^11.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/rehype-prism-plus": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/rehype-prism-plus/-/rehype-prism-plus-2.0.1.tgz", + "integrity": "sha512-Wglct0OW12tksTUseAPyWPo3srjBOY7xKlql/DPKi7HbsdZTyaLCAoO58QBKSczFQxElTsQlOY3JDOFzB/K++Q==", + "license": "MIT", + "dependencies": { + "hast-util-to-string": "^3.0.0", + "parse-numeric-range": "^1.3.0", + "refractor": "^4.8.0", + "rehype-parse": "^9.0.0", + "unist-util-filter": "^5.0.0", + "unist-util-visit": "^5.0.0" + } + }, + "node_modules/rehype-raw": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/rehype-raw/-/rehype-raw-7.0.0.tgz", + "integrity": "sha512-/aE8hCfKlQeA8LmyeyQvQF3eBiLRGNlfBJEvWH7ivp9sBqs7TNqBL5X3v157rM4IFETqDnIOO+z5M/biZbo9Ww==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "hast-util-raw": "^9.0.0", + "vfile": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/rehype-sanitize": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/rehype-sanitize/-/rehype-sanitize-6.0.0.tgz", + "integrity": "sha512-CsnhKNsyI8Tub6L4sm5ZFsme4puGfc6pYylvXo1AeqaGbjOYyzNv3qZPwvs0oMJ39eryyeOdmxwUIo94IpEhqg==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "hast-util-sanitize": "^5.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/remark": { + "version": "15.0.1", + "resolved": "https://registry.npmjs.org/remark/-/remark-15.0.1.tgz", + "integrity": "sha512-Eht5w30ruCXgFmxVUSlNWQ9iiimq07URKeFS3hNc8cUWy1llX4KDWfyEDZRycMc+znsN9Ux5/tJ/BFdgdOwA3A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "remark-parse": "^11.0.0", + "remark-stringify": "^11.0.0", + "unified": "^11.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/remark-gfm": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/remark-gfm/-/remark-gfm-4.0.1.tgz", + "integrity": "sha512-1quofZ2RQ9EWdeN34S79+KExV1764+wCUGop5CPL1WGdD0ocPpu91lzPGbwWMECpEpd42kJGQwzRfyov9j4yNg==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "mdast-util-gfm": "^3.0.0", + "micromark-extension-gfm": "^3.0.0", + "remark-parse": "^11.0.0", + "remark-stringify": "^11.0.0", + "unified": "^11.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/remark-math": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/remark-math/-/remark-math-6.0.0.tgz", + "integrity": "sha512-MMqgnP74Igy+S3WwnhQ7kqGlEerTETXMvJhrUzDikVZ2/uogJCb+WHUg97hK9/jcfc0dkD73s3LN8zU49cTEtA==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "mdast-util-math": "^3.0.0", + "micromark-extension-math": "^3.0.0", + "unified": "^11.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/remark-parse": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/remark-parse/-/remark-parse-11.0.0.tgz", + "integrity": "sha512-FCxlKLNGknS5ba/1lmpYijMUzX2esxW5xQqjWxw2eHFfS2MSdaHVINFmhjo+qN1WhZhNimq0dZATN9pH0IDrpA==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "mdast-util-from-markdown": "^2.0.0", + "micromark-util-types": "^2.0.0", + "unified": "^11.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/remark-rehype": { + "version": "11.1.2", + "resolved": "https://registry.npmjs.org/remark-rehype/-/remark-rehype-11.1.2.tgz", + "integrity": "sha512-Dh7l57ianaEoIpzbp0PC9UKAdCSVklD8E5Rpw7ETfbTl3FqcOOgq5q2LVDhgGCkaBv7p24JXikPdvhhmHvKMsw==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "@types/mdast": "^4.0.0", + "mdast-util-to-hast": "^13.0.0", + "unified": "^11.0.0", + "vfile": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/remark-stringify": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/remark-stringify/-/remark-stringify-11.0.0.tgz", + "integrity": "sha512-1OSmLd3awB/t8qdoEOMazZkNsfVTeY4fTsgzcQFdXNq8ToTN4ZGwrMnlda4K6smTFKD+GRV6O48i6Z4iKgPPpw==", + "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0", + "mdast-util-to-markdown": "^2.0.0", + "unified": "^11.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/resolve": { + "version": "1.22.10", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.10.tgz", + "integrity": "sha512-NPRy+/ncIMeDlTAsuqwKIiferiawhefFJtkNSW0qZJEqMEb+qBt/77B/jGeeek+F0uOeN05CDa6HXbbIgtVX4w==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-core-module": "^2.16.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/resolve-pkg-maps": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", + "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" + } + }, + "node_modules/reusify": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.1.0.tgz", + "integrity": "sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==", + "dev": true, + "license": "MIT", + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, + "node_modules/robust-predicates": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/robust-predicates/-/robust-predicates-3.0.2.tgz", + "integrity": "sha512-IXgzBWvWQwE6PrDI05OvmXUIruQTcoMDzRsOd5CDvHCVLcLHMTSYvOK5Cm46kWqlV3yAbuSpBZdJ5oP5OUoStg==", + "license": "Unlicense" + }, + "node_modules/rollup": { + "version": "4.42.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.42.0.tgz", + "integrity": "sha512-LW+Vse3BJPyGJGAJt1j8pWDKPd73QM8cRXYK1IxOBgL2AGLu7Xd2YOW0M2sLUBCkF5MshXXtMApyEAEzMVMsnw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "1.0.7" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.42.0", + "@rollup/rollup-android-arm64": "4.42.0", + "@rollup/rollup-darwin-arm64": "4.42.0", + "@rollup/rollup-darwin-x64": "4.42.0", + "@rollup/rollup-freebsd-arm64": "4.42.0", + "@rollup/rollup-freebsd-x64": "4.42.0", + "@rollup/rollup-linux-arm-gnueabihf": "4.42.0", + "@rollup/rollup-linux-arm-musleabihf": "4.42.0", + "@rollup/rollup-linux-arm64-gnu": "4.42.0", + "@rollup/rollup-linux-arm64-musl": "4.42.0", + "@rollup/rollup-linux-loongarch64-gnu": "4.42.0", + "@rollup/rollup-linux-powerpc64le-gnu": "4.42.0", + "@rollup/rollup-linux-riscv64-gnu": "4.42.0", + "@rollup/rollup-linux-riscv64-musl": "4.42.0", + "@rollup/rollup-linux-s390x-gnu": "4.42.0", + "@rollup/rollup-linux-x64-gnu": "4.42.0", + "@rollup/rollup-linux-x64-musl": "4.42.0", + "@rollup/rollup-win32-arm64-msvc": "4.42.0", + "@rollup/rollup-win32-ia32-msvc": "4.42.0", + "@rollup/rollup-win32-x64-msvc": "4.42.0", + "fsevents": "~2.3.2" + } + }, + "node_modules/rollup/node_modules/@types/estree": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.7.tgz", + "integrity": "sha512-w28IoSUCJpidD/TGviZwwMJckNESJZXFu7NBZ5YJ4mEUnNraUn9Pm8HSZm/jDF1pDWYKspWE7oVphigUPRakIQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/roughjs": { + "version": "4.6.6", + "resolved": "https://registry.npmjs.org/roughjs/-/roughjs-4.6.6.tgz", + "integrity": "sha512-ZUz/69+SYpFN/g/lUlo2FXcIjRkSu3nDarreVdGGndHEBJ6cXPdKguS8JGxwj5HA5xIbVKSmLgr5b3AWxtRfvQ==", + "license": "MIT", + "dependencies": { + "hachure-fill": "^0.5.2", + "path-data-parser": "^0.1.0", + "points-on-curve": "^0.2.0", + "points-on-path": "^0.2.1" + } + }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, + "node_modules/rw": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/rw/-/rw-1.3.3.tgz", + "integrity": "sha512-PdhdWy89SiZogBLaw42zdeqtRJ//zFd2PgQavcICDUgJT5oW10QCRKbJ6bg4r0/UY2M6BWd5tkxuGFRvCkgfHQ==", + "license": "BSD-3-Clause" + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT" + }, + "node_modules/scheduler": { + "version": "0.26.0", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.26.0.tgz", + "integrity": "sha512-NlHwttCI/l5gCPR3D1nNXtWABUmBwvZpEQiD4IXSbIDq8BzLIK/7Ir5gTFSGZDUu37K5cMNp0hFtzO38sC7gWA==", + "license": "MIT" + }, + "node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/seroval": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/seroval/-/seroval-1.3.2.tgz", + "integrity": "sha512-RbcPH1n5cfwKrru7v7+zrZvjLurgHhGyso3HTyGtRivGWgYjbOmGuivCQaORNELjNONoK35nj28EoWul9sb1zQ==", + "license": "MIT", + "engines": { + "node": ">=10" + } + }, + "node_modules/seroval-plugins": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/seroval-plugins/-/seroval-plugins-1.3.2.tgz", + "integrity": "sha512-0QvCV2lM3aj/U3YozDiVwx9zpH0q8A60CTWIv4Jszj/givcudPb48B+rkU5D51NJ0pTpweGMttHjboPa9/zoIQ==", + "license": "MIT", + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "seroval": "^1.0" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/shiki": { + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-3.14.0.tgz", + "integrity": "sha512-J0yvpLI7LSig3Z3acIuDLouV5UCKQqu8qOArwMx+/yPVC3WRMgrP67beaG8F+j4xfEWE0eVC4GeBCIXeOPra1g==", + "license": "MIT", + "dependencies": { + "@shikijs/core": "3.14.0", + "@shikijs/engine-javascript": "3.14.0", + "@shikijs/engine-oniguruma": "3.14.0", + "@shikijs/langs": "3.14.0", + "@shikijs/themes": "3.14.0", + "@shikijs/types": "3.14.0", + "@shikijs/vscode-textmate": "^10.0.2", + "@types/hast": "^3.0.4" + } + }, + "node_modules/siginfo": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", + "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==", + "dev": true, + "license": "ISC" + }, + "node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/sirv": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/sirv/-/sirv-3.0.1.tgz", + "integrity": "sha512-FoqMu0NCGBLCcAkS1qA+XJIQTR6/JHfQXl+uGteNCQ76T91DMUjPa9xfmeqMY3z80nLSg9yQmNjK0Px6RWsH/A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@polka/url": "^1.0.0-next.24", + "mrmime": "^2.0.0", + "totalist": "^3.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/sisteransi": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", + "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==", + "dev": true, + "license": "MIT" + }, + "node_modules/solid-js": { + "version": "1.9.7", + "resolved": "https://registry.npmjs.org/solid-js/-/solid-js-1.9.7.tgz", + "integrity": "sha512-/saTKi8iWEM233n5OSi1YHCCuh66ZIQ7aK2hsToPe4tqGm7qAejU1SwNuTPivbWAYq7SjuHVVYxxuZQNRbICiw==", + "license": "MIT", + "dependencies": { + "csstype": "^3.1.0", + "seroval": "~1.3.0", + "seroval-plugins": "~1.3.0" + } + }, + "node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/space-separated-tokens": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-2.0.2.tgz", + "integrity": "sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/stackback": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", + "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==", + "dev": true, + "license": "MIT" + }, + "node_modules/std-env": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.9.0.tgz", + "integrity": "sha512-UGvjygr6F6tpH7o2qyqR6QYpwraIjKSdtzyBdyytFOHmPZY917kwdwLG0RbOjWOnKmnm3PeHjaoLLMie7kPLQw==", + "dev": true, + "license": "MIT" + }, + "node_modules/storybook": { + "version": "9.0.14", + "resolved": "https://registry.npmjs.org/storybook/-/storybook-9.0.14.tgz", + "integrity": "sha512-PfVo9kSa4XsDTD2gXFvMRGix032+clBDcUMI4MhUzYxONLiZifnhwch4p/1lG+c3IVN4qkOEgGNc9PEgVMgApw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@storybook/global": "^5.0.0", + "@testing-library/jest-dom": "^6.6.3", + "@testing-library/user-event": "^14.6.1", + "@vitest/expect": "3.2.4", + "@vitest/spy": "3.2.4", + "better-opn": "^3.0.2", + "esbuild": "^0.18.0 || ^0.19.0 || ^0.20.0 || ^0.21.0 || ^0.22.0 || ^0.23.0 || ^0.24.0 || ^0.25.0", + "esbuild-register": "^3.5.0", + "recast": "^0.23.5", + "semver": "^7.6.2", + "ws": "^8.18.0" + }, + "bin": { + "storybook": "bin/index.cjs" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/storybook" + }, + "peerDependencies": { + "prettier": "^2 || ^3" + }, + "peerDependenciesMeta": { + "prettier": { + "optional": true + } + } + }, + "node_modules/storybook/node_modules/semver": { + "version": "7.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz", + "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/streamdown": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/streamdown/-/streamdown-1.4.0.tgz", + "integrity": "sha512-ylhDSQ4HpK5/nAH9v7OgIIdGJxlJB2HoYrYkJNGrO8lMpnWuKUcrz/A8xAMwA6eILA27469vIavcOTjmxctrKg==", + "license": "Apache-2.0", + "dependencies": { + "clsx": "^2.1.1", + "katex": "^0.16.22", + "lucide-react": "^0.542.0", + "marked": "^16.2.1", + "mermaid": "^11.11.0", + "react-markdown": "^10.1.0", + "rehype-harden": "^1.1.5", + "rehype-katex": "^7.0.1", + "rehype-raw": "^7.0.0", + "remark-gfm": "^4.0.1", + "remark-math": "^6.0.0", + "shiki": "^3.12.2", + "tailwind-merge": "^3.3.1" + }, + "peerDependencies": { + "react": "^18.0.0 || ^19.0.0" + } + }, + "node_modules/string-width": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", + "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "eastasianwidth": "^0.2.0", + "emoji-regex": "^9.2.2", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/string-width-cjs": { + "name": "string-width", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width-cjs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true, + "license": "MIT" + }, + "node_modules/string-width-cjs/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/stringify-entities": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/stringify-entities/-/stringify-entities-4.0.4.tgz", + "integrity": "sha512-IwfBptatlO+QCJUo19AqvrPNqlVMpW9YEL2LIVY+Rpv2qsjCGxaDLNRgeGsQWJhfItebuJhsGSLjaBbNSQ+ieg==", + "license": "MIT", + "dependencies": { + "character-entities-html4": "^2.0.0", + "character-entities-legacy": "^3.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/strip-ansi-cjs": { + "name": "strip-ansi", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi/node_modules/ansi-regex": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", + "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/strip-indent": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-4.0.0.tgz", + "integrity": "sha512-mnVSV2l+Zv6BLpSD/8V87CW/y9EmmbYzGCIavsnsI6/nwn26DwffM/yztm30Z/I2DY9wdS3vXVCMnHDgZaVNoA==", + "dev": true, + "license": "MIT", + "dependencies": { + "min-indent": "^1.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/strip-literal": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-literal/-/strip-literal-3.0.0.tgz", + "integrity": "sha512-TcccoMhJOM3OebGhSBEmp3UZ2SfDMZUEBdRA/9ynfLi8yYajyWX3JiXArcJt4Umh4vISpspkQIY8ZZoCqjbviA==", + "dev": true, + "license": "MIT", + "dependencies": { + "js-tokens": "^9.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/strip-literal/node_modules/js-tokens": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-9.0.1.tgz", + "integrity": "sha512-mxa9E9ITFOt0ban3j6L5MpjwegGz6lBQmM1IJkWeBZGcMxto50+eWdjC/52xDbS2vy0k7vIMK0Fe2wfL9OQSpQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/style-to-js": { + "version": "1.1.16", + "resolved": "https://registry.npmjs.org/style-to-js/-/style-to-js-1.1.16.tgz", + "integrity": "sha512-/Q6ld50hKYPH3d/r6nr117TZkHR0w0kGGIVfpG9N6D8NymRPM9RqCUv4pRpJ62E5DqOYx2AFpbZMyCPnjQCnOw==", + "license": "MIT", + "dependencies": { + "style-to-object": "1.0.8" + } + }, + "node_modules/style-to-object": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/style-to-object/-/style-to-object-1.0.8.tgz", + "integrity": "sha512-xT47I/Eo0rwJmaXC4oilDGDWLohVhR6o/xAQcPQN8q6QBuZVL8qMYL85kLmST5cPjAorwvqIA4qXTRQoYHaL6g==", + "license": "MIT", + "dependencies": { + "inline-style-parser": "0.2.4" + } + }, + "node_modules/stylis": { + "version": "4.3.6", + "resolved": "https://registry.npmjs.org/stylis/-/stylis-4.3.6.tgz", + "integrity": "sha512-yQ3rwFWRfwNUY7H5vpU0wfdkNSnvnJinhF9830Swlaxl03zsOjCfmX0ugac+3LtK0lYSgwL/KXc8oYL3mG4YFQ==", + "license": "MIT" + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/tabbable": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/tabbable/-/tabbable-6.2.0.tgz", + "integrity": "sha512-Cat63mxsVJlzYvN51JmVXIgNoUokrIaT2zLclCXjRd8boZ0004U4KCs/sToJ75C6sdlByWxpYnb5Boif1VSFew==" + }, + "node_modules/tailwind-merge": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-3.3.1.tgz", + "integrity": "sha512-gBXpgUm/3rp1lMZZrM/w7D8GKqshif0zAymAhbCyIt8KMe+0v9DQ7cdYLR4FHH/cKpdTXb+A/tKKU3eolfsI+g==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/dcastil" + } + }, + "node_modules/tailwindcss": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.1.11.tgz", + "integrity": "sha512-2E9TBm6MDD/xKYe+dvJZAmg3yxIEDNRc0jwlNyDg/4Fil2QcSLjFKGVff0lAf1jjeaArlG/M75Ey/EYr/OJtBA==", + "dev": true, + "license": "MIT" + }, + "node_modules/tapable": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.2.tgz", + "integrity": "sha512-Re10+NauLTMCudc7T5WLFLAwDhQ0JWdrMK+9B2M8zR5hRExKmsRDCBA7/aV/pNJFltmBFO5BAMlQFi/vq3nKOg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/tar": { + "version": "7.4.3", + "resolved": "https://registry.npmjs.org/tar/-/tar-7.4.3.tgz", + "integrity": "sha512-5S7Va8hKfV7W5U6g3aYxXmlPoZVAwUMy9AOKyF2fVuZa2UD3qZjg578OrLRt8PcNN1PleVaL/5/yYATNL0ICUw==", + "dev": true, + "license": "ISC", + "dependencies": { + "@isaacs/fs-minipass": "^4.0.0", + "chownr": "^3.0.0", + "minipass": "^7.1.2", + "minizlib": "^3.0.1", + "mkdirp": "^3.0.1", + "yallist": "^5.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/tar/node_modules/yallist": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-5.0.0.tgz", + "integrity": "sha512-YgvUTfwqyc7UXVMrB+SImsVYSmTS8X/tSrtdNZMImM+n7+QTriRXyXim0mBrTXNeqzVF0KWGgHPeiyViFFrNDw==", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": ">=18" + } + }, + "node_modules/test-exclude": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-7.0.1.tgz", + "integrity": "sha512-pFYqmTw68LXVjeWJMST4+borgQP2AyMNbg1BpZh9LbyhUeNkeaPF9gzfPGUAnSMV3qPYdWUwDIjjCLiSDOl7vg==", + "dev": true, + "license": "ISC", + "dependencies": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^10.4.1", + "minimatch": "^9.0.4" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/test-exclude/node_modules/brace-expansion": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", + "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/test-exclude/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/tiny-invariant": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.3.3.tgz", + "integrity": "sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg==", + "license": "MIT" + }, + "node_modules/tiny-warning": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/tiny-warning/-/tiny-warning-1.0.3.tgz", + "integrity": "sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA==", + "license": "MIT" + }, + "node_modules/tinybench": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", + "integrity": "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==", + "dev": true, + "license": "MIT" + }, + "node_modules/tinyexec": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-0.3.2.tgz", + "integrity": "sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==", + "dev": true, + "license": "MIT" + }, + "node_modules/tinyglobby": { + "version": "0.2.14", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.14.tgz", + "integrity": "sha512-tX5e7OM1HnYr2+a2C/4V0htOcSQcoSTH9KgJnVvNm5zm/cyEWKJ7j7YutsH9CxMdtOkkLFy2AHrMci9IM8IPZQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.4.4", + "picomatch": "^4.0.2" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/tinyglobby/node_modules/fdir": { + "version": "6.4.5", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.5.tgz", + "integrity": "sha512-4BG7puHpVsIYxZUbiUE3RqGloLaSSwzYie5jvasC4LWuBWzZawynvYouhjbQKw2JuIGYdm0DzIxl8iVidKlUEw==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/tinyglobby/node_modules/picomatch": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", + "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/tinypool": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-1.1.1.tgz", + "integrity": "sha512-Zba82s87IFq9A9XmjiX5uZA/ARWDrB03OHlq+Vw1fSdt0I+4/Kutwy8BP4Y/y/aORMo61FQ0vIb5j44vSo5Pkg==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.0.0 || >=20.0.0" + } + }, + "node_modules/tinyrainbow": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-2.0.0.tgz", + "integrity": "sha512-op4nsTR47R6p0vMUUoYl/a+ljLFVtlfaXkLQmqfLR1qHma1h/ysYk4hEXZ880bf2CYgTskvTa/e196Vd5dDQXw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/tinyspy": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-4.0.3.tgz", + "integrity": "sha512-t2T/WLB2WRgZ9EpE4jgPJ9w+i66UZfDc8wHh0xrwiRNN+UwH98GIJkTeZqX9rg0i0ptwzqW+uYeIF0T4F8LR7A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/totalist": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/totalist/-/totalist-3.0.1.tgz", + "integrity": "sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/trim-lines": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/trim-lines/-/trim-lines-3.0.1.tgz", + "integrity": "sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/trough": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/trough/-/trough-2.2.0.tgz", + "integrity": "sha512-tmMpK00BjZiUyVyvrBK7knerNgmgvcV/KLVyuma/SC+TQN167GrMRciANTz09+k3zW8L8t60jWO1GpfkZdjTaw==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/ts-api-utils": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.1.0.tgz", + "integrity": "sha512-CUgTZL1irw8u29bzrOD/nH85jqyc74D6SshFgujOIA7osm2Rz7dYH77agkx7H4FBNxDq7Cjf+IjaX/8zwFW+ZQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18.12" + }, + "peerDependencies": { + "typescript": ">=4.8.4" + } + }, + "node_modules/ts-dedent": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/ts-dedent/-/ts-dedent-2.2.0.tgz", + "integrity": "sha512-q5W7tVM71e2xjHZTlgfTDoPF/SmqKG5hddq9SzR49CH2hayqRKJtQ4mtRlSxKaJlR/+9rEM+mnBHf7I2/BQcpQ==", + "license": "MIT", + "engines": { + "node": ">=6.10" + } + }, + "node_modules/tsconfck": { + "version": "3.1.6", + "resolved": "https://registry.npmjs.org/tsconfck/-/tsconfck-3.1.6.tgz", + "integrity": "sha512-ks6Vjr/jEw0P1gmOVwutM3B7fWxoWBL2KRDb1JfqGVawBmO5UsvmWOQFGHBPl5yxYz4eERr19E6L7NMv+Fej4w==", + "dev": true, + "license": "MIT", + "bin": { + "tsconfck": "bin/tsconfck.js" + }, + "engines": { + "node": "^18 || >=20" + }, + "peerDependencies": { + "typescript": "^5.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/tsconfig-paths": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-4.2.0.tgz", + "integrity": "sha512-NoZ4roiN7LnbKn9QqE1amc9DJfzvZXxF4xDavcOWt1BPkdx+m+0gJuPM+S0vCe7zTJMYUP0R8pO2XMr+Y8oLIg==", + "dev": true, + "license": "MIT", + "dependencies": { + "json5": "^2.2.2", + "minimist": "^1.2.6", + "strip-bom": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==" + }, + "node_modules/tsx": { + "version": "4.19.4", + "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.19.4.tgz", + "integrity": "sha512-gK5GVzDkJK1SI1zwHf32Mqxf2tSJkNx+eYcNly5+nHvWqXUJYUkWBQtKauoESz3ymezAI++ZwT855x5p5eop+Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "~0.25.0", + "get-tsconfig": "^4.7.5" + }, + "bin": { + "tsx": "dist/cli.mjs" + }, + "engines": { + "node": ">=18.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + } + }, + "node_modules/type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "license": "MIT", + "dependencies": { + "prelude-ls": "^1.2.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/typescript": { + "version": "5.8.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", + "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/typescript-eslint": { + "version": "8.34.0", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.34.0.tgz", + "integrity": "sha512-MRpfN7uYjTrTGigFCt8sRyNqJFhjN0WwZecldaqhWm+wy0gaRt8Edb/3cuUy0zdq2opJWT6iXINKAtewnDOltQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/eslint-plugin": "8.34.0", + "@typescript-eslint/parser": "8.34.0", + "@typescript-eslint/utils": "8.34.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.9.0" + } + }, + "node_modules/ufo": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.6.1.tgz", + "integrity": "sha512-9a4/uxlTWJ4+a5i0ooc1rU7C7YOw3wT+UGqdeNNHWnOF9qcMBgLRS+4IYUqbczewFx4mLEig6gawh7X6mFlEkA==", + "license": "MIT" + }, + "node_modules/undici-types": { + "version": "7.14.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.14.0.tgz", + "integrity": "sha512-QQiYxHuyZ9gQUIrmPo3IA+hUl4KYk8uSA7cHrcKd/l3p1OTpZcM0Tbp9x7FAtXdAYhlasd60ncPpgu6ihG6TOA==", + "dev": true, + "license": "MIT" + }, + "node_modules/unicorn-magic": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/unicorn-magic/-/unicorn-magic-0.1.0.tgz", + "integrity": "sha512-lRfVq8fE8gz6QMBuDM6a+LO3IAzTi05H6gCVaUpir2E1Rwpo4ZUog45KpNXKC/Mn3Yb9UDuHumeFTo9iV/D9FQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/unified": { + "version": "11.0.5", + "resolved": "https://registry.npmjs.org/unified/-/unified-11.0.5.tgz", + "integrity": "sha512-xKvGhPWw3k84Qjh8bI3ZeJjqnyadK+GEFtazSfZv/rKeTkTjOJho6mFqh2SM96iIcZokxiOpg78GazTSg8+KHA==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "bail": "^2.0.0", + "devlop": "^1.0.0", + "extend": "^3.0.0", + "is-plain-obj": "^4.0.0", + "trough": "^2.0.0", + "vfile": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-builder": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/unist-builder/-/unist-builder-4.0.0.tgz", + "integrity": "sha512-wmRFnH+BLpZnTKpc5L7O67Kac89s9HMrtELpnNaE6TAobq5DTZZs5YaTQfAZBA9bFPECx2uVAPO31c+GVug8mg==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-util-filter": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/unist-util-filter/-/unist-util-filter-5.0.1.tgz", + "integrity": "sha512-pHx7D4Zt6+TsfwylH9+lYhBhzyhEnCXs/lbq/Hstxno5z4gVdyc2WEW0asfjGKPyG4pEKrnBv5hdkO6+aRnQJw==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "unist-util-is": "^6.0.0", + "unist-util-visit-parents": "^6.0.0" + } + }, + "node_modules/unist-util-find-after": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/unist-util-find-after/-/unist-util-find-after-5.0.0.tgz", + "integrity": "sha512-amQa0Ep2m6hE2g72AugUItjbuM8X8cGQnFoHk0pGfrFeT9GZhzN5SW8nRsiGKK7Aif4CrACPENkA6P/Lw6fHGQ==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "unist-util-is": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-util-is": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", + "integrity": "sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-util-parents": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/unist-util-parents/-/unist-util-parents-3.0.0.tgz", + "integrity": "sha512-3DVSfp+MkJhcJbGn/W7aOlZYVpsMQQ054cpfbPHZAqYPu/lvu5rCdzjuIt4eEMriLkCWLcnJjax97Awm1Bkhtg==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-util-position": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-5.0.0.tgz", + "integrity": "sha512-fucsC7HjXvkB5R3kTCO7kUjRdrS0BJt3M/FPxmHMBOm8JQi2BsHAHFsy27E0EolP8rp0NzXsJ+jNPyDWvOJZPA==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-util-remove-position": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/unist-util-remove-position/-/unist-util-remove-position-5.0.0.tgz", + "integrity": "sha512-Hp5Kh3wLxv0PHj9m2yZhhLt58KzPtEYKQQ4yxfYFEO7EvHwzyDYnduhHnY1mDxoqr7VUwVuHXk9RXKIiYS1N8Q==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "unist-util-visit": "^5.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-util-stringify-position": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-4.0.0.tgz", + "integrity": "sha512-0ASV06AAoKCDkS2+xw5RXJywruurpbC4JZSm7nr7MOt1ojAzvyyaO+UxZf18j8FCF6kmzCZKcAgN/yu2gm2XgQ==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-util-visit": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz", + "integrity": "sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "unist-util-is": "^6.0.0", + "unist-util-visit-parents": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/unist-util-visit-parents": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz", + "integrity": "sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "unist-util-is": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/universalify": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", + "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 10.0.0" + } + }, + "node_modules/unplugin": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/unplugin/-/unplugin-2.3.5.tgz", + "integrity": "sha512-RyWSb5AHmGtjjNQ6gIlA67sHOsWpsbWpwDokLwTcejVdOjEkJZh7QKu14J00gDDVSh8kGH4KYC/TNBceXFZhtw==", + "dev": true, + "license": "MIT", + "dependencies": { + "acorn": "^8.14.1", + "picomatch": "^4.0.2", + "webpack-virtual-modules": "^0.6.2" + }, + "engines": { + "node": ">=18.12.0" + } + }, + "node_modules/unplugin/node_modules/picomatch": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", + "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/update-browserslist-db": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.3.tgz", + "integrity": "sha512-UxhIZQ+QInVdunkDAaiazvvT/+fXL5Osr0JZlJulepYu6Jd7qJtDZjlur0emRlT71EN3ScPoE7gvsuIKKNavKw==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "escalade": "^3.2.0", + "picocolors": "^1.1.1" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/use-sync-external-store": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.5.0.tgz", + "integrity": "sha512-Rb46I4cGGVBmjamjphe8L/UnvJD+uPPtTkNvX5mZgqdbavhI4EbgIWJiIHXJ8bc/i9EQGPRh4DwEURJ552Do0A==", + "license": "MIT", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "dev": true, + "license": "MIT" + }, + "node_modules/uuid": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-11.1.0.tgz", + "integrity": "sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "license": "MIT", + "bin": { + "uuid": "dist/esm/bin/uuid" + } + }, + "node_modules/vfile": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/vfile/-/vfile-6.0.3.tgz", + "integrity": "sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "vfile-message": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/vfile-location": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-5.0.3.tgz", + "integrity": "sha512-5yXvWDEgqeiYiBe1lbxYF7UMAIm/IcopxMHrMQDq3nvKcjPKIhZklUKL+AE7J7uApI4kwe2snsK+eI6UTj9EHg==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "vfile": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/vfile-message": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-4.0.2.tgz", + "integrity": "sha512-jRDZ1IMLttGj41KcZvlrYAaI3CfqpLpfpf+Mfig13viT6NKvRzWZ+lXz0Y5D60w6uJIBAOGq9mSHf0gktF0duw==", + "license": "MIT", + "dependencies": { + "@types/unist": "^3.0.0", + "unist-util-stringify-position": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/vite": { + "version": "6.3.5", + "resolved": "https://registry.npmjs.org/vite/-/vite-6.3.5.tgz", + "integrity": "sha512-cZn6NDFE7wdTpINgs++ZJ4N49W2vRp8LCKrn3Ob1kYNtOo21vfDoaV5GzBfLU4MovSAB8uNRm4jgzVQZ+mBzPQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "^0.25.0", + "fdir": "^6.4.4", + "picomatch": "^4.0.2", + "postcss": "^8.5.3", + "rollup": "^4.34.9", + "tinyglobby": "^0.2.13" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^18.0.0 || ^20.0.0 || >=22.0.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0", + "jiti": ">=1.21.0", + "less": "*", + "lightningcss": "^1.21.0", + "sass": "*", + "sass-embedded": "*", + "stylus": "*", + "sugarss": "*", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "node_modules/vite-node": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-3.2.4.tgz", + "integrity": "sha512-EbKSKh+bh1E1IFxeO0pg1n4dvoOTt0UDiXMd/qn++r98+jPO1xtJilvXldeuQ8giIB5IkpjCgMleHMNEsGH6pg==", + "dev": true, + "license": "MIT", + "dependencies": { + "cac": "^6.7.14", + "debug": "^4.4.1", + "es-module-lexer": "^1.7.0", + "pathe": "^2.0.3", + "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0" + }, + "bin": { + "vite-node": "vite-node.mjs" + }, + "engines": { + "node": "^18.0.0 || ^20.0.0 || >=22.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/vite-tsconfig-paths": { + "version": "5.1.4", + "resolved": "https://registry.npmjs.org/vite-tsconfig-paths/-/vite-tsconfig-paths-5.1.4.tgz", + "integrity": "sha512-cYj0LRuLV2c2sMqhqhGpaO3LretdtMn/BVX4cPLanIZuwwrkVl+lK84E/miEXkCHWXuq65rhNN4rXsBcOB3S4w==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^4.1.1", + "globrex": "^0.1.2", + "tsconfck": "^3.0.3" + }, + "peerDependencies": { + "vite": "*" + }, + "peerDependenciesMeta": { + "vite": { + "optional": true + } + } + }, + "node_modules/vite/node_modules/fdir": { + "version": "6.4.5", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.5.tgz", + "integrity": "sha512-4BG7puHpVsIYxZUbiUE3RqGloLaSSwzYie5jvasC4LWuBWzZawynvYouhjbQKw2JuIGYdm0DzIxl8iVidKlUEw==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/vite/node_modules/picomatch": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", + "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/vitest": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-3.2.4.tgz", + "integrity": "sha512-LUCP5ev3GURDysTWiP47wRRUpLKMOfPh+yKTx3kVIEiu5KOMeqzpnYNsKyOoVrULivR8tLcks4+lga33Whn90A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/chai": "^5.2.2", + "@vitest/expect": "3.2.4", + "@vitest/mocker": "3.2.4", + "@vitest/pretty-format": "^3.2.4", + "@vitest/runner": "3.2.4", + "@vitest/snapshot": "3.2.4", + "@vitest/spy": "3.2.4", + "@vitest/utils": "3.2.4", + "chai": "^5.2.0", + "debug": "^4.4.1", + "expect-type": "^1.2.1", + "magic-string": "^0.30.17", + "pathe": "^2.0.3", + "picomatch": "^4.0.2", + "std-env": "^3.9.0", + "tinybench": "^2.9.0", + "tinyexec": "^0.3.2", + "tinyglobby": "^0.2.14", + "tinypool": "^1.1.1", + "tinyrainbow": "^2.0.0", + "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0", + "vite-node": "3.2.4", + "why-is-node-running": "^2.3.0" + }, + "bin": { + "vitest": "vitest.mjs" + }, + "engines": { + "node": "^18.0.0 || ^20.0.0 || >=22.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@edge-runtime/vm": "*", + "@types/debug": "^4.1.12", + "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0", + "@vitest/browser": "3.2.4", + "@vitest/ui": "3.2.4", + "happy-dom": "*", + "jsdom": "*" + }, + "peerDependenciesMeta": { + "@edge-runtime/vm": { + "optional": true + }, + "@types/debug": { + "optional": true + }, + "@types/node": { + "optional": true + }, + "@vitest/browser": { + "optional": true + }, + "@vitest/ui": { + "optional": true + }, + "happy-dom": { + "optional": true + }, + "jsdom": { + "optional": true + } + } + }, + "node_modules/vitest/node_modules/picomatch": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", + "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/vscode-jsonrpc": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.2.0.tgz", + "integrity": "sha512-C+r0eKJUIfiDIfwJhria30+TYWPtuHJXHtI7J0YlOmKAo7ogxP20T0zxB7HZQIFhIyvoBPwWskjxrvAtfjyZfA==", + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/vscode-languageserver": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-9.0.1.tgz", + "integrity": "sha512-woByF3PDpkHFUreUa7Hos7+pUWdeWMXRd26+ZX2A8cFx6v/JPTtd4/uN0/jB6XQHYaOlHbio03NTHCqrgG5n7g==", + "license": "MIT", + "dependencies": { + "vscode-languageserver-protocol": "3.17.5" + }, + "bin": { + "installServerIntoExtension": "bin/installServerIntoExtension" + } + }, + "node_modules/vscode-languageserver-protocol": { + "version": "3.17.5", + "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.5.tgz", + "integrity": "sha512-mb1bvRJN8SVznADSGWM9u/b07H7Ecg0I3OgXDuLdn307rl/J3A9YD6/eYOssqhecL27hK1IPZAsaqh00i/Jljg==", + "license": "MIT", + "dependencies": { + "vscode-jsonrpc": "8.2.0", + "vscode-languageserver-types": "3.17.5" + } + }, + "node_modules/vscode-languageserver-textdocument": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/vscode-languageserver-textdocument/-/vscode-languageserver-textdocument-1.0.12.tgz", + "integrity": "sha512-cxWNPesCnQCcMPeenjKKsOCKQZ/L6Tv19DTRIGuLWe32lyzWhihGVJ/rcckZXJxfdKCFvRLS3fpBIsV/ZGX4zA==", + "license": "MIT" + }, + "node_modules/vscode-languageserver-types": { + "version": "3.17.5", + "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.5.tgz", + "integrity": "sha512-Ld1VelNuX9pdF39h2Hgaeb5hEZM2Z3jUrrMgWQAu82jMtZp7p3vJT3BzToKtZI7NgQssZje5o0zryOrhQvzQAg==", + "license": "MIT" + }, + "node_modules/vscode-uri": { + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-3.0.8.tgz", + "integrity": "sha512-AyFQ0EVmsOZOlAnxoFOGOq1SQDWAB7C6aqMGS23svWAllfOaxbuFvcT8D1i8z3Gyn8fraVeZNNmN6e9bxxXkKw==", + "license": "MIT" + }, + "node_modules/web-namespaces": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/web-namespaces/-/web-namespaces-2.0.1.tgz", + "integrity": "sha512-bKr1DkiNa2krS7qxNtdrtHAmzuYGFQLiQ13TsorsdT6ULTkPLKuu5+GsFpDlg6JFjUTwX2DyhMPG2be8uPrqsQ==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/webpack-virtual-modules": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/webpack-virtual-modules/-/webpack-virtual-modules-0.6.2.tgz", + "integrity": "sha512-66/V2i5hQanC51vBQKPH4aI8NMAcBW59FVBs+rC7eGHupMyfn34q7rZIE+ETlJ+XTevqfUhVVBgSUNSW2flEUQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/whatwg-fetch": { + "version": "3.6.20", + "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.6.20.tgz", + "integrity": "sha512-EqhiFU6daOA8kpjOWTL0olhVOF3i7OrFzSYiGsEMB8GcXS+RrzauAERX65xMeNWVqxA6HXH2m69Z9LaKKdisfg==", + "license": "MIT" + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/why-is-node-running": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz", + "integrity": "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==", + "dev": true, + "license": "MIT", + "dependencies": { + "siginfo": "^2.0.0", + "stackback": "0.0.2" + }, + "bin": { + "why-is-node-running": "cli.js" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/word-wrap": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/wrap-ansi": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", + "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^6.1.0", + "string-width": "^5.0.1", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs": { + "name": "wrap-ansi", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true, + "license": "MIT" + }, + "node_modules/wrap-ansi-cjs/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi/node_modules/ansi-styles": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", + "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/ws": { + "version": "8.18.3", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.3.tgz", + "integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "dev": true, + "license": "ISC" + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/zod": { + "version": "3.25.57", + "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.57.tgz", + "integrity": "sha512-6tgzLuwVST5oLUxXTmBqoinKMd3JeesgbgseXeFasKKj8Q1FCZrHnbqJOyiEvr4cVAlbug+CgIsmJ8cl/pU5FA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } + }, + "node_modules/zwitch": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/zwitch/-/zwitch-2.0.4.tgz", + "integrity": "sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + } + } +} diff --git a/app/ui/app/package.json b/app/ui/app/package.json new file mode 100644 index 0000000..5532e70 --- /dev/null +++ b/app/ui/app/package.json @@ -0,0 +1,82 @@ +{ + "name": "app", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc -b && vite build", + "lint": "eslint .", + "preview": "vite preview", + "prettier": "prettier --write .", + "prettier:check": "prettier --check .", + "storybook": "storybook dev -p 6006", + "build-storybook": "storybook build", + "test": "vitest", + "test:ui": "vitest --ui", + "test:coverage": "vitest --coverage" + }, + "dependencies": { + "@headlessui/react": "^2.2.4", + "@heroicons/react": "^2.2.0", + "@tanstack/react-query": "^5.80.7", + "@tanstack/react-router": "^1.120.20", + "@tanstack/react-router-devtools": "^1.120.20", + "clsx": "^2.1.1", + "framer-motion": "^12.17.0", + "katex": "^0.16.22", + "micromark-extension-llm-math": "^3.1.0", + "ollama": "^0.6.0", + "react": "^19.1.0", + "react-dom": "^19.1.0", + "rehype-katex": "^7.0.1", + "rehype-prism-plus": "^2.0.1", + "rehype-raw": "^7.0.0", + "rehype-sanitize": "^6.0.0", + "remark-math": "^6.0.0", + "streamdown": "^1.4.0", + "unist-builder": "^4.0.0", + "unist-util-parents": "^3.0.0" + }, + "devDependencies": { + "@chromatic-com/storybook": "^4.0.1", + "@eslint/js": "^9.25.0", + "@storybook/addon-a11y": "^9.0.14", + "@storybook/addon-docs": "^9.0.14", + "@storybook/addon-onboarding": "^9.0.14", + "@storybook/addon-vitest": "^9.0.14", + "@storybook/react-vite": "^9.0.14", + "@tailwindcss/typography": "^0.5.16", + "@tailwindcss/vite": "^4.1.11", + "@tanstack/router-plugin": "^1.120.20", + "@types/node": "^24.7.2", + "@types/react": "^19.1.2", + "@types/react-dom": "^19.1.2", + "@vitejs/plugin-react": "^4.4.1", + "@vitest/browser": "^3.2.4", + "@vitest/coverage-v8": "^3.2.4", + "@vitest/ui": "^3.2.4", + "autoprefixer": "^10.4.21", + "eslint": "^9.25.0", + "eslint-plugin-react-hooks": "^5.2.0", + "eslint-plugin-react-refresh": "^0.4.19", + "eslint-plugin-storybook": "^9.0.14", + "globals": "^16.0.0", + "playwright": "^1.53.2", + "postcss-preset-env": "^10.2.4", + "react-markdown": "^10.1.0", + "remark": "^15.0.1", + "remark-gfm": "^4.0.1", + "remark-stringify": "^11.0.0", + "storybook": "^9.0.14", + "tailwindcss": "^4.1.9", + "typescript": "~5.8.3", + "typescript-eslint": "^8.30.1", + "vite": "^6.3.5", + "vite-tsconfig-paths": "^5.1.4", + "vitest": "^3.2.4" + }, + "overrides": { + "mdast-util-gfm-autolink-literal": "2.0.0" + } +} diff --git a/app/ui/app/public/hello.png b/app/ui/app/public/hello.png new file mode 100644 index 0000000..fd04d9d Binary files /dev/null and b/app/ui/app/public/hello.png differ diff --git a/app/ui/app/public/launch-icons/claude-code.svg b/app/ui/app/public/launch-icons/claude-code.svg new file mode 100644 index 0000000..ed1293c --- /dev/null +++ b/app/ui/app/public/launch-icons/claude-code.svg @@ -0,0 +1 @@ +Claude Code \ No newline at end of file diff --git a/app/ui/app/public/launch-icons/claude.svg b/app/ui/app/public/launch-icons/claude.svg new file mode 100644 index 0000000..879ad81 --- /dev/null +++ b/app/ui/app/public/launch-icons/claude.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/app/ui/app/public/launch-icons/codex-app.png b/app/ui/app/public/launch-icons/codex-app.png new file mode 100644 index 0000000..72e9baf Binary files /dev/null and b/app/ui/app/public/launch-icons/codex-app.png differ diff --git a/app/ui/app/public/launch-icons/codex-dark.svg b/app/ui/app/public/launch-icons/codex-dark.svg new file mode 100644 index 0000000..d40ada6 --- /dev/null +++ b/app/ui/app/public/launch-icons/codex-dark.svg @@ -0,0 +1 @@ + diff --git a/app/ui/app/public/launch-icons/codex.svg b/app/ui/app/public/launch-icons/codex.svg new file mode 100644 index 0000000..683aefc --- /dev/null +++ b/app/ui/app/public/launch-icons/codex.svg @@ -0,0 +1 @@ + diff --git a/app/ui/app/public/launch-icons/copilot-dark.svg b/app/ui/app/public/launch-icons/copilot-dark.svg new file mode 100644 index 0000000..84e1beb --- /dev/null +++ b/app/ui/app/public/launch-icons/copilot-dark.svg @@ -0,0 +1 @@ + diff --git a/app/ui/app/public/launch-icons/copilot.svg b/app/ui/app/public/launch-icons/copilot.svg new file mode 100644 index 0000000..c78fe47 --- /dev/null +++ b/app/ui/app/public/launch-icons/copilot.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/ui/app/public/launch-icons/droid.svg b/app/ui/app/public/launch-icons/droid.svg new file mode 100644 index 0000000..16b99b6 --- /dev/null +++ b/app/ui/app/public/launch-icons/droid.svg @@ -0,0 +1,8 @@ + + + + + + \ No newline at end of file diff --git a/app/ui/app/public/launch-icons/hermes-agent.svg b/app/ui/app/public/launch-icons/hermes-agent.svg new file mode 100644 index 0000000..0112bb4 --- /dev/null +++ b/app/ui/app/public/launch-icons/hermes-agent.svg @@ -0,0 +1,181 @@ + + + + + + + \ No newline at end of file diff --git a/app/ui/app/public/launch-icons/openclaw.svg b/app/ui/app/public/launch-icons/openclaw.svg new file mode 100644 index 0000000..00fa9b5 --- /dev/null +++ b/app/ui/app/public/launch-icons/openclaw.svg @@ -0,0 +1,242 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/ui/app/public/launch-icons/opencode.svg b/app/ui/app/public/launch-icons/opencode.svg new file mode 100644 index 0000000..157edc4 --- /dev/null +++ b/app/ui/app/public/launch-icons/opencode.svg @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/app/ui/app/public/launch-icons/pi-dark.svg b/app/ui/app/public/launch-icons/pi-dark.svg new file mode 100644 index 0000000..ade868d --- /dev/null +++ b/app/ui/app/public/launch-icons/pi-dark.svg @@ -0,0 +1,9 @@ + + + + + + diff --git a/app/ui/app/public/launch-icons/pi.svg b/app/ui/app/public/launch-icons/pi.svg new file mode 100644 index 0000000..1cf7eed --- /dev/null +++ b/app/ui/app/public/launch-icons/pi.svg @@ -0,0 +1,9 @@ + + + + + + diff --git a/app/ui/app/src/api.ts b/app/ui/app/src/api.ts new file mode 100644 index 0000000..c22fee0 --- /dev/null +++ b/app/ui/app/src/api.ts @@ -0,0 +1,480 @@ +import { + ChatResponse, + ChatsResponse, + ChatEvent, + DownloadEvent, + ErrorEvent, + InferenceComputeResponse, + ModelCapabilitiesResponse, + Model, + ChatRequest, + Settings, + User, +} from "@/gotypes"; +import { parseJsonlFromResponse } from "./util/jsonl-parsing"; +import { ollamaClient as ollama } from "./lib/ollama-client"; +import type { ModelResponse } from "ollama/browser"; +import { API_BASE, OLLAMA_DOT_COM } from "./lib/config"; + +// Extend Model class with utility methods +declare module "@/gotypes" { + interface Model { + isCloud(): boolean; + } +} + +Model.prototype.isCloud = function (): boolean { + return this.model.endsWith("cloud"); +}; + +export type CloudStatusSource = "env" | "config" | "both" | "none"; +export interface CloudStatusResponse { + disabled: boolean; + source: CloudStatusSource; +} +// Helper function to convert Uint8Array to base64 +function uint8ArrayToBase64(uint8Array: Uint8Array): string { + const chunkSize = 0x8000; // 32KB chunks to avoid stack overflow + let binary = ""; + + for (let i = 0; i < uint8Array.length; i += chunkSize) { + const chunk = uint8Array.subarray(i, i + chunkSize); + binary += String.fromCharCode(...chunk); + } + + return btoa(binary); +} + +export async function fetchUser(): Promise { + const response = await fetch(`${API_BASE}/api/me`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + }); + + if (response.ok) { + const userData: User = await response.json(); + + if (userData.avatarurl && !userData.avatarurl.startsWith("http")) { + userData.avatarurl = `${OLLAMA_DOT_COM}${userData.avatarurl}`; + } + + return userData; + } + + if (response.status === 401 || response.status === 403) { + return null; + } + + throw new Error(`Failed to fetch user: ${response.status}`); +} + +export async function fetchConnectUrl(): Promise { + const response = await fetch(`${API_BASE}/api/me`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + }); + + if (response.status === 401) { + const data = await response.json(); + if (data.signin_url) { + return data.signin_url; + } + } + + throw new Error("Failed to fetch connect URL"); +} + +export async function disconnectUser(): Promise { + const response = await fetch(`${API_BASE}/api/signout`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + }); + + if (!response.ok) { + throw new Error("Failed to disconnect user"); + } +} + +export async function getChats(): Promise { + const response = await fetch(`${API_BASE}/api/v1/chats`); + const data = await response.json(); + return new ChatsResponse(data); +} + +export async function getChat(chatId: string): Promise { + const response = await fetch(`${API_BASE}/api/v1/chat/${chatId}`); + const data = await response.json(); + return new ChatResponse(data); +} + +export async function getModels(query?: string): Promise { + try { + const { models: modelsResponse } = await ollama.list(); + + let models: Model[] = modelsResponse + .filter((m: ModelResponse) => { + const families = m.details?.families; + + if (!families || families.length === 0) { + return true; + } + + const isBertOnly = families.every((family: string) => + family.toLowerCase().includes("bert"), + ); + + return !isBertOnly; + }) + .map((m: ModelResponse) => { + // Remove the latest tag from the returned model + const modelName = m.name.replace(/:latest$/, ""); + + return new Model({ + model: modelName, + digest: m.digest, + modified_at: m.modified_at ? new Date(m.modified_at) : undefined, + }); + }); + + // Filter by query if provided + if (query) { + const normalizedQuery = query.toLowerCase().trim(); + + const filteredModels = models.filter((m: Model) => { + return m.model.toLowerCase().startsWith(normalizedQuery); + }); + + let exactMatch = false; + for (const m of filteredModels) { + if (m.model.toLowerCase() === normalizedQuery) { + exactMatch = true; + break; + } + } + + // Add query if it's in the registry and not already in the list + if (!exactMatch) { + const result = await getModelUpstreamInfo(new Model({ model: query })); + const existsUpstream = result.exists; + if (existsUpstream) { + filteredModels.push(new Model({ model: query })); + } + } + + models = filteredModels; + } + + return models; + } catch (err) { + throw new Error(`Failed to fetch models: ${err}`); + } +} + +export async function getModelCapabilities( + modelName: string, +): Promise { + try { + const showResponse = await ollama.show({ model: modelName }); + + return new ModelCapabilitiesResponse({ + capabilities: Array.isArray(showResponse.capabilities) + ? showResponse.capabilities + : [], + }); + } catch (error) { + // Model might not be downloaded yet, return empty capabilities + console.error(`Failed to get capabilities for ${modelName}:`, error); + return new ModelCapabilitiesResponse({ capabilities: [] }); + } +} + +export type ChatEventUnion = ChatEvent | DownloadEvent | ErrorEvent; + +export async function* sendMessage( + chatId: string, + message: string, + model: Model, + attachments?: Array<{ filename: string; data: Uint8Array }>, + signal?: AbortSignal, + index?: number, + webSearch?: boolean, + fileTools?: boolean, + forceUpdate?: boolean, + think?: boolean | string, +): AsyncGenerator { + // Convert Uint8Array to base64 for JSON serialization + const serializedAttachments = attachments?.map((att) => ({ + filename: att.filename, + data: uint8ArrayToBase64(att.data), + })); + + // Send think parameter when it's explicitly set (true, false, or a non-empty string). + const shouldSendThink = + think !== undefined && + (typeof think === "boolean" || (typeof think === "string" && think !== "")); + + const response = await fetch(`${API_BASE}/api/v1/chat/${chatId}`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify( + new ChatRequest({ + model: model.model, + prompt: message, + ...(index !== undefined ? { index } : {}), + ...(serializedAttachments !== undefined + ? { attachments: serializedAttachments } + : {}), + // Always send web_search as a boolean value (default to false) + web_search: webSearch ?? false, + file_tools: fileTools ?? false, + ...(forceUpdate !== undefined ? { forceUpdate } : {}), + ...(shouldSendThink ? { think } : {}), + }), + ), + signal, + }); + + for await (const event of parseJsonlFromResponse(response)) { + switch (event.eventName) { + case "download": + yield new DownloadEvent(event); + break; + case "error": + yield new ErrorEvent(event); + break; + default: + yield new ChatEvent(event); + break; + } + } +} + +export async function getSettings(): Promise<{ + settings: Settings; +}> { + const response = await fetch(`${API_BASE}/api/v1/settings`); + if (!response.ok) { + throw new Error("Failed to fetch settings"); + } + const data = await response.json(); + return { + settings: new Settings(data.settings), + }; +} + +export async function updateSettings(settings: Settings): Promise<{ + settings: Settings; +}> { + const response = await fetch(`${API_BASE}/api/v1/settings`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(settings), + }); + if (!response.ok) { + const error = await response.text(); + throw new Error(error || "Failed to update settings"); + } + const data = await response.json(); + return { + settings: new Settings(data.settings), + }; +} + +export async function updateCloudSetting( + enabled: boolean, +): Promise { + const response = await fetch(`${API_BASE}/api/v1/cloud`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ enabled }), + }); + if (!response.ok) { + const error = await response.text(); + throw new Error(error || "Failed to update cloud setting"); + } + + const data = await response.json(); + return { + disabled: Boolean(data.disabled), + source: (data.source as CloudStatusSource) || "none", + }; +} + +export async function renameChat(chatId: string, title: string): Promise { + const response = await fetch(`${API_BASE}/api/v1/chat/${chatId}/rename`, { + method: "PUT", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ title: title.trim() }), + }); + if (!response.ok) { + const error = await response.text(); + throw new Error(error || "Failed to rename chat"); + } +} + +export async function deleteChat(chatId: string): Promise { + const response = await fetch(`${API_BASE}/api/v1/chat/${chatId}`, { + method: "DELETE", + }); + if (!response.ok) { + const error = await response.text(); + throw new Error(error || "Failed to delete chat"); + } +} + +// Get upstream information for model staleness checking +export async function getModelUpstreamInfo( + model: Model, +): Promise<{ stale: boolean; exists: boolean; error?: string }> { + try { + const response = await fetch(`${API_BASE}/api/v1/model/upstream`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + model: model.model, + }), + }); + + if (!response.ok) { + console.warn( + `Failed to check upstream for ${model.model}: ${response.status}`, + ); + return { stale: false, exists: false }; + } + + const data = await response.json(); + + if (data.error) { + console.warn(`Upstream check: ${data.error}`); + return { stale: false, exists: false, error: data.error }; + } + + return { stale: !!data.stale, exists: true }; + } catch (error) { + console.warn(`Error checking model staleness:`, error); + return { stale: false, exists: false }; + } +} + +export async function* pullModel( + modelName: string, + signal?: AbortSignal, +): AsyncGenerator<{ + status: string; + digest?: string; + total?: number; + completed?: number; + done?: boolean; +}> { + const response = await fetch(`${API_BASE}/api/v1/models/pull`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ name: modelName }), + signal, + }); + + if (!response.ok) { + throw new Error(`Failed to pull model: ${response.statusText}`); + } + + for await (const event of parseJsonlFromResponse<{ + status: string; + digest?: string; + total?: number; + completed?: number; + done?: boolean; + }>(response)) { + yield event; + } +} + +export interface ModelRecommendation { + model: string; + description: string; + context_length?: number; + max_output_tokens?: number; + vram_bytes?: number; +} + +export interface ModelRecommendationsResponse { + recommendations: ModelRecommendation[]; +} + +export async function getModelRecommendations(): Promise { + const response = await fetch( + `${API_BASE}/api/experimental/model-recommendations`, + ); + if (!response.ok) { + throw new Error( + `Failed to fetch model recommendations: ${response.statusText}`, + ); + } + const data: ModelRecommendationsResponse = await response.json(); + return data.recommendations || []; +} + +export async function getInferenceCompute(): Promise { + const response = await fetch(`${API_BASE}/api/v1/inference-compute`); + if (!response.ok) { + throw new Error( + `Failed to fetch inference compute: ${response.statusText}`, + ); + } + + const data = await response.json(); + return new InferenceComputeResponse(data); +} + +export async function fetchHealth(): Promise { + try { + // Use the /api/version endpoint as a health check + const response = await fetch(`${API_BASE}/api/version`, { + method: "GET", + headers: { + "Content-Type": "application/json", + }, + }); + + if (response.ok) { + const data = await response.json(); + // If we get a version back, the server is healthy + return !!data.version; + } + + return false; + } catch (error) { + console.error("Error checking health:", error); + return false; + } +} + +export async function getCloudStatus(): Promise { + const response = await fetch(`${API_BASE}/api/v1/cloud`); + if (!response.ok) { + throw new Error(`Failed to fetch cloud status: ${response.status}`); + } + + const data = await response.json(); + return { + disabled: Boolean(data.disabled), + source: (data.source as CloudStatusSource) || "none", + }; +} diff --git a/app/ui/app/src/components/Chat.tsx b/app/ui/app/src/components/Chat.tsx new file mode 100644 index 0000000..e0fcb4f --- /dev/null +++ b/app/ui/app/src/components/Chat.tsx @@ -0,0 +1,298 @@ +import MessageList from "./MessageList"; +import ChatForm from "./ChatForm"; +import { FileUpload } from "./FileUpload"; +import { DisplayUpgrade } from "./DisplayUpgrade"; +import { DisplayStale } from "./DisplayStale"; +import { DisplayLogin } from "./DisplayLogin"; +import { + useChat, + useSendMessage, + useIsStreaming, + useIsWaitingForLoad, + useDownloadProgress, + useChatError, + useShouldShowStaleDisplay, + useDismissStaleModel, +} from "@/hooks/useChats"; +import { useHealth } from "@/hooks/useHealth"; +import { useMessageAutoscroll } from "@/hooks/useMessageAutoscroll"; +import { + useState, + useEffect, + useLayoutEffect, + useRef, + useCallback, +} from "react"; +import { useQueryClient } from "@tanstack/react-query"; +import { useNavigate } from "@tanstack/react-router"; +import { useSelectedModel } from "@/hooks/useSelectedModel"; +import { useUser } from "@/hooks/useUser"; +import { useHasVisionCapability } from "@/hooks/useModelCapabilities"; +import { Message } from "@/gotypes"; + +export default function Chat({ chatId }: { chatId: string }) { + const queryClient = useQueryClient(); + const navigate = useNavigate(); + const chatQuery = useChat(chatId === "new" ? "" : chatId); + const chatErrorQuery = useChatError(chatId === "new" ? "" : chatId); + const { selectedModel } = useSelectedModel(chatId); + const { user } = useUser(); + const hasVisionCapability = useHasVisionCapability(selectedModel?.model); + const shouldShowStaleDisplay = useShouldShowStaleDisplay(selectedModel); + const dismissStaleModel = useDismissStaleModel(); + const { isHealthy } = useHealth(); + + const [editingMessage, setEditingMessage] = useState<{ + content: string; + index: number; + originalMessage: Message; + } | null>(null); + const prevChatIdRef = useRef(chatId); + + const chatFormCallbackRef = useRef< + | (( + files: Array<{ filename: string; data: Uint8Array; type?: string }>, + errors: Array<{ filename: string; error: string }>, + ) => void) + | null + >(null); + + const handleFilesReceived = useCallback( + ( + callback: ( + files: Array<{ + filename: string; + data: Uint8Array; + type?: string; + }>, + errors: Array<{ filename: string; error: string }>, + ) => void, + ) => { + chatFormCallbackRef.current = callback; + }, + [], + ); + + const handleFilesProcessed = useCallback( + ( + files: Array<{ filename: string; data: Uint8Array; type?: string }>, + errors: Array<{ filename: string; error: string }> = [], + ) => { + chatFormCallbackRef.current?.(files, errors); + }, + [], + ); + + const allMessages = chatQuery?.data?.chat?.messages ?? []; + // TODO(parthsareen): will need to consolidate when used with more tools with state + const browserToolResult = chatQuery?.data?.chat?.browser_state; + const chatError = chatErrorQuery.data; + + const messages = allMessages; + const isStreaming = useIsStreaming(chatId); + const isWaitingForLoad = useIsWaitingForLoad(chatId); + const downloadProgress = useDownloadProgress(chatId); + const isDownloadingModel = downloadProgress && !downloadProgress.done; + const isDisabled = !isHealthy; + + // Clear editing state when navigating to a different chat + useEffect(() => { + setEditingMessage(null); + }, [chatId]); + + const sendMessageMutation = useSendMessage(chatId); + + const { containerRef, handleNewUserMessage, spacerHeight } = + useMessageAutoscroll({ + messages, + isStreaming, + chatId, + }); + + // Scroll to bottom only when switching to a different existing chat + useLayoutEffect(() => { + // Only scroll if the chatId actually changed (not just messages updating) + if ( + prevChatIdRef.current !== chatId && + containerRef.current && + messages.length > 0 && + chatId !== "new" + ) { + // Always scroll to the bottom when opening a chat + containerRef.current.scrollTop = containerRef.current.scrollHeight; + } + prevChatIdRef.current = chatId; + }, [chatId, messages.length]); + + // Simplified submit handler - ChatForm handles all the attachment logic + const handleChatFormSubmit = ( + message: string, + options: { + attachments?: Array<{ filename: string; data: Uint8Array }>; + index?: number; + webSearch?: boolean; + fileTools?: boolean; + think?: boolean | string; + }, + ) => { + // Clear any existing errors when sending a new message + sendMessageMutation.reset(); + if (chatError) { + clearChatError(); + } + + // Prepare attachments for backend + const allAttachments = (options.attachments || []).map((att) => ({ + filename: att.filename, + data: att.data.length === 0 ? new Uint8Array(0) : att.data, + })); + + sendMessageMutation.mutate({ + message, + attachments: allAttachments, + index: editingMessage ? editingMessage.index : options.index, + webSearch: options.webSearch, + fileTools: options.fileTools, + think: options.think, + onChatEvent: (event) => { + if (event.eventName === "chat_created" && event.chatId) { + navigate({ + to: "/c/$chatId", + params: { + chatId: event.chatId, + }, + }); + } + }, + }); + + // Clear edit mode after submission + setEditingMessage(null); + handleNewUserMessage(); + }; + + const handleEditMessage = (content: string, index: number) => { + setEditingMessage({ + content, + index, + originalMessage: messages[index], + }); + }; + + const handleCancelEdit = () => { + setEditingMessage(null); + if (chatError) { + clearChatError(); + } + }; + + const clearChatError = () => { + queryClient.setQueryData( + ["chatError", chatId === "new" ? "" : chatId], + null, + ); + }; + + const isWindows = navigator.platform.toLowerCase().includes("win"); + + return chatId === "new" || chatQuery ? ( + + {chatId === "new" ? ( +
+
+ +
+
+ ) : ( +
+
+ { + handleEditMessage(content, index); + }} + editingMessageIndex={editingMessage?.index} + error={chatError} + browserToolResult={browserToolResult} + /> +
+ +
+ {selectedModel && shouldShowStaleDisplay && ( +
+ + dismissStaleModel(selectedModel?.model || "") + } + chatId={chatId} + onScrollToBottom={() => { + if (containerRef.current) { + containerRef.current.scrollTo({ + top: containerRef.current.scrollHeight, + behavior: "smooth", + }); + } + }} + /> +
+ )} + {chatError && chatError.code === "usage_limit_upgrade" && ( +
+ +
+ )} + {chatError && chatError.code === "cloud_unauthorized" && ( +
+ +
+ )} + 0} + onSubmit={handleChatFormSubmit} + chatId={chatId} + autoFocus={true} + editingMessage={editingMessage} + onCancelEdit={handleCancelEdit} + isDisabled={isDisabled} + isDownloadingModel={isDownloadingModel} + onFilesReceived={handleFilesReceived} + /> +
+
+ )} +
+ ) : ( +
Loading...
+ ); +} diff --git a/app/ui/app/src/components/ChatForm.tsx b/app/ui/app/src/components/ChatForm.tsx new file mode 100644 index 0000000..b0ae1af --- /dev/null +++ b/app/ui/app/src/components/ChatForm.tsx @@ -0,0 +1,1013 @@ +import Logo from "@/components/Logo"; +import { ModelPicker } from "@/components/ModelPicker"; +import { WebSearchButton } from "@/components/WebSearchButton"; +import { ImageThumbnail } from "@/components/ImageThumbnail"; +import { isImageFile } from "@/utils/imageUtils"; +import { + useRef, + useState, + useEffect, + useLayoutEffect, + useCallback, +} from "react"; +import { + useSendMessage, + useIsStreaming, + useCancelMessage, +} from "@/hooks/useChats"; +import { useNavigate } from "@tanstack/react-router"; +import { useSelectedModel } from "@/hooks/useSelectedModel"; +import { + useHasVisionCapability, + useHasToolsCapability, +} from "@/hooks/useModelCapabilities"; +import { useUser } from "@/hooks/useUser"; +import { DisplayLogin } from "@/components/DisplayLogin"; +import { ErrorEvent, Message } from "@/gotypes"; +import { useSettings } from "@/hooks/useSettings"; +import { useCloudStatus } from "@/hooks/useCloudStatus"; +import { ThinkButton } from "./ThinkButton"; +import { ErrorMessage } from "./ErrorMessage"; +import { processFiles } from "@/utils/fileValidation"; +import type { ImageData } from "@/types/webview"; +import { PlusIcon } from "@heroicons/react/24/outline"; + +export type ThinkingLevel = "low" | "medium" | "high"; + +interface FileAttachment { + filename: string; + data: Uint8Array; + type?: string; // MIME type +} + +interface MessageInput { + content: string; + attachments: Array<{ + id: string; + filename: string; + data?: Uint8Array; // undefined for existing files from editing + }>; + fileErrors: Array<{ filename: string; error: string }>; +} + +interface ChatFormProps { + hasMessages: boolean; + onSubmit?: ( + message: string, + options: { + attachments?: FileAttachment[]; + index?: number; + webSearch?: boolean; + fileTools?: boolean; + think?: boolean | string; + }, + ) => void; + autoFocus?: boolean; + chatId?: string; + isDownloadingModel?: boolean; + isDisabled?: boolean; + // Editing props - when provided, ChatForm enters edit mode + editingMessage?: { + content: string; + index: number; + originalMessage: Message; + } | null; + onCancelEdit?: () => void; + onFilesReceived?: ( + callback: ( + files: Array<{ filename: string; data: Uint8Array; type?: string }>, + errors: Array<{ filename: string; error: string }>, + ) => void, + ) => void; +} + +function ChatForm({ + hasMessages, + onSubmit, + autoFocus = false, + chatId = "new", + isDownloadingModel = false, + isDisabled = false, + editingMessage, + onCancelEdit, + onFilesReceived, +}: ChatFormProps) { + const [message, setMessage] = useState({ + content: "", + attachments: [], + fileErrors: [], + }); + const [isEditing, setIsEditing] = useState(false); + const compositionEndTimeoutRef = useRef(null); + const fileInputRef = useRef(null); + const textareaRef = useRef(null); + const thinkButtonRef = useRef(null); + const thinkingLevelButtonRef = useRef(null); + const webSearchButtonRef = useRef(null); + const modelPickerRef = useRef(null); + const submitButtonRef = useRef(null); + + const { mutate: sendMessageMutation } = useSendMessage(chatId); + const navigate = useNavigate(); + const isStreaming = useIsStreaming(chatId); + const cancelMessage = useCancelMessage(); + const isDownloading = isDownloadingModel; + const { selectedModel } = useSelectedModel(); + const hasVisionCapability = useHasVisionCapability(selectedModel?.model); + const { isAuthenticated, isLoading: isLoadingUser } = useUser(); + const [loginPromptFeature, setLoginPromptFeature] = useState< + "webSearch" | "turbo" | null + >(null); + const [fileUploadError, setFileUploadError] = useState( + null, + ); + + const handleThinkingLevelDropdownToggle = (isOpen: boolean) => { + if ( + isOpen && + modelPickerRef.current && + (modelPickerRef.current as any).closeDropdown + ) { + (modelPickerRef.current as any).closeDropdown(); + } + }; + + const handleModelPickerDropdownToggle = (isOpen: boolean) => { + if ( + isOpen && + thinkingLevelButtonRef.current && + (thinkingLevelButtonRef.current as any).closeDropdown + ) { + (thinkingLevelButtonRef.current as any).closeDropdown(); + } + }; + + const { + settings: { + webSearchEnabled, + thinkEnabled, + thinkLevel: settingsThinkLevel, + }, + setSettings, + } = useSettings(); + const { cloudDisabled } = useCloudStatus(); + + const supportsWebSearch = useHasToolsCapability(selectedModel?.model); + // Use per-chat thinking level instead of global + const thinkLevel: ThinkingLevel = + settingsThinkLevel === "none" || !settingsThinkLevel + ? "medium" + : (settingsThinkLevel as ThinkingLevel); + const setThinkingLevel = (newLevel: ThinkingLevel) => { + setSettings({ ThinkLevel: newLevel }); + }; + + const modelSupportsThinkingLevels = + selectedModel?.model.toLowerCase().startsWith("gpt-oss") || false; + const supportsThinkToggling = + selectedModel?.model.toLowerCase().startsWith("deepseek-v3.1") || false; + + useEffect(() => { + if (supportsThinkToggling && thinkEnabled && webSearchEnabled) { + setSettings({ WebSearchEnabled: false }); + } + }, [ + selectedModel?.model, + supportsThinkToggling, + thinkEnabled, + webSearchEnabled, + setSettings, + ]); + + useEffect(() => { + if (cloudDisabled && webSearchEnabled) { + setSettings({ WebSearchEnabled: false }); + } + }, [cloudDisabled, webSearchEnabled, setSettings]); + + const removeFile = (index: number) => { + setMessage((prev) => ({ + ...prev, + attachments: prev.attachments.filter((_, i) => i !== index), + })); + }; + + const removeFileError = (index: number) => { + setMessage((prev) => ({ + ...prev, + fileErrors: prev.fileErrors.filter((_, i) => i !== index), + })); + }; + + // Create stable callback for file handling + const handleFilesReceived = useCallback( + ( + files: Array<{ filename: string; data: Uint8Array; type?: string }>, + errors: Array<{ filename: string; error: string }> = [], + ) => { + if (files.length > 0) { + setFileUploadError(null); + + const newAttachments = files.map((file) => ({ + id: crypto.randomUUID(), + filename: file.filename, + data: file.data, + })); + + setMessage((prev) => ({ + ...prev, + attachments: [...prev.attachments, ...newAttachments], + })); + } + + // Add validation errors to form state + if (errors.length > 0) { + setMessage((prev) => ({ + ...prev, + fileErrors: [...prev.fileErrors, ...errors], + })); + } + }, + [], + ); + + useEffect(() => { + if (onFilesReceived) { + onFilesReceived(handleFilesReceived); + } + }, [onFilesReceived, handleFilesReceived]); + + // Determine if login banner should be shown + const shouldShowLoginBanner = + !cloudDisabled && + !isLoadingUser && + !isAuthenticated && + ((webSearchEnabled && supportsWebSearch) || selectedModel?.isCloud()); + + // Determine which feature to highlight in the banner + const getActiveFeatureForBanner = () => { + if (cloudDisabled) return null; + if (!isAuthenticated) { + if (loginPromptFeature) return loginPromptFeature; + if (webSearchEnabled && selectedModel?.isCloud()) return "webSearch"; + if (webSearchEnabled) return "webSearch"; + if (selectedModel?.isCloud()) return "turbo"; + } + return null; + }; + + const activeFeatureForBanner = getActiveFeatureForBanner(); + + const resetChatForm = () => { + setMessage({ + content: "", + attachments: [], + fileErrors: [], + }); + + if (textareaRef.current) { + textareaRef.current.style.height = "auto"; + } + }; + + // Clear loginPromptFeature when user becomes authenticated or no features are enabled + useEffect(() => { + if ( + isAuthenticated || + cloudDisabled || + (!webSearchEnabled && !!selectedModel?.isCloud()) + ) { + setLoginPromptFeature(null); + } + }, [isAuthenticated, webSearchEnabled, selectedModel, cloudDisabled]); + + // When entering edit mode, populate the composition with existing data + useEffect(() => { + if (!editingMessage) { + // Clear composition and reset textarea height when not editing + resetChatForm(); + return; + } + + const existingAttachments = + editingMessage.originalMessage?.attachments || []; + setMessage({ + content: editingMessage.content, + attachments: existingAttachments.map((att) => ({ + id: crypto.randomUUID(), + filename: att.filename, + // No data for existing files - backend will handle them + })), + fileErrors: [], + }); + }, [editingMessage]); + + // Focus and setup textarea when editing + useLayoutEffect(() => { + if (editingMessage && textareaRef.current) { + textareaRef.current.focus(); + textareaRef.current.style.transition = + "height 0.2s ease-out, opacity 0.3s ease-in"; + textareaRef.current.style.height = "auto"; + textareaRef.current.style.height = + Math.min(textareaRef.current.scrollHeight, 24 * 8) + "px"; + } + }, [editingMessage]); + + // Clear composition and reset textarea height when chatId changes + useEffect(() => { + resetChatForm(); + }, [chatId]); + + // Auto-focus textarea when autoFocus is true or when streaming completes (but not when editing) + useEffect(() => { + if ((autoFocus || !isStreaming) && textareaRef.current && !editingMessage) { + const timer = setTimeout( + () => { + textareaRef.current?.focus(); + }, + autoFocus ? 0 : 100, + ); + return () => clearTimeout(timer); + } + }, [autoFocus, isStreaming, editingMessage]); + + const focusChatFormInput = () => { + // Focus textarea after model selection or navigation + if (textareaRef.current) { + setTimeout(() => { + textareaRef.current?.focus(); + }, 100); + } + }; + + // Navigation helper function + const navigateToNextElement = useCallback( + (current: HTMLElement, direction: "next" | "prev") => { + const elements = [ + textareaRef, + modelSupportsThinkingLevels ? thinkingLevelButtonRef : thinkButtonRef, + webSearchButtonRef, + modelPickerRef, + submitButtonRef, + ] + .map((ref) => ref.current) + .filter(Boolean) as HTMLElement[]; + const index = elements.indexOf(current); + if (index === -1) return; + const nextIndex = + direction === "next" + ? (index + 1) % elements.length + : (index - 1 + elements.length) % elements.length; + elements[nextIndex].focus(); + }, + [], + ); + + // Focus textarea when navigating to a chat (when chatId changes) + useEffect(() => { + if (chatId !== "new") { + focusChatFormInput(); + } + }, [chatId]); + + // Global keyboard and paste event handlers + useEffect(() => { + const focusTextareaIfAppropriate = (target: HTMLElement) => { + if ( + !textareaRef.current || + textareaRef.current === document.activeElement + ) { + return; + } + + const isEditableTarget = + target.tagName === "INPUT" || + target.tagName === "TEXTAREA" || + target.contentEditable === "true" || + target.closest("input") || + target.closest("textarea") || + target.closest("[contenteditable='true']"); + + if (!isEditableTarget) { + textareaRef.current.focus(); + } + }; + + const handleKeyDown = (e: KeyboardEvent) => { + // Handle escape key for canceling + if (e.key === "Escape") { + e.preventDefault(); + if (editingMessage && onCancelEdit) { + handleCancelEdit(); + } else if (isStreaming) { + handleCancel(); + } + return; + } + + // Handle Tab navigation between controls + if (e.key === "Tab" && e.target !== textareaRef.current) { + const target = e.target as HTMLElement; + const focusableElements = [ + modelSupportsThinkingLevels + ? thinkingLevelButtonRef.current + : thinkButtonRef.current, + webSearchButtonRef.current, + modelPickerRef.current, + submitButtonRef.current, + ].filter(Boolean) as HTMLElement[]; + + if (focusableElements.includes(target)) { + e.preventDefault(); + if (e.shiftKey) { + navigateToNextElement(target, "prev"); + } else { + navigateToNextElement(target, "next"); + } + return; + } + } + + // Handle paste shortcuts + const isPasteShortcut = (e.ctrlKey || e.metaKey) && e.key === "v"; + if (isPasteShortcut) { + focusTextareaIfAppropriate(e.target as HTMLElement); + return; + } + + // Handle auto-focus when typing printable characters + const target = e.target as HTMLElement; + const isInInputField = + target.tagName === "INPUT" || + target.tagName === "TEXTAREA" || + target.contentEditable === "true"; + + if ( + !isInInputField && + e.key.length === 1 && + !e.ctrlKey && + !e.metaKey && + !e.altKey && + textareaRef.current + ) { + textareaRef.current.focus(); + } + }; + + const handlePaste = (e: ClipboardEvent) => { + focusTextareaIfAppropriate(e.target as HTMLElement); + }; + + window.addEventListener("keydown", handleKeyDown); + document.addEventListener("paste", handlePaste); + + return () => { + window.removeEventListener("keydown", handleKeyDown); + document.removeEventListener("paste", handlePaste); + }; + }, [isStreaming, editingMessage, onCancelEdit, navigateToNextElement]); + + const handleSubmit = async () => { + if (!message.content.trim() || isStreaming || isDownloading) return; + + if (cloudDisabled && selectedModel?.isCloud()) { + return; + } + + // Check if cloud mode is enabled but user is not authenticated + if (shouldShowLoginBanner) { + return; + } + + // Prepare attachments for submission, excluding unsupported images + const attachmentsToSend: FileAttachment[] = message.attachments + .filter( + (att) => hasVisionCapability || !isImageFile(att.filename), + ) + .map((att) => ({ + filename: att.filename, + data: att.data || new Uint8Array(0), // Empty data for existing files + })); + + const useWebSearch = + supportsWebSearch && webSearchEnabled && !cloudDisabled; + const useThink = modelSupportsThinkingLevels + ? thinkLevel + : supportsThinkToggling + ? thinkEnabled + : undefined; + + if (onSubmit) { + onSubmit(message.content, { + attachments: attachmentsToSend, + index: undefined, + webSearch: useWebSearch, + think: useThink, + }); + } else { + sendMessageMutation({ + message: message.content, + attachments: attachmentsToSend, + webSearch: useWebSearch, + think: useThink, + onChatEvent: (event) => { + if (event.eventName === "chat_created" && event.chatId) { + navigate({ + to: "/c/$chatId", + params: { + chatId: event.chatId, + }, + }); + } + }, + }); + } + + // Clear composition after successful submission + setMessage({ + content: "", + attachments: [], + fileErrors: [], + }); + + // Reset textarea height and refocus after submit + setTimeout(() => { + if (textareaRef.current) { + textareaRef.current.style.height = "auto"; + textareaRef.current.focus(); + } + }, 100); + }; + + const handleKeyDown = (e: React.KeyboardEvent) => { + // Handle Enter to submit + if (e.key === "Enter" && !e.shiftKey && !isEditing) { + e.preventDefault(); + if (!isStreaming && !isDownloading) { + handleSubmit(); + } + return; + } + + // Handle Tab navigation + if (e.key === "Tab") { + e.preventDefault(); + const focusableElements = [ + modelSupportsThinkingLevels + ? thinkingLevelButtonRef.current + : thinkButtonRef.current, + webSearchButtonRef.current, + modelPickerRef.current, + submitButtonRef.current, + ].filter(Boolean); + + if (e.shiftKey) { + // Shift+Tab: focus last focusable element + const lastElement = focusableElements[focusableElements.length - 1]; + lastElement?.focus(); + } else { + // Tab: focus first focusable element + const firstElement = focusableElements[0]; + firstElement?.focus(); + } + return; + } + }; + + const handleCompositionStart = () => { + if (compositionEndTimeoutRef.current) { + window.clearTimeout(compositionEndTimeoutRef.current); + } + setIsEditing(true); + }; + + const handleCompositionEnd = () => { + // Add a small delay to handle the timing issue where Enter keydown + // fires immediately after composition end + compositionEndTimeoutRef.current = window.setTimeout(() => { + setIsEditing(false); + }, 10); + }; + + const handleCancel = () => { + cancelMessage(chatId); + }; + + const handleCancelEdit = () => { + // Clear composition and call parent callback + setMessage({ + content: "", + attachments: [], + fileErrors: [], + }); + + onCancelEdit?.(); + + // Focus the textarea after canceling edit mode + setTimeout(() => { + textareaRef.current?.focus(); + }, 0); + }; + + const handleFileInputChange = (e: React.ChangeEvent) => { + const files = e.target.files; + if (!files) return; + + Array.from(files).forEach((file) => { + const reader = new FileReader(); + reader.readAsDataURL(file); + }); + + // Reset file input + if (e.target) { + e.target.value = ""; + } + }; + + // Auto-resize textarea function + const handleTextareaChange = (e: React.ChangeEvent) => { + setMessage((prev) => ({ ...prev, content: e.target.value })); + + // Reset height to auto to get the correct scrollHeight, then cap at 8 lines + e.target.style.height = "auto"; + e.target.style.height = Math.min(e.target.scrollHeight, 24 * 8) + "px"; + }; + + const handleFilesUpload = async () => { + try { + setFileUploadError(null); + + const results = await window.webview?.selectMultipleFiles(); + if (results && results.length > 0) { + // Convert native dialog results to File objects + const files = results + .map((result: ImageData) => { + if (result.dataURL) { + // Convert dataURL back to File object + const base64Data = result.dataURL.split(",")[1]; + const mimeType = result.dataURL.split(";")[0].split(":")[1]; + const binaryString = atob(base64Data); + const bytes = new Uint8Array(binaryString.length); + for (let i = 0; i < binaryString.length; i++) { + bytes[i] = binaryString.charCodeAt(i); + } + + const blob = new Blob([bytes], { type: mimeType }); + const file = new File([blob], result.filename, { + type: mimeType, + }); + return file; + } + return null; + }) + .filter(Boolean) as File[]; + + if (files.length > 0) { + const { validFiles, errors } = await processFiles(files, { + selectedModel, + hasVisionCapability, + }); + + // Send processed files and errors to the same handler as FileUpload + if (validFiles.length > 0 || errors.length > 0) { + handleFilesReceived(validFiles, errors); + } + } + } + } catch (error) { + console.error("Error selecting multiple files:", error); + + const errorEvent = new ErrorEvent({ + eventName: "error" as const, + error: + error instanceof Error ? error.message : "Failed to select files", + code: "file_selection_error", + details: + "An error occurred while trying to open the file selection dialog. Please try again.", + }); + + setFileUploadError(errorEvent); + } + }; + return ( +
+ {chatId === "new" && } + + {shouldShowLoginBanner && ( + { + // Disable the active features when dismissing + if (webSearchEnabled) setSettings({ WebSearchEnabled: false }); + setLoginPromptFeature(null); + }} + /> + )} + + {/* File upload error message */} + {fileUploadError && } +
+ {isDisabled && ( + // overlay to block interaction +
+ )} + {editingMessage && ( +
+

+ Press ESC to cancel editing +

+
+ )} + {(message.attachments.length > 0 || message.fileErrors.length > 0) && ( +
+ {message.attachments.map((attachment, index) => { + const isUnsupportedImage = + !hasVisionCapability && isImageFile(attachment.filename); + return ( +
+ {isImageFile(attachment.filename) ? ( + + ) : ( + + + + )} +
+ + {attachment.filename} + + {isUnsupportedImage && ( + + This model does not support images + + )} +
+ +
+ ); + })} + {message.fileErrors.map((fileError, index) => ( +
+ + + + + {fileError.filename} + + + • {fileError.error} + + +
+ ))} +
+ )} + +
+