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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/template-tauri-build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ jobs:
run: |
cargo install ctoml

- name: Set up Xcode version
run: sudo xcode-select -s /Applications/Xcode_26.2.app/Contents/Developer

- name: Update app version based on latest release tag with build number
run: |
echo "Version: ${{ inputs.new_version }}"
Expand All @@ -107,7 +110,7 @@ jobs:

jq --arg version "${{ inputs.new_version }}" '.version = $version' ./src-tauri/plugins/tauri-plugin-hardware/package.json > /tmp/package.json
mv /tmp/package.json ./src-tauri/plugins/tauri-plugin-hardware/package.json

echo "---------./src-tauri/plugins/tauri-plugin-hardware/package.json---------"
cat ./src-tauri/plugins/tauri-plugin-hardware/package.json

Expand All @@ -120,7 +123,7 @@ jobs:
ctoml ./src-tauri/plugins/tauri-plugin-hardware/Cargo.toml package.version "${{ inputs.new_version }}"
echo "---------./src-tauri/plugins/tauri-plugin-hardware/Cargo.toml---------"
cat ./src-tauri/plugins/tauri-plugin-hardware/Cargo.toml

ctoml ./src-tauri/plugins/tauri-plugin-llamacpp/Cargo.toml package.version "${{ inputs.new_version }}"
echo "---------./src-tauri/plugins/tauri-plugin-llamacpp/Cargo.toml---------"
cat ./src-tauri/plugins/tauri-plugin-llamacpp/Cargo.toml
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,6 @@ src-tauri/resources/
test-data
llm-docs
.claude/agents
mlx-server/.build
mlx-server/.swiftpm
.claude
32 changes: 32 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,38 @@ endif
cargo test --manifest-path src-tauri/plugins/tauri-plugin-llamacpp/Cargo.toml
cargo test --manifest-path src-tauri/utils/Cargo.toml

# Build MLX server (macOS Apple Silicon only)
build-mlx-server:
ifeq ($(shell uname -s),Darwin)
@echo "Building MLX server for Apple Silicon..."
# cd mlx-server && swift build -c release
cd mlx-server && xcodebuild build -scheme mlx-server -destination 'platform=OS X' -configuration Release OTHER_LDFLAGS="-dead_strip"
@echo "Finding build products..."
@DERIVED_DATA=$$(find ~/Library/Developer/Xcode/DerivedData/mlx-server-*/Build/Products/Release -maxdepth 0 2>/dev/null | head -1); \
if [ -z "$$DERIVED_DATA" ]; then \
echo "Error: Could not find build products"; \
exit 1; \
fi; \
echo "Copying mlx-server from $$DERIVED_DATA..."; \
cp "$$DERIVED_DATA/mlx-server" src-tauri/resources/bin/mlx-server; \
cp -r "$$DERIVED_DATA/mlx-swift_Cmlx.bundle" src-tauri/resources/bin/; \
chmod +x src-tauri/resources/bin/mlx-server; \
echo "MLX server built and copied successfully"; \
echo "Checking for code signing identity..."; \
SIGNING_IDENTITY=$$(security find-identity -v -p codesigning | grep "Developer ID Application" | head -1 | sed 's/.*"\(.*\)".*/\1/'); \
if [ -n "$$SIGNING_IDENTITY" ]; then \
echo "Signing mlx-server with identity: $$SIGNING_IDENTITY"; \
codesign --force --options runtime --timestamp --sign "$$SIGNING_IDENTITY" src-tauri/resources/bin/mlx-server; \
echo "Signing mlx-swift_Cmlx.bundle..."; \
codesign --force --options runtime --timestamp --sign "$$SIGNING_IDENTITY" --deep src-tauri/resources/bin/mlx-swift_Cmlx.bundle; \
echo "Code signing completed successfully"; \
else \
echo "Warning: No Developer ID Application identity found. Skipping code signing (notarization will fail)."; \
fi
else
@echo "Skipping MLX server build (macOS only)"
endif

# Build
build: install-and-build install-rust-targets
yarn build
Expand Down
7 changes: 7 additions & 0 deletions core/src/browser/extensions/engines/AIEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,13 @@ export interface ImportOptions {
modelSize?: number
mmprojSha256?: string
mmprojSize?: number
// Additional files to download for MLX models
files?: Array<{
url: string
filename: string
sha256?: string
size?: number
}>
}

export interface importResult {
Expand Down
40 changes: 40 additions & 0 deletions extensions/mlx-extension/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "@janhq/mlx-extension",
"productName": "MLX Inference Engine",
"version": "1.0.0",
"description": "This extension enables MLX-Swift inference on Apple Silicon Macs",
"main": "dist/index.js",
"module": "dist/module.js",
"engine": "mlx",
"author": "Jan <service@jan.ai>",
"license": "AGPL-3.0",
"scripts": {
"build": "rolldown -c rolldown.config.mjs",
"build:publish": "rimraf *.tgz --glob || true && yarn build && npm pack && cpx *.tgz ../../pre-install"
},
"devDependencies": {
"cpx": "1.5.0",
"rimraf": "3.0.2",
"rolldown": "1.0.0-beta.1",
"typescript": "5.9.2"
},
"dependencies": {
"@janhq/core": "../../core/package.tgz",
"@janhq/tauri-plugin-llamacpp-api": "link:../../src-tauri/plugins/tauri-plugin-llamacpp",
"@janhq/tauri-plugin-mlx-api": "link:../../src-tauri/plugins/tauri-plugin-mlx",
"@tauri-apps/api": "2.8.0",
"@tauri-apps/plugin-http": "2.5.0",
"@tauri-apps/plugin-log": "^2.6.0"
},
"engines": {
"node": ">=18.0.0"
},
"files": [
"dist/*",
"package.json"
],
"installConfig": {
"hoistingLimits": "workspaces"
},
"packageManager": "yarn@4.5.3"
}
21 changes: 21 additions & 0 deletions extensions/mlx-extension/rolldown.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

import { defineConfig } from 'rolldown'
import pkgJson from './package.json' with { type: 'json' }
import settingJson from './settings.json' with { type: 'json' }

export default defineConfig({
input: 'src/index.ts',
output: {
format: 'esm',
file: 'dist/index.js',
},
platform: 'browser',
define: {
SETTINGS: JSON.stringify(settingJson),
ENGINE: JSON.stringify(pkgJson.engine),
IS_MAC: JSON.stringify(process.platform === 'darwin'),
},
inject: process.env.IS_DEV ? {} : {
fetch: ['@tauri-apps/plugin-http', 'fetch'],
},
})
28 changes: 28 additions & 0 deletions extensions/mlx-extension/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[
{
"key": "batch_size",
"title": "Batch Size",
"description": "Maximum number of concurrent requests to batch (0 = disabled)",
"controllerType": "input",
"controllerProps": {
"value": 4,
"placeholder": "4",
"type": "number",
"textAlign": "right"
}
},
{
"key": "enable_continuous_batching",
"title": "Continuous Batching",
"description": "Enable continuous batching for higher throughput",
"controllerType": "checkbox",
"controllerProps": { "value": false }
},
{
"key": "auto_unload",
"title": "Auto unload model",
"description": "Automatically unload other models when loading a new one",
"controllerType": "checkbox",
"controllerProps": { "value": true }
}
]
5 changes: 5 additions & 0 deletions extensions/mlx-extension/src/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare const SETTINGS: SettingComponentProps[]
declare const ENGINE: string
declare const IS_WINDOWS: boolean
declare const IS_MAC: boolean
declare const IS_LINUX: boolean
Loading
Loading