From a38432dae183698bed9a21f1c3e3e1ee6a5b6d9e Mon Sep 17 00:00:00 2001 From: Diane0111 <141645593+Diane0111@users.noreply.github.com> Date: Tue, 2 Jan 2024 17:22:55 +0700 Subject: [PATCH 01/12] Update onboarding.md --- docs/docs/handbook/onboarding.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/handbook/onboarding.md b/docs/docs/handbook/onboarding.md index e9124bdad..3aec99258 100644 --- a/docs/docs/handbook/onboarding.md +++ b/docs/docs/handbook/onboarding.md @@ -32,7 +32,7 @@ Welcome to Jan! We’re really excited to bring you onboard. - We operate on the basis of trust. - We expect you to be available and communicative during scheduled meetings or work hours. - Turning on video during meetings is encouraged. -- Casual dress during meetings is acceptable; however, use discretion (No naked top, pajamas, etc.) +- Casual dress during meetings is acceptable; however, use discretion (No nudity, pajamas, etc.) - While it’s natural for people to disagree at times, disagreement is no excuse for poor behavior and poor manners. We cannot allow that frustration to turn into a personal attack. - Respect other people's cultures. Especially since we are working in a diverse working culture. - Sexual harassment is a specific type of prohibited conduct. Sexual harassment is any unwelcome conduct of a sexual nature that might reasonably be expected or be perceived to cause offense or humiliation. Sexual harassment may involve any conduct of a verbal, nonverbal, or physical nature, including written and electronic communications, and may occur between persons of the same or different genders. From 1c38710308e9a105d1bdbc97dc83fa5c850ad972 Mon Sep 17 00:00:00 2001 From: Gri-ffin Date: Tue, 2 Jan 2024 14:05:52 +0100 Subject: [PATCH 02/12] add social media links --- web/containers/Layout/Ribbon/index.tsx | 45 ++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/web/containers/Layout/Ribbon/index.tsx b/web/containers/Layout/Ribbon/index.tsx index fa6d53193..1a63b1d44 100644 --- a/web/containers/Layout/Ribbon/index.tsx +++ b/web/containers/Layout/Ribbon/index.tsx @@ -11,6 +11,8 @@ import { SettingsIcon, MonitorIcon, LayoutGridIcon, + Twitter, + Github, } from 'lucide-react' import { twMerge } from 'tailwind-merge' @@ -52,6 +54,23 @@ export default function RibbonNav() { }, ] + const linksMenu = [ + { + name: 'Twitter', + icon: ( + + ), + link: 'https://twitter.com/janhq', + }, + { + name: 'Github', + icon: ( + + ), + link: 'https://github.com/janhq/jan', + }, + ] + const secondaryMenus = [ { name: 'System Monitor', @@ -118,6 +137,32 @@ export default function RibbonNav() {
+ <> + {linksMenu + .filter((link) => !!link) + .map((link, i) => { + return ( +
+ + + + {link.icon} + + + + {link.name} + + + +
+ ) + })} + {secondaryMenus .filter((secondary) => !!secondary) .map((secondary, i) => { From d20810e67834be6b6a79fd96cc0495f4e1e2321a Mon Sep 17 00:00:00 2001 From: Gri-ffin Date: Tue, 2 Jan 2024 14:06:18 +0100 Subject: [PATCH 03/12] open social media in default browser instead of electron window --- electron/main.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/electron/main.ts b/electron/main.ts index 4ddf4df56..257842cf5 100644 --- a/electron/main.ts +++ b/electron/main.ts @@ -68,6 +68,12 @@ function createMainWindow() { if (process.platform !== 'darwin') app.quit() }) + /* Open external links in the default browser */ + mainWindow.webContents.setWindowOpenHandler(({ url }) => { + require('electron').shell.openExternal(url) + return { action: 'deny' } + }) + /* Enable dev tools for development */ if (!app.isPackaged) mainWindow.webContents.openDevTools() } From b5c72f65cf3238912415b6b7ecee2e438035316f Mon Sep 17 00:00:00 2001 From: Louis Date: Tue, 2 Jan 2024 23:26:36 +0700 Subject: [PATCH 04/12] fix: disable process logging from server (#1296) --- core/src/node/index.ts | 1 + core/src/node/log.ts | 14 ++++++++++++++ server/index.ts | 25 +++++-------------------- 3 files changed, 20 insertions(+), 20 deletions(-) create mode 100644 core/src/node/log.ts diff --git a/core/src/node/index.ts b/core/src/node/index.ts index 49c2c3c26..50651d1fd 100644 --- a/core/src/node/index.ts +++ b/core/src/node/index.ts @@ -5,3 +5,4 @@ export * from './extension/store' export * from './download' export * from './module' export * from './api' +export * from './log' diff --git a/core/src/node/log.ts b/core/src/node/log.ts new file mode 100644 index 000000000..6979e2afd --- /dev/null +++ b/core/src/node/log.ts @@ -0,0 +1,14 @@ +import fs from 'fs' +import util from 'util' +import path from 'path' +import os from 'os' + +export const logPath = path.join(os.homedir(), 'jan', 'app.log') + +var log_file = fs.createWriteStream(logPath, { + flags: 'a', +}) + +export const log = function (d: any) { + log_file.write(util.format(d) + '\n') +} diff --git a/server/index.ts b/server/index.ts index 6a03c06fd..55b4a8d3c 100644 --- a/server/index.ts +++ b/server/index.ts @@ -1,9 +1,8 @@ import fastify from "fastify"; import dotenv from "dotenv"; -import { v1Router } from "@janhq/core/node"; +import { log, v1Router } from "@janhq/core/node"; import path from "path"; -import fs from "fs"; -import util from "util"; + import os from "os"; dotenv.config(); @@ -14,18 +13,6 @@ const serverLogPath = path.join(os.homedir(), "jan", "server.log"); let server: any | undefined = undefined; -var log_file = fs.createWriteStream(serverLogPath, { - flags: "a", -}); -var log_stdout = process.stdout; -var log_stderr = process.stderr; - -const logServer = function (d: any) { - log_file.write(util.format(d) + "\n"); - log_stdout.write(util.format(d) + "\n"); - log_stderr.write(util.format(d) + "\n"); -}; - export const startServer = async (schemaPath?: string, baseDir?: string) => { try { server = fastify({ @@ -75,12 +62,10 @@ export const startServer = async (schemaPath?: string, baseDir?: string) => { host: JAN_API_HOST, }) .then(() => { - logServer( - `JAN API listening at: http://${JAN_API_HOST}:${JAN_API_PORT}` - ); + log(`JAN API listening at: http://${JAN_API_HOST}:${JAN_API_PORT}`); }); } catch (e) { - logServer(e); + log(e); } }; @@ -88,6 +73,6 @@ export const stopServer = async () => { try { await server.close(); } catch (e) { - logServer(e); + log(e); } }; From 1392da7cd41ca81f1f619044cf41b218e7e68c9b Mon Sep 17 00:00:00 2001 From: Service Account Date: Tue, 2 Jan 2024 16:47:16 +0000 Subject: [PATCH 05/12] janhq/jan: Update README.md with nightly build artifact URL --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7d8cd7802..a205cc896 100644 --- a/README.md +++ b/README.md @@ -70,25 +70,25 @@ Jan is an open-source ChatGPT alternative that runs 100% offline on your compute Experimental (Nightly Build) - + jan.exe - + Intel - + M1/M2 - + jan.deb From 162fa48c63a70962676dbba3482d5f54fc8c4af9 Mon Sep 17 00:00:00 2001 From: Louis Date: Wed, 3 Jan 2024 00:10:50 +0700 Subject: [PATCH 06/12] fix: should check app dir before spawning log (#1297) --- core/src/node/log.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/core/src/node/log.ts b/core/src/node/log.ts index 6979e2afd..7291516cd 100644 --- a/core/src/node/log.ts +++ b/core/src/node/log.ts @@ -3,12 +3,16 @@ import util from 'util' import path from 'path' import os from 'os' -export const logPath = path.join(os.homedir(), 'jan', 'app.log') +const appDir = path.join(os.homedir(), 'jan') -var log_file = fs.createWriteStream(logPath, { - flags: 'a', -}) +export const logPath = path.join(appDir, 'app.log') export const log = function (d: any) { - log_file.write(util.format(d) + '\n') + if (fs.existsSync(appDir)) { + var log_file = fs.createWriteStream(logPath, { + flags: 'a', + }) + log_file.write(util.format(d) + '\n') + log_file.close() + } } From 0a7e26d5fb55d9bc869b7291d0bbaaf2ab5340db Mon Sep 17 00:00:00 2001 From: hiento09 <136591877+hiento09@users.noreply.github.com> Date: Wed, 3 Jan 2024 02:09:17 +0700 Subject: [PATCH 07/12] Fix memory on mac included cached and swap (#1298) * Fix memory on mac included cached and swap * set inteval monitor to 0.5s --------- Co-authored-by: Hien To --- extensions/monitoring-extension/package.json | 4 +-- extensions/monitoring-extension/src/module.ts | 28 +++++++++---------- web/hooks/useGetSystemResources.ts | 4 +-- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/extensions/monitoring-extension/package.json b/extensions/monitoring-extension/package.json index 4fc51d578..9935e536e 100644 --- a/extensions/monitoring-extension/package.json +++ b/extensions/monitoring-extension/package.json @@ -17,7 +17,7 @@ }, "dependencies": { "@janhq/core": "file:../../core", - "os-utils": "^0.0.14", + "node-os-utils": "^1.3.7", "ts-loader": "^9.5.0" }, "files": [ @@ -26,6 +26,6 @@ "README.md" ], "bundleDependencies": [ - "os-utils" + "node-os-utils" ] } diff --git a/extensions/monitoring-extension/src/module.ts b/extensions/monitoring-extension/src/module.ts index 18b3b6c49..310e7359c 100644 --- a/extensions/monitoring-extension/src/module.ts +++ b/extensions/monitoring-extension/src/module.ts @@ -1,25 +1,25 @@ const os = require("os"); -const osUtils = require("os-utils"); +const nodeOsUtils = require("node-os-utils"); const getResourcesInfo = () => new Promise((resolve) => { - const totalMemory = os.totalmem(); - const freeMemory = os.freemem(); - const usedMemory = totalMemory - freeMemory; - - const response = { - mem: { - totalMemory, - usedMemory, - }, - }; - resolve(response); + nodeOsUtils.mem.used() + .then(ramUsedInfo => { + const totalMemory = ramUsedInfo.totalMemMb * 1024 * 1024; + const usedMemory = ramUsedInfo.usedMemMb * 1024 * 1024; + const response = { + mem: { + totalMemory, + usedMemory, + }, + }; + resolve(response); + }) }); const getCurrentLoad = () => new Promise((resolve) => { - osUtils.cpuUsage(function(v){ - const cpuPercentage = v * 100; + nodeOsUtils.cpu.usage().then(cpuPercentage =>{ const response = { cpu: { usage: cpuPercentage, diff --git a/web/hooks/useGetSystemResources.ts b/web/hooks/useGetSystemResources.ts index 74f8e6c40..9d6716480 100644 --- a/web/hooks/useGetSystemResources.ts +++ b/web/hooks/useGetSystemResources.ts @@ -46,12 +46,12 @@ export default function useGetSystemResources() { useEffect(() => { getSystemResources() - // Fetch interval - every 2s + // Fetch interval - every 0.5s // TODO: Will we really need this? // There is a possibility that this will be removed and replaced by the process event hook? const intervalId = setInterval(() => { getSystemResources() - }, 2000) + }, 500) // clean up interval return () => clearInterval(intervalId) From 7920069e246e3275a9cc6a6474cc85395f96fbbc Mon Sep 17 00:00:00 2001 From: Service Account Date: Tue, 2 Jan 2024 20:16:48 +0000 Subject: [PATCH 08/12] janhq/jan: Update README.md with nightly build artifact URL --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a205cc896..31e2c4714 100644 --- a/README.md +++ b/README.md @@ -70,25 +70,25 @@ Jan is an open-source ChatGPT alternative that runs 100% offline on your compute Experimental (Nightly Build) - + jan.exe - + Intel - + M1/M2 - + jan.deb From 868be419283fc074f58733c8d6541abc7162e18e Mon Sep 17 00:00:00 2001 From: 0xSage <69952136+0xSage@users.noreply.github.com> Date: Wed, 3 Jan 2024 12:32:45 +0800 Subject: [PATCH 09/12] fix: Jan twitter url --- web/containers/Layout/Ribbon/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/containers/Layout/Ribbon/index.tsx b/web/containers/Layout/Ribbon/index.tsx index 1a63b1d44..6a0146e64 100644 --- a/web/containers/Layout/Ribbon/index.tsx +++ b/web/containers/Layout/Ribbon/index.tsx @@ -60,7 +60,7 @@ export default function RibbonNav() { icon: ( ), - link: 'https://twitter.com/janhq', + link: 'https://twitter.com/janhq_', }, { name: 'Github', From 76aa41e7e5c0440f1bb30b9aaf591b937f47c500 Mon Sep 17 00:00:00 2001 From: 0xSage Date: Wed, 3 Jan 2024 13:57:45 +0800 Subject: [PATCH 10/12] docs: contributor docs overview --- docs/docs/docs/README.md | 65 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/docs/docs/docs/README.md b/docs/docs/docs/README.md index d6ff08d55..a1d1fc233 100644 --- a/docs/docs/docs/README.md +++ b/docs/docs/docs/README.md @@ -3,4 +3,67 @@ title: Overview slug: /docs --- -Hello world +The following low-level docs are aimed at core contributors and cover how to contribute to the Core SDK. + +:::tip +If you are interested to **build on top of the SDK**, like creating assistants or adding app level extensions, please refer to [developer docs](/developer) instead. +::: + +## Core SDK + +At its Core, Jan is a cross-platform, local-first and AI native framework that can be used to build anything. In fact, current features are all implemented as 3rd party extensions on top of this Core SDK. + +Ultimately, we aim for a VSCode or Obsidian like framework that allows devs to build and customize complex AI applications for their specific needs, in less than 15 minutes. + +### Cross Platform + +Jan follows [Clean Architecture](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html) to the best of our ability. Though leaky abstractions remain (we're a fast moving, open source codebase), we do our best to build an SDK that allows devs to **build once, deploy everywhere.** + +Currently, Jan supports: + +- `Node Native Runtime`, good for server side apps +- `Electron Chromium`, good for Desktop Native apps +- `Capacitor`, good for Mobile apps (planned, not built yet) +- `Python Runtime`, good for MLOps workflows (planned, not built yet) + +Currently, Jan works across: + +- Mac Intel & Silicon +- Windows +- Ubuntu +- Nvidia GPUs + +Read more: + +- [Code Entrypoint](https://github.com/janhq/jan/tree/main/core) +- [Dependency Inversion](https://en.wikipedia.org/wiki/Dependency_inversion_principle) + +### Local First + +Jan's data persistence happens on the user's local filesystem. + +We implemented abstractions on top of `fs` and other core modules in an opinionated way, s.t. user data is saved in a folder based way that allows for easy packaging and exporting. + +Read more: + +- [Jan fs wrapper](https://github.com/janhq/jan/blob/main/core/src/fs.ts) + +### AI Native + +All software applications can be natively supercharged with an embedded AI server and AI abstractions. + +The core SDK provides: + +- Native and common AI [types](https://github.com/janhq/jan/tree/main/core/src/types) and [core extensions](https://github.com/janhq/jan/tree/main/core/src/extensions) to support common AI functionality like making an inference call. +- An OpenAI compatible API definition that is autogenerated from code +- A lightweight, embedded C++ [inference engine](https://github.com/janhq/jan/tree/main/extensions/inference-nitro-extension) that is ready to be used. + +Read more: + +- [Code Entrypoint](https://github.com/janhq/jan/tree/main/core/src/api) + +## Fun Project Ideas + +- `GAme engine`: We think the Core SDK can be a cool AI game engine + +If you are interested to tackle these issues, or have suggestions for integrations and other OSS tools we can use, please hit us up in [Discord](https://discord.gg/5rQ2zTv3be). From 6c8c0ea6e04008b2bbfa9c7c7b5237341ad1cc82 Mon Sep 17 00:00:00 2001 From: 0xSage <69952136+0xSage@users.noreply.github.com> Date: Wed, 3 Jan 2024 14:24:42 +0800 Subject: [PATCH 11/12] chore: github PR template (#1304) * chore: github PR template * style: correct caps --- .github/pull_request_template.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/pull_request_template.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 000000000..45fd5d159 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,13 @@ +## Describe Your Changes + +- + +## Fixes Issues + +- + +## Self Checklist + +- [ ] Added relevant comments, esp in complex areas +- [ ] Updated docs (for bug fixes / features) +- [ ] Created issues for follow-up changes or refactoring needed From d472fdb24b12ef78361f37f1f076e6f681ef4634 Mon Sep 17 00:00:00 2001 From: 0xSage Date: Wed, 3 Jan 2024 14:56:04 +0800 Subject: [PATCH 12/12] docs: add core sdk ideas --- docs/docs/docs/README.md | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/docs/docs/docs/README.md b/docs/docs/docs/README.md index a1d1fc233..a82a8a801 100644 --- a/docs/docs/docs/README.md +++ b/docs/docs/docs/README.md @@ -42,28 +42,30 @@ Read more: Jan's data persistence happens on the user's local filesystem. -We implemented abstractions on top of `fs` and other core modules in an opinionated way, s.t. user data is saved in a folder based way that allows for easy packaging and exporting. +We implemented abstractions on top of `fs` and other core modules in an opinionated way, s.t. user data is saved in a folder-based framework that lets users easily package, export, and manage their data. Read more: -- [Jan fs wrapper](https://github.com/janhq/jan/blob/main/core/src/fs.ts) +- [Folder-based fs wrapper](https://github.com/janhq/jan/blob/main/core/src/fs.ts) +- [Piping Node modules across infrastructures](https://github.com/janhq/jan/tree/main/core/src/node) ### AI Native All software applications can be natively supercharged with an embedded AI server and AI abstractions. -The core SDK provides: +Including: -- Native and common AI [types](https://github.com/janhq/jan/tree/main/core/src/types) and [core extensions](https://github.com/janhq/jan/tree/main/core/src/extensions) to support common AI functionality like making an inference call. -- An OpenAI compatible API definition that is autogenerated from code -- A lightweight, embedded C++ [inference engine](https://github.com/janhq/jan/tree/main/extensions/inference-nitro-extension) that is ready to be used. - -Read more: +- OpenAI Compatible AI [types](https://github.com/janhq/jan/tree/main/core/src/types) and [core extensions](https://github.com/janhq/jan/tree/main/core/src/extensions) to support common functionality like making an inference call. +- A lightweight, embedded C++ [inference engine](https://github.com/janhq/jan/tree/main/extensions/inference-nitro-extension) that's immediately callable from code. - [Code Entrypoint](https://github.com/janhq/jan/tree/main/core/src/api) ## Fun Project Ideas -- `GAme engine`: We think the Core SDK can be a cool AI game engine +Beyond the current Jan client and UX, the Core SDK can be used to build many other AI-powered and privacy preserving applications. + +- `Game engine`: For AI enabled character games, procedural generation games +- `Health app`: For a personal healthcare app that improves habits +- Got ideas? Make a PR into this docs page! If you are interested to tackle these issues, or have suggestions for integrations and other OSS tools we can use, please hit us up in [Discord](https://discord.gg/5rQ2zTv3be).