Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: user provided addresses #61

Open
wants to merge 11 commits into
base: development
Choose a base branch
from
12 changes: 12 additions & 0 deletions .setup/error-with-remedy.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export class ErrorWithRemedy extends Error {
constructor(errorMessage, remedyMessage) {
super(errorMessage);
this.name = this.constructor.name;
this.remedy = remedyMessage;

// Maintaining proper stack trace for where our error was thrown (only available on V8)
if (Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor);
}
}
}
23 changes: 23 additions & 0 deletions .setup/format.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export function formatRed(message) {
return `\x1b[31m${message}\x1b[0m`;
}

export function formatGray(message) {
return `\x1b[37m${message}\x1b[0m`;
}

export function formatItalics(message) {
return `\x1b[3m${message}\x1b[0m`;
}

export function formatBold(message) {
return `\x1b[1m${message}\x1b[0m`;
}

export function formatError(message) {
return formatBold(formatRed(message));
}

export function formatExample(message) {
return formatGray(formatItalics(message));
}
21 changes: 21 additions & 0 deletions .setup/log.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { formatBold, formatError, formatGray } from './format.mjs';

export function logInfo(message) {
console.log(formatGray(message));
}

/**
* Log an error to the console with an error `message` and optional `remedy`
* @param error in the format { message: string, remedy?: string }
* @returns void
*/
export function logError(error) {
console.error();
console.error(formatError(error?.message || error));
if (error?.remedy) {
console.error();
console.error(formatBold('Suggested remedy:'));
console.error(error.remedy);
}
console.error();
}
13 changes: 13 additions & 0 deletions .setup/macos/python-path.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { logInfo } from '../log.mjs';
import { execSync } from 'child_process';

export function getPythonPath() {
const nodeGypPythonPath = process.env.NODE_GYP_FORCE_PYTHON;
if (nodeGypPythonPath) {
logInfo(`NODE_GYP_FORCE_PYTHON=${nodeGypPythonPath}`);
return nodeGypPythonPath;
}
logInfo(`defaulting to system's python3`);
return execSync(`which python3`).toString().trim();
}

27 changes: 27 additions & 0 deletions .setup/macos/validate-executable.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import fs from 'fs';

export function validateExecutable(path) {
existsOnSystem(path)
isNotADirectory(path)
isExecutable(path)
}

function existsOnSystem(path) {
if (!fs.existsSync(path)) {
throw new Error(`Path ${path} does not exist`);
}
}

function isNotADirectory(path) {
if (fs.statSync(path).isDirectory()) {
throw new Error(`${path} is a directory. Please provide the path to an executable.`);
}
}

function isExecutable(path) {
try {
fs.accessSync(path, fs.constants.X_OK);
} catch (err) {
throw new Error(`${path} is not executable`);
}
}
53 changes: 53 additions & 0 deletions .setup/macos/validate-setup.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { execSync } from 'child_process';
import { ErrorWithRemedy } from '../error-with-remedy.mjs';
import { formatExample } from '../format.mjs';
import { getPythonPath } from './python-path.mjs';
import { logInfo } from '../log.mjs';
import { validateExecutable } from './validate-executable.mjs';

/**
* On macOS, this script checks if Python 3.10 is installed and accessible to node-gyp.
*
* I ran into a problem trying to `yarn` install, with a system Python version of `3.12.2`,
* but ran into the error `ModuleNotFoundError: No module named 'distutils'`.
* Since node-gyp relies on `distutils`, which is removed in Python `3.12`,
* you need to use a Python version that still includes `distutils`.
*/
export function validateMacSetup() {
logInfo('Installing on macOS');
const pythonPath = getPythonPath();
validateExecutable(pythonPath);

let error;
try {
const pythonVersionOutput = execSync(`${pythonPath} --version`).toString().trim();
logInfo(`${pythonPath} == (${pythonVersionOutput})`);

const pythonVersion = pythonVersionOutput.split(' ')[1].trim();
const majorVersion = parseInt(pythonVersion.split('.')[0]);
const minorVersion = parseInt(pythonVersion.split('.')[1]);
const noCompatiblePythonVersionFound = !(majorVersion === 3 && (minorVersion >= 10 && minorVersion < 12));

if (noCompatiblePythonVersionFound) {
error = `Incompatible Python version ${pythonVersion} found. Python 3.10 is required.`;
}

} catch (caughtError) {
error = `Python 3.10 was not found with error: ${caughtError?.message || caughtError}`;
}
if (error) {
const checkForPythonInstall = 'Check for versions of python installed on your system. For example, if you use brew:';
const displayBrewPythonVersionsExample = formatExample('brew list --versions | grep python');

const pleaseInstallPython = 'If python 3.10 was not found, install it. For example:';
const installPythonExample = formatExample('brew install [email protected]');

const configureNodeGypPython = 'Ensure you have an environment variable for NODE_GYP_FORCE_PYTHON pointing to your python 3.10 path.\n For example, assuming you installed [email protected] with brew:';
const exportNodeGypPythonEnvVariable = formatExample('export NODE_GYP_FORCE_PYTHON=$(brew --prefix [email protected])/bin/python3.10');

throw new ErrorWithRemedy(error, ` STEP 1: ${checkForPythonInstall} ${displayBrewPythonVersionsExample}
\n STEP 2: ${pleaseInstallPython} ${installPythonExample}
\n STEP 3: ${configureNodeGypPython} ${exportNodeGypPythonEnvVariable}`
);
}
}
20 changes: 20 additions & 0 deletions .setup/yarn-preinstall-system-validation.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import * as os from 'os';
import { validateMacSetup } from './macos/validate-setup.mjs';
import { logError } from './log.mjs';

/**
* Validate the system setup at the beginning of `yarn` install.
*/
try {
const platform = os.platform();
switch (platform) {
case 'darwin':
validateMacSetup();
break;
default:
console.log(`No setup validation required for platform ${platform}`);
}
} catch(setupError) {
logError(setupError);
process.exit(1);
}
70 changes: 58 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,70 @@
MORPHEUS NODE

First, clone this repo.
Morhpheus Node Setup

Then, start yarn.

`yarn`

This will set up all node modules needed.
Windows OS Systems

If you want to test the app without building an executable:
Prerequisites

`yarn start`
Node.js for Windows
Follow the instructions listed here for Node.js setup:
• https://phoenixnap.com/kb/install-node-js-npm-on-windows

To build an executable to run on your current system's specs:
Yarn for Windows
Follow the instructions listed here for Yarn Package Manager setup:
• https://phoenixnap.com/kb/yarn-windows

`yarn make`
1. Create Project Directory
Open a Windows command prompt and create a project folder and put your command line at that directory

I.e. Presume the starting directory is: C:\projects

Other run, test, and build scripts can be found in package.json
mkdir c:\projects

Please visit MOR.software to sign up as a developer to be rewarded for your merged contributions. Submit an MRC to get support for feature and improvement ideas.
cd /d c:\projects

2. Morpheus client Workspace Setup
From a command line at the project directory (created in #1), type:

git clone https://github.com/MorpheusAIs/Lite-Client.git

3. Project Environment Setup
Set up the modules and components using the Yarn Package Manager

Navigate to the command line of the Morpheus client local repository, then type the following command:

yarn

This will set up all node modules needed.

4. Build the Morpheus Client App
From a command line at the root directory of the local Morpheus Client repo, build the client executable, type:

yarn make


6. Application Runtime and Testing
Upon successful build, run the Morpheus client app by clicking the following executable or start from the command line:

<PATH-TO-LOCAL-MORPHEUS-CLIENT-REPO>\Lite-Client-main\out\morpheus-win32-x64.exe



NOTES

• Additional Run, Test, and Build scripts are located in the package.json configuration file in the root directory of the Morpheus client repo

• Please visit https://mor.software/ to sign up as a developer to be rewarded for your merged contributions. Submit an MRC to get support for feature and improvement ideas.

• https://mor.software/ is also the place to build, submit, deploy, and manage all of your Smart Agents.

• Be sure to complete these steps from an account with administrative access to the host machine

• The initial start of the application may take extended time to start due to the initial configuration and run of the application



### Windows installer instructions (Doc format)
[Google Doc](https://docs.google.com/document/d/1YjGAlTzglct8aNEqZAUeYD7SAmOETtmv/edit?usp=sharing&ouid=118042204753952761929&rtpof=true&sd=true)

MOR.software is also the place to build, submit, deplloy, and manage all of your Smart Agents.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"description": "Morpheus is private, sovereign, AI",
"main": ".webpack/main",
"scripts": {
"preinstall": "node .setup/yarn-preinstall-system-validation.mjs",
"start": "cross-env NODE_ENV=development DEBUG=electron-packager electron-forge start",
"package": "set DEBUG=electron-packager && electron-forge package",
"make": "electron-forge make",
Expand Down
4 changes: 4 additions & 0 deletions src/frontend/assets/images/addresses.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions src/frontend/components/layout/navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,20 @@ import MainNavigationButton from '../buttons/navigation-button';
// images
import ChatImg from './../../assets/images/chat.svg';
import HomeImg from './../../assets/images/home.svg';
import AddressesImg from './../../assets/images/addresses.svg';
import SettingsImg from './../../assets/images/settings.svg';

const MainNavigation = () => {
return (
<TopNav.Layout>
<TopNav.MainNavButton icon={<TopNav.ChatIcon />} text="chat" href="/chat" exact={true} />
{/* <TopNav.MainNavButton icon={<TopNav.HomeIcon />} text="home" href="/" exact={true} /> */}
<TopNav.MainNavButton
icon={<TopNav.AddressesIcon />}
text="addresses"
href="/addresses"
exact={true}
/>
<TopNav.MainNavButton
icon={<TopNav.SettingsIcon />}
text="settings"
Expand Down Expand Up @@ -52,6 +59,11 @@ const TopNav = {
width: 50px;
height: 50px;
`,
AddressesIcon: Styled(AddressesImg)`
display: flex;
width: 50px;
height: 50px;
`,
SettingsIcon: Styled(SettingsImg)`
display: flex;
width: 50px;
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import Styled from 'styled-components';
// views
// import HomeView from './views/home';
import SettingsView from './views/settings';
import AddressesView from './views/addresses';
import ChatView from './views/chat';

export const RoutesWrapper = () => {
return (
<Routes>
<Route path="/" element={<Navigate to="/chat" />} />
<Route path="/settings" Component={SettingsView} />
<Route path="/addresses" Component={AddressesView} />
<Route path="/chat" Component={ChatView} />
</Routes>
);
Expand Down
Loading
Loading