Skip to content

Commit

Permalink
Merge branch 'chore/update-extensions-and-engines-docs' of https://gi…
Browse files Browse the repository at this point in the history
…thub.com/janhq/jan into chore/update-extensions-and-engines-docs
  • Loading branch information
imtuyethan committed Jan 13, 2025
2 parents ed131f9 + 18f99b1 commit 5457d34
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/src/pages/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Home from "@/components/Home"

export const getStaticProps = async() => {
const resReleaseLatest = await fetch('https://api.github.com/repos/janhq/jan/releases/latest')
const resRelease = await fetch('https://api.github.com/repos/janhq/jan/releases')
const resRelease = await fetch('https://api.github.com/repos/janhq/jan/releases?per_page=500')
const resRepo = await fetch('https://api.github.com/repos/janhq/jan')
const repo = await resRepo.json()
const latestRelease = await resReleaseLatest.json()
Expand Down
15 changes: 11 additions & 4 deletions electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,15 @@
"lint": "eslint . --ext \".js,.jsx,.ts,.tsx\"",
"test:e2e": "DEBUG=pw:browser xvfb-maybe -- playwright test --workers=1",
"copy:assets": "rimraf --glob \"./pre-install/*.tgz\" && cpx \"../pre-install/*.tgz\" \"./pre-install\"",
"version-patch": "jq '.version' package.json | tr -d '\"' > .version.bak && jq --arg ver \"0.1.$(date +%s)\" '.version = $ver' package.json > package.tmp && mv package.tmp package.json",
"version-restore": "jq --arg ver $(cat .version.bak) '.version = $ver' package.json > package.tmp && mv package.tmp package.json && rm .version.bak",
"dev": "yarn copy:assets && tsc -p . && yarn version-patch && electron . && yarn version-restore",
"version-patch": "run-script-os",
"version-patch:darwin:linux": "jq '.version' package.json | tr -d '\"' > .version.bak && jq --arg ver \"0.1.$(date +%s)\" '.version = $ver' package.json > package.tmp && mv package.tmp package.json",
"version-patch:win32": "node -e \"const fs=require('fs');const pkg=require('./package.json');const bak=pkg.version;fs.writeFileSync('.version.bak',bak);pkg.version='0.1.'+Math.floor(Date.now()/1000);fs.writeFileSync('package.json',JSON.stringify(pkg,null,2));\"",
"version-restore": "run-script-os",
"version-restore:darwin:linux": "jq --arg ver $(cat .version.bak) '.version = $ver' package.json > package.tmp && mv package.tmp package.json && rm .version.bak",
"version-restore:win32": "node -e \"const fs=require('fs');const pkg=require('./package.json');const bak=fs.readFileSync('.version.bak','utf8');pkg.version=bak;fs.writeFileSync('package.json',JSON.stringify(pkg,null,2));\"",
"dev:darwin:linux": "yarn copy:assets && tsc -p . && yarn version-patch && electron . && yarn version-restore",
"dev:windows": "yarn copy:assets && tsc -p . && electron .",
"dev": "run-script-os",
"compile": "tsc -p .",
"start": "electron .",
"build": "yarn copy:assets && run-script-os",
Expand Down Expand Up @@ -129,6 +135,7 @@
"electron-playwright-helpers": "^1.6.0",
"eslint": "8.57.0",
"eslint-plugin-react": "^7.34.0",
"jq": "^1.7.2",
"rimraf": "^5.0.5",
"run-script-os": "^1.1.6",
"typescript": "^5.3.3",
Expand All @@ -138,4 +145,4 @@
"hoistingLimits": "workspaces"
},
"packageManager": "[email protected]"
}
}
6 changes: 5 additions & 1 deletion extensions/engine-management-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
"scripts": {
"test": "jest",
"build": "rolldown -c rolldown.config.mjs",
"build:publish": "rimraf *.tgz --glob || true && yarn build && ../../.github/scripts/auto-sign.sh && npm pack && cpx *.tgz ../../pre-install"
"codesign:darwin": "../../.github/scripts/auto-sign.sh",
"codesign:win32:linux": "echo 'No codesigning required'",
"codesign": "run-script-os",
"build:publish": "rimraf *.tgz --glob || true && yarn build && yarn codesign && npm pack && cpx *.tgz ../../pre-install"
},
"exports": {
".": "./dist/index.js",
Expand All @@ -20,6 +23,7 @@
"cpx": "^1.5.0",
"rimraf": "^3.0.2",
"rolldown": "^1.0.0-beta.1",
"run-script-os": "^1.1.6",
"ts-loader": "^9.5.0",
"typescript": "^5.3.3"
},
Expand Down
2 changes: 1 addition & 1 deletion extensions/inference-cortex-extension/rolldown.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export default defineConfig([
SETTINGS: JSON.stringify(defaultSettingJson),
CORTEX_API_URL: JSON.stringify('http://127.0.0.1:39291'),
CORTEX_SOCKET_URL: JSON.stringify('ws://127.0.0.1:39291'),
CORTEX_ENGINE_VERSION: JSON.stringify('v0.1.42'),
CORTEX_ENGINE_VERSION: JSON.stringify('v0.1.43'),
},
},
{
Expand Down
27 changes: 26 additions & 1 deletion extensions/inference-cortex-extension/src/node/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from 'path'
import { getJanDataFolderPath, log, SystemInformation } from '@janhq/core/node'
import { appResourcePath, getJanDataFolderPath, log, SystemInformation } from '@janhq/core/node'
import { ProcessWatchdog } from './watchdog'
import { readdir, symlink } from 'fs/promises'

// The HOST address to use for the Nitro subprocess
const LOCAL_PORT = '39291'
Expand All @@ -17,7 +18,13 @@ function run(systemInfo?: SystemInformation): Promise<any> {
let gpuVisibleDevices = systemInfo?.gpuSetting?.gpus_in_use.join(',') ?? ''
let binaryName = `cortex-server${process.platform === 'win32' ? '.exe' : ''}`
const binPath = path.join(__dirname, '..', 'bin')
await createEngineSymlinks(binPath)

const executablePath = path.join(binPath, binaryName)
const sharedPath = path.join(
appResourcePath(),
'shared'
)
// Execute the binary
log(`[CORTEX]:: Spawn cortex at path: ${executablePath}`)

Expand Down Expand Up @@ -46,13 +53,31 @@ function run(systemInfo?: SystemInformation): Promise<any> {
GGML_VK_VISIBLE_DEVICES: gpuVisibleDevices,
}),
},
cwd: sharedPath,
}
)
watchdog.start()
resolve()
})
}

/**
* Create symlinks for the engine shared libraries
* @param binPath
*/
async function createEngineSymlinks(binPath: string) {
const sharedPath = path.join(appResourcePath(), 'shared')
const sharedLibFiles = await readdir(sharedPath)
for (const sharedLibFile of sharedLibFiles) {
if (sharedLibFile.endsWith('.dll') || sharedLibFile.endsWith('.so')) {
const targetDllPath = path.join(sharedPath, sharedLibFile)
const symlinkDllPath = path.join(binPath, sharedLibFile)
await symlink(targetDllPath, symlinkDllPath).catch(console.error)
console.log(`Symlink created: ${targetDllPath} -> ${symlinkDllPath}`)
}
}
}

/**
* Every module should have a dispose function
* This will be called when the extension is unloaded and should clean up any resources
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"rimraf": "^3.0.2",
"run-script-os": "^1.1.6",
"wait-on": "^7.0.1"
},
"version": "0.0.0",
Expand Down

0 comments on commit 5457d34

Please sign in to comment.