From 92769d491280b6f1b03423d7eb028b0d615429f9 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 14 Sep 2023 20:22:18 -0700 Subject: [PATCH 001/349] Await output just in case --- packages/core/shared/src/nodes/io/Output.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/shared/src/nodes/io/Output.ts b/packages/core/shared/src/nodes/io/Output.ts index 29ac030adb..d8e09e44e5 100644 --- a/packages/core/shared/src/nodes/io/Output.ts +++ b/packages/core/shared/src/nodes/io/Output.ts @@ -167,7 +167,7 @@ export class Output extends MagickComponent { } else if (!t.handler) { this.logger.error({ outputType, finalType: t }, 'Output type is not defined') } else { - t.handler({ + await t.handler({ output, agent: agent, event, From c345c5feb02a9b086c70235c53b05f178ebfe309 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 14 Sep 2023 20:26:13 -0700 Subject: [PATCH 002/349] Add ping to agent methods array --- packages/core/server/src/services/agents/agents.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/server/src/services/agents/agents.ts b/packages/core/server/src/services/agents/agents.ts index cac5a42cf8..b86134f0ae 100644 --- a/packages/core/server/src/services/agents/agents.ts +++ b/packages/core/server/src/services/agents/agents.ts @@ -58,7 +58,7 @@ const AGENT_EVENTS = ['log', 'result', 'spell', 'run'] export const agent = (app: Application) => { // Register the agent service on the Feathers application app.use('agents', new AgentService(getOptions(app), app), { - methods: ['find', 'get', 'create', 'patch', 'remove', 'run'], + methods: ['find', 'get', 'create', 'patch', 'remove', 'run', 'ping'], events: AGENT_EVENTS, }) From c1a8fbcee8fbb9917f29f560b6887b291c9037f3 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 14 Sep 2023 20:49:33 -0700 Subject: [PATCH 003/349] Publish to agent channel and project channel --- packages/core/server/src/sockets/channels.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/core/server/src/sockets/channels.ts b/packages/core/server/src/sockets/channels.ts index afe9d8c3ca..f8d331a22a 100644 --- a/packages/core/server/src/sockets/channels.ts +++ b/packages/core/server/src/sockets/channels.ts @@ -92,6 +92,15 @@ export default function (app: Application): void { context.data?.projectId || data.projectId + const agentId = + context.params?.agentId || + context.result.agentId || + context.data?.agentId || + data.agentId + + // don't publish if we are an agent + if (app.get('isAgent')) return + // Lets not relay up all the patch events if (context.method === 'patch' || !projectId) return @@ -100,7 +109,8 @@ export default function (app: Application): void { projectId ) // Publish all events to the authenticated user channel - const channel = app.channel(projectId) - return channel + const projectChannel = app.channel(projectId) + const agentChannel = app.channel(`agent:${agentId}`) + return [projectChannel, agentChannel] }) } From 2be4b98cdca87a8fef8c61cfdb2b96be2f0fab5a Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 14 Sep 2023 20:49:46 -0700 Subject: [PATCH 004/349] Add new subscribagent class method --- .../src/services/agents/agents.class.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/packages/core/server/src/services/agents/agents.class.ts b/packages/core/server/src/services/agents/agents.class.ts index 0eddbbaf2d..3ccc17a7ac 100644 --- a/packages/core/server/src/services/agents/agents.class.ts +++ b/packages/core/server/src/services/agents/agents.class.ts @@ -61,6 +61,25 @@ export class AgentService< return { response } } + async subscribe(agentId: string, params: ServiceParams) { + // check for socket io + if (!params.provider) + throw new Error('subscribe is only available via socket io') + + // get the socket from the params + const connection = params.connection + const oldAgentChannel = app.channels.filter(channel => + agentId.match(/agent:/) + )[0] + // leave the old channel + app.channel(oldAgentChannel).leave(connection) + + // join the new channel + app.channel(`agent:${agentId}`).join(connection) + + return true + } + async create( data: AgentData | AgentData[] | any ): Promise { From 2c2f27b24754bab936c3be18b0c7a6ab7f3af6cb Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 14 Sep 2023 20:50:28 -0700 Subject: [PATCH 005/349] Add subscribe method to agent methods array --- packages/core/server/src/services/agents/agents.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/core/server/src/services/agents/agents.ts b/packages/core/server/src/services/agents/agents.ts index b86134f0ae..be8f2a25b9 100644 --- a/packages/core/server/src/services/agents/agents.ts +++ b/packages/core/server/src/services/agents/agents.ts @@ -58,7 +58,16 @@ const AGENT_EVENTS = ['log', 'result', 'spell', 'run'] export const agent = (app: Application) => { // Register the agent service on the Feathers application app.use('agents', new AgentService(getOptions(app), app), { - methods: ['find', 'get', 'create', 'patch', 'remove', 'run', 'ping'], + methods: [ + 'find', + 'get', + 'create', + 'patch', + 'remove', + 'run', + 'ping', + 'subscribe', + ], events: AGENT_EVENTS, }) From a61b4e560091a6a5f6c99af8a59881b71add7620 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 14 Sep 2023 21:37:13 -0700 Subject: [PATCH 006/349] Add state package --- packages/state/.eslintrc.json | 25 ++++ packages/state/README.md | 11 ++ packages/state/package.json | 8 + packages/state/project.json | 34 +++++ packages/state/src/index.ts | 7 + packages/state/src/lib/api/api.ts | 65 ++++++++ packages/state/src/lib/api/spells.ts | 196 +++++++++++++++++++++++++ packages/state/src/lib/globalConfig.ts | 54 +++++++ packages/state/src/lib/hooks.ts | 22 +++ packages/state/src/lib/localState.ts | 61 ++++++++ packages/state/src/lib/preferences.ts | 43 ++++++ packages/state/src/lib/store.ts | 73 +++++++++ packages/state/src/lib/tabs.ts | 171 +++++++++++++++++++++ packages/state/tsconfig.json | 23 +++ packages/state/tsconfig.lib.json | 10 ++ packages/state/tsconfig.spec.json | 19 +++ packages/state/vite.config.ts | 52 +++++++ tsconfig.base.json | 2 + 18 files changed, 876 insertions(+) create mode 100644 packages/state/.eslintrc.json create mode 100644 packages/state/README.md create mode 100644 packages/state/package.json create mode 100644 packages/state/project.json create mode 100644 packages/state/src/index.ts create mode 100644 packages/state/src/lib/api/api.ts create mode 100644 packages/state/src/lib/api/spells.ts create mode 100644 packages/state/src/lib/globalConfig.ts create mode 100644 packages/state/src/lib/hooks.ts create mode 100644 packages/state/src/lib/localState.ts create mode 100644 packages/state/src/lib/preferences.ts create mode 100644 packages/state/src/lib/store.ts create mode 100644 packages/state/src/lib/tabs.ts create mode 100644 packages/state/tsconfig.json create mode 100644 packages/state/tsconfig.lib.json create mode 100644 packages/state/tsconfig.spec.json create mode 100644 packages/state/vite.config.ts diff --git a/packages/state/.eslintrc.json b/packages/state/.eslintrc.json new file mode 100644 index 0000000000..adbe7ae2df --- /dev/null +++ b/packages/state/.eslintrc.json @@ -0,0 +1,25 @@ +{ + "extends": ["../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], + "rules": {} + }, + { + "files": ["*.ts", "*.tsx"], + "rules": {} + }, + { + "files": ["*.js", "*.jsx"], + "rules": {} + }, + { + "files": ["*.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": "error" + } + } + ] +} diff --git a/packages/state/README.md b/packages/state/README.md new file mode 100644 index 0000000000..6135205718 --- /dev/null +++ b/packages/state/README.md @@ -0,0 +1,11 @@ +# state + +This library was generated with [Nx](https://nx.dev). + +## Building + +Run `nx build state` to build the library. + +## Running unit tests + +Run `nx test state` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/packages/state/package.json b/packages/state/package.json new file mode 100644 index 0000000000..c841eb7800 --- /dev/null +++ b/packages/state/package.json @@ -0,0 +1,8 @@ +{ + "name": "@magickml/state", + "version": "0.0.1", + "dependencies": {}, + "main": "./index.js", + "module": "./index.mjs", + "typings": "./index.d.ts" +} diff --git a/packages/state/project.json b/packages/state/project.json new file mode 100644 index 0000000000..24359c01b8 --- /dev/null +++ b/packages/state/project.json @@ -0,0 +1,34 @@ +{ + "name": "state", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "packages/state/src", + "projectType": "library", + "targets": { + "build": { + "executor": "@nx/vite:build", + "outputs": ["{options.outputPath}"], + "options": { + "outputPath": "dist/packages/state" + } + }, + "test": { + "executor": "@nx/vite:test", + "outputs": ["{options.reportsDirectory}"], + "options": { + "passWithNoTests": true, + "reportsDirectory": "../../coverage/packages/state" + } + }, + "lint": { + "executor": "@nx/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": [ + "packages/state/**/*.ts", + "packages/state/package.json" + ] + } + } + }, + "tags": [] +} diff --git a/packages/state/src/index.ts b/packages/state/src/index.ts new file mode 100644 index 0000000000..a2217ef3c3 --- /dev/null +++ b/packages/state/src/index.ts @@ -0,0 +1,7 @@ +export * from './lib/api/spells' +export * from './lib/globalConfig' +export * from './lib/hooks' +export * from './lib/localState' +export * from './lib/preferences' +export * from './lib/store' +export * from './lib/tabs' diff --git a/packages/state/src/lib/api/api.ts b/packages/state/src/lib/api/api.ts new file mode 100644 index 0000000000..b68bdb9ec2 --- /dev/null +++ b/packages/state/src/lib/api/api.ts @@ -0,0 +1,65 @@ +// DOCUMENTED +// Import necessary libraries and types from toolkit +import { + BaseQueryFn, + createApi, + FetchArgs, + fetchBaseQuery, + FetchBaseQueryError, +} from '@reduxjs/toolkit/query/react' +import { RootState } from '../store' + +/** + * Dynamic base query that can be used to create a Redux Toolkit Query API + * with a dynamic API url and token based on the current state. + * + * @param args - The URL or FetchArgs containing the request information. + * @param api - The Redux Toolkit Query API instance. + * @param extraOptions - Any extra options provided during the request. + * @returns A FetchBaseQueryError if apiUrl missing, otherwise the response of the request. + */ +const dynamicBaseQuery: BaseQueryFn< + string | FetchArgs, + unknown, + FetchBaseQueryError +> = async (args, api, extraOptions) => { + // Get state from Redux store + const state = api.getState() as RootState + // Extract apiUrl and token from state + const apiUrl = state.globalConfig.apiUrl + const token = state.globalConfig.token + + // Handle scenarios where apiUrl is not present gracefully + if (!apiUrl) { + return { + error: { + status: 400, + statusText: 'Bad Request', + data: 'No apiUrl present', + }, + } + } + + // Create rawBaseQuery with provided apiUrl and token (if exists) + const rawBaseQuery = fetchBaseQuery({ + baseUrl: apiUrl, + prepareHeaders: async headers => { + if (token) headers.set('authorization', `Bearer ${token}`) + return headers + }, + }) + + // Return rawBaseQuery result with provided args and extraOptions + return rawBaseQuery(args, api, extraOptions) +} + +/** + * Creates a root API with a dynamic base query, appropriate reducerPath, + * tagTypes, and empty endpoints. + */ +export const rootApi = createApi({ + reducerPath: 'api', // Set reducer path + baseQuery: dynamicBaseQuery, // Use dynamicBaseQuery as baseQuery + tagTypes: ['Spell', 'Spells', 'Version'], // Define tagTypes for invalidation + endpoints: () => ({}), // Provide an empty object for endpoints +}) \ No newline at end of file diff --git a/packages/state/src/lib/api/spells.ts b/packages/state/src/lib/api/spells.ts new file mode 100644 index 0000000000..3690c55dac --- /dev/null +++ b/packages/state/src/lib/api/spells.ts @@ -0,0 +1,196 @@ +// DOCUMENTED +import { FetchBaseQueryError } from '@reduxjs/toolkit/query/react' +import { QueryReturnValue } from '@reduxjs/toolkit/dist/query/baseQueryTypes' +import { rootApi } from './api' +import { SpellInterface } from '@magickml/core' +import md5 from 'md5' + +/** + * @interface Diff represents a spell diff. + */ +export interface Diff { + name: string + diff: Record +} + +/** + * @interface PatchArgs represents arguments for patching a spell. + */ +export interface PatchArgs { + spellName: string + update: Partial +} + +/** + * @interface UserSpellArgs represents arguments for user spell. + */ +export interface UserSpellArgs { + spellName: string +} + +/** + * @interface SpellData represents spell data pagination. + */ +export interface SpellData { + limit: number + skip: number + total: number + data: SpellInterface[] +} + +/** + * @name spellApi Injects API endpoints used for spell management. + */ +export const spellApi = rootApi.injectEndpoints({ + endpoints: builder => ({ + // Api endpoint for getting spells + getSpells: builder.query({ + providesTags: ['Spells'], + query: ({ projectId }) => ({ + url: `spells?projectId=${projectId}`, + }), + }), + // Api endpoint for getting a spell by name + getSpell: builder.query({ + providesTags: ['Spell'], + query: ({ spellName, projectId }) => { + return { + url: `spells?name=${spellName}&projectId=${projectId}`, + params: {}, + } + }, + }), + // Api endpoint for getting a spell by name and ID + getSpellById: builder.query({ + providesTags: ['Spell'], + query: ({ spellName, projectId, id }) => { + return { + url: `spells?name=${spellName}&projectId=${projectId}&id=${id}`, + params: {}, + } + }, + }), + // Api endpoint for getting a spell by ID only + getSpellByJustId: builder.query({ + providesTags: ['Spell'], + query: ({ projectId, id }) => { + return { + url: `spells?projectId=${projectId}&id=${id}`, + params: {}, + } + }, + }), + // Api endpoint for running a spell + runSpell: builder.mutation({ + query: ({ spellName, inputs, state = {}, projectId }) => ({ + url: `spells/${spellName}`, + method: 'POST', + body: { + ...inputs, + state, + projectId, + }, + }), + }), + // Api endpoint for saving a spell diff + saveDiff: builder.mutation({ + invalidatesTags: ['Spell'], + query: diffData => ({ + url: 'spells/saveDiff', + method: 'POST', + body: diffData, + }), + }), + // Api endpoint for checking if a spell exists + spellExists: builder.mutation({ + query: ({ name, projectId }) => ({ + url: 'spells/exists', + method: 'GET', + body: { + name, + projectId, + }, + }), + }), + // Api endpoint for saving a spell + saveSpell: builder.mutation({ + invalidatesTags: ['Spell'], + async queryFn( + { spell, projectId }, + { dispatch }, + extraOptions, + baseQuery + ) { + const spellCopy = { ...spell } as any + if (spellCopy.id) delete spellCopy.id + if (Object.keys(spellCopy).includes('modules')) delete spellCopy.modules + if (!spellCopy.createdAt) spellCopy.createdAt = new Date().toISOString() + spellCopy.updatedAt = new Date().toISOString() + spellCopy.projectId = spell.projectId ?? projectId + spellCopy.hash = md5(JSON.stringify(spellCopy.graph.nodes)) + + delete spellCopy.creatorId + + const baseQueryOptions = { + url: 'spells/' + spell.id, + body: spellCopy, + method: 'PATCH', + } + + return baseQuery(baseQueryOptions) as QueryReturnValue< + Partial, + FetchBaseQueryError, + unknown + > + }, + }), + // Api endpoint for creating a new spell + newSpell: builder.mutation({ + invalidatesTags: ['Spells'], + query: spellData => ({ + url: 'spells', + method: 'POST', + body: spellData, + }), + }), + // Api endpoint for patching a spell + patchSpell: builder.mutation({ + invalidatesTags: ['Spell'], + query({ id, update }) { + return { + url: `spells/${id}`, + body: { + ...update, + }, + method: 'PATCH', + } + }, + }), + // Api endpoint for deleting a spell + deleteSpell: builder.mutation({ + invalidatesTags: ['Spells'], + query: ({ spellName }) => ({ + url: `spells/${spellName}`, + method: 'DELETE', + }), + }), + }), +}) + +// Export the generated hooks for each API endpoint +export const { + useGetSpellsQuery, + useLazyGetSpellsQuery, + useLazyGetSpellQuery, + useLazyGetSpellByIdQuery, + useGetSpellQuery, + useGetSpellByIdQuery, + useGetSpellByJustIdQuery, + useRunSpellMutation, + useSaveDiffMutation, + useSpellExistsMutation, + useSaveSpellMutation, + useNewSpellMutation, + usePatchSpellMutation, + useDeleteSpellMutation, +} = spellApi diff --git a/packages/state/src/lib/globalConfig.ts b/packages/state/src/lib/globalConfig.ts new file mode 100644 index 0000000000..cdd9dd5edc --- /dev/null +++ b/packages/state/src/lib/globalConfig.ts @@ -0,0 +1,54 @@ +// DOCUMENTED +/** + * Module that exports a Redux slice for the global config that carries the authentication, project id and API url information. + * @module globalConfigSlice + */ + +import { createSlice, PayloadAction, Slice } from '@reduxjs/toolkit' + +/** + * Interface that defines the Global Config type. + */ +export interface GlobalConfig { + apiUrl: string + token: string + projectId: string +} + +/** + * Slice of the GlobalConfig to be used in Redux store. + * @type {Slice} + */ +export const globalConfigSlice: Slice = createSlice({ + name: 'globalConfig', + initialState: { + apiUrl: '', + token: '', + projectId: '', + }, + reducers: { + /** + * Reducer method for setting the global config. + * @param {GlobalConfig} state - The current global config state. + * @param {PayloadAction} action - Config to set on the global state. + * @return {void} + */ + setConfig: (state: GlobalConfig, action: PayloadAction): void => { + const { apiUrl, token, projectId } = action.payload + state.apiUrl = apiUrl + state.token = token + state.projectId = projectId + }, + }, +}) + +// Actions +/** + * Action to set the global configuration. + */ +export const { setConfig } = globalConfigSlice.actions + +/** + * Export GlobalConfigSlice reducer. + */ +export default globalConfigSlice.reducer \ No newline at end of file diff --git a/packages/state/src/lib/hooks.ts b/packages/state/src/lib/hooks.ts new file mode 100644 index 0000000000..eeeb0c3554 --- /dev/null +++ b/packages/state/src/lib/hooks.ts @@ -0,0 +1,22 @@ +// DOCUMENTED +// Import the necessary hooks and types from the required libraries. +import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux' +import type { RootState, AppDispatch } from './store' + +/** + * Custom hook that wraps useDispatch with AppDispatch type. + * Provides typed dispatch for redux actions. + * Use this instead of the plain useDispatch from react-redux. + * + * @returns The typed dispatch function + */ +export const useAppDispatch = () => useDispatch() + +/** + * Custom typed useSelector hook. + * Provides type checking for redux state selections. + * Use this instead of the plain useSelector from react-redux. + * + * @type TypedUseSelectorHook + */ +export const useAppSelector: TypedUseSelectorHook = useSelector diff --git a/packages/state/src/lib/localState.ts b/packages/state/src/lib/localState.ts new file mode 100644 index 0000000000..2f5b670dfb --- /dev/null +++ b/packages/state/src/lib/localState.ts @@ -0,0 +1,61 @@ +// DOCUMENTED +import { + createSlice, + createDraftSafeSelector, + createEntityAdapter, +} from '@reduxjs/toolkit' + +/** + * Interface for local state. + */ +export interface LocalState { + id: string + playtestData?: string + chatwindowData?: string +} + +// Entity adapter to handle local state operations +const localAdapater = createEntityAdapter({ + selectId: localState => localState.id, +}) +const localSelectors = localAdapater.getSelectors() + +// Initial State +const initialState = localAdapater.getInitialState() + +/** + * This is the primary slice of our "duck", + * which returns helper functions and properties. + */ +export const localStateSlice = createSlice({ + name: 'localState', + initialState, + reducers: { + addLocalState: localAdapater.addOne, + deleteLocalState: localAdapater.removeOne, + upsertLocalState: localAdapater.upsertOne, + }, +}) + +// actions +export const { addLocalState, deleteLocalState, upsertLocalState } = + localStateSlice.actions + +// selectors +/* export const selectStateBySpellId = createDraftSafeSelector( + [state => localSelectors.selectAll(state), (_, spellName) => spellName], + (states, spellName) => + Object.values(states).find(state => state.spellName === spellName) +) */ + +/** + * Selector to find a state by tabId. + */ +export const selectStateBytabId = createDraftSafeSelector( + [state => localSelectors.selectAll(state), (_, id) => id], + (states, id) => + Object.values(states).find(state => state.id === id) +) + +// export the default reducer +export default localStateSlice.reducer \ No newline at end of file diff --git a/packages/state/src/lib/preferences.ts b/packages/state/src/lib/preferences.ts new file mode 100644 index 0000000000..7ff5495f3c --- /dev/null +++ b/packages/state/src/lib/preferences.ts @@ -0,0 +1,43 @@ +// DOCUMENTED +/** + * @fileoverview A module that manages user preferences using Redux Toolkit. + * @package + */ + +import { createSlice } from '@reduxjs/toolkit' + +/** Interface for the preference state. */ +export interface PreferenceState { + autoSave: boolean +} + +/** The initial state for preferences. */ +const initialState: PreferenceState = { + autoSave: true, +} + +/** + * A Slice that creates reducers and actions for preferences. + * @param name - The name of the slice. + * @param initialState - The initial state of the slice. + * @param reducers - Reducers that modify the state, generated by createSlice. + */ +export const preferenceSlice = createSlice({ + name: 'preferences', + initialState, + reducers: { + /** + * Toggles the auto-save preference, modifying the state accordingly. + * @param state - The current state of the preferences. + */ + toggleAutoSave: state => { + state.autoSave = !state.autoSave + }, + }, +}) + +/** Actions generated from the preference slice. */ +export const { toggleAutoSave } = preferenceSlice.actions + +/** The preference reducer generated by the slice. */ +export default preferenceSlice.reducer diff --git a/packages/state/src/lib/store.ts b/packages/state/src/lib/store.ts new file mode 100644 index 0000000000..8858e75295 --- /dev/null +++ b/packages/state/src/lib/store.ts @@ -0,0 +1,73 @@ +// DOCUMENTED +import { configureStore, ThunkAction, Action, Dispatch } from '@reduxjs/toolkit' +import { setupListeners } from '@reduxjs/toolkit/query/react' + +import { persistStore, persistReducer } from 'redux-persist' +import storage from 'redux-persist/lib/storage' +import { combineReducers } from 'redux' + +import { spellApi } from './api/spells' +import { rootApi } from './api/api' +import tabReducer from './tabs' +import localStateReducer from './localState' +import preferencesReducer from './preferences' +import globalConfigReducer from './globalConfig' +import { AppConfig } from '@magickml/client-core' + +/** + * Combine all reducers into the root reducer. + */ +const rootReducer = combineReducers({ + globalConfig: globalConfigReducer, + tabs: tabReducer, + preferences: preferencesReducer, + [spellApi.reducerPath]: spellApi.reducer, + localState: localStateReducer, +}) + +// Store instance placeholder +let _store: any = null + +/** + * Create a new store with optional configuration. + * @param config - Optional configuration for the store. + * @returns The created store. + */ +export const createStore = (config: AppConfig) => { + if (_store) return _store + + const persistConfig = { + key: config.projectId, + version: 1, + storage, + blacklist: [spellApi.reducerPath, 'globalConfig'], + } + + const store = configureStore({ + reducer: persistReducer(persistConfig, rootReducer), + preloadedState: { + globalConfig: config, + }, + middleware: getDefaultMiddleware => + getDefaultMiddleware({ + serializableCheck: false, + }).concat(rootApi.middleware), + }) + + setupListeners(store.dispatch) + persistStore(store) + + _store = store + + return store +} + +// Export types for the application's Redux store +export type AppDispatch = Dispatch +export type RootState = ReturnType +export type AppThunk = ThunkAction< + ReturnType, + RootState, + unknown, + Action +> diff --git a/packages/state/src/lib/tabs.ts b/packages/state/src/lib/tabs.ts new file mode 100644 index 0000000000..df84bde8ca --- /dev/null +++ b/packages/state/src/lib/tabs.ts @@ -0,0 +1,171 @@ +// DOCUMENTED +import { + createDraftSafeSelector, + createEntityAdapter, + createSlice, +} from '@reduxjs/toolkit' + +import defaultJson from '../data/layouts/defaultLayout.json' +import fullScreen from '../data/layouts/fullScreenLayout.json' +import promptEngineering from '../data/layouts/promptEngineeringLayout.json' +import troubleShooting from '../data/layouts/troubleshootingLayout.json' +import { RootState } from './store' + +// Workspace map for initializing tabs with layout data +export const workspaceMap = { + default: defaultJson, + fullScreen, + promptEngineering, + troubleShooting, +} + +/** + * Tab interface representing a tab object + */ +export interface Tab { + id: string + name: string + URI: string + active: boolean + layoutJson: Record + type?: 'spell' + spell?: string + spellName: string + module: string + componentType?: string +} + +// Entity adapter for tabs +const tabAdapater = createEntityAdapter() +const tabSelectors = tabAdapater.getSelectors() + +// Initial State for tabs +const initialState = tabAdapater.getInitialState() + +/** + * Selects the active tab from the given tabs array. + */ +const _activeTabSelector = createDraftSafeSelector( + tabSelectors.selectAll, + tabs => { + return Object.values(tabs).find(tab => tab?.active) + } +) + +/** + * Selects the tab with the specified UUID from the given tabs array. + */ +const selectTabBySpellUUID = createDraftSafeSelector( + [state => tabSelectors.selectAll(state), (_, id) => id], + (tabs, id) => Object.values(tabs).find(tab => tab.id === id) +) + +/** + * Decodes a URI-encoded string and returns the decoded name portion. + */ +const encodedToName = (uri: string) => { + uri = decodeURIComponent(uri) + return atob(uri.slice(37)) +} + +/** + * Decodes a URI-encoded string and returns the decoded ID portion. + */ +const encodedToId = (uri: string) => { + uri = decodeURIComponent(uri) + return uri.slice(0, 36) +} + +/** + * Constructs a new tab object with the specified properties and defaults. + */ +const buildTab = (tab, properties = {}) => ({ + ...tab, + id: encodedToId(tab.name) || tab.name, + URI: encodeURIComponent(tab.name) || tab.name, + name: encodedToName(tab.name) || tab.name, + layoutJson: workspaceMap[tab.workspace || 'default'], + spell: tab?.spell || null, + type: tab?.type, + module: tab?.moduleName || null, + ...properties, +}) + +/** + * Tab slice containing reducer and actions for managing tabs. + */ +export const tabSlice = createSlice({ + name: 'tabs', + initialState, + reducers: { + // Opens a tab, either creating a new one or switching to the existing tab + openTab: (state, action) => { + const switchActive = + 'switchActive' in action.payload ? action.payload.switchActive : true + const activeTab = _activeTabSelector(state) as Tab + if (activeTab && switchActive) + tabAdapater.updateOne(state, { + id: activeTab.id, + changes: { active: false }, + }) + + const existingTab = selectTabBySpellUUID( + state, + encodedToId(action.payload.name) + ) + + if (existingTab && !switchActive) return + + if (existingTab && !action.payload.openNew) { + tabAdapater.updateOne(state, { + id: existingTab.id, + changes: { + active: switchActive, + }, + }) + return + } + + const tab = buildTab(action.payload, { + active: true, + componentType: action.payload.componentType || 'DefaultComponent', + }) + tabAdapater.addOne(state, tab) + }, + closeTab: tabAdapater.removeOne, + switchTab: tabAdapater.updateOne, + clearTabs: tabAdapater.removeAll, + changeActive: tabAdapater.updateMany, + saveTabLayout: (state, action) => { + tabAdapater.updateOne(state, { + id: action.payload.tabId, + changes: { layoutJson: action.payload.layoutJson }, + }) + }, + changeEditorLayout: (state, action) => { + tabAdapater.updateOne(state, { + id: action.payload.tabId, + changes: { layoutJson: workspaceMap[action.payload.layout] }, + }) + }, + }, +}) + +// Export actions +export const { + openTab, + closeTab, + switchTab, + clearTabs, + saveTabLayout, + changeActive, + changeEditorLayout, +} = tabSlice.actions + +// Export selectors +export const activeTabSelector = (state: RootState) => + _activeTabSelector(state.tabs) + +export const { selectAll: selectAllTabs } = tabSelectors + +export default tabSlice.reducer diff --git a/packages/state/tsconfig.json b/packages/state/tsconfig.json new file mode 100644 index 0000000000..bdf594cdb1 --- /dev/null +++ b/packages/state/tsconfig.json @@ -0,0 +1,23 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "module": "commonjs", + "forceConsistentCasingInFileNames": true, + "strict": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "types": ["vitest"] + }, + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + } + ] +} diff --git a/packages/state/tsconfig.lib.json b/packages/state/tsconfig.lib.json new file mode 100644 index 0000000000..33eca2c2cd --- /dev/null +++ b/packages/state/tsconfig.lib.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "declaration": true, + "types": ["node"] + }, + "include": ["src/**/*.ts"], + "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"] +} diff --git a/packages/state/tsconfig.spec.json b/packages/state/tsconfig.spec.json new file mode 100644 index 0000000000..6d3be74271 --- /dev/null +++ b/packages/state/tsconfig.spec.json @@ -0,0 +1,19 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "types": ["vitest/globals", "vitest/importMeta", "vite/client", "node"] + }, + "include": [ + "vite.config.ts", + "src/**/*.test.ts", + "src/**/*.spec.ts", + "src/**/*.test.tsx", + "src/**/*.spec.tsx", + "src/**/*.test.js", + "src/**/*.spec.js", + "src/**/*.test.jsx", + "src/**/*.spec.jsx", + "src/**/*.d.ts" + ] +} diff --git a/packages/state/vite.config.ts b/packages/state/vite.config.ts new file mode 100644 index 0000000000..9f661bbe4c --- /dev/null +++ b/packages/state/vite.config.ts @@ -0,0 +1,52 @@ +/// +import { defineConfig } from 'vite' + +import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin' +import dts from 'vite-plugin-dts' +import * as path from 'path' + +export default defineConfig({ + cacheDir: '../../node_modules/.vite/state', + + plugins: [ + dts({ + entryRoot: 'src', + tsConfigFilePath: path.join(__dirname, 'tsconfig.lib.json'), + skipDiagnostics: true, + }), + + nxViteTsPaths(), + ], + + // Uncomment this if you are using workers. + // worker: { + // plugins: [ nxViteTsPaths() ], + // }, + + // Configuration for building your library. + // See: https://vitejs.dev/guide/build.html#library-mode + build: { + lib: { + // Could also be a dictionary or array of multiple entry points. + entry: 'src/index.ts', + name: 'state', + fileName: 'index', + // Change this to the formats you want to support. + // Don't forget to update your package.json as well. + formats: ['es', 'cjs'], + }, + rollupOptions: { + // External packages that should not be bundled into your library. + external: [], + }, + }, + + test: { + globals: true, + cache: { + dir: '../../node_modules/.vitest', + }, + environment: 'node', + include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], + }, +}) diff --git a/tsconfig.base.json b/tsconfig.base.json index 9c1213a502..91e550d8e2 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -39,6 +39,7 @@ "@magickml/core": ["packages/core/shared/src/index.ts"], "@magickml/docs": ["apps/docs/src/index.ts"], "@magickml/editor": ["packages/editor/src/index.ts"], + "@magickml/layouts": ["packages/layouts/src/index.ts"], "@magickml/plugin-anthropic-client": [ "packages/plugins/anthropic/client/src/index.ts" ], @@ -193,6 +194,7 @@ "@magickml/rete": ["packages/rete/src/index.ts"], "@magickml/server": ["apps/server/src/index.ts"], "@magickml/server-core": ["packages/core/server/src/index.ts"], + "@magickml/state": ["packages/state/src/index.ts"], "@magickml/types": ["packages/@types/src/index.ts"], "@magickml/ui": ["packages/ui/src/index.ts"], "@magickml/ui/components": ["packages/utils/components/src/index.ts"], From c6f1ba6cecefe787cbd72814372fecb786a09ef4 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 14 Sep 2023 21:37:32 -0700 Subject: [PATCH 007/349] Add layouts package --- packages/layouts/.eslintrc.json | 25 +++++++++++++++++ packages/layouts/README.md | 7 +++++ packages/layouts/package.json | 8 ++++++ packages/layouts/project.json | 26 +++++++++++++++++ packages/layouts/src/index.ts | 1 + packages/layouts/src/lib/layouts.ts | 3 ++ packages/layouts/tsconfig.json | 19 +++++++++++++ packages/layouts/tsconfig.lib.json | 10 +++++++ packages/layouts/vite.config.ts | 43 +++++++++++++++++++++++++++++ 9 files changed, 142 insertions(+) create mode 100644 packages/layouts/.eslintrc.json create mode 100644 packages/layouts/README.md create mode 100644 packages/layouts/package.json create mode 100644 packages/layouts/project.json create mode 100644 packages/layouts/src/index.ts create mode 100644 packages/layouts/src/lib/layouts.ts create mode 100644 packages/layouts/tsconfig.json create mode 100644 packages/layouts/tsconfig.lib.json create mode 100644 packages/layouts/vite.config.ts diff --git a/packages/layouts/.eslintrc.json b/packages/layouts/.eslintrc.json new file mode 100644 index 0000000000..adbe7ae2df --- /dev/null +++ b/packages/layouts/.eslintrc.json @@ -0,0 +1,25 @@ +{ + "extends": ["../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], + "rules": {} + }, + { + "files": ["*.ts", "*.tsx"], + "rules": {} + }, + { + "files": ["*.js", "*.jsx"], + "rules": {} + }, + { + "files": ["*.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": "error" + } + } + ] +} diff --git a/packages/layouts/README.md b/packages/layouts/README.md new file mode 100644 index 0000000000..40b7afe840 --- /dev/null +++ b/packages/layouts/README.md @@ -0,0 +1,7 @@ +# layouts + +This library was generated with [Nx](https://nx.dev). + +## Building + +Run `nx build layouts` to build the library. diff --git a/packages/layouts/package.json b/packages/layouts/package.json new file mode 100644 index 0000000000..19f9cdc541 --- /dev/null +++ b/packages/layouts/package.json @@ -0,0 +1,8 @@ +{ + "name": "@magickml/layouts", + "version": "0.0.1", + "dependencies": {}, + "main": "./index.js", + "module": "./index.mjs", + "typings": "./index.d.ts" +} diff --git a/packages/layouts/project.json b/packages/layouts/project.json new file mode 100644 index 0000000000..78f58eee5e --- /dev/null +++ b/packages/layouts/project.json @@ -0,0 +1,26 @@ +{ + "name": "layouts", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "packages/layouts/src", + "projectType": "library", + "targets": { + "build": { + "executor": "@nx/vite:build", + "outputs": ["{options.outputPath}"], + "options": { + "outputPath": "dist/packages/layouts" + } + }, + "lint": { + "executor": "@nx/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": [ + "packages/layouts/**/*.ts", + "packages/layouts/package.json" + ] + } + } + }, + "tags": [] +} diff --git a/packages/layouts/src/index.ts b/packages/layouts/src/index.ts new file mode 100644 index 0000000000..378fec1215 --- /dev/null +++ b/packages/layouts/src/index.ts @@ -0,0 +1 @@ +export * from './lib/layouts' diff --git a/packages/layouts/src/lib/layouts.ts b/packages/layouts/src/lib/layouts.ts new file mode 100644 index 0000000000..e1adcf7b2d --- /dev/null +++ b/packages/layouts/src/lib/layouts.ts @@ -0,0 +1,3 @@ +export function layouts(): string { + return 'layouts' +} diff --git a/packages/layouts/tsconfig.json b/packages/layouts/tsconfig.json new file mode 100644 index 0000000000..db7b566661 --- /dev/null +++ b/packages/layouts/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "module": "commonjs", + "forceConsistentCasingInFileNames": true, + "strict": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true + }, + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + } + ] +} diff --git a/packages/layouts/tsconfig.lib.json b/packages/layouts/tsconfig.lib.json new file mode 100644 index 0000000000..33eca2c2cd --- /dev/null +++ b/packages/layouts/tsconfig.lib.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "declaration": true, + "types": ["node"] + }, + "include": ["src/**/*.ts"], + "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"] +} diff --git a/packages/layouts/vite.config.ts b/packages/layouts/vite.config.ts new file mode 100644 index 0000000000..6cf0760398 --- /dev/null +++ b/packages/layouts/vite.config.ts @@ -0,0 +1,43 @@ +/// +import { defineConfig } from 'vite' + +import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin' +import dts from 'vite-plugin-dts' +import * as path from 'path' + +export default defineConfig({ + cacheDir: '../../node_modules/.vite/layouts', + + plugins: [ + dts({ + entryRoot: 'src', + tsConfigFilePath: path.join(__dirname, 'tsconfig.lib.json'), + skipDiagnostics: true, + }), + + nxViteTsPaths(), + ], + + // Uncomment this if you are using workers. + // worker: { + // plugins: [ nxViteTsPaths() ], + // }, + + // Configuration for building your library. + // See: https://vitejs.dev/guide/build.html#library-mode + build: { + lib: { + // Could also be a dictionary or array of multiple entry points. + entry: 'src/index.ts', + name: 'layouts', + fileName: 'index', + // Change this to the formats you want to support. + // Don't forget to update your package.json as well. + formats: ['es', 'cjs'], + }, + rollupOptions: { + // External packages that should not be bundled into your library. + external: [], + }, + }, +}) From 5aeb9696020084f53cf62ecb9262fed75be7e449 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 14 Sep 2023 23:18:07 -0700 Subject: [PATCH 008/349] Migrate state into its own package --- packages/@types/svg.d.ts | 8 ++ .../src/components/Drawer/AgentMenu.tsx | 28 +++-- .../client/src/providers/FeathersProvider.tsx | 2 +- .../src/services/agents/agents.class.ts | 3 + .../shared/src/dataControls/ArrayControl.ts | 8 +- .../shared/src/dataControls/BooleanControl.ts | 18 +-- .../shared/src/dataControls/CodeControl.ts | 16 +-- .../shared/src/dataControls/EmptyControl.ts | 10 +- .../shared/src/dataControls/FewshotControl.ts | 16 +-- .../shared/src/dataControls/NumberControl.ts | 13 +- .../editor/src/DataControls/SpellSelect.tsx | 4 +- .../editor/src/components/EventHandler.tsx | 5 +- .../components/MenuBar/OldMenuBar/index.tsx | 4 +- .../components/MenuBar/newMenuBar/index.tsx | 4 +- .../src/components/Modals/EditSpellModal.tsx | 4 +- .../src/components/Modals/SaveAsModal.tsx | 2 +- .../editor/src/components/TabBar/TabBar.tsx | 4 +- packages/editor/src/components/Workspace.tsx | 4 +- .../editor/src/contexts/EditorProvider.tsx | 3 +- .../editor/src/contexts/LayoutProvider.tsx | 2 +- .../src/contexts/MagickInterfaceProvider.tsx | 2 +- packages/editor/src/main.tsx | 1 + .../src/screens/HomeScreen/CreateNew.tsx | 2 +- .../src/screens/HomeScreen/HomeScreen.tsx | 8 +- .../src/screens/HomeScreen/OpenProject.tsx | 3 +- packages/editor/src/screens/Magick/Magick.tsx | 8 +- .../editor/src/windows/PlaytestWindow.tsx | 8 +- packages/layouts/src/data/defaultLayout.json | 111 ++++++++++++++++++ .../layouts/src/data/fullScreenLayout.json | 42 +++++++ .../src/data/promptEngineeringLayout.json | 96 +++++++++++++++ .../src/data/troubleshootingLayout.json | 97 +++++++++++++++ packages/layouts/src/index.ts | 2 +- packages/layouts/src/lib/layouts.ts | 3 - packages/layouts/src/main.ts | 16 +++ packages/layouts/tsconfig.json | 3 +- packages/state/src/lib/api/spells.ts | 7 +- packages/state/src/lib/store.ts | 4 +- packages/state/src/lib/tabs.ts | 18 +-- packages/state/tsconfig.json | 2 +- tsconfig.base.json | 7 +- 40 files changed, 466 insertions(+), 132 deletions(-) create mode 100644 packages/@types/svg.d.ts create mode 100644 packages/layouts/src/data/defaultLayout.json create mode 100644 packages/layouts/src/data/fullScreenLayout.json create mode 100644 packages/layouts/src/data/promptEngineeringLayout.json create mode 100644 packages/layouts/src/data/troubleshootingLayout.json delete mode 100644 packages/layouts/src/lib/layouts.ts create mode 100644 packages/layouts/src/main.ts diff --git a/packages/@types/svg.d.ts b/packages/@types/svg.d.ts new file mode 100644 index 0000000000..af032b8654 --- /dev/null +++ b/packages/@types/svg.d.ts @@ -0,0 +1,8 @@ +declare module '*.svg' { + import React = require('react') + export const ReactComponent: React.FunctionComponent< + React.SVGProps + > + const src: string + export default src +} diff --git a/packages/core/client/src/components/Drawer/AgentMenu.tsx b/packages/core/client/src/components/Drawer/AgentMenu.tsx index cde778da2c..cb2cef34d5 100644 --- a/packages/core/client/src/components/Drawer/AgentMenu.tsx +++ b/packages/core/client/src/components/Drawer/AgentMenu.tsx @@ -22,8 +22,13 @@ import { enqueueSnackbar } from 'notistack' import { useSelector } from 'react-redux' import { Modal } from '@magickml/client-core' import { DEFAULT_USER_TOKEN, STANDALONE, API_ROOT_URL } from '@magickml/config' + +import { useFeathers } from '../../providers/FeathersProvider' + +// todo fix this import import { useSpellList } from '../../../../../plugins/avatar/client/src/hooks/useSpellList' import { useTreeData } from '../../../../client/src/contexts/TreeDataProvider' +import { AgentInterface, SpellInterface } from '@magickml/core' interface Spell { id: number @@ -31,27 +36,32 @@ interface Spell { // Add other relevant properties } -interface Agent { - rootSpellId: number - // Add other relevant properties -} - function AgentMenu({ data, resetData }) { const navigate = useNavigate() + const { client } = useFeathers() const [openMenu1, setOpenMenu1] = useState(null) const [openConfirm, setOpenConfirm] = useState(false) const [openMenu2, setOpenMenu2] = useState(null) const [editMode, setEditMode] = useState(false) const [oldName, setOldName] = useState('') const [selectedAgentData, setSelectedAgentData] = useState(null) - const [currentAgent, setCurrentAgent] = useState(null) + const [currentAgent, _setCurrentAgent] = useState(null) const globalConfig = useSelector((state: any) => state.globalConfig) const token = globalConfig?.token const config = useConfig() - const spellList: Spell[] = useSpellList() + const spellList: SpellInterface[] = useSpellList() const imageInputRef = useRef(null) const { agentUpdate, setAgentUpdate } = useTreeData() + const setCurrentAgent = useCallback( + (agent: AgentInterface) => { + // Subscribe to agent service + client.service('agents').subscribe(agent.id) + _setCurrentAgent(agent) + }, + [] + ) + const handleClose = () => { setOpenConfirm(false) } @@ -232,7 +242,7 @@ function AgentMenu({ data, resetData }) { marginBottom: '4px', })) - const handleSelectAgent = (agent: Agent) => { + const handleSelectAgent = (agent: AgentInterface) => { setCurrentAgent(agent) if (spellList) { @@ -262,7 +272,7 @@ function AgentMenu({ data, resetData }) { const defaultAgent = data.find(agent => agent.default) // Set currentAgent to 'Default Agent' if it exists, otherwise choose the first agent - setCurrentAgent(defaultAgent || data[0]) + setCurrentAgent((defaultAgent || data[0]) as AgentInterface) } }, [data]) diff --git a/packages/core/client/src/providers/FeathersProvider.tsx b/packages/core/client/src/providers/FeathersProvider.tsx index e672af5468..b5f7d9d494 100644 --- a/packages/core/client/src/providers/FeathersProvider.tsx +++ b/packages/core/client/src/providers/FeathersProvider.tsx @@ -54,7 +54,7 @@ const configureCustomServices = ( }) app.use('agents', socketClient.service('agents'), { - methods: ['find', 'get', 'create', 'patch', 'remove', 'log', 'run'], + methods: ['find', 'get', 'create', 'patch', 'remove', 'log', 'run', 'subscribe'], events: ['log', 'result'], }) app.use('request', socketClient.service('request'), { diff --git a/packages/core/server/src/services/agents/agents.class.ts b/packages/core/server/src/services/agents/agents.class.ts index 3ccc17a7ac..edc7d1c98f 100644 --- a/packages/core/server/src/services/agents/agents.class.ts +++ b/packages/core/server/src/services/agents/agents.class.ts @@ -68,6 +68,9 @@ export class AgentService< // get the socket from the params const connection = params.connection + + if (!connection) throw new Error('connection is required') + const oldAgentChannel = app.channels.filter(channel => agentId.match(/agent:/) )[0] diff --git a/packages/core/shared/src/dataControls/ArrayControl.ts b/packages/core/shared/src/dataControls/ArrayControl.ts index f4ed134eb4..6d39276f05 100644 --- a/packages/core/shared/src/dataControls/ArrayControl.ts +++ b/packages/core/shared/src/dataControls/ArrayControl.ts @@ -1,4 +1,4 @@ -// DOCUMENTED +// DOCUMENTED /** * Represents a data control for an array */ @@ -11,7 +11,7 @@ export class ArrayControl extends DataControl { * @param {string} data.name - The name of the control * @param {string} [data.icon = 'hand'] - The icon of the control */ - constructor({ dataKey, name, icon = 'hand' ,tooltip}) { + constructor({ dataKey, name, icon = 'hand', tooltip }) { const options = { dataKey, name, @@ -28,7 +28,7 @@ export class ArrayControl extends DataControl { * Returns the data of the control * @returns {void} */ - onData() { + override onData() { return } -} \ No newline at end of file +} diff --git a/packages/core/shared/src/dataControls/BooleanControl.ts b/packages/core/shared/src/dataControls/BooleanControl.ts index 85aa358012..d9121a6883 100644 --- a/packages/core/shared/src/dataControls/BooleanControl.ts +++ b/packages/core/shared/src/dataControls/BooleanControl.ts @@ -1,15 +1,15 @@ -// DOCUMENTED +// DOCUMENTED /** * This class represents a boolean control for data manipulation. * It extends the DataControl class from the inspectorPlugin module. * @extends DataControl */ -import { DataControl } from '../plugins/inspectorPlugin'; +import { DataControl } from '../plugins/inspectorPlugin' export class BooleanControl extends DataControl { /** * Creates an instance of BooleanControl. - * @param {object} config - The configuration object for this control. + * @param {object} config - The configuration object for this control. * It should contain the following properties: * @param {string} dataKey - The key of the data the control will manipulate. * @param {string} name - The name of the control to be shown in the inspector UI. @@ -26,17 +26,17 @@ export class BooleanControl extends DataControl { icon: config.icon || 'hand', // Assign the icon property from the configuration object or default to 'hand'. type: 'boolean', // Set the control type to 'boolean'. defaultValue: config.defaultValue || false, // Assign the defaultValue property from the configuration object or default to 'false'. - tooltip: config.tooltip - }; + tooltip: config.tooltip, + } - super(options); // Call the super constructor with the options object. + super(options) // Call the super constructor with the options object. } /** * This function is called when new data is set to the control. It does not perform any action * except returning control to the parent component. */ - onData() { - return; + override onData() { + return } -} +} diff --git a/packages/core/shared/src/dataControls/CodeControl.ts b/packages/core/shared/src/dataControls/CodeControl.ts index 2f94406633..cd9d731348 100644 --- a/packages/core/shared/src/dataControls/CodeControl.ts +++ b/packages/core/shared/src/dataControls/CodeControl.ts @@ -1,4 +1,4 @@ -// DOCUMENTED +// DOCUMENTED /** * A subclass of DataControl that represents a control for editing code. */ @@ -17,11 +17,11 @@ export class CodeControl extends DataControl { name, icon = 'feathers', language = 'javascript', - tooltip= '' + tooltip = '', }: { - dataKey: string, - name: string, - icon?: string, + dataKey: string + name: string + icon?: string language?: string tooltip?: string }) { @@ -32,7 +32,7 @@ export class CodeControl extends DataControl { icon, options: { editor: true, - language + language, }, tooltip: tooltip, } @@ -45,7 +45,7 @@ export class CodeControl extends DataControl { * Since this is a CodeControl, it doesn't really handle data. * @return Always returns undefined. */ - onData() { + override onData() { return undefined } -} \ No newline at end of file +} diff --git a/packages/core/shared/src/dataControls/EmptyControl.ts b/packages/core/shared/src/dataControls/EmptyControl.ts index 500250c9a7..00889e01d9 100644 --- a/packages/core/shared/src/dataControls/EmptyControl.ts +++ b/packages/core/shared/src/dataControls/EmptyControl.ts @@ -1,4 +1,4 @@ -// DOCUMENTED +// DOCUMENTED /** * EmptyControl represents a DataControl that does not present any value. * It inherits from DataControl. @@ -8,11 +8,11 @@ import { DataControl } from '../plugins/inspectorPlugin' export class EmptyControl extends DataControl { /** * Constructor method for EmptyControl. - * + * * @param {string} dataKey - The key of the data that the control will interact with. * @param {array} ignored - The list of ignored values by the control. */ - constructor({ dataKey, ignored = [],tooltip }) { + constructor({ dataKey, ignored = [], tooltip }) { const options = { dataKey: dataKey, name: 'empty', @@ -30,7 +30,7 @@ export class EmptyControl extends DataControl { * onData method simply returns nothing. * It overrides its parent onData method. */ - onData() { + override onData() { return } -} \ No newline at end of file +} diff --git a/packages/core/shared/src/dataControls/FewshotControl.ts b/packages/core/shared/src/dataControls/FewshotControl.ts index cb4e963e23..75970b5845 100644 --- a/packages/core/shared/src/dataControls/FewshotControl.ts +++ b/packages/core/shared/src/dataControls/FewshotControl.ts @@ -1,9 +1,9 @@ -// DOCUMENTED +// DOCUMENTED /** * A class that extends `DataControl` to create a custom control for fewshot data. * @extends DataControl */ -import { DataControl } from '../plugins/inspectorPlugin'; +import { DataControl } from '../plugins/inspectorPlugin' export class FewshotControl extends DataControl { /** @@ -21,7 +21,7 @@ export class FewshotControl extends DataControl { dataKey = 'fewshot', name = 'fewshot', defaultValue = '', - tooltip='' + tooltip = '', }) { const options = { dataKey, @@ -31,21 +31,21 @@ export class FewshotControl extends DataControl { options: { editor: true, language, - wordWrap: true + wordWrap: true, }, defaultValue, tooltip: tooltip, } // Calls the constructor of parent class and passes the options object to it. - super(options); + super(options) } /** * Returns data for the control. * @returns {void} */ - onData() { - return; + override onData() { + return } -} \ No newline at end of file +} diff --git a/packages/core/shared/src/dataControls/NumberControl.ts b/packages/core/shared/src/dataControls/NumberControl.ts index cbbef18b9b..21767e9f00 100644 --- a/packages/core/shared/src/dataControls/NumberControl.ts +++ b/packages/core/shared/src/dataControls/NumberControl.ts @@ -1,9 +1,9 @@ -// DOCUMENTED +// DOCUMENTED /** * A custom control class for number inputs that extends the DataControl class * from the inspectorPlugin module. */ -import { DataControl } from '../plugins/inspectorPlugin'; +import { DataControl } from '../plugins/inspectorPlugin' export class NumberControl extends DataControl { /** @@ -13,7 +13,6 @@ export class NumberControl extends DataControl { * defaultValue of the control. */ constructor({ dataKey, name, icon = 'hand', defaultValue = -1, tooltip }) { - super({ dataKey: dataKey, name: name, @@ -22,7 +21,7 @@ export class NumberControl extends DataControl { type: 'number', defaultValue, tooltip: tooltip, - }); + }) } /** @@ -30,7 +29,7 @@ export class NumberControl extends DataControl { * * @returns {void} */ - onData() { - return; + override onData() { + return } -} \ No newline at end of file +} diff --git a/packages/editor/src/DataControls/SpellSelect.tsx b/packages/editor/src/DataControls/SpellSelect.tsx index e3c2251183..b325f9833c 100644 --- a/packages/editor/src/DataControls/SpellSelect.tsx +++ b/packages/editor/src/DataControls/SpellSelect.tsx @@ -7,9 +7,7 @@ import { useSnackbar } from 'notistack' import { useEffect } from 'react' import { useConfig } from '@magickml/client-core' -import { spellApi } from '@magickml/core' -import { useAppDispatch } from '@magickml/core' -import { openTab } from '@magickml/core' +import { openTab, spellApi, useAppDispatch } from '@magickml/state' // Default graph for spells const defaultGraph = getTemplates().spells[0].graph diff --git a/packages/editor/src/components/EventHandler.tsx b/packages/editor/src/components/EventHandler.tsx index 1130459478..e8efdddd35 100644 --- a/packages/editor/src/components/EventHandler.tsx +++ b/packages/editor/src/components/EventHandler.tsx @@ -5,15 +5,12 @@ import { GraphData, SpellInterface } from '@magickml/core' import md5 from 'md5' -import { - useLazyGetSpellByIdQuery, - useSaveSpellMutation, -} from '@magickml/core' import { useLayout } from '../contexts/LayoutProvider' import { useEditor } from '../contexts/EditorProvider' import { diff } from '../utils/json0' import { useConfig, useFeathers } from '@magickml/client-core' +import { useLazyGetSpellByIdQuery, useSaveSpellMutation } from '@magickml/state' /** * Event Handler component for handling various events in the editor diff --git a/packages/editor/src/components/MenuBar/OldMenuBar/index.tsx b/packages/editor/src/components/MenuBar/OldMenuBar/index.tsx index 630465f2e6..89f18d627e 100644 --- a/packages/editor/src/components/MenuBar/OldMenuBar/index.tsx +++ b/packages/editor/src/components/MenuBar/OldMenuBar/index.tsx @@ -5,10 +5,8 @@ import { useHotkeys } from 'react-hotkeys-hook' import { useDispatch, useSelector } from 'react-redux' import { useNavigate } from 'react-router-dom' import { useModal } from '../../../contexts/ModalProvider' -import { toggleAutoSave } from '@magickml/core' -import { RootState } from '@magickml/core' -import { Tab, activeTabSelector, changeEditorLayout } from '@magickml/core' import css from '../menuBar.module.css' +import { RootState, Tab, activeTabSelector, changeEditorLayout, toggleAutoSave } from '@magickml/state' /** * MenuBar component diff --git a/packages/editor/src/components/MenuBar/newMenuBar/index.tsx b/packages/editor/src/components/MenuBar/newMenuBar/index.tsx index f5d8f84dfa..b364b6d957 100644 --- a/packages/editor/src/components/MenuBar/newMenuBar/index.tsx +++ b/packages/editor/src/components/MenuBar/newMenuBar/index.tsx @@ -5,14 +5,12 @@ import { useHotkeys } from 'react-hotkeys-hook' import { useDispatch, useSelector } from 'react-redux' import { useNavigate } from 'react-router-dom' import { useModal } from '../../../contexts/ModalProvider' -import { toggleAutoSave } from '@magickml/core' -import { RootState } from '@magickml/core' -import { Tab, activeTabSelector, changeEditorLayout } from '@magickml/core' import { Menu, MenuItem, IconButton } from '@mui/material' import MenuIcon from '@mui/icons-material/Menu' import css from '../menuBar.module.css' import { styled } from '@mui/material/styles' import { NestedMenuItem } from 'mui-nested-menu' +import { RootState, Tab, activeTabSelector, changeEditorLayout, toggleAutoSave } from '@magickml/state' /** * MenuBar component diff --git a/packages/editor/src/components/Modals/EditSpellModal.tsx b/packages/editor/src/components/Modals/EditSpellModal.tsx index eff07b3d47..2866ae2082 100644 --- a/packages/editor/src/components/Modals/EditSpellModal.tsx +++ b/packages/editor/src/components/Modals/EditSpellModal.tsx @@ -4,11 +4,9 @@ import { useState } from 'react' import { useForm } from 'react-hook-form' import { useDispatch } from 'react-redux' -import { closeTab, openTab } from '@magickml/core' import Modal from '../Modal/Modal' import css from './modalForms.module.css' -import { spellApi } from '@magickml/core' - +import { closeTab, openTab, spellApi } from '@magickml/state' /** * Represents a modal to edit spells. * @param {Object} props - properties passed to the component diff --git a/packages/editor/src/components/Modals/SaveAsModal.tsx b/packages/editor/src/components/Modals/SaveAsModal.tsx index 661fc7bdba..1d2edfe95f 100644 --- a/packages/editor/src/components/Modals/SaveAsModal.tsx +++ b/packages/editor/src/components/Modals/SaveAsModal.tsx @@ -1,7 +1,6 @@ // DOCUMENTED import { useState } from 'react' import { useSnackbar } from 'notistack' -import { spellApi } from '@magickml/core' import { useForm } from 'react-hook-form' import Modal from '../Modal/Modal' import css from './modalForms.module.css' @@ -10,6 +9,7 @@ import { getTemplates } from '@magickml/client-core' import { useConfig } from '@magickml/client-core' import md5 from 'md5' import { v4 as uuidv4 } from 'uuid' +import { spellApi } from '@magickml/state' // Initial graph for the spell const defaultGraph = getTemplates().spells[0].graph diff --git a/packages/editor/src/components/TabBar/TabBar.tsx b/packages/editor/src/components/TabBar/TabBar.tsx index b6a2870f02..49b9d868f2 100644 --- a/packages/editor/src/components/TabBar/TabBar.tsx +++ b/packages/editor/src/components/TabBar/TabBar.tsx @@ -7,10 +7,8 @@ import { useNavigate } from 'react-router-dom' import MenuBar from '../MenuBar/MenuBar' import CreateTab from './CreateTab' import css from './tabBar.module.css' -import { closeTab, selectAllTabs } from '@magickml/core' -import { changeActive } from '@magickml/core' -import { RootState } from '@magickml/core' import { Icon } from '@magickml/client-core' +import { RootState, changeActive, closeTab, selectAllTabs } from '@magickml/state' /** * Tab Component diff --git a/packages/editor/src/components/Workspace.tsx b/packages/editor/src/components/Workspace.tsx index 04706963d5..d1b765b085 100644 --- a/packages/editor/src/components/Workspace.tsx +++ b/packages/editor/src/components/Workspace.tsx @@ -7,7 +7,6 @@ import { SpellInterface } from '@magickml/core' import { useConfig, useFeathers, usePubSub } from '@magickml/client-core' import { useEditor } from '../contexts/EditorProvider' import { Layout } from '../contexts/LayoutProvider' -import { spellApi } from '@magickml/core' import { debounce } from '../utils/debounce' import EventHandler from './EventHandler' @@ -17,8 +16,7 @@ import Playtest from '../windows/PlaytestWindow' import DebugConsole from '../windows/DebugConsole' import TextEditor from '../windows/TextEditorWindow' -import { RootState } from '@magickml/core' - +import { RootState, spellApi } from '@magickml/state' /** * Workspace component that handles different tabs and their layouts. diff --git a/packages/editor/src/contexts/EditorProvider.tsx b/packages/editor/src/contexts/EditorProvider.tsx index 9690cc327c..f5992be082 100644 --- a/packages/editor/src/contexts/EditorProvider.tsx +++ b/packages/editor/src/contexts/EditorProvider.tsx @@ -19,11 +19,10 @@ import { useConfig, usePubSub } from '@magickml/client-core' import { MyNode } from '../components/Node/Node' import { initEditor } from '../editor' import { zoomAt } from '../plugins/areaPlugin/zoom-at' -import { spellApi } from '@magickml/core' -import { activeTabSelector } from '@magickml/core' import { useMagickInterface } from './MagickInterfaceProvider' import styles from './styles.module.scss' import { EngineComponent } from '@magickml/rete' +import { activeTabSelector, spellApi } from '@magickml/state' /** * MagickTab type definition. diff --git a/packages/editor/src/contexts/LayoutProvider.tsx b/packages/editor/src/contexts/LayoutProvider.tsx index 8965728bb9..a5ec227bc5 100644 --- a/packages/editor/src/contexts/LayoutProvider.tsx +++ b/packages/editor/src/contexts/LayoutProvider.tsx @@ -1,5 +1,6 @@ // DOCUMENTED import { LoadingScreen } from '@magickml/client-core' +import { activeTabSelector, saveTabLayout } from '@magickml/state' import { Actions, DockLocation, @@ -10,7 +11,6 @@ import { } from 'flexlayout-react' import { createContext, useContext, useEffect, useRef, useState } from 'react' import { useDispatch, useSelector } from 'react-redux' -import { activeTabSelector, saveTabLayout } from '@magickml/core' // List of window types used to load components from data sent by rete const windowTypes: WindowTypes = { diff --git a/packages/editor/src/contexts/MagickInterfaceProvider.tsx b/packages/editor/src/contexts/MagickInterfaceProvider.tsx index f825ce8c5f..0afa9cd2a0 100644 --- a/packages/editor/src/contexts/MagickInterfaceProvider.tsx +++ b/packages/editor/src/contexts/MagickInterfaceProvider.tsx @@ -14,8 +14,8 @@ import { SpellInterface, SupportedLanguages, } from '@magickml/core' +import { spellApi } from '@magickml/state' import { createContext, useContext } from 'react' -import { spellApi } from '@magickml/core' // Create context for EditorContext type const Context = createContext(undefined) diff --git a/packages/editor/src/main.tsx b/packages/editor/src/main.tsx index a3a1767c13..09ebe5bd13 100644 --- a/packages/editor/src/main.tsx +++ b/packages/editor/src/main.tsx @@ -20,6 +20,7 @@ import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs' import { AppConfig } from '@magickml/client-core' import { createStore } from '@magickml/core' import { MagickmlChatbox } from '@magickml/chatbox' +import { createStore } from '@magickml/state' /** * Type definition for the props that can be passed to MagickIDE diff --git a/packages/editor/src/screens/HomeScreen/CreateNew.tsx b/packages/editor/src/screens/HomeScreen/CreateNew.tsx index 16c58a93d9..dc9b743f0e 100644 --- a/packages/editor/src/screens/HomeScreen/CreateNew.tsx +++ b/packages/editor/src/screens/HomeScreen/CreateNew.tsx @@ -14,12 +14,12 @@ import { } from 'unique-names-generator' import TemplatePanel from '../../components/TemplatePanel' import { useConfig } from '@magickml/client-core' -import { spellApi } from '@magickml/core' import LoadingButton from '@mui/lab/LoadingButton' import emptyImg from './empty.png' import css from './homeScreen.module.css' import { v4 as uuidv4 } from 'uuid' import { useTreeData } from "../../../../core/client/src/contexts/TreeDataProvider" +import { spellApi } from '@magickml/state' // Custom configuration for unique name generator const customConfig = { diff --git a/packages/editor/src/screens/HomeScreen/HomeScreen.tsx b/packages/editor/src/screens/HomeScreen/HomeScreen.tsx index 3f62d5f66a..269d557dff 100644 --- a/packages/editor/src/screens/HomeScreen/HomeScreen.tsx +++ b/packages/editor/src/screens/HomeScreen/HomeScreen.tsx @@ -4,19 +4,13 @@ import { useState } from 'react' import { useDispatch, useSelector } from 'react-redux' import { Route, Routes, useNavigate } from 'react-router-dom' import { useConfig } from '@magickml/client-core' -import { - useDeleteSpellMutation, - useGetSpellsQuery, - useNewSpellMutation, -} from '@magickml/core' -import { RootState } from '@magickml/core' -import { closeTab, openTab, selectAllTabs } from '@magickml/core' import AllProjects from './AllProjects' import CreateNew from './CreateNew' import css from './homeScreen.module.css' import OpenProject from './OpenProject' import { v4 as uuidv4 } from 'uuid' import { useTreeData } from "../../../../core/client/src/contexts/TreeDataProvider" +import { RootState, closeTab, openTab, selectAllTabs, useDeleteSpellMutation, useGetSpellsQuery, useNewSpellMutation } from '@magickml/state' /** * StartScreen component. Displays an overlay with options to open or create new spells. diff --git a/packages/editor/src/screens/HomeScreen/OpenProject.tsx b/packages/editor/src/screens/HomeScreen/OpenProject.tsx index 4a19bd7e91..a9ac3d7fb2 100644 --- a/packages/editor/src/screens/HomeScreen/OpenProject.tsx +++ b/packages/editor/src/screens/HomeScreen/OpenProject.tsx @@ -5,11 +5,10 @@ import { useNavigate } from 'react-router-dom' import packageJson from '../../../package.json' import FileInput from '../../components/FileInput' -import { RootState } from '@magickml/core' -import { selectAllTabs } from '@magickml/core' import ProjectRow from '../../components/ProjectRow' import css from './homeScreen.module.css' import banner from './banner.png' +import { RootState, selectAllTabs } from '@magickml/state' const version = packageJson.version diff --git a/packages/editor/src/screens/Magick/Magick.tsx b/packages/editor/src/screens/Magick/Magick.tsx index c7e12b29b6..220975a980 100644 --- a/packages/editor/src/screens/Magick/Magick.tsx +++ b/packages/editor/src/screens/Magick/Magick.tsx @@ -5,19 +5,13 @@ import { useDispatch, useSelector } from 'react-redux' import { useNavigate, useParams } from 'react-router-dom' import TabBar from '../../components/TabBar/TabBar' import Workspaces from '../../components/Workspaces' -import { RootState } from '@magickml/core' -import { - activeTabSelector, - closeTab, - openTab, - selectAllTabs, -} from '@magickml/core' import Events from '../EventWindow' import Requests from '../RequestWindow' import Settings from '../settings/SettingsWindow' import Documents from '../DocumentWindow' import Agents from '../agents/AgentManagerWindow'; import { ClientPluginManager, pluginManager } from '@magickml/core' +import { RootState, activeTabSelector, closeTab, openTab, selectAllTabs } from '@magickml/state' /** * Magick component * @param empty flag to control whether the workspaces should be rendered or not diff --git a/packages/editor/src/windows/PlaytestWindow.tsx b/packages/editor/src/windows/PlaytestWindow.tsx index 02d7191e52..13e8d1adcc 100644 --- a/packages/editor/src/windows/PlaytestWindow.tsx +++ b/packages/editor/src/windows/PlaytestWindow.tsx @@ -10,13 +10,7 @@ import { useEditor } from '../contexts/EditorProvider' import { useInspector } from '../contexts/InspectorProvider' import { usePubSub } from '@magickml/client-core' import css from '../screens/Magick/magick.module.css' -import { spellApi } from '@magickml/core' -import { useAppSelector } from '@magickml/core' -import { - addLocalState, - selectStateBytabId, - upsertLocalState -} from '@magickml/core' +import { addLocalState, selectStateBytabId, spellApi, upsertLocalState, useAppSelector } from '@magickml/state' /** * Input component - Receives and sends playtest input. diff --git a/packages/layouts/src/data/defaultLayout.json b/packages/layouts/src/data/defaultLayout.json new file mode 100644 index 0000000000..e7c22e3d54 --- /dev/null +++ b/packages/layouts/src/data/defaultLayout.json @@ -0,0 +1,111 @@ +{ + "global": { + "splitterSize": 4, + "tabSetTabStripHeight": 24 + }, + "borders": [], + "layout": { + "type": "row", + "id": "#root", + "children": [ + { + "type": "row", + "id": "#311b4548-d97d-4136-8a52-428df5b18b46", + "weight": 8.270856285820575, + "children": [ + { + "type": "tabset", + "id": "#157c8b9b-9606-4318-8852-320632c3d017", + "weight": 57.369062119366625, + "children": [ + { + "type": "tab", + "id": "#31", + "name": "Inspector", + "component": "inspector" + } + ] + } + ] + }, + { + "type": "row", + "id": "#9", + "weight": 27.17567065341046, + "children": [ + { + "type": "row", + "id": "#450a1b4f-ad0d-464a-a5e8-2391756d2070", + "weight": 60, + "children": [ + { + "type": "tabset", + "id": "#15", + "weight": 58.797127468581685, + "children": [ + { + "type": "tab", + "id": "#21", + "name": "Composer", + "component": "editorWindow", + "enableClose": false, + "className": "editor-tab" + } + ] + }, + { + "type": "tabset", + "id": "#49908c21-6f95-45b8-8b79-b9a6069bdcb6", + "weight": 41.202872531418315, + "children": [ + { + "type": "tab", + "id": "#40", + "name": "Text Editor", + "component": "textEditor" + } + ] + } + ] + }, + { + "type": "row", + "id": "#76df7889-b60a-425e-8f0c-8f064b43f680", + "weight": 30, + "children": [ + { + "type": "tabset", + "id": "#8", + "weight": 50, + "children": [ + { + "type": "tab", + "id": "#22", + "name": "Playtest", + "component": "playtest" + } + ], + "active": true + }, + { + "type": "tabset", + "id": "#0eca02af-8282-4d36-98b0-3d688b095b71", + "weight": 50, + "children": [ + { + "type": "tab", + "id": "44", + "name": "Console", + "component": "debugConsole", + "className": "debug-console", + "enableFloat": true + } + ] + } + ] + } + ] + } + ] + } +} diff --git a/packages/layouts/src/data/fullScreenLayout.json b/packages/layouts/src/data/fullScreenLayout.json new file mode 100644 index 0000000000..5dae96ed44 --- /dev/null +++ b/packages/layouts/src/data/fullScreenLayout.json @@ -0,0 +1,42 @@ +{ + "global": { + "splitterSize": 4, + "tabSetTabStripHeight": 24 + }, + "borders": [], + "layout": { + "type": "row", + "id": "#root", + "children": [ + { + "type": "row", + "id": "#9", + "weight": 27.17567065341046, + "children": [ + { + "type": "row", + "id": "#450a1b4f-ad0d-464a-a5e8-2391756d2070", + "weight": 60, + "children": [ + { + "type": "tabset", + "id": "#15", + "weight": 58.797127468581685, + "children": [ + { + "type": "tab", + "id": "#21", + "name": "Composer", + "component": "editorWindow", + "enableClose": false, + "className": "editor-tab" + } + ] + } + ] + } + ] + } + ] + } +} diff --git a/packages/layouts/src/data/promptEngineeringLayout.json b/packages/layouts/src/data/promptEngineeringLayout.json new file mode 100644 index 0000000000..f4363a12e2 --- /dev/null +++ b/packages/layouts/src/data/promptEngineeringLayout.json @@ -0,0 +1,96 @@ +{ + "global": { + "splitterSize": 4, + "tabSetTabStripHeight": 24 + }, + "borders": [], + "layout": { + "type": "row", + "id": "#root", + "children": [ + { + "type": "row", + "id": "#311b4548-d97d-4136-8a52-428df5b18b46", + "weight": 8.270856285820575, + "children": [ + { + "type": "tabset", + "id": "#157c8b9b-9606-4318-8852-320632c3d017", + "weight": 57.369062119366625, + "children": [ + { + "type": "tab", + "id": "#31", + "name": "Inspector", + "component": "inspector" + } + ] + } + ] + }, + { + "type": "row", + "id": "#9", + "weight": 27.17567065341046, + "children": [ + { + "type": "row", + "id": "#450a1b4f-ad0d-464a-a5e8-2391756d2070", + "weight": 60, + "children": [ + { + "type": "tabset", + "id": "#15", + "weight": 58.797127468581685, + "children": [ + { + "type": "tab", + "id": "#21", + "name": "Composer", + "component": "editorWindow", + "enableClose": false, + "className": "editor-tab" + } + ] + }, + { + "type": "tabset", + "id": "#49908c21-6f95-45b8-8b79-b9a6069bdcb6", + "weight": 41.202872531418315, + "children": [ + { + "type": "tab", + "id": "#40", + "name": "Text Editor", + "component": "textEditor" + } + ] + } + ] + }, + { + "type": "row", + "id": "#76df7889-b60a-425e-8f0c-8f064b43f680", + "weight": 30, + "children": [ + { + "type": "tabset", + "id": "#8", + "weight": 50, + "children": [ + { + "type": "tab", + "id": "#22", + "name": "Playtest", + "component": "playtest" + } + ], + "active": true + } + ] + } + ] + } + ] + } +} diff --git a/packages/layouts/src/data/troubleshootingLayout.json b/packages/layouts/src/data/troubleshootingLayout.json new file mode 100644 index 0000000000..b740264cbe --- /dev/null +++ b/packages/layouts/src/data/troubleshootingLayout.json @@ -0,0 +1,97 @@ +{ + "global": { + "splitterSize": 4, + "tabSetTabStripHeight": 24 + }, + "borders": [], + "layout": { + "type": "row", + "id": "#root", + "children": [ + { + "type": "row", + "id": "#311b4548-d97d-4136-8a52-428df5b18b46", + "weight": 8.270856285820575, + "children": [ + { + "type": "tabset", + "id": "#157c8b9b-9606-4318-8852-320632c3d017", + "weight": 57.369062119366625, + "children": [ + { + "type": "tab", + "id": "#31", + "name": "Inspector", + "component": "inspector" + } + ] + } + ] + }, + { + "type": "row", + "id": "#9", + "weight": 27.17567065341046, + "children": [ + { + "type": "row", + "id": "#450a1b4f-ad0d-464a-a5e8-2391756d2070", + "weight": 60, + "children": [ + { + "type": "tabset", + "id": "#15", + "weight": 58.797127468581685, + "children": [ + { + "type": "tab", + "id": "#21", + "name": "Composer", + "component": "editorWindow", + "enableClose": false, + "className": "editor-tab" + } + ] + } + ] + }, + { + "type": "row", + "id": "#76df7889-b60a-425e-8f0c-8f064b43f680", + "weight": 30, + "children": [ + { + "type": "tabset", + "id": "#8", + "weight": 50, + "children": [ + { + "type": "tab", + "id": "#22", + "name": "Playtest", + "component": "playtest" + } + ], + "active": true + }, + { + "type": "tabset", + "id": "#0eca02af-8282-4d36-98b0-3d688b095b71", + "weight": 50, + "children": [ + { + "type": "tab", + "id": "44", + "name": "Console", + "component": "debugConsole", + "className": "debug-console" + } + ] + } + ] + } + ] + } + ] + } +} diff --git a/packages/layouts/src/index.ts b/packages/layouts/src/index.ts index 378fec1215..48d1a756fc 100644 --- a/packages/layouts/src/index.ts +++ b/packages/layouts/src/index.ts @@ -1 +1 @@ -export * from './lib/layouts' +export * from './main' diff --git a/packages/layouts/src/lib/layouts.ts b/packages/layouts/src/lib/layouts.ts deleted file mode 100644 index e1adcf7b2d..0000000000 --- a/packages/layouts/src/lib/layouts.ts +++ /dev/null @@ -1,3 +0,0 @@ -export function layouts(): string { - return 'layouts' -} diff --git a/packages/layouts/src/main.ts b/packages/layouts/src/main.ts new file mode 100644 index 0000000000..90eeea1737 --- /dev/null +++ b/packages/layouts/src/main.ts @@ -0,0 +1,16 @@ +import defaultJson from './data/defaultLayout.json' +import fullScreen from './data/fullScreenLayout.json' +import promptEngineering from './data/promptEngineeringLayout.json' +import troubleShooting from './data/troubleshootingLayout.json' + +// Workspace map for initializing tabs with layout data +export const workspaceMap = { + default: defaultJson, + fullScreen, + promptEngineering, + troubleShooting, +} + +export const getWorkspaceLayout = layoutKey => { + return workspaceMap[layoutKey] || workspaceMap.default +} diff --git a/packages/layouts/tsconfig.json b/packages/layouts/tsconfig.json index db7b566661..1f79d516e6 100644 --- a/packages/layouts/tsconfig.json +++ b/packages/layouts/tsconfig.json @@ -7,7 +7,8 @@ "noImplicitOverride": true, "noPropertyAccessFromIndexSignature": true, "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true + "noFallthroughCasesInSwitch": true, + "resolveJsonModule": true }, "files": [], "include": [], diff --git a/packages/state/src/lib/api/spells.ts b/packages/state/src/lib/api/spells.ts index 3690c55dac..f6ca9dae61 100644 --- a/packages/state/src/lib/api/spells.ts +++ b/packages/state/src/lib/api/spells.ts @@ -2,7 +2,6 @@ import { FetchBaseQueryError } from '@reduxjs/toolkit/query/react' import { QueryReturnValue } from '@reduxjs/toolkit/dist/query/baseQueryTypes' import { rootApi } from './api' -import { SpellInterface } from '@magickml/core' import md5 from 'md5' /** @@ -18,7 +17,7 @@ export interface Diff { */ export interface PatchArgs { spellName: string - update: Partial + update: Partial } /** @@ -35,7 +34,7 @@ export interface SpellData { limit: number skip: number total: number - data: SpellInterface[] + data: any[] } /** @@ -138,7 +137,7 @@ export const spellApi = rootApi.injectEndpoints({ } return baseQuery(baseQueryOptions) as QueryReturnValue< - Partial, + Partial, FetchBaseQueryError, unknown > diff --git a/packages/state/src/lib/store.ts b/packages/state/src/lib/store.ts index 8858e75295..20ea063691 100644 --- a/packages/state/src/lib/store.ts +++ b/packages/state/src/lib/store.ts @@ -12,7 +12,7 @@ import tabReducer from './tabs' import localStateReducer from './localState' import preferencesReducer from './preferences' import globalConfigReducer from './globalConfig' -import { AppConfig } from '@magickml/client-core' +// import { AppConfig } from '@magickml/client-core' /** * Combine all reducers into the root reducer. @@ -33,7 +33,7 @@ let _store: any = null * @param config - Optional configuration for the store. * @returns The created store. */ -export const createStore = (config: AppConfig) => { +export const createStore = (config: any) => { if (_store) return _store const persistConfig = { diff --git a/packages/state/src/lib/tabs.ts b/packages/state/src/lib/tabs.ts index df84bde8ca..11bc8eecca 100644 --- a/packages/state/src/lib/tabs.ts +++ b/packages/state/src/lib/tabs.ts @@ -1,24 +1,12 @@ // DOCUMENTED +import { getWorkspaceLayout } from '@magickml/layouts' import { createDraftSafeSelector, createEntityAdapter, createSlice, } from '@reduxjs/toolkit' - -import defaultJson from '../data/layouts/defaultLayout.json' -import fullScreen from '../data/layouts/fullScreenLayout.json' -import promptEngineering from '../data/layouts/promptEngineeringLayout.json' -import troubleShooting from '../data/layouts/troubleshootingLayout.json' import { RootState } from './store' -// Workspace map for initializing tabs with layout data -export const workspaceMap = { - default: defaultJson, - fullScreen, - promptEngineering, - troubleShooting, -} - /** * Tab interface representing a tab object */ @@ -84,7 +72,7 @@ const buildTab = (tab, properties = {}) => ({ id: encodedToId(tab.name) || tab.name, URI: encodeURIComponent(tab.name) || tab.name, name: encodedToName(tab.name) || tab.name, - layoutJson: workspaceMap[tab.workspace || 'default'], + layoutJson: getWorkspaceLayout(tab.workspace), spell: tab?.spell || null, type: tab?.type, module: tab?.moduleName || null, @@ -145,7 +133,7 @@ export const tabSlice = createSlice({ changeEditorLayout: (state, action) => { tabAdapater.updateOne(state, { id: action.payload.tabId, - changes: { layoutJson: workspaceMap[action.payload.layout] }, + changes: { layoutJson: getWorkspaceLayout(action.payload.layout) }, }) }, }, diff --git a/packages/state/tsconfig.json b/packages/state/tsconfig.json index bdf594cdb1..e5d6cc367b 100644 --- a/packages/state/tsconfig.json +++ b/packages/state/tsconfig.json @@ -8,7 +8,7 @@ "noPropertyAccessFromIndexSignature": true, "noImplicitReturns": true, "noFallthroughCasesInSwitch": true, - "types": ["vitest"] + "resolveJsonModule": true }, "files": [], "include": [], diff --git a/tsconfig.base.json b/tsconfig.base.json index 91e550d8e2..8cb04e7ceb 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -9,7 +9,7 @@ "experimentalDecorators": true, "importHelpers": true, "noImplicitAny": false, - "jsx": "react", + "jsx": "react-jsx", "target": "esnext", "module": "esnext", "lib": ["es2021", "dom"], @@ -19,9 +19,10 @@ "esModuleInterop": true, "strict": false, "typeRoots": [ - "./packages/@types", + "packages/@types", "./node_modules/@types", - "./node_modules" + "./node_modules", + "/node_modules/@types" ], "paths": { "@magickml/agent": ["apps/agent/src/index.ts"], From fde4a8346ebec190d00ae8ced4b9c70cb3595af4 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 14 Sep 2023 23:20:07 -0700 Subject: [PATCH 009/349] Add current agent to global state config --- packages/state/src/lib/globalConfig.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/state/src/lib/globalConfig.ts b/packages/state/src/lib/globalConfig.ts index cdd9dd5edc..f90c3d07fe 100644 --- a/packages/state/src/lib/globalConfig.ts +++ b/packages/state/src/lib/globalConfig.ts @@ -1,4 +1,4 @@ -// DOCUMENTED +// DOCUMENTED /** * Module that exports a Redux slice for the global config that carries the authentication, project id and API url information. * @module globalConfigSlice @@ -13,6 +13,7 @@ export interface GlobalConfig { apiUrl: string token: string projectId: string + currentAgentId: string } /** @@ -25,6 +26,7 @@ export const globalConfigSlice: Slice = createSlice({ apiUrl: '', token: '', projectId: '', + currentAgentId: '', }, reducers: { /** @@ -33,12 +35,21 @@ export const globalConfigSlice: Slice = createSlice({ * @param {PayloadAction} action - Config to set on the global state. * @return {void} */ - setConfig: (state: GlobalConfig, action: PayloadAction): void => { + setConfig: ( + state: GlobalConfig, + action: PayloadAction + ): void => { const { apiUrl, token, projectId } = action.payload state.apiUrl = apiUrl state.token = token state.projectId = projectId }, + setCurrentAgentId: ( + state: GlobalConfig, + action: PayloadAction + ): void => { + state.currentAgentId = action.payload + }, }, }) @@ -46,9 +57,9 @@ export const globalConfigSlice: Slice = createSlice({ /** * Action to set the global configuration. */ -export const { setConfig } = globalConfigSlice.actions +export const { setConfig, setCurrentAgentId } = globalConfigSlice.actions /** * Export GlobalConfigSlice reducer. */ -export default globalConfigSlice.reducer \ No newline at end of file +export default globalConfigSlice.reducer From 9e7f648e9d325ca253573ac79d13ff2a306a2b1b Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 14 Sep 2023 23:29:59 -0700 Subject: [PATCH 010/349] Set current agent into redux state --- packages/core/client/src/components/Drawer/AgentMenu.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/core/client/src/components/Drawer/AgentMenu.tsx b/packages/core/client/src/components/Drawer/AgentMenu.tsx index cb2cef34d5..b363565fd6 100644 --- a/packages/core/client/src/components/Drawer/AgentMenu.tsx +++ b/packages/core/client/src/components/Drawer/AgentMenu.tsx @@ -19,7 +19,7 @@ import { Close, Done } from '@mui/icons-material' import styles from './menu.module.css' import { useConfig } from '@magickml/client-core' import { enqueueSnackbar } from 'notistack' -import { useSelector } from 'react-redux' +import { useDispatch, useSelector } from 'react-redux' import { Modal } from '@magickml/client-core' import { DEFAULT_USER_TOKEN, STANDALONE, API_ROOT_URL } from '@magickml/config' @@ -29,6 +29,7 @@ import { useFeathers } from '../../providers/FeathersProvider' import { useSpellList } from '../../../../../plugins/avatar/client/src/hooks/useSpellList' import { useTreeData } from '../../../../client/src/contexts/TreeDataProvider' import { AgentInterface, SpellInterface } from '@magickml/core' +import { setCurrentAgentId } from '@magickml/state' interface Spell { id: number @@ -52,12 +53,16 @@ function AgentMenu({ data, resetData }) { const spellList: SpellInterface[] = useSpellList() const imageInputRef = useRef(null) const { agentUpdate, setAgentUpdate } = useTreeData() + const dispatch = useDispatch() const setCurrentAgent = useCallback( (agent: AgentInterface) => { // Subscribe to agent service client.service('agents').subscribe(agent.id) _setCurrentAgent(agent) + + // store this current agent in the global state for use in the editor + dispatch(setCurrentAgentId(agent.id)) }, [] ) From 452d698dfb8bd7b6fb06e7104c7445e15aeceebf Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 14 Sep 2023 23:30:47 -0700 Subject: [PATCH 011/349] Add agent getter state selector into playtest --- packages/editor/src/windows/PlaytestWindow.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/editor/src/windows/PlaytestWindow.tsx b/packages/editor/src/windows/PlaytestWindow.tsx index 13e8d1adcc..1a622ba7fc 100644 --- a/packages/editor/src/windows/PlaytestWindow.tsx +++ b/packages/editor/src/windows/PlaytestWindow.tsx @@ -5,18 +5,21 @@ import { useSnackbar } from 'notistack' import React, { useCallback, useEffect, useRef, useState } from 'react' import { Scrollbars } from 'react-custom-scrollbars-2' import { useHotkeys } from 'react-hotkeys-hook' -import { useDispatch } from 'react-redux' +import { useDispatch, useSelector } from 'react-redux' import { useEditor } from '../contexts/EditorProvider' import { useInspector } from '../contexts/InspectorProvider' import { usePubSub } from '@magickml/client-core' import css from '../screens/Magick/magick.module.css' -import { addLocalState, selectStateBytabId, spellApi, upsertLocalState, useAppSelector } from '@magickml/state' +import { RootState, addLocalState, selectStateBytabId, spellApi, upsertLocalState, useAppSelector } from '@magickml/state' /** * Input component - Receives and sends playtest input. */ const Input = props => { const ref = useRef() as React.MutableRefObject + const { currentAgentid } = useSelector( + state => state.globalConfig + ) as any const [playtestCache, setPlaytestCache] = useState([]) @@ -31,6 +34,11 @@ const Input = props => { [props, ref] ) + // console log current agent id on change + useEffect(() => { + console.log('current agent id', currentAgentid) + }, [currentAgentid]) + // Use up and down arrows to move through history and set valye of input. useHotkeys( 'up', From 9adbaa9d60fb771f3116f1ba95490491485a0c4a Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 15 Sep 2023 00:04:44 -0700 Subject: [PATCH 012/349] Send data along run spell in event handler --- packages/editor/src/components/EventHandler.tsx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/editor/src/components/EventHandler.tsx b/packages/editor/src/components/EventHandler.tsx index e8efdddd35..3e92099ae6 100644 --- a/packages/editor/src/components/EventHandler.tsx +++ b/packages/editor/src/components/EventHandler.tsx @@ -10,7 +10,8 @@ import { useEditor } from '../contexts/EditorProvider' import { diff } from '../utils/json0' import { useConfig, useFeathers } from '@magickml/client-core' -import { useLazyGetSpellByIdQuery, useSaveSpellMutation } from '@magickml/state' +import { useLazyGetSpellByIdQuery, useSaveSpellMutation, RootState } from '@magickml/state' +import { useSelector } from 'react-redux' /** * Event Handler component for handling various events in the editor @@ -25,6 +26,8 @@ const EventHandler = ({ pubSub, tab }) => { const { createOrFocus, windowTypes } = useLayout() const { enqueueSnackbar } = useSnackbar() + const { currentAgentId } = useSelector((state: RootState) => state.globalConfig) + const [saveSpellMutation] = useSaveSpellMutation() // TODO: is this a bug? const [getSpell, { data: spell }] = useLazyGetSpellByIdQuery({ @@ -326,9 +329,17 @@ const EventHandler = ({ pubSub, tab }) => { * @param {object} event - The run Spell event object * @param {object} data - The data object for running the spell */ - const runSpell = async (event, data) => { + const runSpell = async (event, _data) => { // run the spell in the spell runner service - client.service('spell-runner').create(data) + const data = { + spell: spellRef.current, + agentId: currentAgentId, + projectId: config.projectId, + ..._data + } + console.log('DATA', data) + const response = await client.service('agents').run(data) + console.log("RESOPONSE!", response) } const handlerMap = { From eaa528f7b60d8fbb947914eac1808cf06ae5651a Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 15 Sep 2023 16:21:51 -0700 Subject: [PATCH 013/349] Add cloud agent worker to vscode launch json --- .vscode/launch.json | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.vscode/launch.json b/.vscode/launch.json index fa131bf53a..78de29eacd 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -28,6 +28,17 @@ "request": "attach", "port": 7777 }, + { + "name": "CloudAgentWorker", + "type": "node", + "request": "attach", + "port": 8089, + "resolveSourceMapLocations": [ + "${workspaceFolder}/**", + "!**/node_modules/**" + ], + "outFiles": ["${workspaceFolder}/dist/**/*.js"] + }, { "name": "Server", "type": "node", From 771a0ad9b1f6c74f6100b820154bb322afb2e0a0 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 15 Sep 2023 16:22:57 -0700 Subject: [PATCH 014/349] Fall back in agent runWorker to the agents rootSpell --- packages/agents/src/lib/Agent.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/agents/src/lib/Agent.ts b/packages/agents/src/lib/Agent.ts index b47a000018..892f35736a 100644 --- a/packages/agents/src/lib/Agent.ts +++ b/packages/agents/src/lib/Agent.ts @@ -221,13 +221,16 @@ export class Agent implements AgentInterface { } async runWorker(job: Job) { + console.log('RUNNING WORKER!', job) // the job name is the agent id. Only run if the agent id matches. this.logger.debug('running worker', { id: this.id, data: job.data }) if (this.id !== job.data.agentId) return const { data } = job - const spellRunner = await this.spellManager.loadById(data.spellId) + const spellRunner = await this.spellManager.loadById( + data.spellId || this.rootSpellId + ) // Handle the case where we don't get a sepllRunner if (!spellRunner) { @@ -271,6 +274,7 @@ export class Agent implements AgentInterface { result: output, }) } catch (err) { + console.log('ERROR', err) this.logger.error( { spellId: data.spellId, agent: { name: this.name, id: this.id } }, 'Error running agent spell: %o', From 97f057c19791d61eb7e1c5e51459d6b0096f3db1 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 15 Sep 2023 16:23:27 -0700 Subject: [PATCH 015/349] Update agent run function to use agent commander --- packages/core/server/src/services/agents/agents.class.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/core/server/src/services/agents/agents.class.ts b/packages/core/server/src/services/agents/agents.class.ts index edc7d1c98f..801cda4b83 100644 --- a/packages/core/server/src/services/agents/agents.class.ts +++ b/packages/core/server/src/services/agents/agents.class.ts @@ -7,6 +7,7 @@ import { app } from '@magickml/server-core' import md5 from 'md5' import type { Application } from '../../declarations' import type { Agent, AgentData, AgentPatch, AgentQuery } from './agents.schema' +import { Queue } from 'bullmq' import { RunRootSpellArgs } from '@magickml/agents' // Define AgentParams type based on KnexAdapterParams with AgentQuery From 1722ecebbc26067f0da8dc1dccae0a1ff8d2cf21 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 15 Sep 2023 16:23:54 -0700 Subject: [PATCH 016/349] Agent commander working with just agentId --- packages/agents/src/lib/AgentCommander.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/agents/src/lib/AgentCommander.ts b/packages/agents/src/lib/AgentCommander.ts index b2f19d9287..63eca9a0aa 100644 --- a/packages/agents/src/lib/AgentCommander.ts +++ b/packages/agents/src/lib/AgentCommander.ts @@ -80,6 +80,8 @@ export class AgentCommander extends EventEmitter { } }) + console.log('running spell with response') + debugger jobId = await this.runSpell(args) })() }) From 68121179db01e786302f6d5a2bc5c7fbece74f1d Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 15 Sep 2023 16:24:22 -0700 Subject: [PATCH 017/349] Block message publishing from all but main server app --- packages/core/server/src/sockets/channels.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/server/src/sockets/channels.ts b/packages/core/server/src/sockets/channels.ts index f8d331a22a..3216b5e472 100644 --- a/packages/core/server/src/sockets/channels.ts +++ b/packages/core/server/src/sockets/channels.ts @@ -98,8 +98,8 @@ export default function (app: Application): void { context.data?.agentId || data.agentId - // don't publish if we are an agent - if (app.get('isAgent')) return + // Block publishing unless we are on the main server + if (app.get('environment') !== 'server') return // Lets not relay up all the patch events if (context.method === 'patch' || !projectId) return From 0d6d3a8c2f152d73ede8e5248c3b86f33de43027 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 15 Sep 2023 16:25:09 -0700 Subject: [PATCH 018/349] Add run to agent commands and block pubsub if not on main server --- .../core/server/src/services/agents/agents.ts | 68 +++++++++---------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/packages/core/server/src/services/agents/agents.ts b/packages/core/server/src/services/agents/agents.ts index be8f2a25b9..0bebe7443a 100644 --- a/packages/core/server/src/services/agents/agents.ts +++ b/packages/core/server/src/services/agents/agents.ts @@ -74,44 +74,44 @@ export const agent = (app: Application) => { const pubSub = app.get<'pubsub'>('pubsub') // this handles relaying all agent messages up to connected clients. - pubSub.patternSubscribe('agent*', (message, channel) => { - if (app.get('environment') !== 'server') return - // parse the channel from agent:agentId:messageType - const agentId = channel.split(':')[1] - - // parse the type of agent message - const messageType = channel.split(':')[2] - - // check if message type is an agent event - if (!AGENT_EVENTS.includes(messageType)) { - // notify connected clients via log message that an unknown message type was received - app.service('agents').emit('log', { + // Only subscribe on the main server not any workers. + if (app.get('environment') === 'server') + pubSub.patternSubscribe('agent*', (message, channel) => { + // parse the channel from agent:agentId:messageType + const agentId = channel.split(':')[1] + + // parse the type of agent message + const messageType = channel.split(':')[2] + + // check if message type is an agent event + if (!AGENT_EVENTS.includes(messageType)) { + // notify connected clients via log message that an unknown message type was received + app.service('agents').emit('log', { + channel, + agentId, + data: { + message: `Unknown message type ${messageType}`, + }, + }) + } + + // remove unwanted properties from the message + // embeddings and spells are large data packages we don't need on the client + const cleanMessage = removeUnwantedProperties(message, [ + 'embedding', + 'spell', + ]) + + // this is where we relay messages up based upon the time. + // note for every custom type we need to add it to the above + // todo harder typing on all message transports + app.service('agents').emit(messageType, { + ...cleanMessage, + messageType, channel, agentId, - project: agentId, - data: { - message: `Unknown message type ${messageType} on channel ${channel}`, - }, }) - } - - // remove unwanted properties from the message - // embeddings and spells are large data packages we don't need on the client - const cleanMessage = removeUnwantedProperties(message, [ - // 'embedding', - 'spell', - ]) - - // this is where we relay messages up based upon the time. - // note for every custom type we need to add it to the above - // todo harder typing on all message transports - app.service('agents').emit(messageType, { - ...cleanMessage, - messageType, - channel, - agentId, }) - }) // Initialize hooks for the agent service app.service('agents').hooks({ From 7388a7aa5d6fd13a5b7cb6143c43f97d4463e825 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 15 Sep 2023 23:13:55 -0700 Subject: [PATCH 019/349] Wrap internals of spellRunner in a try catch and fix busy stataus --- packages/core/shared/src/spellManager/SpellRunner.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/core/shared/src/spellManager/SpellRunner.ts b/packages/core/shared/src/spellManager/SpellRunner.ts index 6ef6a8a650..7770c0b600 100644 --- a/packages/core/shared/src/spellManager/SpellRunner.ts +++ b/packages/core/shared/src/spellManager/SpellRunner.ts @@ -395,7 +395,6 @@ class SpellRunner { // subscribe to a run pubsub and then we just use that. This would treat running // from a trigger in node like any other data stream. Or even just pass in socket IO. // - await component.run(triggeredNode as NodeData, inputs, this.engine) this.busy = false From 656aebc85d32540940436235b942f9886beec58c Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 15 Sep 2023 23:15:27 -0700 Subject: [PATCH 020/349] Clean up playtest window a bit --- packages/editor/src/windows/PlaytestWindow.tsx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/packages/editor/src/windows/PlaytestWindow.tsx b/packages/editor/src/windows/PlaytestWindow.tsx index 1a622ba7fc..0608e8bc45 100644 --- a/packages/editor/src/windows/PlaytestWindow.tsx +++ b/packages/editor/src/windows/PlaytestWindow.tsx @@ -34,11 +34,6 @@ const Input = props => { [props, ref] ) - // console log current agent id on change - useEffect(() => { - console.log('current agent id', currentAgentid) - }, [currentAgentid]) - // Use up and down arrows to move through history and set valye of input. useHotkeys( 'up', @@ -386,9 +381,9 @@ const Playtest = ({ tab }) => { secrets: JSON.parse(localStorage.getItem('secrets') || '{}'), } - publish($RUN_SPELL(tab.id), data) - setValue('') + + publish($RUN_SPELL(tab.id), data) } // Update state when playtest data is changed. From 38e28fda98c821cd6ee2d644c9bd32eef3c41708 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 15 Sep 2023 23:16:41 -0700 Subject: [PATCH 021/349] Pass in spellId with runspell data in event handler --- packages/editor/src/components/EventHandler.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/editor/src/components/EventHandler.tsx b/packages/editor/src/components/EventHandler.tsx index 3e92099ae6..1e6253ac0d 100644 --- a/packages/editor/src/components/EventHandler.tsx +++ b/packages/editor/src/components/EventHandler.tsx @@ -332,14 +332,12 @@ const EventHandler = ({ pubSub, tab }) => { const runSpell = async (event, _data) => { // run the spell in the spell runner service const data = { - spell: spellRef.current, + spellId: spellRef.current.id, agentId: currentAgentId, projectId: config.projectId, ..._data } - console.log('DATA', data) const response = await client.service('agents').run(data) - console.log("RESOPONSE!", response) } const handlerMap = { From dd777b8dac149093c4894b5317951bd11d74693f Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 15 Sep 2023 23:17:00 -0700 Subject: [PATCH 022/349] Formatting in cloud agent worker --- .../src/lib/cloud-agent-worker.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/cloud-agent-worker/src/lib/cloud-agent-worker.ts b/packages/cloud-agent-worker/src/lib/cloud-agent-worker.ts index fd25eee997..58c386a20e 100644 --- a/packages/cloud-agent-worker/src/lib/cloud-agent-worker.ts +++ b/packages/cloud-agent-worker/src/lib/cloud-agent-worker.ts @@ -8,6 +8,7 @@ import { BullQueue, } from '@magickml/server-core' import { Agent, AgentManager, type AgentRunJob } from '@magickml/agents' +import { v4 as uuidv4 } from 'uuid' import { AGENT_DELETE, AGENT_DELETE_JOB, @@ -49,6 +50,18 @@ export class CloudAgentWorker extends AgentManager { this.updateAgents = this.updateAgents.bind(this) } + heartbeat() { + this.pubSub.subscribe('cloud-agents:ping', async () => { + this.pubSub.publish( + 'cloud-agents:pong', + JSON.stringify({ + id: uuidv4(), + currentAgents: Object.keys(this.currentAgents), + }) + ) + }) + } + async addAgent(agentId: string) { this.logger.info(`Creating agent ${agentId}...`) const agentDBResult = ( From e0b2da9b73c7c54be16a0f4c1d1fed69a179e9ca Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 17 Sep 2023 10:54:41 -0700 Subject: [PATCH 023/349] Handle output from playtest to send it back properly --- packages/agents/src/lib/Agent.ts | 3 ++- packages/agents/src/lib/AgentCommander.ts | 5 +++-- packages/core/shared/src/nodes/io/Output.ts | 5 +++-- .../core/shared/src/plugins/modulePlugin/module.ts | 12 +++++++++++- packages/core/shared/src/spellManager/SpellRunner.ts | 3 +++ packages/core/shared/src/types.ts | 1 + packages/editor/src/components/EventHandler.tsx | 1 + 7 files changed, 24 insertions(+), 6 deletions(-) diff --git a/packages/agents/src/lib/Agent.ts b/packages/agents/src/lib/Agent.ts index 892f35736a..e7606d38d1 100644 --- a/packages/agents/src/lib/Agent.ts +++ b/packages/agents/src/lib/Agent.ts @@ -221,7 +221,6 @@ export class Agent implements AgentInterface { } async runWorker(job: Job) { - console.log('RUNNING WORKER!', job) // the job name is the agent id. Only run if the agent id matches. this.logger.debug('running worker', { id: this.id, data: job.data }) if (this.id !== job.data.agentId) return @@ -264,6 +263,7 @@ export class Agent implements AgentInterface { publicVariables: this.publicVariables, runSubspell: data.runSubspell, app: this.app, + isPlaytest: data.isPlaytest, }) this.publishEvent(AGENT_RUN_RESULT(this.id), { @@ -304,6 +304,7 @@ export interface AgentRunJob { runSubspell: boolean secrets: Record publicVariables: Record + isPlaytest?: boolean } export interface AgentResult { diff --git a/packages/agents/src/lib/AgentCommander.ts b/packages/agents/src/lib/AgentCommander.ts index 63eca9a0aa..34be9fc219 100644 --- a/packages/agents/src/lib/AgentCommander.ts +++ b/packages/agents/src/lib/AgentCommander.ts @@ -27,6 +27,7 @@ export type RunRootSpellArgs = { currentJob?: Job subSpellDepth?: number sessionId?: string + isPlaytest?: boolean } interface AgentCommanderArgs { @@ -80,8 +81,6 @@ export class AgentCommander extends EventEmitter { } }) - console.log('running spell with response') - debugger jobId = await this.runSpell(args) })() }) @@ -99,6 +98,7 @@ export class AgentCommander extends EventEmitter { spellId, subSpellDepth, sessionId, + isPlaytest = false, }: RunRootSpellArgs ) { return JSON.stringify({ @@ -112,6 +112,7 @@ export class AgentCommander extends EventEmitter { publicVariables, subSpellDepth, sessionId, + isPlaytest, }) } diff --git a/packages/core/shared/src/nodes/io/Output.ts b/packages/core/shared/src/nodes/io/Output.ts index d8e09e44e5..f7f8d1c9a8 100644 --- a/packages/core/shared/src/nodes/io/Output.ts +++ b/packages/core/shared/src/nodes/io/Output.ts @@ -122,7 +122,7 @@ export class Output extends MagickComponent { console.error('No input provided to output component') return { output: '' } } - const { data, agent } = context + const { data, agent, module } = context const event = // event data is inside a task ((inputs.event?.[0] as any)?.eventData || @@ -139,7 +139,8 @@ export class Output extends MagickComponent { event.connector // handle this being a subspell returning out - if (outputType === 'Subspell') { + // or if this is coming from playest, just return the output + if (outputType === 'Subspell' || module.isPlaytest) { return { output } } diff --git a/packages/core/shared/src/plugins/modulePlugin/module.ts b/packages/core/shared/src/plugins/modulePlugin/module.ts index db4f616a73..dc21967bb2 100644 --- a/packages/core/shared/src/plugins/modulePlugin/module.ts +++ b/packages/core/shared/src/plugins/modulePlugin/module.ts @@ -12,6 +12,7 @@ export class Module { inputs: Record outputs: Record sessionId?: string + isPlaytest: boolean app?: any // set to App, but move App to engine first constructor() { this.inputs = {} @@ -19,14 +20,23 @@ export class Module { this.secrets = {} this.publicVariables = {} this.app = null + this.isPlaytest = false } - read({ inputs, secrets, publicVariables, app, sessionId }: ReadArgs) { + read({ + inputs, + secrets, + publicVariables, + app, + sessionId, + isPlaytest = false, + }) { this.inputs = inputs this.secrets = secrets || ({} as Record) this.publicVariables = publicVariables || ({} as Record) this.app = app this.sessionId = sessionId + this.isPlaytest = isPlaytest } write(outputs: Record) { diff --git a/packages/core/shared/src/spellManager/SpellRunner.ts b/packages/core/shared/src/spellManager/SpellRunner.ts index 7770c0b600..1976893c69 100644 --- a/packages/core/shared/src/spellManager/SpellRunner.ts +++ b/packages/core/shared/src/spellManager/SpellRunner.ts @@ -20,6 +20,7 @@ import { AGENT_SPELL } from '../communication/agentEventTypes' export type RunComponentArgs = { sessionId?: string + isPlaytest?: boolean inputs: MagickSpellInput agent?: any componentName?: string @@ -303,6 +304,7 @@ class SpellRunner { publicVariables, sessionId, app, + isPlaytest = false, }: RunComponentArgs) { this.busy = true // This should break us out of an infinite loop if we have circular spell dependencies. @@ -325,6 +327,7 @@ class SpellRunner { publicVariables, app, sessionId, + isPlaytest, }) const component = this._getComponent( diff --git a/packages/core/shared/src/types.ts b/packages/core/shared/src/types.ts index d386a56b71..39d932f391 100644 --- a/packages/core/shared/src/types.ts +++ b/packages/core/shared/src/types.ts @@ -617,6 +617,7 @@ export type ModuleContext = { inputs: Record outputs: Record sessionId?: string + isPlaytest?: boolean } projectId: string currentSpell: Spell diff --git a/packages/editor/src/components/EventHandler.tsx b/packages/editor/src/components/EventHandler.tsx index 1e6253ac0d..16ef6c0407 100644 --- a/packages/editor/src/components/EventHandler.tsx +++ b/packages/editor/src/components/EventHandler.tsx @@ -335,6 +335,7 @@ const EventHandler = ({ pubSub, tab }) => { spellId: spellRef.current.id, agentId: currentAgentId, projectId: config.projectId, + isPlaytest: true, ..._data } const response = await client.service('agents').run(data) From 8068ad2f5d050a76c75a2da40f6ea775a15fba7e Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 17 Sep 2023 18:41:31 -0700 Subject: [PATCH 024/349] Send if the run was triggered by the playtest --- packages/agents/src/lib/Agent.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/agents/src/lib/Agent.ts b/packages/agents/src/lib/Agent.ts index e7606d38d1..2f148ff3f8 100644 --- a/packages/agents/src/lib/Agent.ts +++ b/packages/agents/src/lib/Agent.ts @@ -271,6 +271,7 @@ export class Agent implements AgentInterface { agentId: this.id, projectId: this.projectId, originalData: data, + fromPlaytest: data.isPlaytest, result: output, }) } catch (err) { @@ -286,6 +287,7 @@ export class Agent implements AgentInterface { agentId: this.id, projectId: this.projectId, originalData: data, + fromPlaytest: data.isPlaytest, result: { error: err instanceof Error ? err.message : 'Error running agent', }, From 3566fe3cd53fb1a2f529adfd980850e8151dd5b4 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 17 Sep 2023 18:42:11 -0700 Subject: [PATCH 025/349] Only send data to playtest print if it came form playtest --- packages/core/shared/src/plugins/remotePlugin/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/core/shared/src/plugins/remotePlugin/index.ts b/packages/core/shared/src/plugins/remotePlugin/index.ts index 580ad0587b..774ec12ba1 100644 --- a/packages/core/shared/src/plugins/remotePlugin/index.ts +++ b/packages/core/shared/src/plugins/remotePlugin/index.ts @@ -88,7 +88,11 @@ function install( // todo might need to not hardcode the output to "output" // could be more elegant - if (node.data.sendToPlaytest && output?.output) { + if ( + node.data.sendToPlaytest && + output?.output && + !data.fromPlaytest + ) { // note for later. output is a property from the output node and that is where it is defined editor.context.sendToPlaytest(output?.output as string) } From c12c2b93bf3f41fb661efbe2e09105c7664c7b5e Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 17 Sep 2023 21:04:19 -0700 Subject: [PATCH 026/349] Move watch spell check to inside agent constructor --- .../core/shared/src/spellManager/SpellManager.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/core/shared/src/spellManager/SpellManager.ts b/packages/core/shared/src/spellManager/SpellManager.ts index 6fd1446a43..d27944391a 100644 --- a/packages/core/shared/src/spellManager/SpellManager.ts +++ b/packages/core/shared/src/spellManager/SpellManager.ts @@ -45,13 +45,12 @@ export default class SpellManager { this.agent = agent // this will keep the spells in sync with the server - if (watchSpells) { - this.app.service('spells').on('updated', (spell: SpellInterface) => { - if (this.hasSpellRunner(spell.id)) { - this.updateSpell(spell) - } - }) - } + this.app.service('spells').on('updated', (spell: SpellInterface) => { + if (!watchSpells) return + if (this.hasSpellRunner(spell.id)) { + this.updateSpell(spell) + } + }) } getReadySpellRunner(spellId: string) { From b8c5e8f357a3a9f62c75626a98f0d3d8e261ed9a Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 18 Sep 2023 10:39:39 -0700 Subject: [PATCH 027/349] Add new commandHub for Agents --- packages/agents/src/lib/CommandHub.ts | 129 ++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 packages/agents/src/lib/CommandHub.ts diff --git a/packages/agents/src/lib/CommandHub.ts b/packages/agents/src/lib/CommandHub.ts new file mode 100644 index 0000000000..64f4cd14fd --- /dev/null +++ b/packages/agents/src/lib/CommandHub.ts @@ -0,0 +1,129 @@ +import { type Worker } from '@magickml/server-core' +import Agent from './Agent' +import { AGENT_COMMAND_JOB } from '@magickml/core' + +interface CommandListener { + callback: (data: T) => void +} + +/** + * CommandHub class that handles incoming commands and publishes events to listeners. + */ +class CommandHub { + /** + * The agent instance. + */ + private agent: Agent + /** + * The event map that stores the listeners for each event type. + */ + private eventMap: { [key: string]: CommandListener[] } = {} + /** + * The worker instance. + */ + private worker: Worker + + /** + * Creates a new CommandHub instance. + * @param agent - The agent instance. + * @param worker - The worker instance. + */ + constructor(agent: Agent, worker: Worker) { + this.agent = agent + + // Generate queue name + const queueName = AGENT_COMMAND_JOB(this.agent.id) + + // Initialize the worker + this.worker = worker + // set the worker listenening to the queue + this.worker.initialize(queueName, this.handleIncomingCommand.bind(this)) + } + + /** + * Handles incoming commands and publishes events to listeners. + * @param job - The job data. + */ + private async handleIncomingCommand(job: any) { + const { commandId, eventType } = job.data + + if (!commandId) { + this.agent.error('Received command without a commandId') + // Log this to your error handling mechanism + return + } + + if (!this.validateEventType(eventType)) { + this.agent.error(`Invalid event type received: ${eventType}`) + // Log this to your error handling mechanism + return + } + this.publish(eventType, job.data) + } + + /** + * Validates the event type. + * @param eventType - The event type to validate. + * @returns True if the event type is valid, false otherwise. + */ + private validateEventType(eventType: string): boolean { + const parts = eventType.split(':') + return parts.length === 3 + } + + /** + * Registers a plugin with the given name and actions. + * @param pluginName - The name of the plugin. + * @param actions - An object containing the actions to register. + */ + registerPlugin( + pluginName: string, + actions: { [key: string]: (data: any) => void } + ) { + for (const action of Object.keys(actions)) { + const eventType = `plugin:${pluginName}:${action}` + this.on(eventType, { callback: actions[action] }) + } + } + + /** + * Adds a listener for the given event type. + * @param eventType - The event type to listen for. + * @param listener - The listener to add. + */ + on(eventType: string, listener: CommandListener) { + if (!this.eventMap[eventType]) { + this.eventMap[eventType] = [] + } + this.eventMap[eventType].push(listener) + } + + /** + * Removes a listener for the given event type. + * @param eventType - The event type to remove the listener from. + * @param listener - The listener to remove. + */ + off(eventType: string, listener: CommandListener) { + const listeners = this.eventMap[eventType] + if (listeners) { + const index = listeners.indexOf(listener) + if (index > -1) { + listeners.splice(index, 1) + } + } + } + + /** + * Publishes an event to all listeners for the given event type. + * @param eventType - The event type to publish. + * @param data - The data to publish. + */ + private publish(eventType: string, data: any) { + const listeners = this.eventMap[eventType] + if (listeners) { + listeners.forEach(listener => listener.callback(data)) + } + } +} + +export { CommandHub, CommandListener, Agent } From 65973d379a138c577d28cb9a4dc318f1d7223052 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 18 Sep 2023 10:40:22 -0700 Subject: [PATCH 028/349] Remove project window --- .../components/Drawer/Newsidebar/index.tsx | 22 +++++-------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/packages/core/client/src/components/Drawer/Newsidebar/index.tsx b/packages/core/client/src/components/Drawer/Newsidebar/index.tsx index 44904a4e28..8388d55b1c 100644 --- a/packages/core/client/src/components/Drawer/Newsidebar/index.tsx +++ b/packages/core/client/src/components/Drawer/Newsidebar/index.tsx @@ -13,12 +13,7 @@ import ListItemText from '@mui/material/ListItemText' import { CSSObject, Theme, styled } from '@mui/material/styles' import { useEffect, useState } from 'react' import { useLocation, useNavigate } from 'react-router-dom' -import { - ProjectWindowProvider, - useProjectWindow, -} from '../../../contexts/ProjectWindowContext' import { useTreeData } from '../../../contexts/TreeDataProvider' -import ProjectWindow from '../ProjectWindow' import { SetAPIKeys } from '../SetAPIKeys' import { Tooltip, Typography } from '@mui/material' import { drawerTooltipText } from '../tooltiptext' @@ -65,10 +60,7 @@ const closedMixin = (theme: Theme): CSSObject => ({ duration: theme.transitions.duration.leavingScreen, }), overflowX: 'hidden', - width: `calc(${theme.spacing(3)} + 1px)`, - [theme.breakpoints.up('sm')]: { - width: `calc(${theme.spacing(5)} + 1px)`, - }, + width: '0px' }) // DrawerHeader component properties @@ -115,6 +107,7 @@ const StyledDrawer = styled(MuiDrawer, { }), })) + // DrawerItem component properties type DrawerItemProps = { Icon: React.ElementType @@ -222,9 +215,8 @@ type DrawerProps = { export function NewSidebar(DrawerProps): JSX.Element { const location = useLocation() const navigate = useNavigate() - const { openProjectWindow, openDrawer, setOpenDrawer, setOpenProjectWindow } = - useProjectWindow() const [isAPIKeysSet, setAPIKeysSet] = useState(false) + const [openDrawer, setOpenDrawer] = useState(true) // State to keep track of the anchor element of the menu and cursor position const [menuAnchorEl, setMenuAnchorEl] = useState(null) const [cursorPosition, setCursorPosition] = useState({ x: 0, y: 0 }) @@ -349,8 +341,7 @@ export function NewSidebar(DrawerProps): JSX.Element { useEffect(() => { const handleKeyDown = (event: KeyboardEvent) => { if (event.key.toLowerCase() === 'b' && event.ctrlKey) { - setOpenProjectWindow(prevState => !prevState) - setOpenDrawer(false) + setOpenDrawer(openDrawer => !openDrawer) } } @@ -548,15 +539,12 @@ export function NewSidebar(DrawerProps): JSX.Element { - {openProjectWindow && } ) } export const DrawerProvider = ({ children }: DrawerProps) => { return ( - - {children} - + {children} ) } From 9f3b1a3c58c41029a8775311271f6866150a4fc8 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 18 Sep 2023 10:41:02 -0700 Subject: [PATCH 029/349] Add agent command job type --- packages/core/shared/src/communication/agentJobTypes.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/core/shared/src/communication/agentJobTypes.ts b/packages/core/shared/src/communication/agentJobTypes.ts index dced93bd68..2c1e48ba2f 100644 --- a/packages/core/shared/src/communication/agentJobTypes.ts +++ b/packages/core/shared/src/communication/agentJobTypes.ts @@ -1,8 +1,9 @@ export const AGENT_RUN_JOB = (id: string) => `agent:run:${id}` +export const AGENT_COMMAND_JOB = (id: string) => `agent:command:${id}` export const AGENT_UPDATE_JOB = (id: string) => `agent:update:${id}` export const AGENT_DELETE_JOB = (id: string) => `agent:delete:${id}` export interface CreateAgentJob { - jobId: string - agentId: string + jobId: string + agentId: string } From a6b77374f77b9f4a658581e79f1efb8392f09e6f Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 18 Sep 2023 10:41:32 -0700 Subject: [PATCH 030/349] Only print data that came from playtest --- packages/core/shared/src/plugins/remotePlugin/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/shared/src/plugins/remotePlugin/index.ts b/packages/core/shared/src/plugins/remotePlugin/index.ts index 774ec12ba1..3712fa8830 100644 --- a/packages/core/shared/src/plugins/remotePlugin/index.ts +++ b/packages/core/shared/src/plugins/remotePlugin/index.ts @@ -91,7 +91,7 @@ function install( if ( node.data.sendToPlaytest && output?.output && - !data.fromPlaytest + data.fromPlaytest ) { // note for later. output is a property from the output node and that is where it is defined editor.context.sendToPlaytest(output?.output as string) From 3ad8087214b3efd769adbcec6bf3c143fc5af5d0 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 18 Sep 2023 10:41:48 -0700 Subject: [PATCH 031/349] Add agent command hub into agent --- packages/agents/src/lib/Agent.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/agents/src/lib/Agent.ts b/packages/agents/src/lib/Agent.ts index 2f148ff3f8..26f702628f 100644 --- a/packages/agents/src/lib/Agent.ts +++ b/packages/agents/src/lib/Agent.ts @@ -25,6 +25,7 @@ import { Application, } from '@magickml/server-core' import { AgentEvents, EventMetadata } from 'server/event-tracker' +import { CommandHub } from './CommandHub' /** * The Agent class that implements AgentInterface. @@ -46,6 +47,7 @@ export class Agent implements AgentInterface { pubsub: PubSub ready = false app: Application + commandHub: CommandHub outputTypes: any[] = [] updateInterval: any @@ -76,6 +78,8 @@ export class Agent implements AgentInterface { this.messageQueue = new BullQueue() this.messageQueue.initialize(AGENT_RUN_JOB(this.id)) + this.commandHub = new CommandHub(this, this.worker) + this.pubsub = pubsub const spellManager = new SpellManager({ From c9eb8a0a346ebf4718aec09963b81d684d2af482 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 18 Sep 2023 13:58:26 -0700 Subject: [PATCH 032/349] better exports in command hub --- packages/agents/src/lib/CommandHub.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/agents/src/lib/CommandHub.ts b/packages/agents/src/lib/CommandHub.ts index 64f4cd14fd..f98deea9d0 100644 --- a/packages/agents/src/lib/CommandHub.ts +++ b/packages/agents/src/lib/CommandHub.ts @@ -2,14 +2,14 @@ import { type Worker } from '@magickml/server-core' import Agent from './Agent' import { AGENT_COMMAND_JOB } from '@magickml/core' -interface CommandListener { +export interface CommandListener { callback: (data: T) => void } /** * CommandHub class that handles incoming commands and publishes events to listeners. */ -class CommandHub { +export class CommandHub { /** * The agent instance. */ @@ -125,5 +125,3 @@ class CommandHub { } } } - -export { CommandHub, CommandListener, Agent } From f007ab8241090e26cf78b475fc667f9ceddfab4d Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 18 Sep 2023 13:59:45 -0700 Subject: [PATCH 033/349] Helper function to list all events on an agent --- packages/core/shared/src/spellManager/SpellManager.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/core/shared/src/spellManager/SpellManager.ts b/packages/core/shared/src/spellManager/SpellManager.ts index d27944391a..548fbed13c 100644 --- a/packages/core/shared/src/spellManager/SpellManager.ts +++ b/packages/core/shared/src/spellManager/SpellManager.ts @@ -53,6 +53,17 @@ export default class SpellManager { }) } + onDestroy() { + this.clear() + + if (this.socket) { + this.socket.disconnect() + } + + // + // this.app.service('spells').removeListener('updated') + } + getReadySpellRunner(spellId: string) { return this.spellRunnerMap.get(spellId)?.find(runner => !runner.isBusy()) } From c5e90f7b95da951e1702a21ff371b3e7598a2890 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 18 Sep 2023 14:32:44 -0700 Subject: [PATCH 034/349] Add registerDomain function to commandHub --- packages/agents/src/lib/CommandHub.ts | 28 ++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/packages/agents/src/lib/CommandHub.ts b/packages/agents/src/lib/CommandHub.ts index f98deea9d0..fa8c26693d 100644 --- a/packages/agents/src/lib/CommandHub.ts +++ b/packages/agents/src/lib/CommandHub.ts @@ -71,6 +71,14 @@ export class CommandHub { return parts.length === 3 } + /** + * Returns an array of all the event names registered in the eventMap object. + * @returns {string[]} An array of all the event names registered in the eventMap object. + */ + listAllEvents() { + return Object.keys(this.eventMap) + } + /** * Registers a plugin with the given name and actions. * @param pluginName - The name of the plugin. @@ -80,9 +88,23 @@ export class CommandHub { pluginName: string, actions: { [key: string]: (data: any) => void } ) { - for (const action of Object.keys(actions)) { - const eventType = `plugin:${pluginName}:${action}` - this.on(eventType, { callback: actions[action] }) + this.registerDomain('plugin', pluginName, actions) + } + + /** + * Registers a list of commands for the given domain and subdomain. + * @param domain - The domain to register the commands for. + * @param subdomain - The subdomain to register the commands for. + * @param commands - An object containing the commands to register. + */ + registerDomain( + domain: string, + subdomain: string, + commands: { [key: string]: (data: any) => void } + ) { + for (const command of Object.keys(commands)) { + const eventType = `${domain}:${subdomain}:${command}` + this.on(eventType, { callback: commands[command] }) } } From 942c93c7f715b452e36a9c889c478d2dd9345f9d Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 18 Sep 2023 14:33:07 -0700 Subject: [PATCH 035/349] Refactor agent initialize plugins and add core commands --- packages/agents/src/lib/Agent.ts | 100 ++++++++++++++++++------------- 1 file changed, 60 insertions(+), 40 deletions(-) diff --git a/packages/agents/src/lib/Agent.ts b/packages/agents/src/lib/Agent.ts index 26f702628f..68e2a63c71 100644 --- a/packages/agents/src/lib/Agent.ts +++ b/packages/agents/src/lib/Agent.ts @@ -44,10 +44,10 @@ export class Agent implements AgentInterface { logger: pino.Logger = getLogger() worker: Worker messageQueue: MessageQueue + commandHub: CommandHub pubsub: PubSub ready = false app: Application - commandHub: CommandHub outputTypes: any[] = [] updateInterval: any @@ -77,54 +77,22 @@ export class Agent implements AgentInterface { this.messageQueue = new BullQueue() this.messageQueue.initialize(AGENT_RUN_JOB(this.id)) + this.pubsub = pubsub this.commandHub = new CommandHub(this, this.worker) - this.pubsub = pubsub - - const spellManager = new SpellManager({ + this.spellManager = new SpellManager({ cache: false, agent: this, app, }) - - this.spellManager = spellManager ;(async () => { - if (!agentData.rootSpellId) { - this.logger.warn('No root spell found for agent: %o', { - id: this.id, - name: this.name, - }) - return - } - const spell = ( - await app.service('spells').find({ - query: { - projectId: agentData.projectId, - id: agentData.rootSpellId, - }, - }) - ).data[0] - - this.spellRunner = await spellManager.load(spell) - - const agentStartMethods = pluginManager.getAgentStartMethods() - - // Runs the agent start methods that were loaded from plugins - for (const method of Object.keys(agentStartMethods)) { - try { - await agentStartMethods[method]({ - agentManager, - agent: this, - spellRunner: this.spellRunner, - }) - } catch (err) { - this.error('Error in agent start method', { method, err }) - } - } + // initialize the plugins + await this.initializePlugins() - const outputTypes = pluginManager.getOutputTypes() - this.outputTypes = outputTypes + // initialize the core commands + // These are used to remotely control the agent + this.initializeCoreCommands() this.logger.info('New agent created: %s | %s', this.name, this.id) this.ready = true @@ -144,6 +112,58 @@ export class Agent implements AgentInterface { this.rootSpellId = data.rootSpellId as string this.logger.info('Updated agent: %s | %s', this.name, this.id) } + /* + * Initializes the plugins for the Agent. + * If no root spell is found, logs a warning and returns. + * Loads the root spell and sets the spellRunner. + * Runs the agent start methods that were loaded from plugins. + * Sets the outputTypes for the Agent. + */ + private async initializePlugins() { + if (!this.data.rootSpellId) { + this.logger.warn('No root spell found for agent: %o', { + id: this.id, + name: this.name, + }) + return + } + const spell = ( + await app.service('spells').find({ + query: { + projectId: this.data.projectId, + id: this.data.rootSpellId, + }, + }) + ).data[0] + + this.spellRunner = await this.spellManager.load(spell) + + const agentStartMethods = pluginManager.getAgentStartMethods() + + // Runs the agent start methods that were loaded from plugins + for (const method of Object.keys(agentStartMethods)) { + try { + await agentStartMethods[method]({ + agentManager: this.agentManager, + agent: this, + spellRunner: this.spellRunner, + }) + } catch (err) { + this.error('Error in agent start method', { method, err }) + } + } + + const outputTypes = pluginManager.getOutputTypes() + this.outputTypes = outputTypes + } + + private initializeCoreCommands() { + this.commandHub.registerDomain('agent', 'core', { + toggleLive: async (data: any) => { + this.spellManager.toggleLive() + }, + }) + } /** * Clean up resources when the instance is destroyed. From d6743d494ae25252da223bd95ed036c9f36f2c15 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 18 Sep 2023 14:33:51 -0700 Subject: [PATCH 036/349] Add comments to spell manager --- .../shared/src/spellManager/SpellManager.ts | 88 +++++++++++++++++-- 1 file changed, 80 insertions(+), 8 deletions(-) diff --git a/packages/core/shared/src/spellManager/SpellManager.ts b/packages/core/shared/src/spellManager/SpellManager.ts index 548fbed13c..4448ec443e 100644 --- a/packages/core/shared/src/spellManager/SpellManager.ts +++ b/packages/core/shared/src/spellManager/SpellManager.ts @@ -23,55 +23,112 @@ type RunArgs = { app: Application } +/** + * SpellManager class manages the spells and their runners. + */ export default class SpellManager { + /** + * Map of spell runners for each spell id. + */ spellRunnerMap: Map = new Map() + + /** + * Socket instance for communication. + */ socket?: io.Socket + + /** + * Flag to enable/disable caching. + */ cache: boolean + + /** + * Application instance. + */ app: Application + + /** + * Agent instance. + */ agent?: any + + /** + * Flag to enable/disable watching spells. + */ + watchSpells = false + + /** + * Logger instance. + */ logger = getLogger() + /** + * Creates an instance of SpellManager. + * @param {SpellManagerArgs} args - Arguments for SpellManager. + */ constructor({ socket = undefined, cache = false, agent = undefined, app, - // ensures that the spells are kept in sync with the server watchSpells = false, }: SpellManagerArgs) { this.socket = socket this.app = app this.cache = cache this.agent = agent + this.watchSpells = watchSpells // this will keep the spells in sync with the server this.app.service('spells').on('updated', (spell: SpellInterface) => { - if (!watchSpells) return + if (!this.watchSpells) return if (this.hasSpellRunner(spell.id)) { this.updateSpell(spell) } }) } + /** + * Cleans up the SpellManager instance. + */ onDestroy() { this.clear() if (this.socket) { this.socket.disconnect() } - // // this.app.service('spells').removeListener('updated') } - getReadySpellRunner(spellId: string) { + /** + * Returns a ready spell runner for the given spell id. + * @param {string} spellId - Id of the spell. + * @returns {SpellRunner | undefined} - Ready spell runner instance. + */ + getReadySpellRunner(spellId: string): SpellRunner | undefined { return this.spellRunnerMap.get(spellId)?.find(runner => !runner.isBusy()) } - hasSpellRunner(spellId: string) { + /** + * Toggles the watchSpells flag. + */ + toggleLive() { + this.watchSpells = !this.watchSpells + } + + /** + * Checks if the spell runner exists for the given spell id. + * @param {string} spellId - Id of the spell. + * @returns {boolean} - True if spell runner exists, false otherwise. + */ + hasSpellRunner(spellId: string): boolean { return this.spellRunnerMap.has(spellId) } + /** + * Clears the spell runner map. + */ clear() { this.spellRunnerMap = new Map() } @@ -105,7 +162,12 @@ export default class SpellManager { } } - async load(spell: SpellInterface) { + /** + * Loads the spell runner for the given spell. + * @param {SpellInterface} spell - Spell instance. + * @returns {Promise} - Promise that resolves with the loaded spell runner instance or undefined if there was an error. + */ + async load(spell: SpellInterface): Promise { if (!spell) { this.agent?.error('No spell provided') console.error('No spell provided') @@ -131,7 +193,12 @@ export default class SpellManager { return spellRunner } - async updateSpell(spell: SpellInterface) { + /** + * Updates the spell runner for the given spell. + * @param {SpellInterface} spell - Spell instance. + * @returns {Promise} - Promise that resolves when the spell runner is updated. + */ + async updateSpell(spell: SpellInterface): Promise { const spellRunner = this.getReadySpellRunner(spell.id) if (!spellRunner) { @@ -150,7 +217,12 @@ export default class SpellManager { } } - async run(runArgs: RunArgs) { + /** + * Runs the spell with the given arguments. + * @param {RunArgs} runArgs - Arguments for running the spell. + * @returns {Promise>} - Promise that resolves with the result of running the spell. + */ + async run(runArgs: RunArgs): Promise> { this.logger.error( `You should use the agent commander to run spells instead of the spellManager run function` ) From 1048e6132e325c0c9147344d62ee0c45f388abfe Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 18 Sep 2023 15:52:25 -0700 Subject: [PATCH 037/349] Add command method to agent commander --- packages/agents/src/lib/AgentCommander.ts | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/packages/agents/src/lib/AgentCommander.ts b/packages/agents/src/lib/AgentCommander.ts index 34be9fc219..e8917126bd 100644 --- a/packages/agents/src/lib/AgentCommander.ts +++ b/packages/agents/src/lib/AgentCommander.ts @@ -7,6 +7,7 @@ import { AGENT_RUN_RESULT, AGENT_DELETE, getLogger, + AGENT_COMMAND_JOB, } from '@magickml/core' import type { MagickSpellInput } from '@magickml/core' import { v4 as uuidv4 } from 'uuid' @@ -30,6 +31,12 @@ export type RunRootSpellArgs = { isPlaytest?: boolean } +export interface AgentCommandData { + agentId: string + command: string + data: Record +} + interface AgentCommanderArgs { pubSub: PubSub } @@ -168,6 +175,23 @@ export class AgentCommander extends EventEmitter { return jobId } + async command(args: AgentCommandData) { + const { agentId, command, data } = args + if (!agentId) throw new Error('agentId is required') + + const jobId = uuidv4() + await this.pubSub.publish( + AGENT_COMMAND_JOB(agentId), + JSON.stringify({ + jobId, + agentId, + command, + data, + }) + ) + return jobId + } + async removeAgent(agentId: string) { this.pubSub.emit(AGENT_DELETE, agentId) } From c069368b4a7d7d3cf870fe7794f1db9a7498c8bd Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 18 Sep 2023 15:53:26 -0700 Subject: [PATCH 038/349] Add command method to agent commander --- .../server/src/services/agents/agents.class.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/core/server/src/services/agents/agents.class.ts b/packages/core/server/src/services/agents/agents.class.ts index 801cda4b83..f2e3b70551 100644 --- a/packages/core/server/src/services/agents/agents.class.ts +++ b/packages/core/server/src/services/agents/agents.class.ts @@ -7,8 +7,7 @@ import { app } from '@magickml/server-core' import md5 from 'md5' import type { Application } from '../../declarations' import type { Agent, AgentData, AgentPatch, AgentQuery } from './agents.schema' -import { Queue } from 'bullmq' -import { RunRootSpellArgs } from '@magickml/agents' +import { AgentCommandData, RunRootSpellArgs } from '@magickml/agents' // Define AgentParams type based on KnexAdapterParams with AgentQuery export type AgentParams = KnexAdapterParams @@ -50,6 +49,18 @@ export class AgentService< return { data: query } } + /** + * Executes a command on the agent. + * @param data - The data required to execute the command. + * @returns An object containing the response from the agent. + */ + async command(data: AgentCommandData) { + const agentCommander = this.app.get('agentCommander') + const response = await agentCommander.command(data) + + return { response } + } + async run(data: Omit) { if (!data.agentId) throw new Error('agentId is required') // probably need to authenticate the request here against project id From 04e1da34e9878961e5a7a55a4c0cd3bd975df63d Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 18 Sep 2023 15:53:53 -0700 Subject: [PATCH 039/349] Register command method with agent service --- packages/core/server/src/services/agents/agents.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/core/server/src/services/agents/agents.ts b/packages/core/server/src/services/agents/agents.ts index 0bebe7443a..1fc2fa2f44 100644 --- a/packages/core/server/src/services/agents/agents.ts +++ b/packages/core/server/src/services/agents/agents.ts @@ -49,7 +49,7 @@ function removeUnwantedProperties(obj: any, keysToRemove: string[]): any { return result } -const AGENT_EVENTS = ['log', 'result', 'spell', 'run'] +const AGENT_EVENTS = ['log', 'result', 'spell', 'run', 'command'] /** * Configure the agent service by registering it, its hooks, and its options. @@ -65,6 +65,7 @@ export const agent = (app: Application) => { 'patch', 'remove', 'run', + 'command', 'ping', 'subscribe', ], From 588273c29c3810b39973602ce3dcfb8556873099 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 18 Sep 2023 15:59:04 -0700 Subject: [PATCH 040/349] Add command method to feathers client, and missing spell event --- packages/core/client/src/providers/FeathersProvider.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/client/src/providers/FeathersProvider.tsx b/packages/core/client/src/providers/FeathersProvider.tsx index b5f7d9d494..d4eef16582 100644 --- a/packages/core/client/src/providers/FeathersProvider.tsx +++ b/packages/core/client/src/providers/FeathersProvider.tsx @@ -54,8 +54,8 @@ const configureCustomServices = ( }) app.use('agents', socketClient.service('agents'), { - methods: ['find', 'get', 'create', 'patch', 'remove', 'log', 'run', 'subscribe'], - events: ['log', 'result'], + methods: ['find', 'get', 'create', 'patch', 'remove', 'log', 'run', 'subscribe', 'command'], + events: ['log', 'result', 'spell'], }) app.use('request', socketClient.service('request'), { methods: ['find', 'get', 'create', 'patch', 'remove'], From d0ae6479a7696613ddb865c902bc756f3f38c84e Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 19 Sep 2023 16:02:24 -0700 Subject: [PATCH 041/349] passpubsub into command hub on agent --- packages/agents/src/lib/Agent.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/agents/src/lib/Agent.ts b/packages/agents/src/lib/Agent.ts index 68e2a63c71..f826ead4cb 100644 --- a/packages/agents/src/lib/Agent.ts +++ b/packages/agents/src/lib/Agent.ts @@ -79,7 +79,7 @@ export class Agent implements AgentInterface { this.messageQueue.initialize(AGENT_RUN_JOB(this.id)) this.pubsub = pubsub - this.commandHub = new CommandHub(this, this.worker) + this.commandHub = new CommandHub(this, this.pubsub) this.spellManager = new SpellManager({ cache: false, @@ -157,10 +157,17 @@ export class Agent implements AgentInterface { this.outputTypes = outputTypes } + /** + * Initializes the core commands for the agent. + * Registers the 'toggleLive' command with the command hub. + * + * @returns void + */ + private initializeCoreCommands() { this.commandHub.registerDomain('agent', 'core', { toggleLive: async (data: any) => { - this.spellManager.toggleLive() + this.spellManager.toggleLive(data) }, }) } From 1f6fbd58adea6b1d3ba0ecf0a671e35c3dc67346 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 19 Sep 2023 16:02:37 -0700 Subject: [PATCH 042/349] Add command method to agent commander --- packages/agents/src/lib/AgentCommander.ts | 29 +++++++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/packages/agents/src/lib/AgentCommander.ts b/packages/agents/src/lib/AgentCommander.ts index e8917126bd..9b41fd81fa 100644 --- a/packages/agents/src/lib/AgentCommander.ts +++ b/packages/agents/src/lib/AgentCommander.ts @@ -7,7 +7,8 @@ import { AGENT_RUN_RESULT, AGENT_DELETE, getLogger, - AGENT_COMMAND_JOB, + AGENT_COMMAND, + AGENT_COMMAND_PROJECT, } from '@magickml/core' import type { MagickSpellInput } from '@magickml/core' import { v4 as uuidv4 } from 'uuid' @@ -32,7 +33,8 @@ export type RunRootSpellArgs = { } export interface AgentCommandData { - agentId: string + agentId?: string + projectId?: string command: string data: Record } @@ -175,13 +177,30 @@ export class AgentCommander extends EventEmitter { return jobId } + /** + * Sends a command to an agent or project for execution. + * @param args - An object containing the agent ID, project ID, command, and data. + * @returns A unique job ID for the command. + * @throws An error if agentId or projectId is missing. + */ async command(args: AgentCommandData) { - const { agentId, command, data } = args - if (!agentId) throw new Error('agentId is required') + const { agentId, command, data, projectId } = args + + const event = agentId + ? AGENT_COMMAND(agentId) + : projectId + ? AGENT_COMMAND_PROJECT(projectId) + : null + + if (!event) throw new Error('Agent ID or project ID is required') + + this.logger.debug( + 'AgentCommander sending event ${event} to agent ${agentId}' + ) const jobId = uuidv4() await this.pubSub.publish( - AGENT_COMMAND_JOB(agentId), + event, JSON.stringify({ jobId, agentId, From cb2e8d846139917a103ade3e6b125b758a655a18 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 19 Sep 2023 16:04:10 -0700 Subject: [PATCH 043/349] Use pubsub inside command hub instead of worker --- packages/agents/src/lib/CommandHub.ts | 49 ++++++++++++++++----------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/packages/agents/src/lib/CommandHub.ts b/packages/agents/src/lib/CommandHub.ts index fa8c26693d..7868deabc1 100644 --- a/packages/agents/src/lib/CommandHub.ts +++ b/packages/agents/src/lib/CommandHub.ts @@ -1,6 +1,6 @@ -import { type Worker } from '@magickml/server-core' +import { type PubSub } from '@magickml/server-core' import Agent from './Agent' -import { AGENT_COMMAND_JOB } from '@magickml/core' +import { AGENT_COMMAND, AGENT_COMMAND_PROJECT } from '@magickml/core' export interface CommandListener { callback: (data: T) => void @@ -21,44 +21,55 @@ export class CommandHub { /** * The worker instance. */ - private worker: Worker + private pubsub: PubSub /** * Creates a new CommandHub instance. * @param agent - The agent instance. * @param worker - The worker instance. */ - constructor(agent: Agent, worker: Worker) { + constructor(agent: Agent, pubsub: PubSub) { this.agent = agent // Generate queue name - const queueName = AGENT_COMMAND_JOB(this.agent.id) + const agentCommandEventName = AGENT_COMMAND(this.agent.id) + const agentProjectEvent = AGENT_COMMAND_PROJECT(this.agent.projectId) // Initialize the worker - this.worker = worker - // set the worker listenening to the queue - this.worker.initialize(queueName, this.handleIncomingCommand.bind(this)) + this.pubsub = pubsub + + // Subscribe to the queue + this.pubsub.subscribe( + agentCommandEventName, + this.handleIncomingCommand.bind(this) + ) + + // Subscribe to the project queue so we can command all agents in a project + this.pubsub.subscribe( + agentProjectEvent, + this.handleIncomingCommand.bind(this) + ) } - /** - * Handles incoming commands and publishes events to listeners. + /**EventHandles incoming commands and publishes events to listeners. * @param job - The job data. */ private async handleIncomingCommand(job: any) { - const { commandId, eventType } = job.data + this.agent.log(`Received command: ${job.command}`) + const { command } = job - if (!commandId) { - this.agent.error('Received command without a commandId') - // Log this to your error handling mechanism - return - } + // if (!commandId) { + // this.agent.error('Received command without a commandId') + // // Log this to your error handling mechanism + // return + // } - if (!this.validateEventType(eventType)) { - this.agent.error(`Invalid event type received: ${eventType}`) + if (!this.validateEventType(command)) { + this.agent.error(`Invalid event type received: ${command}`) // Log this to your error handling mechanism return } - this.publish(eventType, job.data) + this.publish(command, job.data) } /** From 13c57ed6e20eafa187112360f9bfbe11a1316dc0 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 19 Sep 2023 16:04:26 -0700 Subject: [PATCH 044/349] Add default data to agent log functions --- packages/agents/src/lib/Agent.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/agents/src/lib/Agent.ts b/packages/agents/src/lib/Agent.ts index f826ead4cb..68d7108437 100644 --- a/packages/agents/src/lib/Agent.ts +++ b/packages/agents/src/lib/Agent.ts @@ -218,7 +218,7 @@ export class Agent implements AgentInterface { } // sends a log event along the event stream - log(message, data) { + log(message, data = {}) { this.logger.info(`${message} ${JSON.stringify(data)}`) this.publishEvent(AGENT_LOG(this.id), { agentId: this.id, @@ -229,7 +229,7 @@ export class Agent implements AgentInterface { }) } - warn(message, data) { + warn(message, data = {}) { this.logger.warn(`${message} ${JSON.stringify(data)}`) this.publishEvent(AGENT_LOG(this.id), { agentId: this.id, From a73020c207a4898e6bb303718f54baccc869208f Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 19 Sep 2023 16:05:08 -0700 Subject: [PATCH 045/349] Toggle live spells on and off in agent subscribe function --- .../src/services/agents/agents.class.ts | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/packages/core/server/src/services/agents/agents.class.ts b/packages/core/server/src/services/agents/agents.class.ts index f2e3b70551..15477756ef 100644 --- a/packages/core/server/src/services/agents/agents.class.ts +++ b/packages/core/server/src/services/agents/agents.class.ts @@ -84,14 +84,36 @@ export class AgentService< if (!connection) throw new Error('connection is required') const oldAgentChannel = app.channels.filter(channel => - agentId.match(/agent:/) + channel.match(/agent:/) )[0] - // leave the old channel - app.channel(oldAgentChannel).leave(connection) + + if (oldAgentChannel) { + const oldAgentId = oldAgentChannel.split(':')[1] + // leave the old channel + app.channel(oldAgentChannel).leave(connection) + + // turn off the old agent + this.command({ + agentId: oldAgentId, + command: 'agent:core:toggleLive', + data: { + live: false, + }, + }) + } // join the new channel app.channel(`agent:${agentId}`).join(connection) + // turn on the new agent + this.command({ + agentId, + command: 'agent:core:toggleLive', + data: { + live: true, + }, + }) + return true } From f29d17ace1b1c9b39e8a8454e2e1793e22031bce Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 19 Sep 2023 16:05:47 -0700 Subject: [PATCH 046/349] move agent command events into agent events file --- packages/core/shared/src/communication/agentEventTypes.ts | 3 +++ packages/core/shared/src/communication/agentJobTypes.ts | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/core/shared/src/communication/agentEventTypes.ts b/packages/core/shared/src/communication/agentEventTypes.ts index 0f0ae8aea5..f0ac9fc753 100644 --- a/packages/core/shared/src/communication/agentEventTypes.ts +++ b/packages/core/shared/src/communication/agentEventTypes.ts @@ -5,4 +5,7 @@ export const AGENT_SPELL = (agentId: string) => `agent:${agentId}:spell` export const AGENT_LOG = (agentId: string) => `agent:${agentId}:log` export const AGENT_WARN = (agentId: string) => `agent:${agentId}:warn` export const AGENT_ERROR = (agentId: string) => `agent:${agentId}:error` +export const AGENT_COMMAND = (agentId: string) => `agent:${agentId}:command` +export const AGENT_COMMAND_PROJECT = (projectId: string) => + `agent:${projectId}:command` export const AGENT_DELETE = `agent:delete` diff --git a/packages/core/shared/src/communication/agentJobTypes.ts b/packages/core/shared/src/communication/agentJobTypes.ts index 2c1e48ba2f..7effe62a05 100644 --- a/packages/core/shared/src/communication/agentJobTypes.ts +++ b/packages/core/shared/src/communication/agentJobTypes.ts @@ -1,5 +1,4 @@ export const AGENT_RUN_JOB = (id: string) => `agent:run:${id}` -export const AGENT_COMMAND_JOB = (id: string) => `agent:command:${id}` export const AGENT_UPDATE_JOB = (id: string) => `agent:update:${id}` export const AGENT_DELETE_JOB = (id: string) => `agent:delete:${id}` From bbb17fe35ce5bb676c88c997fd776d1226c9f91d Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 19 Sep 2023 16:07:00 -0700 Subject: [PATCH 047/349] Add toggle live to spellManager --- .../shared/src/spellManager/SpellManager.ts | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/packages/core/shared/src/spellManager/SpellManager.ts b/packages/core/shared/src/spellManager/SpellManager.ts index 4448ec443e..1231eecaf4 100644 --- a/packages/core/shared/src/spellManager/SpellManager.ts +++ b/packages/core/shared/src/spellManager/SpellManager.ts @@ -80,12 +80,15 @@ export default class SpellManager { this.watchSpells = watchSpells // this will keep the spells in sync with the server - this.app.service('spells').on('updated', (spell: SpellInterface) => { - if (!this.watchSpells) return - if (this.hasSpellRunner(spell.id)) { - this.updateSpell(spell) - } - }) + this.app.service('spells').on('updated', this.watchSpellHandler.bind(this)) + } + + watchSpellHandler(spell: SpellInterface) { + if (!this.watchSpells) return + if (this.hasSpellRunner(spell.id)) { + this.logger.debug(`Updating spell ${spell.id} in agent ${this.agent.id}`) + this.updateSpell(spell) + } } /** @@ -98,7 +101,7 @@ export default class SpellManager { this.socket.disconnect() } // - // this.app.service('spells').removeListener('updated') + this.app.service('spells').removeListener('updated', this.watchSpellHandler) } /** @@ -113,8 +116,10 @@ export default class SpellManager { /** * Toggles the watchSpells flag. */ - toggleLive() { - this.watchSpells = !this.watchSpells + toggleLive(data) { + this.agent.log(`Toggling watchSpells to ${data.isLive}`) + const { isLive } = data + this.watchSpells = isLive ? isLive : !this.watchSpells } /** From e6d7caed950a66c71879c2cf0ad86c62e1e3fe39 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 19 Sep 2023 16:13:12 -0700 Subject: [PATCH 048/349] Fix string literal --- packages/agents/src/lib/AgentCommander.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/agents/src/lib/AgentCommander.ts b/packages/agents/src/lib/AgentCommander.ts index 9b41fd81fa..bd6f7b611b 100644 --- a/packages/agents/src/lib/AgentCommander.ts +++ b/packages/agents/src/lib/AgentCommander.ts @@ -195,7 +195,7 @@ export class AgentCommander extends EventEmitter { if (!event) throw new Error('Agent ID or project ID is required') this.logger.debug( - 'AgentCommander sending event ${event} to agent ${agentId}' + `AgentCommander sending event ${event} to agent ${agentId}` ) const jobId = uuidv4() From aef55ae385a4fb2042759dad6cc4307a8df9f7fc Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 19 Sep 2023 16:13:22 -0700 Subject: [PATCH 049/349] Rip out old spellRunner --- packages/core/server/src/client.ts | 106 +++++++++++++------ packages/core/server/src/services/index.ts | 2 - packages/editor/src/components/Workspace.tsx | 14 --- 3 files changed, 76 insertions(+), 46 deletions(-) diff --git a/packages/core/server/src/client.ts b/packages/core/server/src/client.ts index 2b8ea823be..0726db1276 100644 --- a/packages/core/server/src/client.ts +++ b/packages/core/server/src/client.ts @@ -1,52 +1,91 @@ -// DOCUMENTED +// DOCUMENTED /** * For more information about this file see https://dove.feathersjs.com/guides/cli/client.html */ // Importing required modules and types -import { feathers } from '@feathersjs/feathers'; -import type { TransportConnection, Params } from '@feathersjs/feathers'; -import type { SpellRunnerService } from './services/spell-runner/spell-runner'; +import { feathers } from '@feathersjs/feathers' +import type { TransportConnection, Params } from '@feathersjs/feathers' // Defining spell runner service methods -export const spellRunnerServiceMethods = ['get', 'create', 'update'] as const; +export const spellRunnerServiceMethods = ['get', 'create', 'update'] as const // Importing Spell related types -import type { SpellData, SpellQuery, SpellService } from './services/spells/spells'; +import type { + SpellData, + SpellQuery, + SpellService, +} from './services/spells/spells' // Exporting Spell related types -export type { SpellData, SpellQuery }; +export type { SpellData, SpellQuery } // Defining spell service methods -export const spellServiceMethods = ['find', 'get', 'create', 'patch', 'remove'] as const; -export type SpellClientService = Pick>, typeof spellServiceMethods[number]>; +export const spellServiceMethods = [ + 'find', + 'get', + 'create', + 'patch', + 'remove', +] as const +export type SpellClientService = Pick< + SpellService>, + (typeof spellServiceMethods)[number] +> // Importing Agent related types -import type { Agent, AgentData, AgentQuery, AgentService } from './services/agents/agents'; +import type { + Agent, + AgentData, + AgentQuery, + AgentService, +} from './services/agents/agents' // Exporting Agent related types -export type { Agent, AgentData, AgentQuery }; +export type { Agent, AgentData, AgentQuery } // Defining agent service methods -export const agentServiceMethods = ['find', 'get', 'create', 'patch', 'remove'] as const; -export type AgentClientService = Pick>, typeof agentServiceMethods[number]>; +export const agentServiceMethods = [ + 'find', + 'get', + 'create', + 'patch', + 'remove', +] as const +export type AgentClientService = Pick< + AgentService>, + (typeof agentServiceMethods)[number] +> // Importing Request related types -import type { Request, RequestData, RequestQuery, RequestService } from './services/requests/requests'; +import type { + Request, + RequestData, + RequestQuery, + RequestService, +} from './services/requests/requests' // Exporting Request related types -export type { Request, RequestData, RequestQuery }; +export type { Request, RequestData, RequestQuery } // Defining request service methods -export const requestServiceMethods = ['find', 'get', 'create', 'patch', 'remove'] as const; -export type RequestClientService = Pick>, typeof requestServiceMethods[number]>; +export const requestServiceMethods = [ + 'find', + 'get', + 'create', + 'patch', + 'remove', +] as const +export type RequestClientService = Pick< + RequestService>, + (typeof requestServiceMethods)[number] +> // Defining the ServiceTypes interface export interface ServiceTypes { - request: RequestClientService; - 'spell-runner': SpellRunnerService; - spells: SpellClientService; - agents: AgentClientService; + request: RequestClientService + spells: SpellClientService + agents: AgentClientService } /** @@ -56,19 +95,26 @@ export interface ServiceTypes { * @see https://dove.feathersjs.com/api/client.html * @returns The Feathers client application */ -export const createClient = (connection: TransportConnection) => { +export const createClient = ( + connection: TransportConnection +) => { // Create a new Feathers client - const client = feathers(); + const client = feathers() // Configure the client with the connection - client.configure(connection); + client.configure(connection) // Registering the services - client.use('agents', connection.service('agents'), { methods: agentServiceMethods }); - client.use('spells', connection.service('spells'), { methods: spellServiceMethods }); - client.use('spell-runner', connection.service('spell-runner'), { methods: spellRunnerServiceMethods }); - client.use('request', connection.service('request'), { methods: requestServiceMethods }); + client.use('agents', connection.service('agents'), { + methods: agentServiceMethods, + }) + client.use('spells', connection.service('spells'), { + methods: spellServiceMethods, + }) + client.use('request', connection.service('request'), { + methods: requestServiceMethods, + }) // Return the configured client - return client; -}; \ No newline at end of file + return client +} diff --git a/packages/core/server/src/services/index.ts b/packages/core/server/src/services/index.ts index 390a8e5082..40213f8055 100644 --- a/packages/core/server/src/services/index.ts +++ b/packages/core/server/src/services/index.ts @@ -6,7 +6,6 @@ import { event } from './events/events' import { task } from './tasks/tasks' import { document } from './documents/documents' import { projects } from './projects/projects' -import { spellRunner } from './spell-runner/spell-runner' import { agentImage } from './agentImage/agentImage' // For more information about this file see https://dove.feathersjs.com/guides/cli/application.html#configure-functions @@ -27,7 +26,6 @@ export const services = async (app: Application): Promise => { app.configure(event) app.configure(task) app.configure(document) - app.configure(spellRunner) app.configure(projects) app.configure(agentImage) diff --git a/packages/editor/src/components/Workspace.tsx b/packages/editor/src/components/Workspace.tsx index d1b765b085..8823868b5b 100644 --- a/packages/editor/src/components/Workspace.tsx +++ b/packages/editor/src/components/Workspace.tsx @@ -89,20 +89,6 @@ const Workspace = ({ tab, tabs, pubSub }) => { }) }, [tab]) - useEffect(() => { - if (!client) return - ; (async () => { - if (!client || !tab || !tab.name) return - - // make sure to pass the projectId to the service call - await client.service('spell-runner').get(tab.id, { - query: { - projectId: config.projectId, - }, - }) - })() - }, [client]) - const factory = tab => { return node => { const props = { From 92d8c733f6b5c66317a1ac953af691387e68ec9c Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 19 Sep 2023 16:29:11 -0700 Subject: [PATCH 050/349] Fix logging to the playtest --- packages/agents/src/lib/Agent.ts | 2 -- .../core/shared/src/plugins/remotePlugin/index.ts | 11 ++++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/agents/src/lib/Agent.ts b/packages/agents/src/lib/Agent.ts index 68d7108437..454afaecc6 100644 --- a/packages/agents/src/lib/Agent.ts +++ b/packages/agents/src/lib/Agent.ts @@ -302,7 +302,6 @@ export class Agent implements AgentInterface { agentId: this.id, projectId: this.projectId, originalData: data, - fromPlaytest: data.isPlaytest, result: output, }) } catch (err) { @@ -318,7 +317,6 @@ export class Agent implements AgentInterface { agentId: this.id, projectId: this.projectId, originalData: data, - fromPlaytest: data.isPlaytest, result: { error: err instanceof Error ? err.message : 'Error running agent', }, diff --git a/packages/core/shared/src/plugins/remotePlugin/index.ts b/packages/core/shared/src/plugins/remotePlugin/index.ts index 3712fa8830..af175fd47c 100644 --- a/packages/core/shared/src/plugins/remotePlugin/index.ts +++ b/packages/core/shared/src/plugins/remotePlugin/index.ts @@ -88,11 +88,8 @@ function install( // todo might need to not hardcode the output to "output" // could be more elegant - if ( - node.data.sendToPlaytest && - output?.output && - data.fromPlaytest - ) { + // also make sure the data originated from the playtest before showing in playtest. + if (node.data.sendToPlaytest && output?.output && data.isPlaytest) { // note for later. output is a property from the output node and that is where it is defined editor.context.sendToPlaytest(output?.output as string) } @@ -143,6 +140,8 @@ function install( ) => { // this is the shared event type for the relayed connection. const eventType = `${context.currentSpell.id}-${node.id}` + // get the current spell from the editor + const isPlaytest = context.module.isPlaytest if (server) { try { @@ -166,6 +165,7 @@ function install( name: node.data.name, output: result, input: inputs, + isPlaytest, }) return result @@ -179,6 +179,7 @@ function install( name: node.data.name, outputType: node.data.outputType || null, sessionId: context.module.sessionId || null, + isPlaytest, error: { message: err.message, stack: err.stack, From 61e5afe3dc271e2b443399644efd14fe4e18cd4b Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 20 Sep 2023 20:46:09 -0700 Subject: [PATCH 051/349] Add env override for show navbar --- packages/config/src/config.ts | 1 + packages/editor/src/components/MenuBar/MenuBar.tsx | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/config/src/config.ts b/packages/config/src/config.ts index caeb909150..ae0df870ae 100644 --- a/packages/config/src/config.ts +++ b/packages/config/src/config.ts @@ -137,6 +137,7 @@ export const AWS_BUCKET_ENDPOINT = export const FEATURE_FLAGS = { // Enable the new editor SHOW_SIDEBAR: getVarForEnvironment('SHOW_SIDEBAR') === 'true' || false, + SHOW_NAVBAR: getVarForEnvironment('SHOW_NAVBAR') === 'true' || false, } export const HEARTBEAT_MSEC = diff --git a/packages/editor/src/components/MenuBar/MenuBar.tsx b/packages/editor/src/components/MenuBar/MenuBar.tsx index e20cdb6323..0627ae177a 100644 --- a/packages/editor/src/components/MenuBar/MenuBar.tsx +++ b/packages/editor/src/components/MenuBar/MenuBar.tsx @@ -2,6 +2,7 @@ import { useFeatureFlagEnabled } from 'posthog-js/react' import OldMenuBar from './OldMenuBar' import NewMenuBar from './newMenuBar' +import { FEATURE_FLAGS } from '@magickml/config' /** * MenuBar component @@ -11,7 +12,7 @@ import NewMenuBar from './newMenuBar' const MenuBar = () => { const showNavBarFlag = useFeatureFlagEnabled('ide-new-sidebar') - return <>{showNavBarFlag ? : } + return <>{showNavBarFlag || FEATURE_FLAGS.SHOW_NAVBAR ? : } } export default MenuBar From 21487a02050162b5dfcaa70bf8bfc5df52e39211 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 20 Sep 2023 20:46:21 -0700 Subject: [PATCH 052/349] Add create agent control pubsub event --- packages/core/client/src/providers/PubSubProvider.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/core/client/src/providers/PubSubProvider.tsx b/packages/core/client/src/providers/PubSubProvider.tsx index 53c7f5afc7..3f313120cf 100644 --- a/packages/core/client/src/providers/PubSubProvider.tsx +++ b/packages/core/client/src/providers/PubSubProvider.tsx @@ -39,6 +39,7 @@ export const events: PubSubEvents = { $CREATE_MESSAGE_REACTION_EDITOR: tabId => `createMessageReactionEditor:${tabId}`, $CREATE_PLAYTEST: tabId => `createPlaytest:${tabId}`, + $CREATE_AGENT_CONTROLS: tabId => `createAgentControls:${tabId}`, $CREATE_INSPECTOR: tabId => `createInspector:${tabId}`, $CREATE_TEXT_EDITOR: tabId => `createTextEditor:${tabId}`, // $CREATE_PROJECT_WINDOW: tabId => `createProjectWindow:${tabId}`, From a9b9d850b9b0ba515df702b252227b7ae1951ec3 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 20 Sep 2023 20:46:36 -0700 Subject: [PATCH 053/349] Add agent control window type --- packages/core/shared/src/types.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/core/shared/src/types.ts b/packages/core/shared/src/types.ts index 39d932f391..56099961d7 100644 --- a/packages/core/shared/src/types.ts +++ b/packages/core/shared/src/types.ts @@ -242,6 +242,7 @@ export type PubSubEvents = { $CREATE_PLAYTEST: (tabId: string) => string $CREATE_INSPECTOR: (tabId: string) => string $CREATE_TEXT_EDITOR: (tabId: string) => string + $CREATE_AGENT_CONTROLS: (tabId: string) => string $CREATE_DEBUG_CONSOLE: (tabId: string) => string $CREATE_CONSOLE: (tabId: string) => string $RUN_SPELL: (tabId?: string) => string From 1b78dd0641e706c5a6d1e3d826e812c8051f092e Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 20 Sep 2023 20:46:47 -0700 Subject: [PATCH 054/349] Add handler for create agent control window --- packages/editor/src/components/EventHandler.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/editor/src/components/EventHandler.tsx b/packages/editor/src/components/EventHandler.tsx index 16ef6c0407..9f6eabdf7c 100644 --- a/packages/editor/src/components/EventHandler.tsx +++ b/packages/editor/src/components/EventHandler.tsx @@ -103,6 +103,7 @@ const EventHandler = ({ pubSub, tab }) => { $CREATE_INSPECTOR, $CREATE_CONSOLE, $CREATE_TEXT_EDITOR, + $CREATE_AGENT_CONTROLS, $EXPORT, $CLOSE_EDITOR, $PROCESS, @@ -210,6 +211,13 @@ const EventHandler = ({ pubSub, tab }) => { createOrFocus(windowTypes.PLAYTEST, 'Playtest') } + /** + * Create a new agent controls window or focus on the existing one + */ + const createAgentControls = () => { + createOrFocus(windowTypes.AGENT_CONTROLS, 'Agent Controls') + } + /** * Create a new inspector window or focus on the existing one */ @@ -347,6 +355,7 @@ const EventHandler = ({ pubSub, tab }) => { [$CREATE_PLAYTEST(tab.id)]: createPlaytest, [$CREATE_INSPECTOR(tab.id)]: createInspector, [$CREATE_TEXT_EDITOR(tab.id)]: createTextEditor, + [$CREATE_AGENT_CONTROLS(tab.id)]: createAgentControls, [$CREATE_CONSOLE(tab.id)]: createConsole, [$EXPORT(tab.id)]: onExport, [$CLOSE_EDITOR(tab.id)]: onCloseEditor, From c289adb50cd81dedf38e4c8d9621c58eb02afc8d Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 20 Sep 2023 20:47:11 -0700 Subject: [PATCH 055/349] Add menu item for agent controls --- .../components/MenuBar/newMenuBar/index.tsx | 46 +++++++++++-------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/packages/editor/src/components/MenuBar/newMenuBar/index.tsx b/packages/editor/src/components/MenuBar/newMenuBar/index.tsx index b364b6d957..ce6ded0f34 100644 --- a/packages/editor/src/components/MenuBar/newMenuBar/index.tsx +++ b/packages/editor/src/components/MenuBar/newMenuBar/index.tsx @@ -47,6 +47,7 @@ const NewMenuBar = () => { $CREATE_PLAYTEST, $CREATE_INSPECTOR, $CREATE_TEXT_EDITOR, + $CREATE_AGENT_CONTROLS, $CREATE_CONSOLE, $EXPORT, $UNDO, @@ -123,6 +124,13 @@ const NewMenuBar = () => { publish($CREATE_INSPECTOR(activeTabRef.current.id)) } + /** + * Agent control creation handler + */ + const onAgentControlCreate = () => { + if (!activeTabRef.current) return + publish($CREATE_AGENT_CONTROLS(activeTabRef.current.id)) + } /** * Text editor creation handler */ @@ -309,9 +317,9 @@ const NewMenuBar = () => { onClick: onConsole, hotKey: 'alt+4, control+4', }, - project_window: { - onClick: onProjectWindowCreate, - hotKey: 'alt+5, control+5', + agent_controls: { + onClick: onAgentControlCreate, + hotKey: 'alt+6, control+6', }, snap: { onClick: toggleSnapFunction, @@ -328,22 +336,22 @@ const NewMenuBar = () => { }, }, }, - layout: { - items: { - default: { - onClick: changeLayout, - }, - full_screen: { - onClick: changeLayout, - }, - prompt_engineering: { - onClick: changeLayout, - }, - trouble_shooting: { - onClick: changeLayout, - }, - }, - }, + // layout: { + // items: { + // default: { + // onClick: changeLayout, + // }, + // full_screen: { + // onClick: changeLayout, + // }, + // prompt_engineering: { + // onClick: changeLayout, + // }, + // trouble_shooting: { + // onClick: changeLayout, + // }, + // }, + // }, } /** From dbc82f8b9d8f2c3e2740e94aa200229a8b83aeab Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 20 Sep 2023 20:47:27 -0700 Subject: [PATCH 056/349] add agent control window to layout and workspace --- packages/editor/src/components/Workspace.tsx | 4 ++++ packages/editor/src/contexts/LayoutProvider.tsx | 2 ++ 2 files changed, 6 insertions(+) diff --git a/packages/editor/src/components/Workspace.tsx b/packages/editor/src/components/Workspace.tsx index 8823868b5b..194d0141d8 100644 --- a/packages/editor/src/components/Workspace.tsx +++ b/packages/editor/src/components/Workspace.tsx @@ -17,6 +17,7 @@ import Playtest from '../windows/PlaytestWindow' import DebugConsole from '../windows/DebugConsole' import TextEditor from '../windows/TextEditorWindow' import { RootState, spellApi } from '@magickml/state' +import AgentControls from '../windows/AgentControlWindow' /** * Workspace component that handles different tabs and their layouts. @@ -107,6 +108,9 @@ const Workspace = ({ tab, tabs, pubSub }) => { return case 'debugConsole': return + case 'agentControls': + console.log("AGENT CONTORLS") + return default: return

} diff --git a/packages/editor/src/contexts/LayoutProvider.tsx b/packages/editor/src/contexts/LayoutProvider.tsx index a5ec227bc5..cca6dae68c 100644 --- a/packages/editor/src/contexts/LayoutProvider.tsx +++ b/packages/editor/src/contexts/LayoutProvider.tsx @@ -20,6 +20,7 @@ const windowTypes: WindowTypes = { PLAYTEST: 'playtest', CONSOLE: 'debugConsole', PROJECT: 'project', + AGENT_CONTROLS: 'agentControls', } type WindowType = @@ -30,6 +31,7 @@ type WindowType = | 'debugConsole' | 'settings' | 'project' + | 'agentControls' type WindowTypes = Record From d61725e305645bd56f31879144cc951a6e139c5f Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 21 Sep 2023 14:43:12 -0700 Subject: [PATCH 057/349] Add loop shared package --- packages/plugins/loop/shared/.babelrc | 10 ++++++ packages/plugins/loop/shared/.eslintrc.json | 33 +++++++++++++++++++ packages/plugins/loop/shared/jest.config.ts | 17 ++++++++++ packages/plugins/loop/shared/package.json | 4 +++ packages/plugins/loop/shared/project.json | 25 ++++++++++++++ packages/plugins/loop/shared/tsconfig.json | 30 +++++++++++++++++ .../plugins/loop/shared/tsconfig.lib.json | 14 ++++++++ .../plugins/loop/shared/tsconfig.spec.json | 19 +++++++++++ 8 files changed, 152 insertions(+) create mode 100644 packages/plugins/loop/shared/.babelrc create mode 100644 packages/plugins/loop/shared/.eslintrc.json create mode 100644 packages/plugins/loop/shared/jest.config.ts create mode 100644 packages/plugins/loop/shared/package.json create mode 100644 packages/plugins/loop/shared/project.json create mode 100644 packages/plugins/loop/shared/tsconfig.json create mode 100644 packages/plugins/loop/shared/tsconfig.lib.json create mode 100644 packages/plugins/loop/shared/tsconfig.spec.json diff --git a/packages/plugins/loop/shared/.babelrc b/packages/plugins/loop/shared/.babelrc new file mode 100644 index 0000000000..b63f0528f9 --- /dev/null +++ b/packages/plugins/loop/shared/.babelrc @@ -0,0 +1,10 @@ +{ + "presets": [ + [ + "@nrwl/js/babel", + { + "useBuiltIns": "usage" + } + ] + ] +} diff --git a/packages/plugins/loop/shared/.eslintrc.json b/packages/plugins/loop/shared/.eslintrc.json new file mode 100644 index 0000000000..359ff63d51 --- /dev/null +++ b/packages/plugins/loop/shared/.eslintrc.json @@ -0,0 +1,33 @@ +{ + "extends": [ + "../../../../.eslintrc.json" + ], + "ignorePatterns": [ + "!**/*" + ], + "overrides": [ + { + "files": [ + "*.ts", + "*.tsx", + "*.js", + "*.jsx" + ], + "rules": {} + }, + { + "files": [ + "*.ts", + "*.tsx" + ], + "rules": {} + }, + { + "files": [ + "*.js", + "*.jsx" + ], + "rules": {} + } + ] +} \ No newline at end of file diff --git a/packages/plugins/loop/shared/jest.config.ts b/packages/plugins/loop/shared/jest.config.ts new file mode 100644 index 0000000000..7deab1ea0b --- /dev/null +++ b/packages/plugins/loop/shared/jest.config.ts @@ -0,0 +1,17 @@ +/* eslint-disable */ +export default { + displayName: 'intent', + preset: '../../jest.preset.js', + globals: {}, + testEnvironment: 'node', + transform: { + '^.+\\.[tj]sx?$': [ + 'ts-jest', + { + tsconfig: '/tsconfig.spec.json', + }, + ], + }, + moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], + coverageDirectory: '../../../coverage/plugins/intent/shared', +} diff --git a/packages/plugins/loop/shared/package.json b/packages/plugins/loop/shared/package.json new file mode 100644 index 0000000000..6af38a3596 --- /dev/null +++ b/packages/plugins/loop/shared/package.json @@ -0,0 +1,4 @@ +{ + "name": "@magickml/plugin-loop-shared", + "version": "0.1.0" +} diff --git a/packages/plugins/loop/shared/project.json b/packages/plugins/loop/shared/project.json new file mode 100644 index 0000000000..83352226ad --- /dev/null +++ b/packages/plugins/loop/shared/project.json @@ -0,0 +1,25 @@ +{ + "name": "@magickml/plugin-loop-shared", + "$schema": "../../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "packages/plugins/loop/shared/src", + "projectType": "library", + "implicitDependencies": ["@magickml/core"], + "targets": { + "lint": { + "executor": "@nrwl/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["packages/plugins/loop/shared/**/*.ts"] + } + }, + "test": { + "executor": "@nrwl/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "jestConfig": "packages/plugins/loop/shared/jest.config.ts", + "passWithNoTests": true + } + } + }, + "tags": [] +} diff --git a/packages/plugins/loop/shared/tsconfig.json b/packages/plugins/loop/shared/tsconfig.json new file mode 100644 index 0000000000..f6e3aba4e9 --- /dev/null +++ b/packages/plugins/loop/shared/tsconfig.json @@ -0,0 +1,30 @@ +{ + "extends": "../../../../tsconfig.base.json", + "compilerOptions": { + "target": "ESNext", + "useDefineForClassFields": true, + "module": "ESNext", + "lib": [ + "ESNext", + "DOM", + "DOM.Iterable" + ], + "rootDir": "../../..", + "skipLibCheck": true, + "esModuleInterop": true, + "strict": true, + "moduleResolution": "Node", + "resolveJsonModule": true, + "isolatedModules": true, + "allowSyntheticDefaultImports": true, + "noEmit": true, + "jsx": "react-jsx", + "types": [ + "vite/client" + ] + }, + "files": [], + "include": [ + "src" + ] +} \ No newline at end of file diff --git a/packages/plugins/loop/shared/tsconfig.lib.json b/packages/plugins/loop/shared/tsconfig.lib.json new file mode 100644 index 0000000000..47de5908d1 --- /dev/null +++ b/packages/plugins/loop/shared/tsconfig.lib.json @@ -0,0 +1,14 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "jsx": "react-jsx", + "outDir": "../../dist/out-tsc", + "declaration": true, + "module": "esnext", + "types": ["node"], + "esModuleInterop": true, + + }, + "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"], + "include": ["src/**/*.ts"] +} diff --git a/packages/plugins/loop/shared/tsconfig.spec.json b/packages/plugins/loop/shared/tsconfig.spec.json new file mode 100644 index 0000000000..503e9a83de --- /dev/null +++ b/packages/plugins/loop/shared/tsconfig.spec.json @@ -0,0 +1,19 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "module": "commonjs", + "types": ["jest", "node"] + }, + "include": [ + "src/**/*.test.ts", + "src/**/*.spec.ts", + "src/**/*.test.tsx", + "src/**/*.spec.tsx", + "src/**/*.test.js", + "src/**/*.spec.js", + "src/**/*.test.jsx", + "src/**/*.spec.jsx", + "src/**/*.d.ts" + ] +} From e98a065e774122d18dfc473d4049f299a2939a47 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 21 Sep 2023 14:43:27 -0700 Subject: [PATCH 058/349] Pass agent into command hub callback --- packages/agents/src/lib/CommandHub.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/agents/src/lib/CommandHub.ts b/packages/agents/src/lib/CommandHub.ts index 7868deabc1..79aedc4757 100644 --- a/packages/agents/src/lib/CommandHub.ts +++ b/packages/agents/src/lib/CommandHub.ts @@ -3,7 +3,7 @@ import Agent from './Agent' import { AGENT_COMMAND, AGENT_COMMAND_PROJECT } from '@magickml/core' export interface CommandListener { - callback: (data: T) => void + callback: (data: T, agent: Agent) => void } /** @@ -154,7 +154,7 @@ export class CommandHub { private publish(eventType: string, data: any) { const listeners = this.eventMap[eventType] if (listeners) { - listeners.forEach(listener => listener.callback(data)) + listeners.forEach(listener => listener.callback(data, this.agent)) } } } From ea4e41d50793bd1e76b6646e4cd958bc8a92d1ca Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 21 Sep 2023 14:43:46 -0700 Subject: [PATCH 059/349] Add get agent commands to plugin managers --- packages/core/shared/src/plugin.ts | 41 ++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/packages/core/shared/src/plugin.ts b/packages/core/shared/src/plugin.ts index 072e659e17..7cfcdf8709 100644 --- a/packages/core/shared/src/plugin.ts +++ b/packages/core/shared/src/plugin.ts @@ -1,6 +1,7 @@ import { FC, LazyExoticComponent } from 'react' import { MagickComponentArray } from './engine' import { CompletionProvider, Route, SpellInterface } from './types' +import { Agent } from '@magickml/agents' export type PluginSecret = { name: string @@ -23,6 +24,20 @@ export type PluginClientRoute = { plugin: string } +export type Command = { + name: string + description: string + command: string + icon: string +} + +export type PluginClientCommandList = Record + +export type PluginServerCommandList = Record< + string, + (data: any, agent: Agent) => void +> + export type PluginServerRoute = Route export type PluginIOType = { @@ -40,6 +55,7 @@ type PluginConstuctor = { outputTypes?: PluginIOType[] secrets?: PluginSecret[] completionProviders?: CompletionProvider[] + agentCommands?: PluginServerCommandList } class Plugin { name: string @@ -72,6 +88,7 @@ export class ClientPlugin extends Plugin { clientPageLayout?: PageLayout clientRoutes?: Array spellTemplates?: SpellInterface[] + agentCommands?: PluginClientCommandList projectTemplates?: any[] constructor({ name, @@ -83,6 +100,7 @@ export class ClientPlugin extends Plugin { clientRoutes = [], drawerItems = [], secrets = [], + agentCommands = {}, completionProviders = [], spellTemplates = [], projectTemplates = [], @@ -117,6 +135,7 @@ export type ServerInits = Record export class ServerPlugin extends Plugin { services: ((app: any) => void)[] serverInit?: ServerInit + agentCommands?: PluginServerCommandList agentMethods?: { start: (args) => Promise | void stop: (args) => Promise | void @@ -137,6 +156,7 @@ export class ServerPlugin extends Plugin { /* null */ }, }, + agentCommands = {}, serverRoutes = [], secrets = [], completionProviders = [], @@ -274,6 +294,17 @@ export class ClientPluginManager extends PluginManager { return agentComp } + getAgentCommands() { + let commands: PluginClientCommandList = {} + + this.pluginList.forEach(plugin => { + if (plugin.agentCommands) { + commands = { ...commands, ...plugin.agentCommands } + } + }) + return commands + } + getSpellTemplates() { const spellTemplates = [] as SpellInterface[] ;(this.pluginList as ClientPlugin[]).forEach((plugin: ClientPlugin) => { @@ -436,6 +467,16 @@ export class ServerPluginManager extends PluginManager { return serviceList } + getAgentCommands() { + let commands = {} + + this.pluginList.forEach(plugin => { + if (plugin.agentCommands) { + commands = { ...commands, ...plugin.agentCommands } + } + }) + } + getServerInits() { let serverInits: ServerInits = {} this.pluginList.forEach((plugin: ServerPlugin) => { From 55e807fea0975c8c5fd19267cfe7b703357b8f22 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 21 Sep 2023 14:44:09 -0700 Subject: [PATCH 060/349] Add loop handler class for controlable loop --- .../plugins/loop/server/src/loopHandler.ts | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 packages/plugins/loop/server/src/loopHandler.ts diff --git a/packages/plugins/loop/server/src/loopHandler.ts b/packages/plugins/loop/server/src/loopHandler.ts new file mode 100644 index 0000000000..f361b32e32 --- /dev/null +++ b/packages/plugins/loop/server/src/loopHandler.ts @@ -0,0 +1,29 @@ +export class LoopHandler { + private interval: NodeJS.Timeout + private isPaused: boolean + private fn: Function + + constructor(fn: Function, delay: number) { + this.fn = fn + this.isPaused = false + this.interval = setInterval(async () => { + if (!this.isPaused) { + await this.fn() + } + }, delay) + } + + pause() { + this.isPaused = true + } + + resume() { + this.isPaused = false + } + + async step() { + if (this.isPaused) { + await this.fn() + } + } +} From 9d24b04119ec4e831531944cbb2bc424e4d8d57f Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 21 Sep 2023 14:44:24 -0700 Subject: [PATCH 061/349] More shared loop files --- packages/plugins/loop/shared/src/index.ts | 4 ++ packages/plugins/loop/shared/vite.config.ts | 73 +++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 packages/plugins/loop/shared/src/index.ts create mode 100644 packages/plugins/loop/shared/vite.config.ts diff --git a/packages/plugins/loop/shared/src/index.ts b/packages/plugins/loop/shared/src/index.ts new file mode 100644 index 0000000000..4e0eb67f8f --- /dev/null +++ b/packages/plugins/loop/shared/src/index.ts @@ -0,0 +1,4 @@ +// DOCUMENTED +/** + * Imports + */ diff --git a/packages/plugins/loop/shared/vite.config.ts b/packages/plugins/loop/shared/vite.config.ts new file mode 100644 index 0000000000..f87adc0d86 --- /dev/null +++ b/packages/plugins/loop/shared/vite.config.ts @@ -0,0 +1,73 @@ +import { defineConfig } from 'vite' + +import viteTsConfigPaths from 'vite-tsconfig-paths' +import dts from 'vite-plugin-dts' +import { join } from 'path' +import react from '@vitejs/plugin-react' +import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill' +import { NodeModulesPolyfillPlugin } from '@esbuild-plugins/node-modules-polyfill' +import rollupNodePolyFill from 'rollup-plugin-node-polyfills' +import mdPlugin, { Mode } from 'vite-plugin-markdown' + +export default defineConfig({ + cacheDir: '../../node_modules/.vite/plugin-intent', + assetsInclude: ['**/*.vrm', '**/*.svg'], + resolve: { + alias: { + stream: 'rollup-plugin-node-polyfills/polyfills/stream', + url: 'rollup-plugin-node-polyfills/polyfills/url', + querystring: 'rollup-plugin-node-polyfills/polyfills/qs', + }, + }, + plugins: [ + mdPlugin({ mode: [Mode.HTML, Mode.TOC, Mode.REACT] }), + dts({ + entryRoot: 'src', + tsConfigFilePath: join(__dirname, 'tsconfig.lib.json'), + skipDiagnostics: true, + }), + react(), + viteTsConfigPaths({ + root: '../../', + }), + ], + // Uncomment this if you are using workers. + // worker: { + // viteTsConfigPaths({ + // root: '../../', + // }), + // }, + optimizeDeps: { + esbuildOptions: { + // Node.js global to browser globalThis + define: { + global: 'globalThis', + }, + // Enable esbuild polyfill plugins + plugins: [ + NodeGlobalsPolyfillPlugin({ + process: false, + }), + NodeModulesPolyfillPlugin(), + ], + }, + }, + // Configuration for building your library. + // See: https://vitejs.dev/guide/build.html#library-mode + build: { + lib: { + // Could also be a dictionary or array of multiple entry points. + entry: 'src/index.ts', + name: 'plugin-intent-shared', + fileName: 'index', + // Change this to the formats you want to support. + // Don't forgot to update your package.json as well. + formats: ['es', 'cjs'], + }, + rollupOptions: { + plugins: [rollupNodePolyFill()], + // External packages that should not be bundled into your library. + external: ['react', 'react-dom', 'react/jsx-runtime'], + }, + }, +}) From 8c07d5972aef05b93d8937ba861c50483f924b35 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 21 Sep 2023 14:44:47 -0700 Subject: [PATCH 062/349] Add control methodasw to loop manager to use loop handler --- packages/plugins/loop/server/src/index.ts | 32 ++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/packages/plugins/loop/server/src/index.ts b/packages/plugins/loop/server/src/index.ts index c7ae913a01..730bf37eac 100644 --- a/packages/plugins/loop/server/src/index.ts +++ b/packages/plugins/loop/server/src/index.ts @@ -1,6 +1,7 @@ // DOCUMENTED import { eventSocket, ServerPlugin, triggerSocket } from '@magickml/core' import { app } from '@magickml/server-core' +import { LoopHandler } from './loopHandler' type StartLoopArgs = { agent: any agentManager: any @@ -11,6 +12,7 @@ type StartLoopArgs = { */ class LoopManager { agentManager: any + loopHandlers: Map // Store loop handlers /** * Constructs a new LoopManager. @@ -25,6 +27,7 @@ class LoopManager { this.agentManager.registerRemoveAgentHandler(({ agent }) => this.removeAgent({ agent }) ) + this.loopHandlers = new Map() } /** @@ -36,11 +39,13 @@ class LoopManager { if (!agentData) return console.log('No data for this agent', agent.id) if (!agentData.data?.loop_enabled) return console.log('Loop is not enabled for this agent') + const loopInterval = parseInt(agentData.data.loop_interval) * 1000 if (!loopInterval) { return console.error('Loop Interval must be a number greater than 0') } - const loopHandler = setInterval(async () => { + + const loopHandler = new LoopHandler(async () => { console.log('running loop handler') const resp = await app.get('agentCommander').runSpell({ inputs: { @@ -64,6 +69,9 @@ class LoopManager { }) console.log('output is', resp) }, loopInterval) + + this.loopHandlers.set(agent.id, loopHandler) + agent.loopHandler = loopHandler console.log('Added agent to loop', agent.id) } @@ -76,8 +84,30 @@ class LoopManager { const _agent = this.agentManager.getAgent({ agent }) if (!_agent || !agent.loopHandler) return clearInterval(agent.loopHandler) + this.loopHandlers.delete(agent.id) delete agent.loopHandler } + + startLoop(_, agentId) { + const loopHandler = this.loopHandlers.get(agentId) + if (loopHandler) { + loopHandler.resume() // Assumes loopHandler has a resume method + } + } + + stopLoop(_, agentId) { + const loopHandler = this.loopHandlers.get(agentId) + if (loopHandler) { + loopHandler.pause() // Assumes loopHandler has a pause method + } + } + + stepLoop(_, agentId) { + const loopHandler = this.loopHandlers.get(agentId) + if (loopHandler) { + loopHandler.step() // Assumes loopHandler has a step method + } + } } /** From de5b9a21b9d120de39228bde0ccb23d9bc71349c Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 21 Sep 2023 14:44:57 -0700 Subject: [PATCH 063/349] Add shared loop to root tsconfig --- tsconfig.base.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tsconfig.base.json b/tsconfig.base.json index 8cb04e7ceb..af3c9ff132 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -143,6 +143,9 @@ "@magickml/plugin-loop-server": [ "packages/plugins/loop/server/src/index.ts" ], + "@magickml/plugin-loop-shared": [ + "packages/plugins/loop/shared/src/index.ts" + ], "@magickml/plugin-openai-client": [ "packages/plugins/openai/client/src/index.ts" ], From 32fa3916bc21f0518a3d8191241f013dfd2f3979 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 22 Sep 2023 00:27:30 -0700 Subject: [PATCH 064/349] Add logging for regostering command event in command hub --- packages/agents/src/lib/CommandHub.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/agents/src/lib/CommandHub.ts b/packages/agents/src/lib/CommandHub.ts index 79aedc4757..2aa8798012 100644 --- a/packages/agents/src/lib/CommandHub.ts +++ b/packages/agents/src/lib/CommandHub.ts @@ -115,6 +115,7 @@ export class CommandHub { ) { for (const command of Object.keys(commands)) { const eventType = `${domain}:${subdomain}:${command}` + this.agent.log(`Registering event type: ${eventType}`) this.on(eventType, { callback: commands[command] }) } } From 75ca66adde9d10eb72ed0b6f70995f2a24b6137a Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 22 Sep 2023 00:27:47 -0700 Subject: [PATCH 065/349] Add commands to the loop plugin --- packages/plugins/loop/server/src/index.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/packages/plugins/loop/server/src/index.ts b/packages/plugins/loop/server/src/index.ts index 730bf37eac..a82708904f 100644 --- a/packages/plugins/loop/server/src/index.ts +++ b/packages/plugins/loop/server/src/index.ts @@ -2,6 +2,7 @@ import { eventSocket, ServerPlugin, triggerSocket } from '@magickml/core' import { app } from '@magickml/server-core' import { LoopHandler } from './loopHandler' +import { Agent } from '@magickml/agents' type StartLoopArgs = { agent: any agentManager: any @@ -142,10 +143,28 @@ const inputSockets = [ }, ] +type AgentWithLoop = Agent & { + loopHandler: LoopHandler +} + const LoopPlugin = new ServerPlugin({ name: 'LoopPlugin', agentMethods: getAgentMethods(), inputTypes: [{ name: 'Loop In', sockets: inputSockets }], + agentCommands: { + start: (data, agent) => { + ;(agent as AgentWithLoop).log('starting loop') + ;(agent as AgentWithLoop).loopHandler.resume() + }, + stop: (data, agent) => { + ;(agent as AgentWithLoop).log('stopping loop') + ;(agent as AgentWithLoop).loopHandler.pause() + }, + step: (data, agent) => { + ;(agent as AgentWithLoop).log('stepping through loop') + ;(agent as AgentWithLoop).loopHandler.step() + }, + }, }) export default LoopPlugin From 5f671cfbdc76ba78d956366dd69e01ff285f4e12 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 22 Sep 2023 00:28:04 -0700 Subject: [PATCH 066/349] Add console command to send commands to the agent --- .../editor/src/windows/DebugConsole/index.tsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/editor/src/windows/DebugConsole/index.tsx b/packages/editor/src/windows/DebugConsole/index.tsx index 56d9649bc4..8177ec8f55 100644 --- a/packages/editor/src/windows/DebugConsole/index.tsx +++ b/packages/editor/src/windows/DebugConsole/index.tsx @@ -4,6 +4,8 @@ import { useCallback, useEffect, useRef, useState } from 'react' import Terminal from 'react-console-emulator' import ReactJson from 'react-json-view' import { useEditor } from '../../contexts/EditorProvider' +import { useSelector } from 'react-redux' +import { RootState } from '@magickml/state' /** * The type for debug messages. @@ -29,6 +31,10 @@ const DebugConsole = ({ tab }): JSX.Element => { const { publish, subscribe, events } = usePubSub() const { $TRIGGER, $DEBUG_PRINT } = events + const { currentAgentId } = useSelector( + state => state.globalConfig + ) as any + const terminalRef = useRef() /** @@ -168,6 +174,18 @@ const DebugConsole = ({ tab }): JSX.Element => { usage: 'trigger ', fn: trigger, }, + command: { + description: 'Send a command to the agent', + usage: 'command ', + fn: function (command: string) { + publish(events.SEND_COMMAND, { + agentId: currentAgentId, + command, + }) + return `Sent agent command ${command} to agent ${currentAgentId}` + } + + } } return ( From 8b626761750de873c5890f74d955ee4a883cc712 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 22 Sep 2023 00:28:29 -0700 Subject: [PATCH 067/349] Add send command event type --- packages/core/shared/src/types.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/core/shared/src/types.ts b/packages/core/shared/src/types.ts index 56099961d7..889e3a7f57 100644 --- a/packages/core/shared/src/types.ts +++ b/packages/core/shared/src/types.ts @@ -225,6 +225,7 @@ export type PubSubEvents = { OPEN_TAB: string TOGGLE_SNAP: string RUN_AGENT: string + SEND_COMMAND: string $SUBSPELL_UPDATED: (spellName: string) => string $TRIGGER: (tabId: string, nodeId?: number) => string $PLAYTEST_INPUT: (tabId: string) => string From 5084f2fa506f34d1e9434014406436ef05b27596 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 22 Sep 2023 00:28:46 -0700 Subject: [PATCH 068/349] Fix server get agent commands function --- packages/core/shared/src/plugin.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/core/shared/src/plugin.ts b/packages/core/shared/src/plugin.ts index 7cfcdf8709..dd697a212f 100644 --- a/packages/core/shared/src/plugin.ts +++ b/packages/core/shared/src/plugin.ts @@ -31,11 +31,15 @@ export type Command = { icon: string } +export type ExtendableAgent = Agent & { + [key: string]: any +} + export type PluginClientCommandList = Record export type PluginServerCommandList = Record< string, - (data: any, agent: Agent) => void + (data: any, agent: ExtendableAgent) => void > export type PluginServerRoute = Route @@ -177,6 +181,7 @@ export class ServerPlugin extends Plugin { secrets, completionProviders, }) + this.agentCommands = agentCommands this.services = services this.nodes = nodes this.agentMethods = agentMethods @@ -468,13 +473,15 @@ export class ServerPluginManager extends PluginManager { } getAgentCommands() { - let commands = {} + const commands = {} this.pluginList.forEach(plugin => { if (plugin.agentCommands) { - commands = { ...commands, ...plugin.agentCommands } + commands[plugin.name] = plugin.agentCommands } }) + + return commands } getServerInits() { From 01eedd54927a6b4e30227f16cf0c28a3fcbb9f67 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 22 Sep 2023 00:29:04 -0700 Subject: [PATCH 069/349] Listen for command event in pubsub provider --- .../core/client/src/providers/PubSubProvider.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/core/client/src/providers/PubSubProvider.tsx b/packages/core/client/src/providers/PubSubProvider.tsx index 3f313120cf..44178e440f 100644 --- a/packages/core/client/src/providers/PubSubProvider.tsx +++ b/packages/core/client/src/providers/PubSubProvider.tsx @@ -23,6 +23,7 @@ export const events: PubSubEvents = { OPEN_TAB: 'openTab', TOGGLE_SNAP: 'toggleSnap', RUN_AGENT: 'runAgent', + SEND_COMMAND: 'sendCommand', $SUBSPELL_UPDATED: spellId => `subspellUpdated:${spellId}`, $TRIGGER: (tabId, nodeId) => `triggerNode:${tabId}:${nodeId ?? 'default'}`, $PLAYTEST_INPUT: tabId => `playtestInput:${tabId}`, @@ -82,12 +83,19 @@ export const PubSubProvider = ({ children }) => { if (!client) return // temporary subscription to run the agent - PubSub.subscribe(events.RUN_AGENT, (event, data) => { + const unsubscribeRun = subscribe(events.RUN_AGENT, (event, data) => { client.service('agents').run(data) }) + const unsubscribeCommand = subscribe(events.SEND_COMMAND, (event, data) => { + console.log("SENDING COMMAND DATA", data) + client.service('agents').command(data) + }) + + return () => { - PubSub.clearAllSubscriptions() + unsubscribeRun() + unsubscribeCommand() } }, [client]) From 4ad2a735ba5c7fb3661024874b9cce7074d9fb28 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 22 Sep 2023 00:29:19 -0700 Subject: [PATCH 070/349] Initialize commands on agent construction --- packages/agents/src/lib/Agent.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/agents/src/lib/Agent.ts b/packages/agents/src/lib/Agent.ts index 454afaecc6..5437c616e5 100644 --- a/packages/agents/src/lib/Agent.ts +++ b/packages/agents/src/lib/Agent.ts @@ -90,6 +90,9 @@ export class Agent implements AgentInterface { // initialize the plugins await this.initializePlugins() + // initialize the plugin commands + this.initializePluginCommands() + // initialize the core commands // These are used to remotely control the agent this.initializeCoreCommands() @@ -157,6 +160,14 @@ export class Agent implements AgentInterface { this.outputTypes = outputTypes } + private initializePluginCommands() { + this.log('Initializing plugin commands') + const pluginCommands = pluginManager.getAgentCommands() + for (const pluginName of Object.keys(pluginCommands)) { + this.commandHub.registerPlugin(pluginName, pluginCommands[pluginName]) + } + } + /** * Initializes the core commands for the agent. * Registers the 'toggleLive' command with the command hub. From acacef067b0d7ca03fcfc42a15846cab5dc30b47 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 22 Sep 2023 09:40:24 -0700 Subject: [PATCH 071/349] Make nodes pulse wqhen activated rather than remain on. --- .../src/plugins/consolePlugin/MagickConsole.ts | 4 ++++ packages/editor/src/components/Node/Node.module.css | 13 ++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/core/shared/src/plugins/consolePlugin/MagickConsole.ts b/packages/core/shared/src/plugins/consolePlugin/MagickConsole.ts index 66a470bea6..0cd490297c 100644 --- a/packages/core/shared/src/plugins/consolePlugin/MagickConsole.ts +++ b/packages/core/shared/src/plugins/consolePlugin/MagickConsole.ts @@ -96,6 +96,10 @@ export class MagickConsole { this.node.data.success = true this.updateNodeView() this.node.data.success = false + setTimeout(() => { + this.updateNodeView() + // todo we could make this timeout configurable + }, 500) } log(_message: unknown) { diff --git a/packages/editor/src/components/Node/Node.module.css b/packages/editor/src/components/Node/Node.module.css index d3ac97f975..22766fe4dd 100644 --- a/packages/editor/src/components/Node/Node.module.css +++ b/packages/editor/src/components/Node/Node.module.css @@ -9,8 +9,9 @@ } } .node { - animation: nodeGenesis 0.2s ease; - transition: background-color 0.05s ease; + animation: nodeGenesis 0.5s ease; + transition: background-color 0.05s ease, border 0.2s ease, + outline-color 0.2s ease; min-width: var(--c30); width: var(--c30); border-radius: var(--extraSmall); @@ -19,6 +20,7 @@ background-color: #0011168f; color: var(--glow); resize: both; + /* backdrop-filter: blur(3px); */ } .node:hover { @@ -36,8 +38,9 @@ /* backdrop-filter: blur(15px); */ } .node.success { - outline-color: var(--green) !important; - border: 2px solid var(--green); + outline-color: var(--glow) !important; + border: 2px solid var(--glow); + transition: border 0.2s ease, outline-color 0.2s ease; } .node-depricated { position: absolute; @@ -167,7 +170,7 @@ div.item { font-family: 'BerkeleyMono-Regular', 'IBM Plex Sans', 'IBM Plex Mono', sans-serif; - font-size: 1.2rem !important; + font-size: 1.2rem !important; } .socket-wrapper { From 4715dbf52370116838f40c0b1940ddb21ea317b3 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 22 Sep 2023 12:00:46 -0700 Subject: [PATCH 072/349] Add on destroy to loop handler --- packages/plugins/loop/server/src/loopHandler.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/plugins/loop/server/src/loopHandler.ts b/packages/plugins/loop/server/src/loopHandler.ts index f361b32e32..a004c83bbf 100644 --- a/packages/plugins/loop/server/src/loopHandler.ts +++ b/packages/plugins/loop/server/src/loopHandler.ts @@ -13,6 +13,10 @@ export class LoopHandler { }, delay) } + destroy() { + clearInterval(this.interval) + } + pause() { this.isPaused = true } From 000b7f43fc48550e7f9075c6e45e9a2cd0eb5cd1 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 22 Sep 2023 12:02:25 -0700 Subject: [PATCH 073/349] Handle destroying loop better --- packages/plugins/loop/server/src/index.ts | 28 +++++++++++++++-------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/packages/plugins/loop/server/src/index.ts b/packages/plugins/loop/server/src/index.ts index a82708904f..11a648b4c3 100644 --- a/packages/plugins/loop/server/src/index.ts +++ b/packages/plugins/loop/server/src/index.ts @@ -1,8 +1,14 @@ // DOCUMENTED -import { eventSocket, ServerPlugin, triggerSocket } from '@magickml/core' +import { + eventSocket, + getLogger, + ServerPlugin, + triggerSocket, +} from '@magickml/core' import { app } from '@magickml/server-core' import { LoopHandler } from './loopHandler' import { Agent } from '@magickml/agents' +import pino from 'pino' type StartLoopArgs = { agent: any agentManager: any @@ -14,19 +20,20 @@ type StartLoopArgs = { class LoopManager { agentManager: any loopHandlers: Map // Store loop handlers + logger: pino.Logger = getLogger() /** * Constructs a new LoopManager. * @param {any} agentManager - The agent manager to manage loops for. */ constructor(agentManager) { - console.log('new loop manager created') + this.logger.debug('Creating new LoopManager') this.agentManager = agentManager this.agentManager.registerAddAgentHandler(({ agent, agentData }) => this.addAgent({ agent, agentData }) ) - this.agentManager.registerRemoveAgentHandler(({ agent }) => - this.removeAgent({ agent }) + this.agentManager.registerRemoveAgentHandler(agent => + this.removeAgent(agent.id) ) this.loopHandlers = new Map() } @@ -81,12 +88,15 @@ class LoopManager { * Removes an agent from the loop manager. * @param {any} agent - Agent to remove. */ - removeAgent({ agent }) { - const _agent = this.agentManager.getAgent({ agent }) - if (!_agent || !agent.loopHandler) return - clearInterval(agent.loopHandler) + removeAgent(agentId) { + const agent = this.agentManager.getAgent(agentId) as AgentWithLoop + if (!agent || !agent.loopHandler) return + const loopHandler = this.loopHandlers.get(agent.id) + if (!loopHandler) return + loopHandler.destroy() this.loopHandlers.delete(agent.id) - delete agent.loopHandler + // @ts-ignore + delete agent?.loopHandler } startLoop(_, agentId) { From be6c7bb35ec0a224d137d40a4d4e09f2461bc07b Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 22 Sep 2023 12:03:02 -0700 Subject: [PATCH 074/349] Add reset highlights event --- packages/editor/src/components/EventHandler.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/editor/src/components/EventHandler.tsx b/packages/editor/src/components/EventHandler.tsx index 9f6eabdf7c..c0b43db60c 100644 --- a/packages/editor/src/components/EventHandler.tsx +++ b/packages/editor/src/components/EventHandler.tsx @@ -108,6 +108,7 @@ const EventHandler = ({ pubSub, tab }) => { $CLOSE_EDITOR, $PROCESS, $RUN_SPELL, + $RESET_HIGHLIGHTS } = events /** @@ -349,6 +350,11 @@ const EventHandler = ({ pubSub, tab }) => { const response = await client.service('agents').run(data) } + const resetHighlights = () => { + const editor = getEditor() as Record + editor.resetHighlights() + } + const handlerMap = { [$SAVE_SPELL(tab.id)]: saveSpell, [$CREATE_MESSAGE_REACTION_EDITOR(tab.id)]: createMessageReactionEditor, @@ -367,6 +373,7 @@ const EventHandler = ({ pubSub, tab }) => { [$PROCESS(tab.id)]: onProcess, [$SAVE_SPELL_DIFF(tab.id)]: onSaveDiff, [$RUN_SPELL(tab.id)]: runSpell, + [$RESET_HIGHLIGHTS(tab.id)]: resetHighlights, } useEffect(() => { From 9f9d68b2deeb10d26606fdd87515546a444f630a Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 22 Sep 2023 12:04:49 -0700 Subject: [PATCH 075/349] Add stuff for working with node highlighting from editor --- .../client/src/providers/PubSubProvider.tsx | 1 + .../plugins/consolePlugin/MagickConsole.ts | 13 +++-- .../shared/src/plugins/consolePlugin/index.ts | 4 +- .../shared/src/plugins/errorPlugin/index.ts | 53 ------------------- .../shared/src/plugins/remotePlugin/index.ts | 12 +++-- .../shared/src/plugins/socketPlugin/index.ts | 3 +- packages/core/shared/src/types.ts | 3 ++ packages/editor/src/editor.ts | 11 ++++ 8 files changed, 36 insertions(+), 64 deletions(-) delete mode 100644 packages/core/shared/src/plugins/errorPlugin/index.ts diff --git a/packages/core/client/src/providers/PubSubProvider.tsx b/packages/core/client/src/providers/PubSubProvider.tsx index 44178e440f..cae5442269 100644 --- a/packages/core/client/src/providers/PubSubProvider.tsx +++ b/packages/core/client/src/providers/PubSubProvider.tsx @@ -46,6 +46,7 @@ export const events: PubSubEvents = { // $CREATE_PROJECT_WINDOW: tabId => `createProjectWindow:${tabId}`, $CREATE_DEBUG_CONSOLE: tabId => `createDebugConsole:${tabId}`, $CREATE_CONSOLE: tabId => `createDebugConsole:${tabId}`, + $RESET_HIGHLIGHTS: tabId => `resetHighlights:${tabId}`, $RUN_SPELL: tabId => `runSpell:${tabId}`, $RUN_AGENT: tabId => `runAgent:${tabId}`, $PROCESS: tabId => `process:${tabId}`, diff --git a/packages/core/shared/src/plugins/consolePlugin/MagickConsole.ts b/packages/core/shared/src/plugins/consolePlugin/MagickConsole.ts index 0cd490297c..798cd915f7 100644 --- a/packages/core/shared/src/plugins/consolePlugin/MagickConsole.ts +++ b/packages/core/shared/src/plugins/consolePlugin/MagickConsole.ts @@ -1,10 +1,15 @@ import { NodeView } from '@magickml/rete' import { MagickComponent } from '../../engine' -import { IRunContextEditor, MagickNode, PubSubData } from '../../types' +import { + IRunContextEditor, + MagickEditor, + MagickNode, + PubSubData, +} from '../../types' type ConsoleConstructor = { component: MagickComponent - editor: IRunContextEditor + editor: MagickEditor node: MagickNode server: boolean throwError?: (error: unknown) => void @@ -33,7 +38,7 @@ function isOutputError(value: unknown): value is OutputError { } export class MagickConsole { node: MagickNode - editor: IRunContextEditor + editor: MagickEditor component: MagickComponent nodeView?: NodeView isServer: boolean @@ -67,8 +72,10 @@ export class MagickConsole { updateNodeView() { if (!this.nodeView) return + console.log('Updating node view in console', this.nodeView) this.nodeView.onStart() this.nodeView.node.update() + this.editor.isHighlighted = true } formatMessage(_message: string, type: 'error' | 'log'): Message { diff --git a/packages/core/shared/src/plugins/consolePlugin/index.ts b/packages/core/shared/src/plugins/consolePlugin/index.ts index 1311a8af69..124b104f34 100644 --- a/packages/core/shared/src/plugins/consolePlugin/index.ts +++ b/packages/core/shared/src/plugins/consolePlugin/index.ts @@ -5,7 +5,7 @@ */ import { MagickComponent } from '../../engine' -import { IRunContextEditor, MagickNode } from '../../types' +import { IRunContextEditor, MagickEditor, MagickNode } from '../../types' import { MagickConsole } from './MagickConsole' /** @@ -44,7 +44,7 @@ function install( node.console = new MagickConsole({ node: _node, component, - editor, + editor: editor as MagickEditor, server, throwError, }) diff --git a/packages/core/shared/src/plugins/errorPlugin/index.ts b/packages/core/shared/src/plugins/errorPlugin/index.ts deleted file mode 100644 index 8c43e379d7..0000000000 --- a/packages/core/shared/src/plugins/errorPlugin/index.ts +++ /dev/null @@ -1,53 +0,0 @@ -// DOCUMENTED -import { MagickComponent } from '../../engine'; -import { IRunContextEditor, MagickNode } from '../../types'; -import { MagickConsole } from '../consolePlugin/MagickConsole'; - -/** - * Installs the error plugin to the provided engine. - * @param {IRunContextEditor} engine - The engine to install the plugin for. - * @param {{ server?: boolean, throwError?: (error: unknown) => void }} options - Optional settings. - * @param {boolean} [options.server] - If true, the plugin is installed in server mode. - * @param {(error: unknown) => void} [options.throwError] - Error throwing function to use instead of the default. - */ -function install( - engine: IRunContextEditor, - { server = false, throwError }: { server?: boolean; throwError?: (error: unknown) => void } -): void { - engine.on( - 'error', - ({ message, data }: { message: string; data: MagickNode }) => { - // Obtain the component from the engine - const component = engine.components.get( - data.name as string - ) as unknown as MagickComponent; - - // If the component doesn't exist, return early - if (!component) return; - - // Create a new MagickConsole instance - const console = new MagickConsole({ - node: data, - component, - editor: engine, - server, - throwError, - isEngine: true, - }); - - // Handle recursion errors - if (message === 'Recursion detected') { - const error = new Error(`Recursion occurred in node ID ${data.id}`); - - console.error(error); - } - } - ); -} - -const defaultExport = { - name: 'errorPlugin', - install, -}; - -export default defaultExport; \ No newline at end of file diff --git a/packages/core/shared/src/plugins/remotePlugin/index.ts b/packages/core/shared/src/plugins/remotePlugin/index.ts index af175fd47c..65a17be350 100644 --- a/packages/core/shared/src/plugins/remotePlugin/index.ts +++ b/packages/core/shared/src/plugins/remotePlugin/index.ts @@ -2,6 +2,7 @@ import { MagickComponent } from '../../engine' import { IRunContextEditor, + MagickEditor, MagickNode, ModuleContext, SpellInterface, @@ -19,7 +20,7 @@ export interface RemoteIRunContextEditor extends IRunContextEditor { } function install( - editor: RemoteIRunContextEditor, + _editor: RemoteIRunContextEditor, // Need to better type the feathers client here { server = false, client, emit }: RemotePluginArgs ) { @@ -28,9 +29,10 @@ function install( if (!server) { // subscribe to the spell event on the client inside the components builder - editor.on( + _editor.on( 'componentregister', (component: MagickComponent>) => { + const editor = _editor as MagickEditor const builder = component.builder // overwrite the base builder with one which subscribes to the event. @@ -59,7 +61,7 @@ function install( node.console = new MagickConsole({ node: node as unknown as MagickNode, component, - editor, + editor: editor as MagickEditor, server, }) @@ -109,7 +111,7 @@ function install( ) // handle removing the subscription when the node is removed - editor.on('noderemoved', (node: MagickNode) => { + _editor.on('noderemoved', (node: MagickNode) => { // get the spell listener from the map const listener = subscriptionMap.get(node.id) @@ -126,7 +128,7 @@ function install( // if we are on the server, we want to emit the data to the client from the worker // the event is relayed through a channel matcher for the type of agent event and relayed. if (server && emit) { - editor.on( + _editor.on( 'componentregister', (component: MagickComponent>) => { const worker = component.worker diff --git a/packages/core/shared/src/plugins/socketPlugin/index.ts b/packages/core/shared/src/plugins/socketPlugin/index.ts index c0fed03c64..ce1faef492 100644 --- a/packages/core/shared/src/plugins/socketPlugin/index.ts +++ b/packages/core/shared/src/plugins/socketPlugin/index.ts @@ -4,6 +4,7 @@ import { MagickComponent } from '../../engine' import { IRunContextEditor, + MagickEditor, MagickNode, MagickWorkerInputs, ModuleContext, @@ -93,7 +94,7 @@ function install( node.console = new MagickConsole({ node: node as unknown as MagickNode, component, - editor, + editor: editor as MagickEditor, server, }) diff --git a/packages/core/shared/src/types.ts b/packages/core/shared/src/types.ts index 889e3a7f57..5d1c6e9eb6 100644 --- a/packages/core/shared/src/types.ts +++ b/packages/core/shared/src/types.ts @@ -152,8 +152,10 @@ export type ControlData = { export class MagickEditor extends NodeEditor { declare tabMap: Record + isHighlighted = false declare getTask: (nodeId: number) => Task declare getTasks: () => TaskStore + declare resetHighlights: () => void declare currentSpell: SpellInterface declare pubSub: PubSubContext declare context: EditorContext @@ -228,6 +230,7 @@ export type PubSubEvents = { SEND_COMMAND: string $SUBSPELL_UPDATED: (spellName: string) => string $TRIGGER: (tabId: string, nodeId?: number) => string + $RESET_HIGHLIGHTS: (tabId: string) => string $PLAYTEST_INPUT: (tabId: string) => string $PLAYTEST_PRINT: (tabId: string) => string $DEBUG_PRINT: (tabId: string) => string diff --git a/packages/editor/src/editor.ts b/packages/editor/src/editor.ts index 0422557124..9256fc3a57 100644 --- a/packages/editor/src/editor.ts +++ b/packages/editor/src/editor.ts @@ -241,5 +241,16 @@ export const initEditor = function ({ editor.view.resize() editor.currentSpell = spell } + + editor.resetHighlights = () => { + const nodeValues = Array.from(editor.view.nodes) + nodeValues.forEach(([, n]) => { + n.node.data.error = false + n.node.data.success = false + n.onStart() + n.node.update() + }) + editor.isHighlighted = false + } return editor } From eb38b6cc87bcd1ba6cb4a04d7f7bb7fa952a1fce Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 22 Sep 2023 12:05:09 -0700 Subject: [PATCH 076/349] Remove reference to error plugin --- packages/core/shared/src/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/core/shared/src/index.ts b/packages/core/shared/src/index.ts index 1306e7267d..46df31256f 100644 --- a/packages/core/shared/src/index.ts +++ b/packages/core/shared/src/index.ts @@ -24,7 +24,6 @@ export * from './plugin' export { default as CachePlugin } from './plugins/cachePlugin' export * from './plugins/consolePlugin' export { default as ConsolePlugin } from './plugins/consolePlugin' -export { default as ErrorPlugin } from './plugins/errorPlugin' export { default as HistoryPlugin } from './plugins/historyPlugin' export { default as InspectorPlugin } from './plugins/inspectorPlugin' export { default as KeyCodePlugin } from './plugins/keyCodePlugin' From 6e7d083f41e27a33f9f3a63227e37dcf3c724966 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 23 Sep 2023 09:20:02 -0700 Subject: [PATCH 077/349] Add key to agent menu --- packages/core/client/src/components/Drawer/AgentMenu.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/client/src/components/Drawer/AgentMenu.tsx b/packages/core/client/src/components/Drawer/AgentMenu.tsx index b363565fd6..feb75adec8 100644 --- a/packages/core/client/src/components/Drawer/AgentMenu.tsx +++ b/packages/core/client/src/components/Drawer/AgentMenu.tsx @@ -370,7 +370,7 @@ function AgentMenu({ data, resetData }) { outline: 'none', }, }} - key={i} + key={i + agent.id} > {editMode && selectedAgentData?.id === agent?.id ? ( <> From aaea4e07900fc511a42f199bec40702827d70154 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 23 Sep 2023 09:20:20 -0700 Subject: [PATCH 078/349] Remove timeout on node highlighting --- .../core/shared/src/plugins/consolePlugin/MagickConsole.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/core/shared/src/plugins/consolePlugin/MagickConsole.ts b/packages/core/shared/src/plugins/consolePlugin/MagickConsole.ts index 798cd915f7..38931897c0 100644 --- a/packages/core/shared/src/plugins/consolePlugin/MagickConsole.ts +++ b/packages/core/shared/src/plugins/consolePlugin/MagickConsole.ts @@ -103,10 +103,6 @@ export class MagickConsole { this.node.data.success = true this.updateNodeView() this.node.data.success = false - setTimeout(() => { - this.updateNodeView() - // todo we could make this timeout configurable - }, 500) } log(_message: unknown) { From 4526a4f0043e0700f0c3d98b95f515e2d8b40c06 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 23 Sep 2023 16:50:19 -0700 Subject: [PATCH 079/349] Switch tab state to have separate active tab id property --- packages/state/src/lib/tabs.ts | 94 ++++++++++++++++------------------ 1 file changed, 43 insertions(+), 51 deletions(-) diff --git a/packages/state/src/lib/tabs.ts b/packages/state/src/lib/tabs.ts index 11bc8eecca..0c02aba417 100644 --- a/packages/state/src/lib/tabs.ts +++ b/packages/state/src/lib/tabs.ts @@ -27,27 +27,6 @@ export interface Tab { const tabAdapater = createEntityAdapter() const tabSelectors = tabAdapater.getSelectors() -// Initial State for tabs -const initialState = tabAdapater.getInitialState() - -/** - * Selects the active tab from the given tabs array. - */ -const _activeTabSelector = createDraftSafeSelector( - tabSelectors.selectAll, - tabs => { - return Object.values(tabs).find(tab => tab?.active) - } -) - -/** - * Selects the tab with the specified UUID from the given tabs array. - */ -const selectTabBySpellUUID = createDraftSafeSelector( - [state => tabSelectors.selectAll(state), (_, id) => id], - (tabs, id) => Object.values(tabs).find(tab => tab.id === id) -) - /** * Decodes a URI-encoded string and returns the decoded name portion. */ @@ -79,51 +58,51 @@ const buildTab = (tab, properties = {}) => ({ ...properties, }) +export type AdditionalState = { + activeTabId: string | null +} + /** * Tab slice containing reducer and actions for managing tabs. */ export const tabSlice = createSlice({ name: 'tabs', - initialState, + initialState: tabAdapater.getInitialState({ + activeTabId: null, + }), reducers: { - // Opens a tab, either creating a new one or switching to the existing tab + // Opens a tab, either creating a new one or switching to the existing tab openTab: (state, action) => { const switchActive = 'switchActive' in action.payload ? action.payload.switchActive : true - const activeTab = _activeTabSelector(state) as Tab - if (activeTab && switchActive) - tabAdapater.updateOne(state, { - id: activeTab.id, - changes: { active: false }, - }) - - const existingTab = selectTabBySpellUUID( - state, - encodedToId(action.payload.name) - ) - - if (existingTab && !switchActive) return - - if (existingTab && !action.payload.openNew) { - tabAdapater.updateOne(state, { - id: existingTab.id, - changes: { - active: switchActive, - }, - }) - return - } - const tab = buildTab(action.payload, { - active: true, + const newTab = buildTab(action.payload, { componentType: action.payload.componentType || 'DefaultComponent', }) - tabAdapater.addOne(state, tab) + + tabAdapater.addOne(state, newTab) + + if (switchActive) { + state.activeTabId = newTab.id + } + }, + closeTab: (state, action) => { + // if there are other tabs, grab the next one to be active + if (state.ids.length > 1) { + const nextTab = state.ids.find(id => id !== action.payload) + const tab = nextTab ? state.entities[nextTab] : null + + state.activeTabId = tab ? tab.id : null + } else { + state.activeTabId = null + } + tabAdapater.removeOne(state, action.payload) }, - closeTab: tabAdapater.removeOne, switchTab: tabAdapater.updateOne, clearTabs: tabAdapater.removeAll, - changeActive: tabAdapater.updateMany, + changeActive: (state, action) => { + state.activeTabId = action.payload + }, saveTabLayout: (state, action) => { tabAdapater.updateOne(state, { id: action.payload.tabId, @@ -150,6 +129,19 @@ export const { changeEditorLayout, } = tabSlice.actions +/** + * Selects the active tab from the given tabs array. + */ +const _activeTabSelector = createDraftSafeSelector( + [state => tabSelectors.selectAll(state), state => state.activeTabId], + (tabs, activeTabId) => { + const activeTab = tabs.find(tab => tab.id === activeTabId) + return activeTab + } +) + +export const activeTabIdSelector = (state: RootState) => state.tabs.activeTabId + // Export selectors export const activeTabSelector = (state: RootState) => _activeTabSelector(state.tabs) From 7cca2ddd7b070259bd162a69289fe192fcddb7dc Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 23 Sep 2023 16:50:48 -0700 Subject: [PATCH 080/349] Fix all usages of active tab and remove all use of navigate --- .../editor/src/components/TabBar/TabBar.tsx | 33 ++------- packages/editor/src/components/Workspace.tsx | 9 ++- packages/editor/src/components/Workspaces.tsx | 73 ++++++++++--------- .../editor/src/contexts/EditorProvider.tsx | 5 +- .../editor/src/contexts/LayoutProvider.tsx | 21 +++--- packages/editor/src/screens/Magick/Magick.tsx | 67 ++++------------- 6 files changed, 81 insertions(+), 127 deletions(-) diff --git a/packages/editor/src/components/TabBar/TabBar.tsx b/packages/editor/src/components/TabBar/TabBar.tsx index 49b9d868f2..24ad872a36 100644 --- a/packages/editor/src/components/TabBar/TabBar.tsx +++ b/packages/editor/src/components/TabBar/TabBar.tsx @@ -15,17 +15,16 @@ import { RootState, changeActive, closeTab, selectAllTabs } from '@magickml/stat * @param {Object} tab - tab object containing { id, name, URI } * @param {Object} activeTab - currently active tab */ -const Tab = ({ tab, activeTab }) => { +const Tab = ({ tab, activeTabId }) => { const dispatch = useDispatch() const navigate = useNavigate() - const tabs = useSelector((state: RootState) => selectAllTabs(state.tabs)) - const active = tab.id === activeTab?.id + const isActive = tab.id === activeTabId const title = `${tab.name.split('--')[0]}` const tabClass = classnames({ [css['tabbar-tab']]: true, - [css['active']]: active, - [css['inactive']]: !active, + [css['active']]: isActive, + [css['inactive']]: !isActive, }) /** @@ -33,24 +32,8 @@ const Tab = ({ tab, activeTab }) => { */ const onClick = () => { // This avoid unnecessary rendering and loading of spell when the same tab is clicked - if (tab.id === activeTab.id) return - const updatedTabs = tabs.map(t => - t.id === tab.id - ? { - id: t.id, - changes: { - active: true, - }, - } - : { - id: t.id, - changes: { - active: false, - }, - } - ) - dispatch(changeActive(updatedTabs)) - navigate(`/magick/${tab.URI}`) + if (tab.id === activeTabId) return + dispatch(changeActive(tab.id)) } /** @@ -86,7 +69,7 @@ const Tab = ({ tab, activeTab }) => { * @param {Array} tabs - array of tab objects containing { id, name, URI } * @param {Object} activeTab - currently active tab */ -const TabBar = ({ tabs, activeTab }) => { +const TabBar = ({ tabs, activeTabId }) => { return (
@@ -94,7 +77,7 @@ const TabBar = ({ tabs, activeTab }) => {
{tabs && - tabs.map((tab) => )} + tabs.map((tab) => )}
diff --git a/packages/editor/src/components/Workspace.tsx b/packages/editor/src/components/Workspace.tsx index 194d0141d8..b5f578b152 100644 --- a/packages/editor/src/components/Workspace.tsx +++ b/packages/editor/src/components/Workspace.tsx @@ -18,14 +18,15 @@ import DebugConsole from '../windows/DebugConsole' import TextEditor from '../windows/TextEditorWindow' import { RootState, spellApi } from '@magickml/state' import AgentControls from '../windows/AgentControlWindow' +import isEqual from 'lodash/isEqual' /** * Workspace component that handles different tabs and their layouts. * Each workspace corresponds to a different tab. - * @param {{tab: object, tabs: object[], pubSub: object}} props + * @param {{tab: object, pubSub: object}} props * @returns {JSX.Element} */ -const Workspace = ({ tab, tabs, pubSub }) => { +const Workspace = ({ tab, pubSub }) => { const config = useConfig() const spellRef = useRef() const { events, publish } = usePubSub() @@ -109,7 +110,6 @@ const Workspace = ({ tab, tabs, pubSub }) => { case 'debugConsole': return case 'agentControls': - console.log("AGENT CONTORLS") return default: return

@@ -130,5 +130,6 @@ const Wrapped = props => { } export default React.memo(Wrapped, (prevProps, nextProps) => { - return prevProps.tab.id !== nextProps.tab.id + return true + return isEqual(prevProps, nextProps) }) diff --git a/packages/editor/src/components/Workspaces.tsx b/packages/editor/src/components/Workspaces.tsx index d6ec7ea1eb..8ccbd3f18a 100644 --- a/packages/editor/src/components/Workspaces.tsx +++ b/packages/editor/src/components/Workspaces.tsx @@ -1,6 +1,9 @@ // DOCUMENTED +import { memo, useEffect } from 'react'; +import isEqual from 'lodash/isEqual'; import WorkspaceProvider from '../contexts/WorkspaceProvider'; import Composer from './Workspace'; +import { Tab } from '@magickml/state'; /** * A mapping of workspace types to their respective components. @@ -10,46 +13,48 @@ const workspaceMap = { module: Composer, }; -/** - * The Workspaces component displays a collection of workspaces, only showing the active one. - * - * @param tabs - An array of tabs. - * @param pubSub - An instance of a publish-subscribe pattern. - * @param activeTab - An object representing the active tab. - * @returns A JSX element containing the active workspace. - */ -const Workspaces = ({ tabs, pubSub, activeTab }) => { +type WorkspaceProps = { + pubSub: any; // You might want to provide a more detailed type based on your usage. + tab: Tab +}; + +const WorkspaceComponent = ({ tab, pubSub, activeTabId }) => { + // const { active, ...tabWithoutActive } = tab; + const Workspace = workspaceMap[tab.type]; + const props = { + pubSub, + tab + }; + + if (!Workspace) { + return null; + } + + return ( +
+ + ; + +
+ ) +} + +const Workspaces = ({ tabs, pubSub, activeTabId }) => { + return ( <> {tabs.map((tab) => { - if (tab.type === "component") { - return null; - } - const Workspace = workspaceMap[tab.type]; - - const props = { - tabs, - pubSub, - tab, - }; - - return ( -
- - - -
- ); + console.log("TAB!", tab) + return ; })} ); }; - export default Workspaces; \ No newline at end of file diff --git a/packages/editor/src/contexts/EditorProvider.tsx b/packages/editor/src/contexts/EditorProvider.tsx index f5992be082..c35e047515 100644 --- a/packages/editor/src/contexts/EditorProvider.tsx +++ b/packages/editor/src/contexts/EditorProvider.tsx @@ -22,7 +22,7 @@ import { zoomAt } from '../plugins/areaPlugin/zoom-at' import { useMagickInterface } from './MagickInterfaceProvider' import styles from './styles.module.scss' import { EngineComponent } from '@magickml/rete' -import { activeTabSelector, spellApi } from '@magickml/state' +import { spellApi } from '@magickml/state' /** * MagickTab type definition. @@ -191,7 +191,6 @@ const RawEditor = ({ tab, children }) => { spellApi.useLazyGetSpellByIdQuery() const [loaded, setLoaded] = useState(false) const { buildEditor } = useEditor() - const activeTab = useSelector(activeTabSelector) const reteInterface = useMagickInterface() as EditorContext useEffect(() => { @@ -203,7 +202,7 @@ const RawEditor = ({ tab, children }) => { }) }, [tab]) - if (isLoading && tab.id === activeTab?.id) return + if (isLoading) return return ( <> diff --git a/packages/editor/src/contexts/LayoutProvider.tsx b/packages/editor/src/contexts/LayoutProvider.tsx index cca6dae68c..df5b5cbc46 100644 --- a/packages/editor/src/contexts/LayoutProvider.tsx +++ b/packages/editor/src/contexts/LayoutProvider.tsx @@ -1,6 +1,6 @@ // DOCUMENTED import { LoadingScreen } from '@magickml/client-core' -import { activeTabSelector, saveTabLayout } from '@magickml/state' +import { saveTabLayout } from '@magickml/state' import { Actions, DockLocation, @@ -155,8 +155,11 @@ const LayoutProvider = ({ children, tab }) => { export const Layout = ({ json, factory, tab }) => { const dispatch = useDispatch() const layoutRef = useRef(null) +<<<<<<< HEAD const { currentModel, createModel, setCurrentRef } = useLayout() const activeTab = useSelector(activeTabSelector) +======= +>>>>>>> ac7d545f (Fix all usages of active tab and remove all use of navigate) // Side effect for creating model if there is JSON data useEffect(() => { @@ -186,15 +189,13 @@ export const Layout = ({ json, factory, tab }) => { // Rendering LayoutComponent return ( - tab.id === activeTab.id && ( - - ) + ) } diff --git a/packages/editor/src/screens/Magick/Magick.tsx b/packages/editor/src/screens/Magick/Magick.tsx index 220975a980..b2c64c5cca 100644 --- a/packages/editor/src/screens/Magick/Magick.tsx +++ b/packages/editor/src/screens/Magick/Magick.tsx @@ -2,7 +2,7 @@ import { LoadingScreen, TabLayout, usePubSub } from '@magickml/client-core' import { useEffect } from 'react' import { useDispatch, useSelector } from 'react-redux' -import { useNavigate, useParams } from 'react-router-dom' +import { useNavigate } from 'react-router-dom' import TabBar from '../../components/TabBar/TabBar' import Workspaces from '../../components/Workspaces' import Events from '../EventWindow' @@ -11,7 +11,7 @@ import Settings from '../settings/SettingsWindow' import Documents from '../DocumentWindow' import Agents from '../agents/AgentManagerWindow'; import { ClientPluginManager, pluginManager } from '@magickml/core' -import { RootState, activeTabSelector, closeTab, openTab, selectAllTabs } from '@magickml/state' +import { RootState, activeTabIdSelector, activeTabSelector, changeActive, openTab, selectAllTabs } from '@magickml/state' /** * Magick component * @param empty flag to control whether the workspaces should be rendered or not @@ -19,14 +19,13 @@ import { RootState, activeTabSelector, closeTab, openTab, selectAllTabs } from ' */ const Magick = ({ empty = false }): JSX.Element => { - const dispatch = useDispatch() const navigate = useNavigate() + const dispatch = useDispatch() + const { subscribe, events } = usePubSub() const tabs = useSelector((state: RootState) => selectAllTabs(state.tabs)) + const activeTabId = useSelector(activeTabIdSelector) const activeTab = useSelector(activeTabSelector) const pubSub = usePubSub() - const { URI } = useParams() - const { events, subscribe } = pubSub - const pluginComponents = [] ; (pluginManager as ClientPluginManager) @@ -54,72 +53,38 @@ const Magick = ({ empty = false }): JSX.Element => { // Subscribe to open tab events useEffect(() => { + if (!subscribe || !events || !dispatch) return return subscribe(events.OPEN_TAB, (_event, tabData) => { dispatch(openTab(tabData)) }) as () => void }, [subscribe, events.OPEN_TAB, dispatch]) - // Handle tabs and navigation + // Handle what we do if there are no tabs useEffect(() => { - // If there are still tabs, grab one at random to open to for now. - // We should do better at this. Probably with some kind of tab ordering. - // Could fit in well with drag and drop for tabs - if (tabs.length > 0 && !activeTab) { - navigate(`/magick/${tabs[Math.floor(Math.random() * tabs.length)].URI}`) - } - - if (tabs.length === 0 && !activeTab && !URI) navigate('/home') - }, [tabs, activeTab, URI, navigate]) + if (tabs.length === 0 && !activeTabId) navigate('/home') - // Handle URI changes - useEffect(() => { - if (!URI) return - // Return if navigating to the spell that is already active - if (activeTab && URI.includes(activeTab.URI.split('%')[0])) return - - // Close spell tab if it exists - const spellNameTab = tabs.filter(tab => tab.URI === URI) - const isSpellNameTabPresent = spellNameTab.length - if (isSpellNameTabPresent) dispatch(closeTab(spellNameTab[0].id)) - const Component = URI.split('-')[0] - if (URI && Component in componentMapping) { - const existingTab = tabs.find(tab => tab.URI === URI) - if (!existingTab) { - dispatch( - openTab({ - name: Component, - componentType: Component, // Set the componentType as the URI for now, you can modify this as needed - openNew: false, - type: 'component', - }) - ) - } - } else { - dispatch( - openTab({ - name: URI, - openNew: false, - type: 'spell', - }) - ) + // Handle what we do if there are tabs but no active tab + if (tabs.length > 0 && !activeTabId) { + const firstTab = tabs[0] + dispatch(changeActive(firstTab.id)) } - }, [URI, activeTab, tabs, dispatch]) + }, [tabs, activeTabId, navigate]) // Render loading screen if there's no active tab - if (!activeTab) return + if (!activeTabId) return const ComponentToRender = componentMapping[activeTab.componentType] || null return ( <> - + {!empty && ( <> {ComponentToRender ? ( // Render the dynamically opened component if available ) : ( - + )} )} From 761f33e67c265972fc438858308d2f45e11034f8 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 23 Sep 2023 23:09:09 -0700 Subject: [PATCH 081/349] Move route mapping to inside workspaces --- packages/editor/src/components/Workspaces.tsx | 57 +++++++++++++++---- packages/editor/src/screens/Magick/Magick.tsx | 32 ++--------- 2 files changed, 49 insertions(+), 40 deletions(-) diff --git a/packages/editor/src/components/Workspaces.tsx b/packages/editor/src/components/Workspaces.tsx index 8ccbd3f18a..9ed9abe159 100644 --- a/packages/editor/src/components/Workspaces.tsx +++ b/packages/editor/src/components/Workspaces.tsx @@ -2,16 +2,15 @@ import { memo, useEffect } from 'react'; import isEqual from 'lodash/isEqual'; import WorkspaceProvider from '../contexts/WorkspaceProvider'; +import { ClientPluginManager, pluginManager } from '@magickml/core' import Composer from './Workspace'; import { Tab } from '@magickml/state'; +import Events from '../screens/EventWindow' +import Requests from '../screens/RequestWindow' +import Settings from '../screens/settings/SettingsWindow' +import Documents from '../screens/DocumentWindow' +import Agents from '../screens/agents/AgentManagerWindow'; -/** - * A mapping of workspace types to their respective components. - */ -const workspaceMap = { - spell: Composer, - module: Composer, -}; type WorkspaceProps = { pubSub: any; // You might want to provide a more detailed type based on your usage. @@ -19,8 +18,35 @@ type WorkspaceProps = { }; const WorkspaceComponent = ({ tab, pubSub, activeTabId }) => { - // const { active, ...tabWithoutActive } = tab; - const Workspace = workspaceMap[tab.type]; + const pluginComponents = [] + + ; (pluginManager as ClientPluginManager) + .getGroupedClientRoutes() + .forEach(plugin => { + plugin.routes.map(route => { + pluginComponents.push({ + name: route.path.charAt(1).toUpperCase() + route.path.slice(2), + component: route.component, + }) + }) + }) + + const componentMapping = { + spell: Composer, + module: Composer, + Events, + Requests, + Settings, + Documents, + Agents, + ...pluginComponents.reduce((acc, obj) => { + acc[obj.name] = obj.component + return acc + }, {}), + } + + + const Workspace = componentMapping[tab.type]; const props = { pubSub, tab @@ -30,12 +56,18 @@ const WorkspaceComponent = ({ tab, pubSub, activeTabId }) => { return null; } + console.log(componentMapping) + return (
@@ -45,12 +77,13 @@ const WorkspaceComponent = ({ tab, pubSub, activeTabId }) => { ) } +// We want to render all workspaces and components together so we can hold them in memory +// and not have to re-render them when switching between tabs. const Workspaces = ({ tabs, pubSub, activeTabId }) => { - return ( <> {tabs.map((tab) => { - console.log("TAB!", tab) + // render the component if it is a component type return ; })} diff --git a/packages/editor/src/screens/Magick/Magick.tsx b/packages/editor/src/screens/Magick/Magick.tsx index b2c64c5cca..c3f82896d2 100644 --- a/packages/editor/src/screens/Magick/Magick.tsx +++ b/packages/editor/src/screens/Magick/Magick.tsx @@ -5,11 +5,7 @@ import { useDispatch, useSelector } from 'react-redux' import { useNavigate } from 'react-router-dom' import TabBar from '../../components/TabBar/TabBar' import Workspaces from '../../components/Workspaces' -import Events from '../EventWindow' -import Requests from '../RequestWindow' -import Settings from '../settings/SettingsWindow' -import Documents from '../DocumentWindow' -import Agents from '../agents/AgentManagerWindow'; + import { ClientPluginManager, pluginManager } from '@magickml/core' import { RootState, activeTabIdSelector, activeTabSelector, changeActive, openTab, selectAllTabs } from '@magickml/state' /** @@ -39,18 +35,6 @@ const Magick = ({ empty = false }): JSX.Element => { }) }) - const componentMapping = { - Events, - Requests, - Settings, - Documents, - Agents, - ...pluginComponents.reduce((acc, obj) => { - acc[obj.name] = obj.component - return acc - }, {}), - } - // Subscribe to open tab events useEffect(() => { if (!subscribe || !events || !dispatch) return @@ -73,21 +57,13 @@ const Magick = ({ empty = false }): JSX.Element => { // Render loading screen if there's no active tab if (!activeTabId) return - const ComponentToRender = componentMapping[activeTab.componentType] || null - return ( <> - {!empty && ( - <> - {ComponentToRender ? ( - // Render the dynamically opened component if available - ) : ( - - )} - - )} + {!empty && + + } ) From 2dcfdde7d1ca322ea669b6e9f82c7d910468d3e5 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 23 Sep 2023 23:09:42 -0700 Subject: [PATCH 082/349] Cleanup --- packages/editor/src/components/Workspace.tsx | 5 +---- packages/state/src/lib/tabs.ts | 4 +--- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/packages/editor/src/components/Workspace.tsx b/packages/editor/src/components/Workspace.tsx index b5f578b152..a77fb09df7 100644 --- a/packages/editor/src/components/Workspace.tsx +++ b/packages/editor/src/components/Workspace.tsx @@ -129,7 +129,4 @@ const Wrapped = props => { return } -export default React.memo(Wrapped, (prevProps, nextProps) => { - return true - return isEqual(prevProps, nextProps) -}) +export default React.memo(Wrapped) diff --git a/packages/state/src/lib/tabs.ts b/packages/state/src/lib/tabs.ts index 0c02aba417..135992efc5 100644 --- a/packages/state/src/lib/tabs.ts +++ b/packages/state/src/lib/tabs.ts @@ -76,9 +76,7 @@ export const tabSlice = createSlice({ const switchActive = 'switchActive' in action.payload ? action.payload.switchActive : true - const newTab = buildTab(action.payload, { - componentType: action.payload.componentType || 'DefaultComponent', - }) + const newTab = buildTab(action.payload) tabAdapater.addOne(state, newTab) From 609dc8a399fe7f62087e93b81f78668b970c1b96 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 23 Sep 2023 23:10:09 -0700 Subject: [PATCH 083/349] Swap sidebar menu to use new tab opening --- .../components/Drawer/Newsidebar/index.tsx | 37 ++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/packages/core/client/src/components/Drawer/Newsidebar/index.tsx b/packages/core/client/src/components/Drawer/Newsidebar/index.tsx index 8388d55b1c..e011d8f195 100644 --- a/packages/core/client/src/components/Drawer/Newsidebar/index.tsx +++ b/packages/core/client/src/components/Drawer/Newsidebar/index.tsx @@ -40,7 +40,8 @@ import StarBorderPurple500OutlinedIcon from '@mui/icons-material/StarBorderPurpl import HistoryEduOutlinedIcon from '@mui/icons-material/HistoryEduOutlined' import { useConfig } from '@magickml/client-core' import { DEFAULT_USER_TOKEN, STANDALONE, PRODUCTION } from '@magickml/config' -import { useSelector } from 'react-redux' +import { useDispatch, useSelector } from 'react-redux' +import { openTab } from '@magickml/state' const drawerWidth = 210 @@ -169,6 +170,7 @@ const PluginDrawerItems: React.FC = ({ onClick, open, }) => { + const dispatch = useDispatch() const location = useLocation() const navigate = useNavigate() const drawerItems = (pluginManager as ClientPluginManager).getDrawerItems() @@ -192,7 +194,12 @@ const PluginDrawerItems: React.FC = ({ Icon={item.icon} open={open} onClick={() => { - navigate(`/magick/${item.text}`) + dispatch(openTab({ + name: item.text, + type: item.text, + switchActive: true, + id: item.text, + })) }} text={item.text} tooltip="Avatar and Tasks Tooltip" @@ -215,6 +222,7 @@ type DrawerProps = { export function NewSidebar(DrawerProps): JSX.Element { const location = useLocation() const navigate = useNavigate() + const dispatch = useDispatch() const [isAPIKeysSet, setAPIKeysSet] = useState(false) const [openDrawer, setOpenDrawer] = useState(true) // State to keep track of the anchor element of the menu and cursor position @@ -393,7 +401,12 @@ export function NewSidebar(DrawerProps): JSX.Element { Icon={BoltIcon} open={openDrawer} onClick={() => { - navigate(`/magick/Events-${encodeURIComponent(btoa('Events'))}`) + dispatch(openTab({ + name: 'Events', + type: 'Events', + switchActive: true, + id: 'events', + })) }} text="Events" tooltip="Events Tooltip" @@ -404,9 +417,12 @@ export function NewSidebar(DrawerProps): JSX.Element { Icon={StorageIcon} open={openDrawer} onClick={() => { - navigate( - `/magick/Requests-${encodeURIComponent(btoa('Requests'))}` - ) + dispatch(openTab({ + name: 'Requests', + type: 'Requests', + switchActive: true, + id: 'requests', + })) }} text="Requests" tooltip="Requests Tooltip" @@ -420,9 +436,12 @@ export function NewSidebar(DrawerProps): JSX.Element { Icon={SettingsIcon} open={openDrawer} onClick={() => { - navigate( - `/magick/Settings-${encodeURIComponent(btoa('Settings'))}` - ) + dispatch(openTab({ + name: 'Settings', + type: 'Settings', + switchActive: true, + id: 'settings', + })) }} text="Settings" tooltip="Settings Tooltip" From b86140d910e0feb59cae21a7ff651b0f7b71a40c Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 24 Sep 2023 00:27:53 -0700 Subject: [PATCH 084/349] use tab id when construrcting tab --- packages/state/src/lib/tabs.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/state/src/lib/tabs.ts b/packages/state/src/lib/tabs.ts index 135992efc5..aa78b226ad 100644 --- a/packages/state/src/lib/tabs.ts +++ b/packages/state/src/lib/tabs.ts @@ -48,7 +48,7 @@ const encodedToId = (uri: string) => { */ const buildTab = (tab, properties = {}) => ({ ...tab, - id: encodedToId(tab.name) || tab.name, + id: tab.id || encodedToId(tab.name) || tab.name, URI: encodeURIComponent(tab.name) || tab.name, name: encodedToName(tab.name) || tab.name, layoutJson: getWorkspaceLayout(tab.workspace), From 552b1616f7fb77a46462a4f0e021222be252bb9f Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 24 Sep 2023 00:28:11 -0700 Subject: [PATCH 085/349] Use new tab system in custom node for file drawer --- .../src/components/Drawer/CustomNode.tsx | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/packages/core/client/src/components/Drawer/CustomNode.tsx b/packages/core/client/src/components/Drawer/CustomNode.tsx index 70232a8021..8412332408 100644 --- a/packages/core/client/src/components/Drawer/CustomNode.tsx +++ b/packages/core/client/src/components/Drawer/CustomNode.tsx @@ -39,6 +39,7 @@ type CustomData = { } export const CustomNode: React.FC = props => { + const dispatch = useDispatch() const { droppable, data }: any = props.node const indent = props.depth * 24 const navigate = useNavigate() @@ -49,7 +50,6 @@ export const CustomNode: React.FC = props => { const FeathersContext = useFeathers() const client = FeathersContext.client const tabs = useSelector((state: RootState) => selectAllTabs(state.tabs)) - const dispatch = useDispatch() const [isRenaming, setIsRenaming] = useState(false) const [newName, setNewName] = useState(props.node.text) const [patchSpell] = spellApi.usePatchSpellMutation() @@ -69,11 +69,21 @@ export const CustomNode: React.FC = props => { if (!props.node) return if (props.node.fileType === 'txt') { setOpenDoc(props.node.id) - navigate(`/magick/Documents-${encodeURIComponent(btoa('Documents'))}`) + dispatch(openTab({ + id: "Documents", + name: 'Documents', + type: 'Documents', + switchActive: true + })) } else if (props.node.fileType === 'spell') { - navigate( - `/magick/${props.node.id}-${encodeURIComponent(btoa(props.node.text))}` - ) + console.log('Open spell', props.node) + + dispatch(openTab({ + id: props.node.id, + name: props.node.text, + spellName: props.node.text, + type: 'spell', + })) } } @@ -164,7 +174,8 @@ export const CustomNode: React.FC = props => { dispatch( openTab({ - name: props.node.id + '-' + encodeURIComponent(btoa(newName)), + id: props.node.id, + name: newName, spellName: newName, type: 'spell', }) From e8ef00582adfc07c9f4c578e6ce03330d6fff6c7 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 24 Sep 2023 00:38:56 -0700 Subject: [PATCH 086/349] Fix tab selection when closing another tab --- packages/state/src/lib/tabs.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/state/src/lib/tabs.ts b/packages/state/src/lib/tabs.ts index aa78b226ad..2b8a13acda 100644 --- a/packages/state/src/lib/tabs.ts +++ b/packages/state/src/lib/tabs.ts @@ -87,7 +87,9 @@ export const tabSlice = createSlice({ closeTab: (state, action) => { // if there are other tabs, grab the next one to be active if (state.ids.length > 1) { - const nextTab = state.ids.find(id => id !== action.payload) + // grab the closest tab to the one which was closed based on proximity in the array + const nextTab = state.ids[state.ids.indexOf(action.payload) - 1] + const tab = nextTab ? state.entities[nextTab] : null state.activeTabId = tab ? tab.id : null From 4895cc863f7598e1b1270680e7a1e7f34e97a685 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 24 Sep 2023 00:48:13 -0700 Subject: [PATCH 087/349] Fix weird floating x from hidden tab bug --- packages/editor/src/components/Workspaces.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/editor/src/components/Workspaces.tsx b/packages/editor/src/components/Workspaces.tsx index 9ed9abe159..5fae009042 100644 --- a/packages/editor/src/components/Workspaces.tsx +++ b/packages/editor/src/components/Workspaces.tsx @@ -56,13 +56,14 @@ const WorkspaceComponent = ({ tab, pubSub, activeTabId }) => { return null; } - console.log(componentMapping) + const isActive = tab.id === activeTabId return (
Date: Mon, 25 Sep 2023 20:48:18 -0700 Subject: [PATCH 088/349] Fix more tab openings in agent menu --- .../src/components/Drawer/AgentMenu.tsx | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/packages/core/client/src/components/Drawer/AgentMenu.tsx b/packages/core/client/src/components/Drawer/AgentMenu.tsx index feb75adec8..b86f87ed9a 100644 --- a/packages/core/client/src/components/Drawer/AgentMenu.tsx +++ b/packages/core/client/src/components/Drawer/AgentMenu.tsx @@ -13,7 +13,6 @@ import MenuItem from '@mui/material/MenuItem' import ListItemIcon from '@mui/material/ListItemIcon' import Divider from '@mui/material/Divider' import AddCircleIcon from '@mui/icons-material/AddCircle' -import { useNavigate } from 'react-router-dom' import { IconBtn } from '@magickml/client-core' import { Close, Done } from '@mui/icons-material' import styles from './menu.module.css' @@ -29,7 +28,7 @@ import { useFeathers } from '../../providers/FeathersProvider' import { useSpellList } from '../../../../../plugins/avatar/client/src/hooks/useSpellList' import { useTreeData } from '../../../../client/src/contexts/TreeDataProvider' import { AgentInterface, SpellInterface } from '@magickml/core' -import { setCurrentAgentId } from '@magickml/state' +import { openTab, setCurrentAgentId } from '@magickml/state' interface Spell { id: number @@ -38,7 +37,6 @@ interface Spell { } function AgentMenu({ data, resetData }) { - const navigate = useNavigate() const { client } = useFeathers() const [openMenu1, setOpenMenu1] = useState(null) const [openConfirm, setOpenConfirm] = useState(false) @@ -259,12 +257,12 @@ function AgentMenu({ data, resetData }) { if (matchingSpell) { const spellName = matchingSpell.name - // Construct the URL - const encodedSpellName = encodeURIComponent(btoa(spellName)) - const url = `/magick/${agent.rootSpellId}-${encodedSpellName}` - - // Navigate to the URL - navigate(url) + dispatch(openTab({ + id: agent.rootSpellId, + name: spellName, + spellName: spellName, + type: 'spell', + })) } } handleCloseMenu1() @@ -463,7 +461,12 @@ function AgentMenu({ data, resetData }) { }, }} onClick={() => { - navigate(`/magick/Agents-${encodeURIComponent(btoa('Agents'))}`) + dispatch(openTab({ + id: "Agents", + name: 'Agents', + type: 'Agents', + switchActive: true + })) }} > { - navigate(`/magick/Agents-${encodeURIComponent(btoa('Agents'))}`) + dispatch(openTab({ + id: "Agents", + name: 'Agents', + type: 'Agents', + switchActive: true + })) }} > Other Options From 092d14714af2db822c0cff43e998cae4db015cd7 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 25 Sep 2023 21:17:14 -0700 Subject: [PATCH 089/349] Fix get agent in agent manager --- packages/agents/src/lib/AgentManager.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/agents/src/lib/AgentManager.ts b/packages/agents/src/lib/AgentManager.ts index d31273cc75..c946592919 100644 --- a/packages/agents/src/lib/AgentManager.ts +++ b/packages/agents/src/lib/AgentManager.ts @@ -23,12 +23,12 @@ export class AgentManager { * @param agent - The agent data. * @returns The agent if found. */ - getAgent({ agent }) { - if (!agent) { - this.logger.error("AgentManager can't find agent %o", agent) + getAgent(agentId) { + if (!agentId) { + this.logger.error("AgentManager can't find agent %o", agentId) return null } - return this.agents[agent.id] + return this.agents[agentId] } /** From 1af2d37106185444499e5adcc5ebb9306f46c43c Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 25 Sep 2023 21:17:32 -0700 Subject: [PATCH 090/349] Call getAgent from agent details properly --- packages/plugins/task/server/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugins/task/server/src/index.ts b/packages/plugins/task/server/src/index.ts index de44e5818d..95125a90a9 100644 --- a/packages/plugins/task/server/src/index.ts +++ b/packages/plugins/task/server/src/index.ts @@ -88,7 +88,7 @@ class TaskManager { * @param {any} agent - Agent to remove. */ removeAgent({ agent }) { - const _agent = this.agentManager.getAgent({ agent }) + const _agent = this.agentManager.getAgent(agent.id) if (!_agent || !agent?.taskHandler) return clearInterval(agent.taskHandler) delete agent.taskHandler From 172feb7bcb6c49937e17a8db995b80e701055863 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 25 Sep 2023 21:18:05 -0700 Subject: [PATCH 091/349] Fix live toggle flag --- packages/agents/src/lib/AgentCommander.ts | 4 +++- packages/agents/src/lib/CommandHub.ts | 4 +++- packages/core/shared/src/spellManager/SpellManager.ts | 6 +++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/agents/src/lib/AgentCommander.ts b/packages/agents/src/lib/AgentCommander.ts index bd6f7b611b..cf7721b161 100644 --- a/packages/agents/src/lib/AgentCommander.ts +++ b/packages/agents/src/lib/AgentCommander.ts @@ -195,7 +195,9 @@ export class AgentCommander extends EventEmitter { if (!event) throw new Error('Agent ID or project ID is required') this.logger.debug( - `AgentCommander sending event ${event} to agent ${agentId}` + `AgentCommander sending event ${event} to agent ${agentId} with data ${JSON.stringify( + data + )}` ) const jobId = uuidv4() diff --git a/packages/agents/src/lib/CommandHub.ts b/packages/agents/src/lib/CommandHub.ts index 2aa8798012..0c41d3fad9 100644 --- a/packages/agents/src/lib/CommandHub.ts +++ b/packages/agents/src/lib/CommandHub.ts @@ -55,7 +55,9 @@ export class CommandHub { * @param job - The job data. */ private async handleIncomingCommand(job: any) { - this.agent.log(`Received command: ${job.command}`) + this.agent.log( + `Received command: ${job.command} with data: ${JSON.stringify(job.data)}` + ) const { command } = job // if (!commandId) { diff --git a/packages/core/shared/src/spellManager/SpellManager.ts b/packages/core/shared/src/spellManager/SpellManager.ts index 1231eecaf4..a730239956 100644 --- a/packages/core/shared/src/spellManager/SpellManager.ts +++ b/packages/core/shared/src/spellManager/SpellManager.ts @@ -117,9 +117,9 @@ export default class SpellManager { * Toggles the watchSpells flag. */ toggleLive(data) { - this.agent.log(`Toggling watchSpells to ${data.isLive}`) - const { isLive } = data - this.watchSpells = isLive ? isLive : !this.watchSpells + this.agent.log(`Toggling watchSpells to ${data.live}`) + const { live } = data + this.watchSpells = live ? live : !this.watchSpells } /** From 05ab6876e2402cd91475ce36648be3a1d49c87a6 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 26 Sep 2023 09:25:26 -0700 Subject: [PATCH 092/349] Helpful logging around plugins --- packages/agents/src/lib/Agent.ts | 22 ++++++++++++------- .../src/services/agents/agents.class.ts | 2 ++ packages/plugins/loop/server/src/index.ts | 1 + 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/packages/agents/src/lib/Agent.ts b/packages/agents/src/lib/Agent.ts index 5437c616e5..c8461b6deb 100644 --- a/packages/agents/src/lib/Agent.ts +++ b/packages/agents/src/lib/Agent.ts @@ -143,6 +143,8 @@ export class Agent implements AgentInterface { const agentStartMethods = pluginManager.getAgentStartMethods() + this.logger.debug('Initializing plugins on agent %s', this.id) + // Runs the agent start methods that were loaded from plugins for (const method of Object.keys(agentStartMethods)) { try { @@ -161,7 +163,6 @@ export class Agent implements AgentInterface { } private initializePluginCommands() { - this.log('Initializing plugin commands') const pluginCommands = pluginManager.getAgentCommands() for (const pluginName of Object.keys(pluginCommands)) { this.commandHub.registerPlugin(pluginName, pluginCommands[pluginName]) @@ -183,13 +184,8 @@ export class Agent implements AgentInterface { }) } - /** - * Clean up resources when the instance is destroyed. - */ - async onDestroy() { - if (this.updateInterval) { - clearInterval(this.updateInterval) - } + removePlugins() { + this.logger.debug('Removing all plugins on agent %s', this.id) const agentStopMethods = pluginManager.getAgentStopMethods() if (agentStopMethods) for (const method of Object.keys(agentStopMethods)) { @@ -199,6 +195,16 @@ export class Agent implements AgentInterface { spellRunner: this.spellRunner, }) } + } + + /** + * Clean up resources when the instance is destroyed. + */ + async onDestroy() { + if (this.updateInterval) { + clearInterval(this.updateInterval) + } + this.removePlugins() this.log('destroyed agent', { id: this.id }) } diff --git a/packages/core/server/src/services/agents/agents.class.ts b/packages/core/server/src/services/agents/agents.class.ts index 15477756ef..b303067566 100644 --- a/packages/core/server/src/services/agents/agents.class.ts +++ b/packages/core/server/src/services/agents/agents.class.ts @@ -83,6 +83,8 @@ export class AgentService< if (!connection) throw new Error('connection is required') + if (app.get('environment') !== 'server') return + const oldAgentChannel = app.channels.filter(channel => channel.match(/agent:/) )[0] diff --git a/packages/plugins/loop/server/src/index.ts b/packages/plugins/loop/server/src/index.ts index 11a648b4c3..c5881e3472 100644 --- a/packages/plugins/loop/server/src/index.ts +++ b/packages/plugins/loop/server/src/index.ts @@ -89,6 +89,7 @@ class LoopManager { * @param {any} agent - Agent to remove. */ removeAgent(agentId) { + this.logger.debug(`Removing agent ${agentId} from loop manager`) const agent = this.agentManager.getAgent(agentId) as AgentWithLoop if (!agent || !agent.loopHandler) return const loopHandler = this.loopHandlers.get(agent.id) From 74b960113c8a2c9eaa7cebf86a1308c968bb4fc3 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 26 Sep 2023 10:21:33 -0700 Subject: [PATCH 093/349] A couple of small fixes --- .../core/client/src/providers/PubSubProvider.tsx | 1 - packages/core/shared/src/state/tabs.ts | 15 ++++++--------- packages/editor/src/contexts/LayoutProvider.tsx | 5 +---- packages/editor/src/main.tsx | 1 - 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/packages/core/client/src/providers/PubSubProvider.tsx b/packages/core/client/src/providers/PubSubProvider.tsx index cae5442269..4352c0c943 100644 --- a/packages/core/client/src/providers/PubSubProvider.tsx +++ b/packages/core/client/src/providers/PubSubProvider.tsx @@ -3,7 +3,6 @@ // Import required modules import { PubSubContext, PubSubData, PubSubEvents } from '@magickml/core' import PubSub from 'pubsub-js' -import * as React from 'react' import { createContext, useContext, useEffect } from 'react' import { useFeathers } from './FeathersProvider' diff --git a/packages/core/shared/src/state/tabs.ts b/packages/core/shared/src/state/tabs.ts index df84bde8ca..58ec4a16c1 100644 --- a/packages/core/shared/src/state/tabs.ts +++ b/packages/core/shared/src/state/tabs.ts @@ -5,18 +5,15 @@ import { createSlice, } from '@reduxjs/toolkit' -import defaultJson from '../data/layouts/defaultLayout.json' -import fullScreen from '../data/layouts/fullScreenLayout.json' -import promptEngineering from '../data/layouts/promptEngineeringLayout.json' -import troubleShooting from '../data/layouts/troubleshootingLayout.json' -import { RootState } from './store' +import { getWorkspaceLayout } from '@magickml/layouts' +import { RootState } from '@magickml/state' // Workspace map for initializing tabs with layout data export const workspaceMap = { - default: defaultJson, - fullScreen, - promptEngineering, - troubleShooting, + default: getWorkspaceLayout('defaultJson'), + fullScreen: getWorkspaceLayout('fullScreen'), + promptEngineering: getWorkspaceLayout('promptEngineering'), + troubleShooting: getWorkspaceLayout('troubleShooting'), } /** diff --git a/packages/editor/src/contexts/LayoutProvider.tsx b/packages/editor/src/contexts/LayoutProvider.tsx index df5b5cbc46..1bb8861e20 100644 --- a/packages/editor/src/contexts/LayoutProvider.tsx +++ b/packages/editor/src/contexts/LayoutProvider.tsx @@ -1,6 +1,6 @@ // DOCUMENTED import { LoadingScreen } from '@magickml/client-core' -import { saveTabLayout } from '@magickml/state' +import { activeTabSelector, saveTabLayout } from '@magickml/state' import { Actions, DockLocation, @@ -155,11 +155,8 @@ const LayoutProvider = ({ children, tab }) => { export const Layout = ({ json, factory, tab }) => { const dispatch = useDispatch() const layoutRef = useRef(null) -<<<<<<< HEAD const { currentModel, createModel, setCurrentRef } = useLayout() const activeTab = useSelector(activeTabSelector) -======= ->>>>>>> ac7d545f (Fix all usages of active tab and remove all use of navigate) // Side effect for creating model if there is JSON data useEffect(() => { diff --git a/packages/editor/src/main.tsx b/packages/editor/src/main.tsx index 09ebe5bd13..eeaad3bc14 100644 --- a/packages/editor/src/main.tsx +++ b/packages/editor/src/main.tsx @@ -18,7 +18,6 @@ import AppProviders from './contexts/AppProviders' import { LocalizationProvider } from '@mui/x-date-pickers' import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs' import { AppConfig } from '@magickml/client-core' -import { createStore } from '@magickml/core' import { MagickmlChatbox } from '@magickml/chatbox' import { createStore } from '@magickml/state' From 4cb7f2787fda5032ecf65f04a74fb52b05755381 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 26 Sep 2023 11:16:48 -0700 Subject: [PATCH 094/349] Install dockview --- package-lock.json | 14 ++++++++++++++ package.json | 1 + packages/editor/src/main.tsx | 1 + 3 files changed, 16 insertions(+) diff --git a/package-lock.json b/package-lock.json index 05a9cdd595..1e91bab5c8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -88,6 +88,7 @@ "deep-equal": "2.2.1", "diff-match-patch": "1.0.5", "discord.js": "^14.13.0", + "dockview": "^1.8.3", "docusaurus-plugin-typedoc": "0.19.2", "dotenv-flow": "3.2.0", "emoji-dictionary": "1.0.11", @@ -28612,6 +28613,19 @@ "node": ">=6" } }, + "node_modules/dockview": { + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/dockview/-/dockview-1.8.3.tgz", + "integrity": "sha512-jNwx7WBSamAztzBi/17llgir7THCulBJ0M5zoNhaxb1GB+MoTsWptJUY2h5QpCie0ttOKQO0GV7+UjRsCn/VEw==", + "dependencies": { + "dockview-core": "^1.8.3" + } + }, + "node_modules/dockview-core": { + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/dockview-core/-/dockview-core-1.8.3.tgz", + "integrity": "sha512-Zz/P7PxjI+TLfnKB5A73yUXh2StKW7ftUJq/JxYCVRsW5eTjHoFet38Ek4GL2njtOUsLeKwEabNkYmKHdwaaEg==" + }, "node_modules/doctrine": { "version": "3.0.0", "dev": true, diff --git a/package.json b/package.json index e9eb357995..e201cbe83d 100644 --- a/package.json +++ b/package.json @@ -119,6 +119,7 @@ "deep-equal": "2.2.1", "diff-match-patch": "1.0.5", "discord.js": "^14.13.0", + "dockview": "^1.8.3", "docusaurus-plugin-typedoc": "0.19.2", "dotenv-flow": "3.2.0", "emoji-dictionary": "1.0.11", diff --git a/packages/editor/src/main.tsx b/packages/editor/src/main.tsx index eeaad3bc14..1b355bb507 100644 --- a/packages/editor/src/main.tsx +++ b/packages/editor/src/main.tsx @@ -3,6 +3,7 @@ * A module which exports a functional component - MagickIDE * @module MagickIDE */ +import 'dockview/dist/styles/dockview.css'; import React from 'react' import './wdyr' From 8094ecdcd6bda5c1db56d4700ae8e18d7b8e66d5 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 26 Sep 2023 11:16:58 -0700 Subject: [PATCH 095/349] Add empty dockview context --- packages/editor/src/contexts/DockviewProvider.tsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 packages/editor/src/contexts/DockviewProvider.tsx diff --git a/packages/editor/src/contexts/DockviewProvider.tsx b/packages/editor/src/contexts/DockviewProvider.tsx new file mode 100644 index 0000000000..dae9f5a000 --- /dev/null +++ b/packages/editor/src/contexts/DockviewProvider.tsx @@ -0,0 +1,15 @@ +import { createContext, useContext } from "react" + +type DocviewContext = {} + +// Creating the context +const Context = createContext(undefined!) + +// Helper hook to use Layout context +export const useLayout = () => useContext(Context) + +export const DockviewProvider = ({ children }) => { + return
+ {children} +
+} \ No newline at end of file From 17195bc4c5978f167a1730d3eb4942abe04c2bb3 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 26 Sep 2023 11:21:59 -0700 Subject: [PATCH 096/349] Set up new route for Magickv2 layout --- packages/editor/src/routes.tsx | 4 +++- packages/editor/src/screens/MagickV2/index.tsx | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 packages/editor/src/screens/MagickV2/index.tsx diff --git a/packages/editor/src/routes.tsx b/packages/editor/src/routes.tsx index 59024ebd1e..a2b039291e 100644 --- a/packages/editor/src/routes.tsx +++ b/packages/editor/src/routes.tsx @@ -10,6 +10,7 @@ import MagickPageLayout from './layouts/MagickPageLayout/MagickPageLayout' import MainLayout from './layouts/MainLayout/MainLayout' import HomeScreen from './screens/HomeScreen/HomeScreen' import Magick from './screens/Magick/Magick' +import MagickV2 from './screens/MagickV2' import AgentManagerWindow from './screens/agents/AgentManagerWindow' import DocumentWindow from './screens/DocumentWindow' import EventWindow from './screens/EventWindow' @@ -72,8 +73,9 @@ const MyRoutes = () => ( } /> }> + } /> } /> - } /> + } /> } /> } /> diff --git a/packages/editor/src/screens/MagickV2/index.tsx b/packages/editor/src/screens/MagickV2/index.tsx new file mode 100644 index 0000000000..9ff1970c40 --- /dev/null +++ b/packages/editor/src/screens/MagickV2/index.tsx @@ -0,0 +1,9 @@ +const MagickV2 = () => { + return ( +
+

MagickV2

+
+ ); +}; + +export default MagickV2 \ No newline at end of file From ef61f9972f4e97ba21b52aaf70e403e06a5e0fe7 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 26 Sep 2023 11:39:24 -0700 Subject: [PATCH 097/349] Switch to tab provider naming and add default dockview --- .../editor/src/contexts/DockviewProvider.tsx | 15 ---- packages/editor/src/contexts/TabProvider.tsx | 71 +++++++++++++++++++ .../editor/src/screens/MagickV2/index.tsx | 12 +++- 3 files changed, 80 insertions(+), 18 deletions(-) delete mode 100644 packages/editor/src/contexts/DockviewProvider.tsx create mode 100644 packages/editor/src/contexts/TabProvider.tsx diff --git a/packages/editor/src/contexts/DockviewProvider.tsx b/packages/editor/src/contexts/DockviewProvider.tsx deleted file mode 100644 index dae9f5a000..0000000000 --- a/packages/editor/src/contexts/DockviewProvider.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import { createContext, useContext } from "react" - -type DocviewContext = {} - -// Creating the context -const Context = createContext(undefined!) - -// Helper hook to use Layout context -export const useLayout = () => useContext(Context) - -export const DockviewProvider = ({ children }) => { - return
- {children} -
-} \ No newline at end of file diff --git a/packages/editor/src/contexts/TabProvider.tsx b/packages/editor/src/contexts/TabProvider.tsx new file mode 100644 index 0000000000..622994b609 --- /dev/null +++ b/packages/editor/src/contexts/TabProvider.tsx @@ -0,0 +1,71 @@ +import { createContext, useContext, useState } from "react" +import { + DockviewReact, DockviewReadyEvent, IDockviewPanelProps, +} from 'dockview'; + +type DockviewTheme = 'dockview-theme-abyss' + +type DocviewContext = { + theme: DockviewTheme, + setTheme: (theme: DockviewTheme) => void +} + +// Creating the context +const Context = createContext(undefined!) + +// Helper hook to use Layout context +export const useLayout = () => useContext(Context) + +export const TabLayout = ({ children }) => { + const { theme, setTheme } = useLayout() + + + const onReady = (event: DockviewReadyEvent) => { + event.api.addPanel({ + id: 'panel_1', + component: 'default', + }); + + event.api.addPanel({ + id: 'panel_2', + component: 'default', + }); + + event.api.addPanel({ + id: 'panel_3', + component: 'default', + }); + }; + + return () +} + +const components = { + default: (props: IDockviewPanelProps<{ title: string }>) => { + return ( +
+ {props.params.title} +
+ ); + } +}; + +export const TabProvider = ({ children }) => { + const [theme, setTheme] = useState('dockview-theme-abyss') + + const publicInterface = { + theme, + setTheme + } + return {children} +} \ No newline at end of file diff --git a/packages/editor/src/screens/MagickV2/index.tsx b/packages/editor/src/screens/MagickV2/index.tsx index 9ff1970c40..dca3836100 100644 --- a/packages/editor/src/screens/MagickV2/index.tsx +++ b/packages/editor/src/screens/MagickV2/index.tsx @@ -1,8 +1,14 @@ +import { TabLayout, TabProvider } from "../../contexts/TabProvider"; + const MagickV2 = () => { + return ( -
-

MagickV2

-
+ + +

MagickV2

+ +
+
); }; From 310a4309b1f701d7c936ea93debfe2463ab8a219 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 26 Sep 2023 11:58:52 -0700 Subject: [PATCH 098/349] Add layout persistance --- packages/editor/src/contexts/TabProvider.tsx | 111 ++++++++++++++----- 1 file changed, 84 insertions(+), 27 deletions(-) diff --git a/packages/editor/src/contexts/TabProvider.tsx b/packages/editor/src/contexts/TabProvider.tsx index 622994b609..3ea36009ff 100644 --- a/packages/editor/src/contexts/TabProvider.tsx +++ b/packages/editor/src/contexts/TabProvider.tsx @@ -1,40 +1,107 @@ -import { createContext, useContext, useState } from "react" +import { createContext, useContext, useEffect, useState } from "react" import { - DockviewReact, DockviewReadyEvent, IDockviewPanelProps, + DockviewApi, + DockviewReact, DockviewReadyEvent, IDockviewPanelProps, SerializedDockview, } from 'dockview'; +function loadDefaultLayout(api: DockviewApi) { + api.addPanel({ + id: 'panel_1', + component: 'default', + }); + + api.addPanel({ + id: 'panel_2', + component: 'default', + }); + + api.addPanel({ + id: 'panel_3', + component: 'default', + }); +} + type DockviewTheme = 'dockview-theme-abyss' type DocviewContext = { theme: DockviewTheme, - setTheme: (theme: DockviewTheme) => void + setTheme: (theme: DockviewTheme) => void, + api: DockviewApi, + setApi: (api: DockviewApi) => void, + getLayout: () => SerializedDockview | null, + setLayout: (layout: SerializedDockview) => void + } +const TAB_LAYOUT_KEY = 'tab-layout' + // Creating the context const Context = createContext(undefined!) // Helper hook to use Layout context export const useLayout = () => useContext(Context) -export const TabLayout = ({ children }) => { - const { theme, setTheme } = useLayout() +export const TabProvider = ({ children }) => { + const [theme, setTheme] = useState('dockview-theme-abyss') + const [api, setApi] = useState(); + const getLayout = () => { + const layout = localStorage.getItem(TAB_LAYOUT_KEY) - const onReady = (event: DockviewReadyEvent) => { - event.api.addPanel({ - id: 'panel_1', - component: 'default', - }); + if (!layout) { + return null + } + return JSON.parse(localStorage.getItem(TAB_LAYOUT_KEY)) as SerializedDockview + } - event.api.addPanel({ - id: 'panel_2', - component: 'default', - }); + const setLayout = (layout: SerializedDockview) => { + localStorage.setItem(TAB_LAYOUT_KEY, JSON.stringify(layout)) + } + + useEffect(() => { + if (!api) { + return; + } - event.api.addPanel({ - id: 'panel_3', - component: 'default', + // set up API event handlers + api.onDidLayoutChange(() => { + const layout = api.toJSON(); + + setLayout(layout) }); + + }, [api]); + + const publicInterface = { + theme, + setTheme, + api, + setApi, + getLayout, + setLayout + } + return {children} +} + +export const TabLayout = ({ children }) => { + const { theme, setTheme, setApi, api, setLayout, getLayout } = useLayout() + + const onReady = (event: DockviewReadyEvent) => { + + const layout = getLayout() + + let success = false; + + if (layout) { + event.api.fromJSON(layout); + success = true; + } + + if (!success) { + loadDefaultLayout(event.api); + } + + setApi(event.api) }; return ( ); } -}; - -export const TabProvider = ({ children }) => { - const [theme, setTheme] = useState('dockview-theme-abyss') - - const publicInterface = { - theme, - setTheme - } - return {children} } \ No newline at end of file From 94d385399a271293c5b95624f823cd2819294a3b Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 26 Sep 2023 15:15:57 -0700 Subject: [PATCH 099/349] Tabs hooked up to open spells --- .../src/components/Drawer/CustomNode.tsx | 44 +++--- .../components/Drawer/Newsidebar/index.tsx | 23 ++-- .../editor/src/DataControls/SpellSelect.tsx | 5 +- packages/editor/src/contexts/AppProviders.tsx | 2 + .../editor/src/contexts/LayoutProvider.tsx | 1 - packages/editor/src/contexts/TabProvider.tsx | 93 ++++++++++--- .../editor/src/screens/Composer/index.tsx | 129 ++++++++++++++++++ .../editor/src/screens/MagickV2/index.tsx | 10 +- 8 files changed, 246 insertions(+), 61 deletions(-) create mode 100644 packages/editor/src/screens/Composer/index.tsx diff --git a/packages/core/client/src/components/Drawer/CustomNode.tsx b/packages/core/client/src/components/Drawer/CustomNode.tsx index 8412332408..43ae061663 100644 --- a/packages/core/client/src/components/Drawer/CustomNode.tsx +++ b/packages/core/client/src/components/Drawer/CustomNode.tsx @@ -1,4 +1,4 @@ -import { useState,useEffect } from 'react' +import { useState, useEffect } from 'react' import Typography from '@mui/material/Typography' import { NodeModel } from '@minoru/react-dnd-treeview' import ChevronRightIcon from '@mui/icons-material/ChevronRight' @@ -18,7 +18,6 @@ import { closeTab, selectAllTabs, spellApi, - openTab, activeTabSelector, } from '@magickml/core' import { useDispatch, useSelector } from 'react-redux' @@ -31,6 +30,7 @@ type Props = { depth: number isOpen: boolean onToggle: (id: NodeModel['id']) => void + openTab: (tab: any) => void } type CustomData = { @@ -69,21 +69,21 @@ export const CustomNode: React.FC = props => { if (!props.node) return if (props.node.fileType === 'txt') { setOpenDoc(props.node.id) - dispatch(openTab({ + props.openTab({ id: "Documents", name: 'Documents', type: 'Documents', switchActive: true - })) + }) } else if (props.node.fileType === 'spell') { console.log('Open spell', props.node) - dispatch(openTab({ + props.openTab({ id: props.node.id, name: props.node.text, spellName: props.node.text, type: 'spell', - })) + }) } } @@ -149,7 +149,7 @@ export const CustomNode: React.FC = props => { } await dispatch(closeTab(props.node.id)) - + const spell: any = props.node.id const response: any = await patchSpell({ id: props.node.id, @@ -157,29 +157,25 @@ export const CustomNode: React.FC = props => { name: newName, }, }) - + if (response.error) { enqueueSnackbar('Error saving spell', { variant: 'error', }) return } - - if (response){ - enqueueSnackbar('Spell saved', { variant: 'success' }) - dispatch( - closeTab(props.node.id ) - ) - } - - dispatch( - openTab({ - id: props.node.id, - name: newName, - spellName: newName, - type: 'spell', - }) - ) + + enqueueSnackbar('Spell saved', { variant: 'success' }) + + // todo implement closing tab + dispatch(closeTab(props.node.id)) + + props.openTab({ + id: props.node.id, + name: newName, + spellName: newName, + type: 'spell', + }) setToDelete(spell) setIsAdded(true) } diff --git a/packages/core/client/src/components/Drawer/Newsidebar/index.tsx b/packages/core/client/src/components/Drawer/Newsidebar/index.tsx index e011d8f195..0939b35f83 100644 --- a/packages/core/client/src/components/Drawer/Newsidebar/index.tsx +++ b/packages/core/client/src/components/Drawer/Newsidebar/index.tsx @@ -41,7 +41,9 @@ import HistoryEduOutlinedIcon from '@mui/icons-material/HistoryEduOutlined' import { useConfig } from '@magickml/client-core' import { DEFAULT_USER_TOKEN, STANDALONE, PRODUCTION } from '@magickml/config' import { useDispatch, useSelector } from 'react-redux' -import { openTab } from '@magickml/state' + +// todo FIX THIS IMPORT +import { useTabLayout } from '../../../../../../editor/src/contexts/TabProvider' const drawerWidth = 210 @@ -170,6 +172,7 @@ const PluginDrawerItems: React.FC = ({ onClick, open, }) => { + const { openTab } = useTabLayout() const dispatch = useDispatch() const location = useLocation() const navigate = useNavigate() @@ -194,12 +197,12 @@ const PluginDrawerItems: React.FC = ({ Icon={item.icon} open={open} onClick={() => { - dispatch(openTab({ + openTab({ name: item.text, type: item.text, switchActive: true, id: item.text, - })) + }) }} text={item.text} tooltip="Avatar and Tasks Tooltip" @@ -220,6 +223,7 @@ type DrawerProps = { * The main Drawer component that wraps around the application content. */ export function NewSidebar(DrawerProps): JSX.Element { + const { openTab } = useTabLayout() const location = useLocation() const navigate = useNavigate() const dispatch = useDispatch() @@ -401,12 +405,12 @@ export function NewSidebar(DrawerProps): JSX.Element { Icon={BoltIcon} open={openDrawer} onClick={() => { - dispatch(openTab({ + openTab({ name: 'Events', type: 'Events', switchActive: true, id: 'events', - })) + }) }} text="Events" tooltip="Events Tooltip" @@ -417,12 +421,12 @@ export function NewSidebar(DrawerProps): JSX.Element { Icon={StorageIcon} open={openDrawer} onClick={() => { - dispatch(openTab({ + openTab({ name: 'Requests', type: 'Requests', switchActive: true, id: 'requests', - })) + }) }} text="Requests" tooltip="Requests Tooltip" @@ -436,12 +440,12 @@ export function NewSidebar(DrawerProps): JSX.Element { Icon={SettingsIcon} open={openDrawer} onClick={() => { - dispatch(openTab({ + openTab({ name: 'Settings', type: 'Settings', switchActive: true, id: 'settings', - })) + }) }} text="Settings" tooltip="Settings Tooltip" @@ -464,6 +468,7 @@ export function NewSidebar(DrawerProps): JSX.Element { { depth, isOpen, onToggle } ) => ( { const { enqueueSnackbar } = useSnackbar() const { dataKey } = control + // Default graph for spells + const defaultGraph = getTemplates().spells[0].graph + // Handle what happens when a new spell is selected and fetched useEffect(() => { if (!spell) return diff --git a/packages/editor/src/contexts/AppProviders.tsx b/packages/editor/src/contexts/AppProviders.tsx index db248de5c8..7f8e6f2b09 100644 --- a/packages/editor/src/contexts/AppProviders.tsx +++ b/packages/editor/src/contexts/AppProviders.tsx @@ -3,6 +3,7 @@ import { ConfigProvider, FeathersProvider, PubSubProvider } from '@magickml/clie import { createTheme, ThemeProvider } from '@mui/material'; import React from 'react'; import ToastProvider from './ToastProvider'; +import { TabProvider } from './TabProvider'; // Create a dark theme for the application const darkTheme = createTheme({ @@ -25,6 +26,7 @@ function ComposeProviders({ config, children }) { [FeathersProvider, { token: config.token }], PubSubProvider, ToastProvider, + TabProvider ].reverse(); // Compose providers together and pass the props for each provider diff --git a/packages/editor/src/contexts/LayoutProvider.tsx b/packages/editor/src/contexts/LayoutProvider.tsx index 1bb8861e20..7e7920091f 100644 --- a/packages/editor/src/contexts/LayoutProvider.tsx +++ b/packages/editor/src/contexts/LayoutProvider.tsx @@ -156,7 +156,6 @@ export const Layout = ({ json, factory, tab }) => { const dispatch = useDispatch() const layoutRef = useRef(null) const { currentModel, createModel, setCurrentRef } = useLayout() - const activeTab = useSelector(activeTabSelector) // Side effect for creating model if there is JSON data useEffect(() => { diff --git a/packages/editor/src/contexts/TabProvider.tsx b/packages/editor/src/contexts/TabProvider.tsx index 3ea36009ff..cc77535e07 100644 --- a/packages/editor/src/contexts/TabProvider.tsx +++ b/packages/editor/src/contexts/TabProvider.tsx @@ -3,11 +3,21 @@ import { DockviewApi, DockviewReact, DockviewReadyEvent, IDockviewPanelProps, SerializedDockview, } from 'dockview'; +import { usePubSub } from "@magickml/client-core"; +import Composer from "../screens/Composer"; +import WorkspaceProvider from "./WorkspaceProvider"; +import { getWorkspaceLayout } from "@magickml/layouts"; +// we will move this out into the layouts package function loadDefaultLayout(api: DockviewApi) { api.addPanel({ id: 'panel_1', component: 'default', + params: { + spellId: 'root', + spellName: 'root', + type: 'spell', + } }); api.addPanel({ @@ -21,8 +31,48 @@ function loadDefaultLayout(api: DockviewApi) { }); } +const components = { + default: (props: IDockviewPanelProps<{ title: string }>) => { + return ( +
+ {JSON.stringify(props.params)} +
+ ); + }, + spell: (props: IDockviewPanelProps<{ tab: Tab, pubSub: any }>) => { + const pubSub = usePubSub() + return ( + +
+ + +
+
+ ); + } +} + type DockviewTheme = 'dockview-theme-abyss' +type Tab = { + id: string + name: string + spellName?: string + type: string + workspace?: string + switchActive?: boolean +} + type DocviewContext = { theme: DockviewTheme, setTheme: (theme: DockviewTheme) => void, @@ -31,19 +81,25 @@ type DocviewContext = { getLayout: () => SerializedDockview | null, setLayout: (layout: SerializedDockview) => void + // IMPLEMENT THESE + openTab: (tab: Tab) => void + closeTab?: (tab: any) => void + switchTab?: (tab: any) => void } const TAB_LAYOUT_KEY = 'tab-layout' + // Creating the context const Context = createContext(undefined!) // Helper hook to use Layout context -export const useLayout = () => useContext(Context) +export const useTabLayout = () => useContext(Context) export const TabProvider = ({ children }) => { const [theme, setTheme] = useState('dockview-theme-abyss') const [api, setApi] = useState(); + const pubSub = usePubSub() const getLayout = () => { const layout = localStorage.getItem(TAB_LAYOUT_KEY) @@ -72,19 +128,34 @@ export const TabProvider = ({ children }) => { }, [api]); + const openTab = (_tab: Tab) => { + const tab = { + ..._tab, + layoutJson: getWorkspaceLayout(_tab?.workspace), + } + api.addPanel({ + id: tab.name, + component: tab.type, + params: { + tab + } + }); + } + const publicInterface = { theme, setTheme, api, setApi, getLayout, - setLayout + setLayout, + openTab } return {children} } export const TabLayout = ({ children }) => { - const { theme, setTheme, setApi, api, setLayout, getLayout } = useLayout() + const { theme, setTheme, setApi, api, setLayout, getLayout } = useTabLayout() const onReady = (event: DockviewReadyEvent) => { @@ -109,20 +180,4 @@ export const TabLayout = ({ children }) => { className={theme} components={components} />) -} - -const components = { - default: (props: IDockviewPanelProps<{ title: string }>) => { - return ( -
- {props.params.title} -
- ); - } } \ No newline at end of file diff --git a/packages/editor/src/screens/Composer/index.tsx b/packages/editor/src/screens/Composer/index.tsx new file mode 100644 index 0000000000..126e724a21 --- /dev/null +++ b/packages/editor/src/screens/Composer/index.tsx @@ -0,0 +1,129 @@ +// DOCUMENTED +import React, { useEffect, useRef } from 'react' +import { useSelector } from 'react-redux' + +import { SpellInterface } from '@magickml/core' + +import { useConfig, useFeathers, usePubSub } from '@magickml/client-core' +import { useEditor } from '../../contexts/EditorProvider' +import { Layout } from '../../contexts/LayoutProvider' +import { debounce } from '../../utils/debounce' +import EventHandler from '../../components/EventHandler' + +import EditorWindow from '../../windows/EditorWindow' +import Inspector from '../../windows/InspectorWindow' +import Playtest from '../../windows/PlaytestWindow' + +import DebugConsole from '../../windows/DebugConsole' +import TextEditor from '../../windows/TextEditorWindow' +import { RootState, spellApi } from '@magickml/state' +import AgentControls from '../../windows/AgentControlWindow' + +/** + * Workspace component that handles different tabs and their layouts. + * Each workspace corresponds to a different tab. + * @param {{tab: object, pubSub: object}} props + * @returns {JSX.Element} + */ +const Composer = ({ tab, pubSub }) => { + const config = useConfig() + const spellRef = useRef() + const { events, publish } = usePubSub() + const [loadSpell, { data: spellData }] = spellApi.useLazyGetSpellByIdQuery() + const { editor, serialize } = useEditor() + const FeathersContext = useFeathers() + const client = FeathersContext?.client + const preferences = useSelector((state: RootState) => state.preferences) + + // Set up autosave for the workspaces + useEffect(() => { + if (!editor?.on) return + const unsubscribe = editor.on( + 'nodecreated noderemoved connectioncreated connectionremoved nodetranslated', + debounce(async data => { + if (tab.type === 'spell' && spellRef.current) { + publish(events.$SAVE_SPELL_DIFF(tab.id), { graph: serialize() }) + } + }, 1000) // debounce for 2000 ms + ) + + return () => { + unsubscribe() + } + }, [editor, preferences.autoSave]) + + useEffect(() => { + if (!editor?.on) return + + const unsubscribe = editor.on('nodecreated noderemoved', (node: any) => { + if (!spellRef.current) return + if (node.category !== 'IO') return + const spell = { + ...spellRef.current, + graph: editor.toJSON(), + } + publish(events.$SUBSPELL_UPDATED(spellRef.current.id), spell) + }) + + return () => { + unsubscribe() + } + }, [editor]) + + useEffect(() => { + if (!spellData) return + spellRef.current = spellData.data[0] + }, [spellData]) + + /** + * This was the issue of getting spell on every click of the editor + */ + + useEffect(() => { + // If there is no tab, or we already have a spell, return early + if (!tab || !tab.name || spellRef.current) return + + loadSpell({ + spellName: tab.name, + projectId: config.projectId, + id: tab.id, + }) + }, [tab]) + + const factory = tab => { + return node => { + const props = { + tab, + node, + } + const component = node.getComponent() + switch (component) { + case 'playtest': + return + case 'inspector': + return + case 'textEditor': + return + case 'editorWindow': + return + case 'debugConsole': + return + case 'agentControls': + return + default: + return

+ } + } + } + + return ( + <> + + + + ) +} + +const Wrapped = React.memo(Composer) + +export default Wrapped \ No newline at end of file diff --git a/packages/editor/src/screens/MagickV2/index.tsx b/packages/editor/src/screens/MagickV2/index.tsx index dca3836100..d21595a49e 100644 --- a/packages/editor/src/screens/MagickV2/index.tsx +++ b/packages/editor/src/screens/MagickV2/index.tsx @@ -1,14 +1,12 @@ -import { TabLayout, TabProvider } from "../../contexts/TabProvider"; +import { TabLayout } from "../../contexts/TabProvider"; const MagickV2 = () => { return ( - - -

MagickV2

+ +

MagickV2

+
-
-
); }; From b4e59bfcdee9ecabafb334abe772361e9a5f514b Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 26 Sep 2023 15:16:59 -0700 Subject: [PATCH 100/349] Turn off node genesis animation for now --- packages/editor/src/components/Node/Node.module.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/editor/src/components/Node/Node.module.css b/packages/editor/src/components/Node/Node.module.css index 22766fe4dd..cf61b5410b 100644 --- a/packages/editor/src/components/Node/Node.module.css +++ b/packages/editor/src/components/Node/Node.module.css @@ -9,7 +9,7 @@ } } .node { - animation: nodeGenesis 0.5s ease; + /* animation: nodeGenesis 0.5s ease; */ transition: background-color 0.05s ease, border 0.2s ease, outline-color 0.2s ease; min-width: var(--c30); From c03a8f2a3ec689b634bb4a02e88203f78864c773 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 26 Sep 2023 15:42:34 -0700 Subject: [PATCH 101/349] Add new side menu to layout --- packages/editor/src/App.css | 5 +++++ .../components/MenuBar/newMenuBar/index.tsx | 4 ++-- packages/editor/src/contexts/TabProvider.tsx | 21 ++++++++++++++----- .../editor/src/contexts/styles.module.scss | 4 ++++ 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/packages/editor/src/App.css b/packages/editor/src/App.css index d4b5dd5778..8cfb5f3989 100644 --- a/packages/editor/src/App.css +++ b/packages/editor/src/App.css @@ -14,6 +14,11 @@ body, height: 100%; } +/* Overrides tabs in dockview */ +.tab-layout .tabs-and-actions-container { + margin-left: 50px !important; +} + .expanding { position: absolute; top: 0; diff --git a/packages/editor/src/components/MenuBar/newMenuBar/index.tsx b/packages/editor/src/components/MenuBar/newMenuBar/index.tsx index ce6ded0f34..c1fdbebb77 100644 --- a/packages/editor/src/components/MenuBar/newMenuBar/index.tsx +++ b/packages/editor/src/components/MenuBar/newMenuBar/index.tsx @@ -17,7 +17,7 @@ import { RootState, Tab, activeTabSelector, changeEditorLayout, toggleAutoSave } * * @returns {JSX.Element} */ -const NewMenuBar = () => { +const NewMenuBar = (props) => { const navigate = useNavigate() const { publish, events } = usePubSub() const dispatch = useDispatch() @@ -497,7 +497,7 @@ const NewMenuBar = () => { return ( <> - + { setApi(event.api) }; - return () + return ( + <> + + + + ) } \ No newline at end of file diff --git a/packages/editor/src/contexts/styles.module.scss b/packages/editor/src/contexts/styles.module.scss index 7ea552c502..47f0bc91c1 100644 --- a/packages/editor/src/contexts/styles.module.scss +++ b/packages/editor/src/contexts/styles.module.scss @@ -5,3 +5,7 @@ z-index: 2; background-color: transparent; } + +.tabs-and-actions-container { + margin-left: 50px !important; +} From c75f6dd627900461c8591d2d99ec639be865fbed Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 26 Sep 2023 16:15:15 -0700 Subject: [PATCH 102/349] Move new menu into file drawer --- .../src/components/Drawer/AgentMenu.tsx | 2 + packages/editor/src/App.css | 4 +- packages/editor/src/contexts/TabProvider.tsx | 94 ++++++++++--------- .../editor/src/screens/Composer/index.tsx | 19 +++- 4 files changed, 74 insertions(+), 45 deletions(-) diff --git a/packages/core/client/src/components/Drawer/AgentMenu.tsx b/packages/core/client/src/components/Drawer/AgentMenu.tsx index b86f87ed9a..8a8d5d67db 100644 --- a/packages/core/client/src/components/Drawer/AgentMenu.tsx +++ b/packages/core/client/src/components/Drawer/AgentMenu.tsx @@ -27,6 +27,7 @@ import { useFeathers } from '../../providers/FeathersProvider' // todo fix this import import { useSpellList } from '../../../../../plugins/avatar/client/src/hooks/useSpellList' import { useTreeData } from '../../../../client/src/contexts/TreeDataProvider' +import NewMenuBar from '../../../../../editor/src/components/MenuBar/newMenuBar' import { AgentInterface, SpellInterface } from '@magickml/core' import { openTab, setCurrentAgentId } from '@magickml/state' @@ -303,6 +304,7 @@ function AgentMenu({ data, resetData }) { justifyContent: 'space-between', }} > + ) => { - return ( -
- {JSON.stringify(props.params)} -
- ); - }, - spell: (props: IDockviewPanelProps<{ tab: Tab, pubSub: any }>) => { - const pubSub = usePubSub() - return ( - -
- - +const getComponents = () => { + const pluginComponents = []; + + (pluginManager as ClientPluginManager) + .getGroupedClientRoutes() + .forEach(plugin => { + plugin.routes.map(route => { + pluginComponents.push({ + name: route.path.charAt(1).toUpperCase() + route.path.slice(2), + component: route.component, + }) + }) + }) + + console.log('pluginComponents', pluginComponents) + return { + Events, + Requests, + Settings, + Documents, + Agents, + ...pluginComponents.reduce((acc, obj) => { + acc[obj.name] = obj.component + return acc + }, {}), + spell: Composer, + default: (props: IDockviewPanelProps<{ title: string }>) => { + return ( +
+ {JSON.stringify(props.params)}
- - ); + ); + }, } } type DockviewTheme = 'dockview-theme-abyss' -type Tab = { +export type Tab = { id: string name: string spellName?: string @@ -177,18 +194,11 @@ export const TabLayout = ({ children }) => { }; return ( - <> - - - + + ) } \ No newline at end of file diff --git a/packages/editor/src/screens/Composer/index.tsx b/packages/editor/src/screens/Composer/index.tsx index 126e724a21..5a8dfd6de0 100644 --- a/packages/editor/src/screens/Composer/index.tsx +++ b/packages/editor/src/screens/Composer/index.tsx @@ -18,6 +18,9 @@ import DebugConsole from '../../windows/DebugConsole' import TextEditor from '../../windows/TextEditorWindow' import { RootState, spellApi } from '@magickml/state' import AgentControls from '../../windows/AgentControlWindow' +import { IDockviewPanelProps } from 'dockview' +import WorkspaceProvider from '../../contexts/WorkspaceProvider' +import { Tab } from '../../contexts/TabProvider' /** * Workspace component that handles different tabs and their layouts. @@ -124,6 +127,20 @@ const Composer = ({ tab, pubSub }) => { ) } -const Wrapped = React.memo(Composer) +const Wrapped = (props: IDockviewPanelProps<{ tab: Tab, pubSub: any }>) => { + const pubSub = usePubSub() + return ( + +
+ + +
+
+ ); +} export default Wrapped \ No newline at end of file From 68115a8125ef99217026d0d0b61cf37318d3c950 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 26 Sep 2023 16:35:47 -0700 Subject: [PATCH 103/349] Make Magick global in Router --- packages/editor/src/routes.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/editor/src/routes.tsx b/packages/editor/src/routes.tsx index a2b039291e..238fe143e1 100644 --- a/packages/editor/src/routes.tsx +++ b/packages/editor/src/routes.tsx @@ -40,6 +40,7 @@ const RenderComp = (props: { element: React.ElementType }) => { */ const MyRoutes = () => ( + } /> }> {(pluginManager as ClientPluginManager) .getGroupedClientRoutes() From 4d4ae4b5f9c95394a3ac1c74380aa3cd5b4b4f1d Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 26 Sep 2023 16:36:21 -0700 Subject: [PATCH 104/349] Refactor tabs to extract main layout from provider --- packages/editor/src/contexts/TabProvider.tsx | 106 ------------------ .../editor/src/screens/MagickV2/index.tsx | 7 +- .../src/screens/MagickV2/panels/mainPanel.tsx | 105 +++++++++++++++++ 3 files changed, 108 insertions(+), 110 deletions(-) create mode 100644 packages/editor/src/screens/MagickV2/panels/mainPanel.tsx diff --git a/packages/editor/src/contexts/TabProvider.tsx b/packages/editor/src/contexts/TabProvider.tsx index 39b0c97896..5b21cddc78 100644 --- a/packages/editor/src/contexts/TabProvider.tsx +++ b/packages/editor/src/contexts/TabProvider.tsx @@ -4,81 +4,7 @@ import { DockviewReact, DockviewReadyEvent, IDockviewPanelProps, SerializedDockview, } from 'dockview'; import { usePubSub } from "@magickml/client-core"; -import Composer from "../screens/Composer"; -import Events from '../screens/EventWindow' -import Requests from '../screens/RequestWindow' -import Settings from '../screens/settings/SettingsWindow' -import Documents from '../screens/DocumentWindow' -import Agents from '../screens/agents/AgentManagerWindow'; import { getWorkspaceLayout } from "@magickml/layouts"; -import NewMenuBar from "../components/MenuBar/newMenuBar"; -import { ClientPluginManager, pluginManager } from "@magickml/core"; - - -// we will move this out into the layouts package -function loadDefaultLayout(api: DockviewApi) { - api.addPanel({ - id: 'panel_1', - component: 'default', - params: { - spellId: 'root', - spellName: 'root', - type: 'spell', - } - }); - - api.addPanel({ - id: 'panel_2', - component: 'default', - }); - - api.addPanel({ - id: 'panel_3', - component: 'default', - }); -} - -const getComponents = () => { - const pluginComponents = []; - - (pluginManager as ClientPluginManager) - .getGroupedClientRoutes() - .forEach(plugin => { - plugin.routes.map(route => { - pluginComponents.push({ - name: route.path.charAt(1).toUpperCase() + route.path.slice(2), - component: route.component, - }) - }) - }) - - console.log('pluginComponents', pluginComponents) - return { - Events, - Requests, - Settings, - Documents, - Agents, - ...pluginComponents.reduce((acc, obj) => { - acc[obj.name] = obj.component - return acc - }, {}), - spell: Composer, - default: (props: IDockviewPanelProps<{ title: string }>) => { - return ( -
- {JSON.stringify(props.params)} -
- ); - }, - } -} type DockviewTheme = 'dockview-theme-abyss' @@ -107,7 +33,6 @@ type DocviewContext = { const TAB_LAYOUT_KEY = 'tab-layout' - // Creating the context const Context = createContext(undefined!) @@ -170,35 +95,4 @@ export const TabProvider = ({ children }) => { openTab } return {children} -} - -export const TabLayout = ({ children }) => { - const { theme, setTheme, setApi, api, setLayout, getLayout } = useTabLayout() - - const onReady = (event: DockviewReadyEvent) => { - - const layout = getLayout() - - let success = false; - - if (layout) { - event.api.fromJSON(layout); - success = true; - } - - if (!success) { - loadDefaultLayout(event.api); - } - - setApi(event.api) - }; - - return ( - - - ) } \ No newline at end of file diff --git a/packages/editor/src/screens/MagickV2/index.tsx b/packages/editor/src/screens/MagickV2/index.tsx index d21595a49e..af202f0257 100644 --- a/packages/editor/src/screens/MagickV2/index.tsx +++ b/packages/editor/src/screens/MagickV2/index.tsx @@ -1,11 +1,10 @@ -import { TabLayout } from "../../contexts/TabProvider"; + +import MainPanel from "./panels/mainPanel"; const MagickV2 = () => { return ( - -

MagickV2

-
+ ); }; diff --git a/packages/editor/src/screens/MagickV2/panels/mainPanel.tsx b/packages/editor/src/screens/MagickV2/panels/mainPanel.tsx new file mode 100644 index 0000000000..25033500b7 --- /dev/null +++ b/packages/editor/src/screens/MagickV2/panels/mainPanel.tsx @@ -0,0 +1,105 @@ +import { DockviewApi, DockviewReact, DockviewReadyEvent, IDockviewPanelProps } from "dockview"; +import { useTabLayout } from "../../../contexts/TabProvider"; +import Composer from "../../Composer"; +import Events from "../../EventWindow" +import Requests from "../../RequestWindow" +import Settings from "../../settings/SettingsWindow" +import Documents from "../../DocumentWindow" +import Agents from "../../agents/AgentManagerWindow"; +import { ClientPluginManager, pluginManager } from "@magickml/core"; + +// we will move this out into the layouts package +function loadDefaultLayout(api: DockviewApi) { + api.addPanel({ + id: 'panel_1', + component: 'default', + params: { + spellId: 'root', + spellName: 'root', + type: 'spell', + } + }); + + api.addPanel({ + id: 'panel_2', + component: 'default', + }); + + api.addPanel({ + id: 'panel_3', + component: 'default', + }); +} + +const getComponents = () => { + const pluginComponents = []; + + (pluginManager as ClientPluginManager) + .getGroupedClientRoutes() + .forEach(plugin => { + plugin.routes.map(route => { + pluginComponents.push({ + name: route.path.charAt(1).toUpperCase() + route.path.slice(2), + component: route.component, + }) + }) + }) + + return { + Events, + Requests, + Settings, + Documents, + Agents, + ...pluginComponents.reduce((acc, obj) => { + acc[obj.name] = obj.component + return acc + }, {}), + spell: Composer, + default: (props: IDockviewPanelProps<{ title: string }>) => { + return ( +
+ {JSON.stringify(props.params)} +
+ ); + }, + } +} + +const MainPanel = () => { + const { theme, setApi, getLayout } = useTabLayout() + + const onReady = (event: DockviewReadyEvent) => { + const layout = getLayout() + + let success = false; + + if (layout) { + event.api.fromJSON(layout); + success = true; + } + + if (!success) { + loadDefaultLayout(event.api); + } + + setApi(event.api) + }; + + return ( + + + ) +}; + +export default MainPanel \ No newline at end of file From fb39420941d3f0d156bcb11a75659ee10dcff010 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 26 Sep 2023 16:36:33 -0700 Subject: [PATCH 105/349] Add a global layout provider --- packages/editor/src/contexts/AppProviders.tsx | 2 + .../src/contexts/GlobalLayoutProvider.tsx | 107 ++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 packages/editor/src/contexts/GlobalLayoutProvider.tsx diff --git a/packages/editor/src/contexts/AppProviders.tsx b/packages/editor/src/contexts/AppProviders.tsx index 7f8e6f2b09..046ee8b705 100644 --- a/packages/editor/src/contexts/AppProviders.tsx +++ b/packages/editor/src/contexts/AppProviders.tsx @@ -4,6 +4,7 @@ import { createTheme, ThemeProvider } from '@mui/material'; import React from 'react'; import ToastProvider from './ToastProvider'; import { TabProvider } from './TabProvider'; +import { GlobalLayoutProvider } from './GlobalLayoutProvider'; // Create a dark theme for the application const darkTheme = createTheme({ @@ -26,6 +27,7 @@ function ComposeProviders({ config, children }) { [FeathersProvider, { token: config.token }], PubSubProvider, ToastProvider, + GlobalLayoutProvider, TabProvider ].reverse(); diff --git a/packages/editor/src/contexts/GlobalLayoutProvider.tsx b/packages/editor/src/contexts/GlobalLayoutProvider.tsx new file mode 100644 index 0000000000..bab9661b0a --- /dev/null +++ b/packages/editor/src/contexts/GlobalLayoutProvider.tsx @@ -0,0 +1,107 @@ +import { createContext, useContext, useEffect, useState } from "react" +import { + DockviewApi, + DockviewReact, DockviewReadyEvent, IDockviewPanelProps, SerializedDockview, +} from 'dockview'; + +// we will move this out into the layouts package +function loadDefaultLayout(api: DockviewApi) { + api.addPanel({ + id: 'panel_1', + component: 'default', + params: { + spellId: 'root', + spellName: 'root', + type: 'spell', + } + }); + + api.addPanel({ + id: 'panel_2', + component: 'default', + }); + + api.addPanel({ + id: 'panel_3', + component: 'default', + }); +} + +const getComponents = () => { + return { + default: (props: IDockviewPanelProps<{ title: string }>) => { + return ( +
+ {JSON.stringify(props.params)} +
+ ); + }, + } +} + +type DockviewTheme = 'dockview-theme-abyss' + +type DocviewContext = { + theme: DockviewTheme, + setTheme: (theme: DockviewTheme) => void, + api: DockviewApi, + setApi: (api: DockviewApi) => void, + getLayout: () => SerializedDockview | null, + setLayout: (layout: SerializedDockview) => void +} + +const LAYOUT_KEY = 'global-layout' + +// Creating the context +const Context = createContext(undefined!) + +// Helper hook to use Layout context +export const useGlobalLayout = () => useContext(Context) + +export const GlobalLayoutProvider = ({ children }) => { + const [theme, setTheme] = useState('dockview-theme-abyss') + const [api, setApi] = useState(); + + const getLayout = () => { + const layout = localStorage.getItem(LAYOUT_KEY) + + if (!layout) { + return null + } + return JSON.parse(localStorage.getItem(LAYOUT_KEY)) as SerializedDockview + } + + const setLayout = (layout: SerializedDockview) => { + localStorage.setItem(LAYOUT_KEY, JSON.stringify(layout)) + } + + useEffect(() => { + if (!api) { + return; + } + + // set up API event handlers + api.onDidLayoutChange(() => { + const layout = api.toJSON(); + + setLayout(layout) + }); + + }, [api]); + + const publicInterface = { + theme, + setTheme, + api, + setApi, + getLayout, + setLayout, + } + return {children} +} \ No newline at end of file From 6f927356fae007b606f91b624e6c5232c43f1601 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 26 Sep 2023 22:14:53 -0700 Subject: [PATCH 106/349] Add basic file drawer --- .../editor/src/screens/MagickV2/index.tsx | 82 ++++++++++++++++++- .../screens/MagickV2/panels/fileDrawer.tsx | 82 +++++++++++++++++++ 2 files changed, 161 insertions(+), 3 deletions(-) create mode 100644 packages/editor/src/screens/MagickV2/panels/fileDrawer.tsx diff --git a/packages/editor/src/screens/MagickV2/index.tsx b/packages/editor/src/screens/MagickV2/index.tsx index af202f0257..cdd3244a95 100644 --- a/packages/editor/src/screens/MagickV2/index.tsx +++ b/packages/editor/src/screens/MagickV2/index.tsx @@ -1,12 +1,88 @@ +import { GridviewApi, GridviewReact, GridviewReadyEvent, IGridviewPanelProps, Orientation } from "dockview"; import MainPanel from "./panels/mainPanel"; +import { useEffect, useState } from "react"; +import { useHotkeys } from 'react-hotkeys-hook' +import FileDrawer from "./panels/fileDrawer"; + +const components = { + MainPanel, + default: (props: IGridviewPanelProps<{ title: string }>) => { + return ( +
+ {JSON.stringify(props.params)} +
+ ); + }, + FileDrawer +}; + +const loadDefaultLayout = (api: GridviewApi) => { + api.addPanel({ + id: 'panel_1', + component: 'default', + params: { + title: 'Panel 1', + }, + maximumHeight: 15, + minimumHeight: 15, + }); + + api.addPanel({ + id: 'panel_3', + component: 'FileDrawer', + params: { + title: 'Panel 3', + }, + }); + + api.addPanel({ + id: 'panel_5', + component: 'MainPanel', + params: { + title: 'Panel 5', + }, + position: { referencePanel: 'panel_3', direction: 'right' }, + }) + api.addPanel({ + id: 'panel_6', + component: 'default', + params: { + title: 'Panel 6', + }, + position: { referencePanel: 'panel_5', direction: 'right' }, + }).api.setSize({ + width: 5 + }); + + console.log(api.toJSON()) +} const MagickV2 = () => { - return ( - + const onReady = (event: GridviewReadyEvent) => { + loadDefaultLayout(event.api); + }; + return ( + ); -}; + + // return ( + // + // ); +} export default MagickV2 \ No newline at end of file diff --git a/packages/editor/src/screens/MagickV2/panels/fileDrawer.tsx b/packages/editor/src/screens/MagickV2/panels/fileDrawer.tsx new file mode 100644 index 0000000000..4b8f866e25 --- /dev/null +++ b/packages/editor/src/screens/MagickV2/panels/fileDrawer.tsx @@ -0,0 +1,82 @@ +import { IGridviewPanelProps } from "dockview"; +import { useEffect, useState } from "react"; +import { useHotkeys } from "react-hotkeys-hook"; + +const ANIMATION_DURATION = 1; + +const FileDrawer = (props: IGridviewPanelProps<{ title: string }>) => { + const [isAnimating, setIsAnimating] = useState(false); + const [currentWidth, setCurrentWidth] = useState(0); + const [targetWidth, setTargetWidth] = useState(0); + + useHotkeys( + 'ctrl+b', + () => { + if (currentWidth > 0) { + close(); + } else { + open(); + } + } + ); + + const animateSize = (initialWidth: number, targetWidth: number) => { + let startTimestamp: number | null = null; + + const frame = (timestamp: number) => { + if (!startTimestamp) startTimestamp = timestamp; + + const elapsed = timestamp - startTimestamp; + const progress = Math.min(elapsed / ANIMATION_DURATION, 1); + + const currentWidth = initialWidth + (targetWidth - initialWidth) * progress; + props.api.setSize({ width: currentWidth }); + + if (progress < 1) { + requestAnimationFrame(frame); + } else { + setIsAnimating(false); + } + }; + + setIsAnimating(true); + requestAnimationFrame(frame); + }; + + const open = () => { + if (!isAnimating) { + animateSize(0, targetWidth); + } + }; + + const close = () => { + if (!isAnimating) { + setTargetWidth(currentWidth); + animateSize(currentWidth, 0); + } + }; + + // useEffect is now used only if you need an initial animation or similar effect + useEffect(() => { + // Example: animate the opening when the component mounts + const dispose = props.api.onDidDimensionsChange(event => { + setCurrentWidth(event.width); + }) + + props.api.setSize({ width: 200 }); + + return () => { + dispose.dispose() + } + }, [props.api]); + + return ( +
+ {props.params.title} + + +
+ ); +} + +export default FileDrawer \ No newline at end of file From 65c83a1e892f66a08081445669e1d86df9489584 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 26 Sep 2023 22:42:53 -0700 Subject: [PATCH 107/349] Fix MUI errors on menu rendering --- .../src/components/Drawer/AgentMenu.tsx | 173 ++++---- .../components/Drawer/Newsidebar/index.tsx | 405 +++++++++--------- .../components/MenuBar/newMenuBar/index.tsx | 180 ++++---- 3 files changed, 365 insertions(+), 393 deletions(-) diff --git a/packages/core/client/src/components/Drawer/AgentMenu.tsx b/packages/core/client/src/components/Drawer/AgentMenu.tsx index 8a8d5d67db..a43355f287 100644 --- a/packages/core/client/src/components/Drawer/AgentMenu.tsx +++ b/packages/core/client/src/components/Drawer/AgentMenu.tsx @@ -358,101 +358,98 @@ function AgentMenu({ data, resetData }) { ? selectedAgentData.name : agent?.name return ( - <> - - {editMode && selectedAgentData?.id === agent?.id ? ( - <> - - setSelectedAgentData({ - ...selectedAgentData, - name: e.target.value, - }) - } - placeholder="Add new agent name here" - onKeyDown={e => { - if (e.key === 'Enter') { - update(selectedAgentData.id) - setEditMode(false) - setOldName('') - } - }} - /> - } - onClick={e => { + + {editMode && selectedAgentData?.id === agent?.id ? ( +
+ + setSelectedAgentData({ + ...selectedAgentData, + name: e.target.value, + }) + } + placeholder="Add new agent name here" + onKeyDown={e => { + if (e.key === 'Enter') { update(selectedAgentData.id) setEditMode(false) setOldName('') - }} - /> - } - onClick={e => { - setSelectedAgentData({ - ...selectedAgentData, - name: oldName, - }) - setOldName('') - setEditMode(false) - }} - /> - - ) : ( - - - handleSelectAgent(agent)} - primary={primaryText} - sx={{ ml: 2 }} - /> - - )} - - handleToggleMenu2(agent, event)} - aria-controls="menu2" - aria-haspopup="true" + }} + /> + } + onClick={e => { + update(selectedAgentData.id) + setEditMode(false) + setOldName('') + }} + /> + } + onClick={e => { + setSelectedAgentData({ + ...selectedAgentData, + name: oldName, + }) + setOldName('') + setEditMode(false) + }} /> - - - - +
+ ) : ( + + + handleSelectAgent(agent)} + primary={primaryText} + sx={{ ml: 2 }} + /> + + )} + + handleToggleMenu2(agent, event)} + aria-controls="menu2" + aria-haspopup="true" + /> + +
) })} - + = ({ open, }) => { const { openTab } = useTabLayout() - const dispatch = useDispatch() const location = useLocation() - const navigate = useNavigate() const drawerItems = (pluginManager as ClientPluginManager).getDrawerItems() let lastPlugin: string | null = null let divider = false return ( - <> - {drawerItems.map(item => { - if (item.plugin !== lastPlugin) { - divider = false - lastPlugin = item.plugin - } else { - divider = false - } - return ( -
- {divider && } - { - openTab({ - name: item.text, - type: item.text, - switchActive: true, - id: item.text, - }) - }} - text={item.text} - tooltip="Avatar and Tasks Tooltip" - tooltipText={item.tooltip} - /> -
- ) - })} - + drawerItems.map(item => { + if (item.plugin !== lastPlugin) { + divider = false + lastPlugin = item.plugin + } else { + divider = false + } + return ( +
+ {divider && } + { + openTab({ + name: item.text, + type: item.text, + switchActive: true, + id: item.text, + }) + }} + text={item.text} + tooltip="Avatar and Tasks Tooltip" + tooltipText={item.tooltip} + /> +
+ ) + }) ) } @@ -226,9 +222,8 @@ export function NewSidebar(DrawerProps): JSX.Element { const { openTab } = useTabLayout() const location = useLocation() const navigate = useNavigate() - const dispatch = useDispatch() const [isAPIKeysSet, setAPIKeysSet] = useState(false) - const [openDrawer, setOpenDrawer] = useState(true) + const [openDrawer] = useState(true) // State to keep track of the anchor element of the menu and cursor position const [menuAnchorEl, setMenuAnchorEl] = useState(null) const [cursorPosition, setCursorPosition] = useState({ x: 0, y: 0 }) @@ -350,20 +345,6 @@ export function NewSidebar(DrawerProps): JSX.Element { })() }, [config?.apiUrl]) - useEffect(() => { - const handleKeyDown = (event: KeyboardEvent) => { - if (event.key.toLowerCase() === 'b' && event.ctrlKey) { - setOpenDrawer(openDrawer => !openDrawer) - } - } - - document.addEventListener('keydown', handleKeyDown) - - return () => { - document.removeEventListener('keydown', handleKeyDown) - } - }, []) - // Function to handle the click event on the hideMenu div const handleHideMenuClick = (event: React.MouseEvent) => { setMenuAnchorEl(event.currentTarget) @@ -390,179 +371,175 @@ export function NewSidebar(DrawerProps): JSX.Element { }, [menuAnchorEl]) return ( -
- - <> - - - - { - openTab({ - name: 'Events', - type: 'Events', - switchActive: true, - id: 'events', - }) - }} - text="Events" - tooltip="Events Tooltip" - tooltipText={drawerTooltipText.events} - /> - { - openTab({ - name: 'Requests', - type: 'Requests', - switchActive: true, - id: 'requests', - }) - }} - text="Requests" - tooltip="Requests Tooltip" - tooltipText={drawerTooltipText.requests} - /> +
+ - - - { - openTab({ - name: 'Settings', - type: 'Settings', - switchActive: true, - id: 'settings', - }) + + { + openTab({ + name: 'Events', + type: 'Events', + switchActive: true, + id: 'events', + }) + }} + text="Events" + tooltip="Events Tooltip" + tooltipText={drawerTooltipText.events} + /> + { + openTab({ + name: 'Requests', + type: 'Requests', + switchActive: true, + id: 'requests', + }) + }} + text="Requests" + tooltip="Requests Tooltip" + tooltipText={drawerTooltipText.requests} + /> + + + + { + openTab({ + name: 'Settings', + type: 'Settings', + switchActive: true, + id: 'settings', + }) + }} + text="Settings" + tooltip="Settings Tooltip" + tooltipText={drawerTooltipText.settings} + /> + {!isAPIKeysSet && } + + + +
+ + +
+ , + { depth, isOpen, onToggle } + ) => ( + + )} + onDrop={handleDrop} + classes={{ + root: styles.treeRoot, + draggingSource: styles.draggingSource, + dropTarget: styles.dropTarget, }} - text="Settings" - tooltip="Settings Tooltip" - tooltipText={drawerTooltipText.settings} /> - {!isAPIKeysSet && } - - - -
- - -
- , - { depth, isOpen, onToggle } - ) => ( - - )} - onDrop={handleDrop} - classes={{ - root: styles.treeRoot, - draggingSource: styles.draggingSource, - dropTarget: styles.dropTarget, - }} - /> -
-
-
-
- - Notion (coming soon) -
-
- - - Google Drive (coming soon) - -
+ +
+
+
+ + Notion (coming soon) +
+
+ + + Google Drive (coming soon) + +
+
+
+ +
+ + New Folder
+
{ + navigate('/home/create-new') + }} > - -
- - New Folder -
- -
{ - navigate('/home/create-new') - }} - > - - New Spell -
- -
- - New Prompt -
- -
{ - navigate( - `/magick/Documents-${encodeURIComponent(btoa('Documents'))}` - ) - }} - > - - New Document -
-
+ + New Spell +
+ +
+ + New Prompt
-
-
- - MP -
- -

300/500 monthly MP

+ +
{ + navigate( + `/magick/Documents-${encodeURIComponent(btoa('Documents'))}` + ) + }} + > + + New Document
- - +
+
+
+
+ + MP +
+ +

300/500 monthly MP

+
) } diff --git a/packages/editor/src/components/MenuBar/newMenuBar/index.tsx b/packages/editor/src/components/MenuBar/newMenuBar/index.tsx index c1fdbebb77..4c94c35b87 100644 --- a/packages/editor/src/components/MenuBar/newMenuBar/index.tsx +++ b/packages/editor/src/components/MenuBar/newMenuBar/index.tsx @@ -496,7 +496,7 @@ const NewMenuBar = (props) => { })) return ( - <> +
@@ -516,104 +516,102 @@ const NewMenuBar = (props) => { variant="menu" > {Object.keys(menuBarItems).map((item, index) => ( - <> - - {Object.keys(menuBarItems[item].items).map( - (subMenuKey, subIndex) => { - const hotKeyLabel = menuBarItems[item] - ? menuBarItems[item].items[subMenuKey].hotKey - : '' - // add useHotkeys for each sub-menu item - if (hotKeyLabel) { - useHotkeys( - menuBarItems[item].items[subMenuKey].hotKey, - event => { - event.preventDefault() - menuBarItems[item].items[subMenuKey].onClick() - }, - { enableOnFormTags: ['INPUT'] }, - [menuBarItems[item].items[subMenuKey].onClick] - ) - } - - return ( - { - menuBarItems[item].items[subMenuKey].onClick(e) - handleMenuClose() - }} - sx={{ - '&:hover, &:focus': { - background: '#49545A', - outline: 'none', - }, - }} - divider={true} - > -
-

- {menuBarItems[item].items[subMenuKey].hasOwnProperty( - 'isActive' - ) && ( - - ●{' '} - - )} - {subMenuKey - .replace(/_/g, ' ') - .charAt(0) - .toUpperCase() + subMenuKey.slice(1)} -

- - {hotKeyLabel && - parseStringToUnicode( - hotKeyLabel.slice(0, hotKeyLabel.indexOf(',')) - )} -
-
+ }, + }} + > + {Object.keys(menuBarItems[item].items).map( + (subMenuKey, subIndex) => { + const hotKeyLabel = menuBarItems[item] + ? menuBarItems[item].items[subMenuKey].hotKey + : '' + // add useHotkeys for each sub-menu item + if (hotKeyLabel) { + useHotkeys( + menuBarItems[item].items[subMenuKey].hotKey, + event => { + event.preventDefault() + menuBarItems[item].items[subMenuKey].onClick() + }, + { enableOnFormTags: ['INPUT'] }, + [menuBarItems[item].items[subMenuKey].onClick] ) } - )} -
- + + return ( + { + menuBarItems[item].items[subMenuKey].onClick(e) + handleMenuClose() + }} + sx={{ + '&:hover, &:focus': { + background: '#49545A', + outline: 'none', + }, + }} + divider={true} + > +
+

+ {menuBarItems[item].items[subMenuKey].hasOwnProperty( + 'isActive' + ) && ( + + ●{' '} + + )} + {subMenuKey + .replace(/_/g, ' ') + .charAt(0) + .toUpperCase() + subMenuKey.slice(1)} +

+ + {hotKeyLabel && + parseStringToUnicode( + hotKeyLabel.slice(0, hotKeyLabel.indexOf(',')) + )} +
+
+ ) + } + )} + ))}
- +
) } From 78e7ad1ecdb5a7deb4a211f44564f4527a7b1c7f Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 26 Sep 2023 23:21:16 -0700 Subject: [PATCH 108/349] Hook up tree provider and fix up sidebar more --- .../client/src/components/Drawer/AgentMenu.tsx | 12 ++++++++---- .../src/components/Drawer/Newsidebar/index.tsx | 14 +++++++++++--- packages/core/client/src/components/index.ts | 2 ++ packages/editor/src/screens/MagickV2/index.tsx | 8 +++----- .../src/screens/MagickV2/panels/fileDrawer.tsx | 9 +++++---- 5 files changed, 29 insertions(+), 16 deletions(-) diff --git a/packages/core/client/src/components/Drawer/AgentMenu.tsx b/packages/core/client/src/components/Drawer/AgentMenu.tsx index a43355f287..bfbdd6b04d 100644 --- a/packages/core/client/src/components/Drawer/AgentMenu.tsx +++ b/packages/core/client/src/components/Drawer/AgentMenu.tsx @@ -311,10 +311,12 @@ function AgentMenu({ data, resetData }) { src={ currentAgent && currentAgent.image ? `https://pub-58d22deb43dc48e792b7b7468610b5f9.r2.dev/magick-dev/agents/${currentAgent.image}` - : currentAgent?.name?.at(0) || 'A' + : undefined // Ensure it's undefined if there's no valid image URL. } sx={{ width: 24, height: 24 }} - /> + > + {currentAgent?.name?.at(0) || 'A'} + + > + {primaryText.at(0) || 'A'} + handleSelectAgent(agent)} primary={primaryText} diff --git a/packages/core/client/src/components/Drawer/Newsidebar/index.tsx b/packages/core/client/src/components/Drawer/Newsidebar/index.tsx index 6726c23346..1b33c9140f 100644 --- a/packages/core/client/src/components/Drawer/Newsidebar/index.tsx +++ b/packages/core/client/src/components/Drawer/Newsidebar/index.tsx @@ -233,6 +233,11 @@ export function NewSidebar(DrawerProps): JSX.Element { const token = globalConfig?.token const { treeData, setTreeData, setAgentUpdate } = useTreeData() + + useEffect(() => { + console.log("!!!!!!!!!TREE DATA", treeData) + }, [treeData]) + const handleDrop = (newTree: NodeModel[]) => { setTreeData(newTree) } @@ -522,9 +527,12 @@ export function NewSidebar(DrawerProps): JSX.Element {
{ - navigate( - `/magick/Documents-${encodeURIComponent(btoa('Documents'))}` - ) + openTab({ + name: 'Documents', + type: 'Documents', + switchActive: true, + id: 'Documents', + }) }} > diff --git a/packages/core/client/src/components/index.ts b/packages/core/client/src/components/index.ts index 633dd3dd6e..ab2d1d4493 100644 --- a/packages/core/client/src/components/index.ts +++ b/packages/core/client/src/components/index.ts @@ -11,6 +11,8 @@ export { Chip } from './Chip' // Export Drawer component export { DrawerProvider } from './Drawer' +export { NewSidebar } from './Drawer/Newsidebar' + // Export Icon and componentCategories export { componentCategories, Icon } from './Icon' diff --git a/packages/editor/src/screens/MagickV2/index.tsx b/packages/editor/src/screens/MagickV2/index.tsx index cdd3244a95..c8b06675c1 100644 --- a/packages/editor/src/screens/MagickV2/index.tsx +++ b/packages/editor/src/screens/MagickV2/index.tsx @@ -1,12 +1,11 @@ import { GridviewApi, GridviewReact, GridviewReadyEvent, IGridviewPanelProps, Orientation } from "dockview"; import MainPanel from "./panels/mainPanel"; -import { useEffect, useState } from "react"; -import { useHotkeys } from 'react-hotkeys-hook' import FileDrawer from "./panels/fileDrawer"; const components = { MainPanel, + FileDrawer, default: (props: IGridviewPanelProps<{ title: string }>) => { return (
); }, - FileDrawer }; const loadDefaultLayout = (api: GridviewApi) => { @@ -37,6 +35,8 @@ const loadDefaultLayout = (api: GridviewApi) => { api.addPanel({ id: 'panel_3', component: 'FileDrawer', + minimumWidth: 200, + maximumWidth: 300, params: { title: 'Panel 3', }, @@ -60,8 +60,6 @@ const loadDefaultLayout = (api: GridviewApi) => { }).api.setSize({ width: 5 }); - - console.log(api.toJSON()) } const MagickV2 = () => { diff --git a/packages/editor/src/screens/MagickV2/panels/fileDrawer.tsx b/packages/editor/src/screens/MagickV2/panels/fileDrawer.tsx index 4b8f866e25..addf4c9dca 100644 --- a/packages/editor/src/screens/MagickV2/panels/fileDrawer.tsx +++ b/packages/editor/src/screens/MagickV2/panels/fileDrawer.tsx @@ -1,3 +1,4 @@ +import { NewSidebar, TreeDataProvider } from "@magickml/client-core"; import { IGridviewPanelProps } from "dockview"; import { useEffect, useState } from "react"; import { useHotkeys } from "react-hotkeys-hook"; @@ -71,10 +72,10 @@ const FileDrawer = (props: IGridviewPanelProps<{ title: string }>) => { }, [props.api]); return ( -
- {props.params.title} - - +
+ + +
); } From 9fa5c4e00d1487e926a02c14d67707b778bacba1 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 26 Sep 2023 23:34:03 -0700 Subject: [PATCH 109/349] Fix agents links --- .../client/src/components/Drawer/AgentMenu.tsx | 18 ++++++++++-------- packages/editor/src/screens/MagickV2/index.tsx | 6 ++++++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/packages/core/client/src/components/Drawer/AgentMenu.tsx b/packages/core/client/src/components/Drawer/AgentMenu.tsx index bfbdd6b04d..35ed1f0c96 100644 --- a/packages/core/client/src/components/Drawer/AgentMenu.tsx +++ b/packages/core/client/src/components/Drawer/AgentMenu.tsx @@ -29,7 +29,8 @@ import { useSpellList } from '../../../../../plugins/avatar/client/src/hooks/use import { useTreeData } from '../../../../client/src/contexts/TreeDataProvider' import NewMenuBar from '../../../../../editor/src/components/MenuBar/newMenuBar' import { AgentInterface, SpellInterface } from '@magickml/core' -import { openTab, setCurrentAgentId } from '@magickml/state' +import { setCurrentAgentId } from '@magickml/state' +import { useTabLayout } from '../../../../../editor/src/contexts/TabProvider' interface Spell { id: number @@ -39,6 +40,7 @@ interface Spell { function AgentMenu({ data, resetData }) { const { client } = useFeathers() + const { openTab } = useTabLayout() const [openMenu1, setOpenMenu1] = useState(null) const [openConfirm, setOpenConfirm] = useState(false) const [openMenu2, setOpenMenu2] = useState(null) @@ -258,12 +260,12 @@ function AgentMenu({ data, resetData }) { if (matchingSpell) { const spellName = matchingSpell.name - dispatch(openTab({ - id: agent.rootSpellId, + openTab({ + id: spellName, name: spellName, spellName: spellName, type: 'spell', - })) + }) } } handleCloseMenu1() @@ -464,12 +466,12 @@ function AgentMenu({ data, resetData }) { }, }} onClick={() => { - dispatch(openTab({ + openTab({ id: "Agents", name: 'Agents', type: 'Agents', switchActive: true - })) + }) }} > { - dispatch(openTab({ + openTab({ id: "Agents", name: 'Agents', type: 'Agents', switchActive: true - })) + }) }} > Other Options diff --git a/packages/editor/src/screens/MagickV2/index.tsx b/packages/editor/src/screens/MagickV2/index.tsx index c8b06675c1..edb4fd381d 100644 --- a/packages/editor/src/screens/MagickV2/index.tsx +++ b/packages/editor/src/screens/MagickV2/index.tsx @@ -22,6 +22,8 @@ const components = { }; const loadDefaultLayout = (api: GridviewApi) => { + + // Bottom status bar api.addPanel({ id: 'panel_1', component: 'default', @@ -32,6 +34,7 @@ const loadDefaultLayout = (api: GridviewApi) => { minimumHeight: 15, }); + // Left side file drawer api.addPanel({ id: 'panel_3', component: 'FileDrawer', @@ -42,6 +45,7 @@ const loadDefaultLayout = (api: GridviewApi) => { }, }); + // Main panel in the in the middle api.addPanel({ id: 'panel_5', component: 'MainPanel', @@ -50,6 +54,8 @@ const loadDefaultLayout = (api: GridviewApi) => { }, position: { referencePanel: 'panel_3', direction: 'right' }, }) + + // Right side console panel api.addPanel({ id: 'panel_6', component: 'default', From a7645524c5e13bb289d91133cb9d7d1cdfd27937 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 27 Sep 2023 00:03:17 -0700 Subject: [PATCH 110/349] Hook up open close keyhandler for file drawer --- .../src/components/Drawer/CustomNode.tsx | 1 + .../components/Drawer/Newsidebar/index.tsx | 4 ++-- .../src/components/Drawer/menu.module.css | 1 + .../client/src/providers/PubSubProvider.tsx | 10 +++++++++ packages/core/shared/src/types.ts | 1 + .../editor/src/screens/MagickV2/index.tsx | 5 ----- .../screens/MagickV2/panels/fileDrawer.tsx | 21 +++++++++++++++++-- 7 files changed, 34 insertions(+), 9 deletions(-) diff --git a/packages/core/client/src/components/Drawer/CustomNode.tsx b/packages/core/client/src/components/Drawer/CustomNode.tsx index 43ae061663..8fd92d2e3c 100644 --- a/packages/core/client/src/components/Drawer/CustomNode.tsx +++ b/packages/core/client/src/components/Drawer/CustomNode.tsx @@ -234,6 +234,7 @@ export const CustomNode: React.FC = props => { sx={{ cursor: 'pointer', marginLeft: '8px', + whiteSpace: 'nowrap' }} onClick={handleClick} onContextMenu={handleContextMenu} diff --git a/packages/core/client/src/components/Drawer/Newsidebar/index.tsx b/packages/core/client/src/components/Drawer/Newsidebar/index.tsx index 1b33c9140f..975986f4a6 100644 --- a/packages/core/client/src/components/Drawer/Newsidebar/index.tsx +++ b/packages/core/client/src/components/Drawer/Newsidebar/index.tsx @@ -472,11 +472,11 @@ export function NewSidebar(DrawerProps): JSX.Element {
- Notion (coming soon) + Notion (coming soon)
- + Google Drive (coming soon)
diff --git a/packages/core/client/src/components/Drawer/menu.module.css b/packages/core/client/src/components/Drawer/menu.module.css index ea596205b5..2c16a3a1d7 100644 --- a/packages/core/client/src/components/Drawer/menu.module.css +++ b/packages/core/client/src/components/Drawer/menu.module.css @@ -38,6 +38,7 @@ ul ul ul li { .credits { padding: 0 1rem; margin-top: auto; + white-space: nowrap; } .creditCount { diff --git a/packages/core/client/src/providers/PubSubProvider.tsx b/packages/core/client/src/providers/PubSubProvider.tsx index 4352c0c943..2846d129c8 100644 --- a/packages/core/client/src/providers/PubSubProvider.tsx +++ b/packages/core/client/src/providers/PubSubProvider.tsx @@ -5,6 +5,7 @@ import { PubSubContext, PubSubData, PubSubEvents } from '@magickml/core' import PubSub from 'pubsub-js' import { createContext, useContext, useEffect } from 'react' import { useFeathers } from './FeathersProvider' +import { useHotkeys } from 'react-hotkeys-hook' // Create new context for PubSub const Context = createContext(undefined!) @@ -23,6 +24,7 @@ export const events: PubSubEvents = { TOGGLE_SNAP: 'toggleSnap', RUN_AGENT: 'runAgent', SEND_COMMAND: 'sendCommand', + TOGGLE_FILE_DRAWER: 'toggleFileDrawer', $SUBSPELL_UPDATED: spellId => `subspellUpdated:${spellId}`, $TRIGGER: (tabId, nodeId) => `triggerNode:${tabId}:${nodeId ?? 'default'}`, $PLAYTEST_INPUT: tabId => `playtestInput:${tabId}`, @@ -79,6 +81,14 @@ export const PubSubProvider = ({ children }) => { } } + useHotkeys('ctrl+b,cmd+b', () => { + publish(events.TOGGLE_FILE_DRAWER, {}) + }) + + useHotkeys('ctrl+c', (event) => { + console.log('TRIGGER TAB SWITCH') + }) + useEffect(() => { if (!client) return diff --git a/packages/core/shared/src/types.ts b/packages/core/shared/src/types.ts index 5d1c6e9eb6..2c8ac18ffd 100644 --- a/packages/core/shared/src/types.ts +++ b/packages/core/shared/src/types.ts @@ -228,6 +228,7 @@ export type PubSubEvents = { TOGGLE_SNAP: string RUN_AGENT: string SEND_COMMAND: string + TOGGLE_FILE_DRAWER: string $SUBSPELL_UPDATED: (spellName: string) => string $TRIGGER: (tabId: string, nodeId?: number) => string $RESET_HIGHLIGHTS: (tabId: string) => string diff --git a/packages/editor/src/screens/MagickV2/index.tsx b/packages/editor/src/screens/MagickV2/index.tsx index edb4fd381d..bfd0935358 100644 --- a/packages/editor/src/screens/MagickV2/index.tsx +++ b/packages/editor/src/screens/MagickV2/index.tsx @@ -38,7 +38,6 @@ const loadDefaultLayout = (api: GridviewApi) => { api.addPanel({ id: 'panel_3', component: 'FileDrawer', - minimumWidth: 200, maximumWidth: 300, params: { title: 'Panel 3', @@ -83,10 +82,6 @@ const MagickV2 = () => { className="dockview-theme-abyss" /> ); - - // return ( - // - // ); } export default MagickV2 \ No newline at end of file diff --git a/packages/editor/src/screens/MagickV2/panels/fileDrawer.tsx b/packages/editor/src/screens/MagickV2/panels/fileDrawer.tsx index addf4c9dca..709438f7bb 100644 --- a/packages/editor/src/screens/MagickV2/panels/fileDrawer.tsx +++ b/packages/editor/src/screens/MagickV2/panels/fileDrawer.tsx @@ -1,14 +1,17 @@ -import { NewSidebar, TreeDataProvider } from "@magickml/client-core"; +import { NewSidebar, TreeDataProvider, usePubSub } from "@magickml/client-core"; import { IGridviewPanelProps } from "dockview"; import { useEffect, useState } from "react"; import { useHotkeys } from "react-hotkeys-hook"; -const ANIMATION_DURATION = 1; +const ANIMATION_DURATION = 50; const FileDrawer = (props: IGridviewPanelProps<{ title: string }>) => { const [isAnimating, setIsAnimating] = useState(false); const [currentWidth, setCurrentWidth] = useState(0); const [targetWidth, setTargetWidth] = useState(0); + const { events, subscribe } = usePubSub() + + const { TOGGLE_FILE_DRAWER } = events useHotkeys( 'ctrl+b', @@ -57,6 +60,20 @@ const FileDrawer = (props: IGridviewPanelProps<{ title: string }>) => { } }; + useEffect(() => { + const unsubscribe = subscribe(TOGGLE_FILE_DRAWER, () => { + if (currentWidth > 0) { + close(); + } else { + open(); + } + }) + + return () => { + unsubscribe() + } + }, [currentWidth, open, close, subscribe, TOGGLE_FILE_DRAWER]) + // useEffect is now used only if you need an initial animation or similar effect useEffect(() => { // Example: animate the opening when the component mounts From 39a2baa9c77daa75a23c7e2eb5d3c92be6e82c28 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 27 Sep 2023 00:44:19 -0700 Subject: [PATCH 111/349] Main workspace windows now rendered in tab --- packages/editor/src/contexts/TabProvider.tsx | 3 +- .../src/screens/MagickV2/panels/mainPanel.tsx | 2 +- .../screens/MagickV2/workspaces/composer.tsx | 231 ++++++++++++++++++ .../editor/src/windows/InspectorWindow.tsx | 28 +-- 4 files changed, 248 insertions(+), 16 deletions(-) create mode 100644 packages/editor/src/screens/MagickV2/workspaces/composer.tsx diff --git a/packages/editor/src/contexts/TabProvider.tsx b/packages/editor/src/contexts/TabProvider.tsx index 5b21cddc78..aa2f1b9a8f 100644 --- a/packages/editor/src/contexts/TabProvider.tsx +++ b/packages/editor/src/contexts/TabProvider.tsx @@ -80,7 +80,8 @@ export const TabProvider = ({ children }) => { id: tab.name, component: tab.type, params: { - tab + tab, + theme } }); } diff --git a/packages/editor/src/screens/MagickV2/panels/mainPanel.tsx b/packages/editor/src/screens/MagickV2/panels/mainPanel.tsx index 25033500b7..6bfbb8b323 100644 --- a/packages/editor/src/screens/MagickV2/panels/mainPanel.tsx +++ b/packages/editor/src/screens/MagickV2/panels/mainPanel.tsx @@ -1,12 +1,12 @@ import { DockviewApi, DockviewReact, DockviewReadyEvent, IDockviewPanelProps } from "dockview"; import { useTabLayout } from "../../../contexts/TabProvider"; -import Composer from "../../Composer"; import Events from "../../EventWindow" import Requests from "../../RequestWindow" import Settings from "../../settings/SettingsWindow" import Documents from "../../DocumentWindow" import Agents from "../../agents/AgentManagerWindow"; import { ClientPluginManager, pluginManager } from "@magickml/core"; +import Composer from "../workspaces/composer"; // we will move this out into the layouts package function loadDefaultLayout(api: DockviewApi) { diff --git a/packages/editor/src/screens/MagickV2/workspaces/composer.tsx b/packages/editor/src/screens/MagickV2/workspaces/composer.tsx new file mode 100644 index 0000000000..4c0595d2c1 --- /dev/null +++ b/packages/editor/src/screens/MagickV2/workspaces/composer.tsx @@ -0,0 +1,231 @@ +import { useConfig, useFeathers, usePubSub } from "@magickml/client-core"; +import { + DockviewApi, + DockviewReact, + DockviewReadyEvent, + IDockviewPanelProps +} from "dockview"; +import { useEffect, useRef } from "react"; +import { SpellInterface, spellApi } from "@magickml/core"; + + +import WorkspaceProvider from '../../../contexts/WorkspaceProvider' +import { debounce } from '../../../utils/debounce' +import EventHandler from '../../../components/EventHandler' + +import EditorWindow from '../../../windows/EditorWindow' +import Inspector from '../../../windows/InspectorWindow' +import Playtest from '../../../windows/PlaytestWindow' + +import DebugConsole from '../../../windows/DebugConsole' +import TextEditor from '../../../windows/TextEditorWindow' +import { useEditor } from '../../../contexts/EditorProvider' +import { Tab } from '../../../contexts/TabProvider' +import { useSelector } from "react-redux"; +import { RootState } from "@magickml/state"; + +function loadDefaultLayout(api: DockviewApi, tab) { + const panel = api.addPanel({ + id: "panel_1", + component: "default", + params: { + title: "Panel 1" + } + }); + + panel.group.locked = true; + panel.group.header.hidden = true; + + api.addPanel({ + id: "Composer", + component: "EditorWindow", + params: { + title: "Composer", + tab + } + }); + + api + .addPanel({ + id: "Inspector", + component: "Inspector", + params: { + title: "Inspector", + tab + }, + position: { referencePanel: "Composer", direction: "left" } + }) + .api.setSize({ + width: 300 + }); + + api.addPanel({ + id: "Text Editor", + component: "TextEditor", + params: { + title: "Text Editor", + tab + }, + position: { referencePanel: "Inspector", direction: "below" } + }); + + // panel5.group!.model.header.hidden = true; + // panel5.group!.model.locked = true; + + api + .addPanel({ + id: "Playtest", + component: "Playtest", + params: { + title: "Playtest", + tab + }, + position: { referencePanel: "Composer", direction: "below" } + }) + .api.setSize({ + height: 300 + }); + + api.addPanel({ + id: "Console", + component: "DebugConsole", + params: { + title: "Console", + tab + }, + position: { referencePanel: "Playtest", direction: "right" } + }); +} + +const components = { + default: (props: IDockviewPanelProps<{ title: string }>) => { + return ( +
+ {props.params.title} +
+ ); + }, + Playtest: (props: IDockviewPanelProps<{ tab: Tab }>) => { + return ; + }, + Inspector: (props: IDockviewPanelProps<{ tab: Tab }>) => { + return ; + }, + TextEditor: (props: IDockviewPanelProps<{ tab: Tab }>) => { + return ; + }, + EditorWindow: (props: IDockviewPanelProps<{ tab: Tab }>) => { + return ; + }, + DebugConsole: (props: IDockviewPanelProps<{ tab: Tab }>) => { + return ; + }, + // AgentControls +}; + +export const Composer = ({ theme, tab, pubSub }) => { + const config = useConfig() + const spellRef = useRef() + const { events, publish } = usePubSub() + const [loadSpell, { data: spellData }] = spellApi.useLazyGetSpellByIdQuery() + const { editor, serialize } = useEditor() + const FeathersContext = useFeathers() + const client = FeathersContext?.client + const preferences = useSelector((state: RootState) => state.preferences) + + // Set up autosave for the workspaces + useEffect(() => { + if (!editor?.on) return + const unsubscribe = editor.on( + 'nodecreated noderemoved connectioncreated connectionremoved nodetranslated', + debounce(async data => { + if (tab.type === 'spell' && spellRef.current) { + publish(events.$SAVE_SPELL_DIFF(tab.id), { graph: serialize() }) + } + }, 1000) // debounce for 2000 ms + ) + + return () => { + unsubscribe() + } + }, [editor, preferences.autoSave]) + + useEffect(() => { + if (!editor?.on) return + + const unsubscribe = editor.on('nodecreated noderemoved', (node: any) => { + if (!spellRef.current) return + if (node.category !== 'IO') return + const spell = { + ...spellRef.current, + graph: editor.toJSON(), + } + publish(events.$SUBSPELL_UPDATED(spellRef.current.id), spell) + }) + + return () => { + unsubscribe() + } + }, [editor]) + + useEffect(() => { + if (!spellData) return + spellRef.current = spellData.data[0] + }, [spellData]) + + useEffect(() => { + // If there is no tab, or we already have a spell, return early + if (!tab || !tab.name || spellRef.current) return + + loadSpell({ + spellName: tab.name, + projectId: config.projectId, + id: tab.id, + }) + }, [tab]) + + const onReady = (event: DockviewReadyEvent) => { + // const layout = tab.layoutJson; + + // let success = false; + + // if (layout) { + // event.api.fromJSON(layout); + // success = true; + // } + + // if (!success) { + loadDefaultLayout(event.api, tab); + // } + }; + + return ( + <> + + + + ); +}; + +const Wrapped = (props: IDockviewPanelProps<{ tab: Tab, theme: string }>) => { + const pubSub = usePubSub() + return ( + +
+ + +
+
+ ); +} + +export default Wrapped; diff --git a/packages/editor/src/windows/InspectorWindow.tsx b/packages/editor/src/windows/InspectorWindow.tsx index 26047a4a0b..36f50d3652 100644 --- a/packages/editor/src/windows/InspectorWindow.tsx +++ b/packages/editor/src/windows/InspectorWindow.tsx @@ -17,22 +17,22 @@ const Inspector = (props) => { const [width, setWidth] = useState() const { openModal } = useModal() - useEffect(() => { - if (props?.node?._rect?.width) { - setWidth(props.node._rect.width) - } + // useEffect(() => { + // if (props?.node?._rect?.width) { + // setWidth(props.node._rect.width) + // } - // Dynamically set the appropriate height so that Monaco editor doesn't break flexbox when resizing - props.node.setEventListener('resize', (data) => { - setTimeout(() => { - setWidth(data.rect.width) - }, 0) - }) + // // Dynamically set the appropriate height so that Monaco editor doesn't break flexbox when resizing + // props.node.setEventListener('resize', (data) => { + // setTimeout(() => { + // setWidth(data.rect.width) + // }, 0) + // }) - return () => { - props.node.removeEventListener('resize') - } - }, [props]) + // return () => { + // props.node.removeEventListener('resize') + // } + // }, [props]) /** * Update a control's properties. From d863543d1e95d5504551f595c1e829670d84a8dc Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 27 Sep 2023 09:49:24 -0700 Subject: [PATCH 112/349] Turn off console drawer for now. --- .../editor/src/screens/MagickV2/index.tsx | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/editor/src/screens/MagickV2/index.tsx b/packages/editor/src/screens/MagickV2/index.tsx index bfd0935358..f75a9e9a46 100644 --- a/packages/editor/src/screens/MagickV2/index.tsx +++ b/packages/editor/src/screens/MagickV2/index.tsx @@ -55,16 +55,16 @@ const loadDefaultLayout = (api: GridviewApi) => { }) // Right side console panel - api.addPanel({ - id: 'panel_6', - component: 'default', - params: { - title: 'Panel 6', - }, - position: { referencePanel: 'panel_5', direction: 'right' }, - }).api.setSize({ - width: 5 - }); + // api.addPanel({ + // id: 'panel_6', + // component: 'default', + // params: { + // title: 'Panel 6', + // }, + // position: { referencePanel: 'panel_5', direction: 'right' }, + // }).api.setSize({ + // width: 5 + // }); } const MagickV2 = () => { From bdc05f1822ebd212ba266aa1fea3c99f676070a4 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 27 Sep 2023 11:32:03 -0700 Subject: [PATCH 113/349] Move state into client folder --- packages/{ => client}/state/.eslintrc.json | 2 +- packages/client/state/README.md | 11 ++ packages/{ => client}/state/package.json | 2 +- packages/{ => client}/state/project.json | 14 +- packages/{ => client}/state/src/index.ts | 0 .../{ => client}/state/src/lib/api/api.ts | 130 +++++++++--------- .../{ => client}/state/src/lib/api/spells.ts | 0 .../state/src/lib/globalConfig.ts | 0 packages/{ => client}/state/src/lib/hooks.ts | 0 .../{ => client}/state/src/lib/localState.ts | 7 +- .../{ => client}/state/src/lib/preferences.ts | 0 packages/{ => client}/state/src/lib/store.ts | 0 packages/{ => client}/state/src/lib/tabs.ts | 0 packages/{ => client}/state/tsconfig.json | 2 +- packages/{ => client}/state/tsconfig.lib.json | 2 +- .../{ => client}/state/tsconfig.spec.json | 2 +- packages/{ => client}/state/vite.config.ts | 4 +- .../src/components/Drawer/AgentMenu.tsx | 51 ++++--- packages/core/shared/src/state/tabs.ts | 2 +- .../editor/src/DataControls/SpellSelect.tsx | 3 +- .../editor/src/components/EventHandler.tsx | 15 +- .../components/MenuBar/OldMenuBar/index.tsx | 8 +- .../components/MenuBar/newMenuBar/index.tsx | 41 +++--- .../src/components/Modals/EditSpellModal.tsx | 2 +- .../src/components/Modals/SaveAsModal.tsx | 2 +- .../editor/src/components/TabBar/TabBar.tsx | 6 +- packages/editor/src/components/Workspace.tsx | 2 +- packages/editor/src/components/Workspaces.tsx | 63 +++++---- .../editor/src/contexts/EditorProvider.tsx | 6 +- .../editor/src/contexts/LayoutProvider.tsx | 2 +- .../src/contexts/MagickInterfaceProvider.tsx | 2 +- packages/editor/src/main.tsx | 4 +- packages/editor/src/routes.tsx | 3 + .../editor/src/screens/Composer/index.tsx | 17 +-- .../src/screens/HomeScreen/CreateNew.tsx | 24 ++-- .../src/screens/HomeScreen/HomeScreen.tsx | 20 ++- .../src/screens/HomeScreen/OpenProject.tsx | 2 +- packages/editor/src/screens/Magick/Magick.tsx | 29 ++-- .../screens/MagickV2/workspaces/composer.tsx | 129 +++++++++-------- .../editor/src/windows/DebugConsole/index.tsx | 19 +-- .../editor/src/windows/PlaytestWindow.tsx | 26 ++-- packages/state/README.md | 11 -- tsconfig.base.json | 6 +- 43 files changed, 354 insertions(+), 317 deletions(-) rename packages/{ => client}/state/.eslintrc.json (90%) create mode 100644 packages/client/state/README.md rename packages/{ => client}/state/package.json (81%) rename packages/{ => client}/state/project.json (60%) rename packages/{ => client}/state/src/index.ts (100%) rename packages/{ => client}/state/src/lib/api/api.ts (96%) rename packages/{ => client}/state/src/lib/api/spells.ts (100%) rename packages/{ => client}/state/src/lib/globalConfig.ts (100%) rename packages/{ => client}/state/src/lib/hooks.ts (100%) rename packages/{ => client}/state/src/lib/localState.ts (91%) rename packages/{ => client}/state/src/lib/preferences.ts (100%) rename packages/{ => client}/state/src/lib/store.ts (100%) rename packages/{ => client}/state/src/lib/tabs.ts (100%) rename packages/{ => client}/state/tsconfig.json (91%) rename packages/{ => client}/state/tsconfig.lib.json (84%) rename packages/{ => client}/state/tsconfig.spec.json (91%) rename packages/{ => client}/state/vite.config.ts (92%) delete mode 100644 packages/state/README.md diff --git a/packages/state/.eslintrc.json b/packages/client/state/.eslintrc.json similarity index 90% rename from packages/state/.eslintrc.json rename to packages/client/state/.eslintrc.json index adbe7ae2df..3230caf3d2 100644 --- a/packages/state/.eslintrc.json +++ b/packages/client/state/.eslintrc.json @@ -1,5 +1,5 @@ { - "extends": ["../../.eslintrc.json"], + "extends": ["../../../.eslintrc.json"], "ignorePatterns": ["!**/*"], "overrides": [ { diff --git a/packages/client/state/README.md b/packages/client/state/README.md new file mode 100644 index 0000000000..522d0d865e --- /dev/null +++ b/packages/client/state/README.md @@ -0,0 +1,11 @@ +# client-state + +This library was generated with [Nx](https://nx.dev). + +## Building + +Run `nx build client-state` to build the library. + +## Running unit tests + +Run `nx test client-state` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/packages/state/package.json b/packages/client/state/package.json similarity index 81% rename from packages/state/package.json rename to packages/client/state/package.json index c841eb7800..5b4eb04f49 100644 --- a/packages/state/package.json +++ b/packages/client/state/package.json @@ -1,5 +1,5 @@ { - "name": "@magickml/state", + "name": "client/state", "version": "0.0.1", "dependencies": {}, "main": "./index.js", diff --git a/packages/state/project.json b/packages/client/state/project.json similarity index 60% rename from packages/state/project.json rename to packages/client/state/project.json index 24359c01b8..26614f1021 100644 --- a/packages/state/project.json +++ b/packages/client/state/project.json @@ -1,14 +1,14 @@ { - "name": "state", - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "packages/state/src", + "name": "client-state", + "$schema": "../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "packages/client/state/src", "projectType": "library", "targets": { "build": { "executor": "@nx/vite:build", "outputs": ["{options.outputPath}"], "options": { - "outputPath": "dist/packages/state" + "outputPath": "dist/packages/client/state" } }, "test": { @@ -16,7 +16,7 @@ "outputs": ["{options.reportsDirectory}"], "options": { "passWithNoTests": true, - "reportsDirectory": "../../coverage/packages/state" + "reportsDirectory": "../../../coverage/packages/client/state" } }, "lint": { @@ -24,8 +24,8 @@ "outputs": ["{options.outputFile}"], "options": { "lintFilePatterns": [ - "packages/state/**/*.ts", - "packages/state/package.json" + "packages/client/state/**/*.ts", + "packages/client/state/package.json" ] } } diff --git a/packages/state/src/index.ts b/packages/client/state/src/index.ts similarity index 100% rename from packages/state/src/index.ts rename to packages/client/state/src/index.ts diff --git a/packages/state/src/lib/api/api.ts b/packages/client/state/src/lib/api/api.ts similarity index 96% rename from packages/state/src/lib/api/api.ts rename to packages/client/state/src/lib/api/api.ts index b68bdb9ec2..65496e4138 100644 --- a/packages/state/src/lib/api/api.ts +++ b/packages/client/state/src/lib/api/api.ts @@ -1,65 +1,65 @@ -// DOCUMENTED -// Import necessary libraries and types from toolkit -import { - BaseQueryFn, - createApi, - FetchArgs, - fetchBaseQuery, - FetchBaseQueryError, -} from '@reduxjs/toolkit/query/react' -import { RootState } from '../store' - -/** - * Dynamic base query that can be used to create a Redux Toolkit Query API - * with a dynamic API url and token based on the current state. - * - * @param args - The URL or FetchArgs containing the request information. - * @param api - The Redux Toolkit Query API instance. - * @param extraOptions - Any extra options provided during the request. - * @returns A FetchBaseQueryError if apiUrl missing, otherwise the response of the request. - */ -const dynamicBaseQuery: BaseQueryFn< - string | FetchArgs, - unknown, - FetchBaseQueryError -> = async (args, api, extraOptions) => { - // Get state from Redux store - const state = api.getState() as RootState - // Extract apiUrl and token from state - const apiUrl = state.globalConfig.apiUrl - const token = state.globalConfig.token - - // Handle scenarios where apiUrl is not present gracefully - if (!apiUrl) { - return { - error: { - status: 400, - statusText: 'Bad Request', - data: 'No apiUrl present', - }, - } - } - - // Create rawBaseQuery with provided apiUrl and token (if exists) - const rawBaseQuery = fetchBaseQuery({ - baseUrl: apiUrl, - prepareHeaders: async headers => { - if (token) headers.set('authorization', `Bearer ${token}`) - return headers - }, - }) - - // Return rawBaseQuery result with provided args and extraOptions - return rawBaseQuery(args, api, extraOptions) -} - -/** - * Creates a root API with a dynamic base query, appropriate reducerPath, - * tagTypes, and empty endpoints. - */ -export const rootApi = createApi({ - reducerPath: 'api', // Set reducer path - baseQuery: dynamicBaseQuery, // Use dynamicBaseQuery as baseQuery - tagTypes: ['Spell', 'Spells', 'Version'], // Define tagTypes for invalidation - endpoints: () => ({}), // Provide an empty object for endpoints -}) \ No newline at end of file +// DOCUMENTED +// Import necessary libraries and types from toolkit +import { + BaseQueryFn, + createApi, + FetchArgs, + fetchBaseQuery, + FetchBaseQueryError, +} from '@reduxjs/toolkit/query/react' +import { RootState } from '../store' + +/** + * Dynamic base query that can be used to create a Redux Toolkit Query API + * with a dynamic API url and token based on the current state. + * + * @param args - The URL or FetchArgs containing the request information. + * @param api - The Redux Toolkit Query API instance. + * @param extraOptions - Any extra options provided during the request. + * @returns A FetchBaseQueryError if apiUrl missing, otherwise the response of the request. + */ +const dynamicBaseQuery: BaseQueryFn< + string | FetchArgs, + unknown, + FetchBaseQueryError +> = async (args, api, extraOptions) => { + // Get state from Redux store + const state = api.getState() as RootState + // Extract apiUrl and token from state + const apiUrl = state.globalConfig.apiUrl + const token = state.globalConfig.token + + // Handle scenarios where apiUrl is not present gracefully + if (!apiUrl) { + return { + error: { + status: 400, + statusText: 'Bad Request', + data: 'No apiUrl present', + }, + } + } + + // Create rawBaseQuery with provided apiUrl and token (if exists) + const rawBaseQuery = fetchBaseQuery({ + baseUrl: apiUrl, + prepareHeaders: async headers => { + if (token) headers.set('authorization', `Bearer ${token}`) + return headers + }, + }) + + // Return rawBaseQuery result with provided args and extraOptions + return rawBaseQuery(args, api, extraOptions) +} + +/** + * Creates a root API with a dynamic base query, appropriate reducerPath, + * tagTypes, and empty endpoints. + */ +export const rootApi = createApi({ + reducerPath: 'api', // Set reducer path + baseQuery: dynamicBaseQuery, // Use dynamicBaseQuery as baseQuery + tagTypes: ['Spell', 'Spells', 'Version'], // Define tagTypes for invalidation + endpoints: () => ({}), // Provide an empty object for endpoints +}) diff --git a/packages/state/src/lib/api/spells.ts b/packages/client/state/src/lib/api/spells.ts similarity index 100% rename from packages/state/src/lib/api/spells.ts rename to packages/client/state/src/lib/api/spells.ts diff --git a/packages/state/src/lib/globalConfig.ts b/packages/client/state/src/lib/globalConfig.ts similarity index 100% rename from packages/state/src/lib/globalConfig.ts rename to packages/client/state/src/lib/globalConfig.ts diff --git a/packages/state/src/lib/hooks.ts b/packages/client/state/src/lib/hooks.ts similarity index 100% rename from packages/state/src/lib/hooks.ts rename to packages/client/state/src/lib/hooks.ts diff --git a/packages/state/src/lib/localState.ts b/packages/client/state/src/lib/localState.ts similarity index 91% rename from packages/state/src/lib/localState.ts rename to packages/client/state/src/lib/localState.ts index 2f5b670dfb..d5ecd95f62 100644 --- a/packages/state/src/lib/localState.ts +++ b/packages/client/state/src/lib/localState.ts @@ -1,4 +1,4 @@ -// DOCUMENTED +// DOCUMENTED import { createSlice, createDraftSafeSelector, @@ -53,9 +53,8 @@ export const { addLocalState, deleteLocalState, upsertLocalState } = */ export const selectStateBytabId = createDraftSafeSelector( [state => localSelectors.selectAll(state), (_, id) => id], - (states, id) => - Object.values(states).find(state => state.id === id) + (states, id) => Object.values(states).find(state => state.id === id) ) // export the default reducer -export default localStateSlice.reducer \ No newline at end of file +export default localStateSlice.reducer diff --git a/packages/state/src/lib/preferences.ts b/packages/client/state/src/lib/preferences.ts similarity index 100% rename from packages/state/src/lib/preferences.ts rename to packages/client/state/src/lib/preferences.ts diff --git a/packages/state/src/lib/store.ts b/packages/client/state/src/lib/store.ts similarity index 100% rename from packages/state/src/lib/store.ts rename to packages/client/state/src/lib/store.ts diff --git a/packages/state/src/lib/tabs.ts b/packages/client/state/src/lib/tabs.ts similarity index 100% rename from packages/state/src/lib/tabs.ts rename to packages/client/state/src/lib/tabs.ts diff --git a/packages/state/tsconfig.json b/packages/client/state/tsconfig.json similarity index 91% rename from packages/state/tsconfig.json rename to packages/client/state/tsconfig.json index e5d6cc367b..8e2296f251 100644 --- a/packages/state/tsconfig.json +++ b/packages/client/state/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig.base.json", + "extends": "../../../tsconfig.base.json", "compilerOptions": { "module": "commonjs", "forceConsistentCasingInFileNames": true, diff --git a/packages/state/tsconfig.lib.json b/packages/client/state/tsconfig.lib.json similarity index 84% rename from packages/state/tsconfig.lib.json rename to packages/client/state/tsconfig.lib.json index 33eca2c2cd..4befa7f099 100644 --- a/packages/state/tsconfig.lib.json +++ b/packages/client/state/tsconfig.lib.json @@ -1,7 +1,7 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", + "outDir": "../../../dist/out-tsc", "declaration": true, "types": ["node"] }, diff --git a/packages/state/tsconfig.spec.json b/packages/client/state/tsconfig.spec.json similarity index 91% rename from packages/state/tsconfig.spec.json rename to packages/client/state/tsconfig.spec.json index 6d3be74271..7f69b8dc09 100644 --- a/packages/state/tsconfig.spec.json +++ b/packages/client/state/tsconfig.spec.json @@ -1,7 +1,7 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", + "outDir": "../../../dist/out-tsc", "types": ["vitest/globals", "vitest/importMeta", "vite/client", "node"] }, "include": [ diff --git a/packages/state/vite.config.ts b/packages/client/state/vite.config.ts similarity index 92% rename from packages/state/vite.config.ts rename to packages/client/state/vite.config.ts index 9f661bbe4c..46b01b2611 100644 --- a/packages/state/vite.config.ts +++ b/packages/client/state/vite.config.ts @@ -6,7 +6,7 @@ import dts from 'vite-plugin-dts' import * as path from 'path' export default defineConfig({ - cacheDir: '../../node_modules/.vite/state', + cacheDir: '../../../node_modules/.vite/state', plugins: [ dts({ @@ -44,7 +44,7 @@ export default defineConfig({ test: { globals: true, cache: { - dir: '../../node_modules/.vitest', + dir: '../../../node_modules/.vitest', }, environment: 'node', include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], diff --git a/packages/core/client/src/components/Drawer/AgentMenu.tsx b/packages/core/client/src/components/Drawer/AgentMenu.tsx index 35ed1f0c96..85a3471c05 100644 --- a/packages/core/client/src/components/Drawer/AgentMenu.tsx +++ b/packages/core/client/src/components/Drawer/AgentMenu.tsx @@ -29,7 +29,7 @@ import { useSpellList } from '../../../../../plugins/avatar/client/src/hooks/use import { useTreeData } from '../../../../client/src/contexts/TreeDataProvider' import NewMenuBar from '../../../../../editor/src/components/MenuBar/newMenuBar' import { AgentInterface, SpellInterface } from '@magickml/core' -import { setCurrentAgentId } from '@magickml/state' +import { setCurrentAgentId } from 'client/state' import { useTabLayout } from '../../../../../editor/src/contexts/TabProvider' interface Spell { @@ -56,17 +56,14 @@ function AgentMenu({ data, resetData }) { const { agentUpdate, setAgentUpdate } = useTreeData() const dispatch = useDispatch() - const setCurrentAgent = useCallback( - (agent: AgentInterface) => { - // Subscribe to agent service - client.service('agents').subscribe(agent.id) - _setCurrentAgent(agent) + const setCurrentAgent = useCallback((agent: AgentInterface) => { + // Subscribe to agent service + client.service('agents').subscribe(agent.id) + _setCurrentAgent(agent) - // store this current agent in the global state for use in the editor - dispatch(setCurrentAgentId(agent.id)) - }, - [] - ) + // store this current agent in the global state for use in the editor + dispatch(setCurrentAgentId(agent.id)) + }, []) const handleClose = () => { setOpenConfirm(false) @@ -313,7 +310,7 @@ function AgentMenu({ data, resetData }) { src={ currentAgent && currentAgent.image ? `https://pub-58d22deb43dc48e792b7b7468610b5f9.r2.dev/magick-dev/agents/${currentAgent.image}` - : undefined // Ensure it's undefined if there's no valid image URL. + : undefined // Ensure it's undefined if there's no valid image URL. } sx={{ width: 24, height: 24 }} > @@ -431,7 +428,7 @@ function AgentMenu({ data, resetData }) { src={ agent.image ? `https://pub-58d22deb43dc48e792b7b7468610b5f9.r2.dev/magick-dev/agents/${agent.image}` - : undefined // Ensure it's undefined if there's no valid image URL. + : undefined // Ensure it's undefined if there's no valid image URL. } sx={{ width: 24, height: 24 }} > @@ -467,10 +464,10 @@ function AgentMenu({ data, resetData }) { }} onClick={() => { openTab({ - id: "Agents", + id: 'Agents', name: 'Agents', type: 'Agents', - switchActive: true + switchActive: true, }) }} > @@ -543,14 +540,14 @@ function AgentMenu({ data, resetData }) { background: 'none', outline: 'none', }, - color: `${selectedAgentData && + color: `${ + selectedAgentData && (selectedAgentData.default ? 'grey' : 'white') - }`, - cursor: `${selectedAgentData && - (selectedAgentData.default - ? 'not-allowed' - : 'pointer') - }`, + }`, + cursor: `${ + selectedAgentData && + (selectedAgentData.default ? 'not-allowed' : 'pointer') + }`, }} onClick={e => { if (!selectedAgentData.default) { @@ -558,7 +555,6 @@ function AgentMenu({ data, resetData }) { } handleCloseMenu2() }} - disabled={data.length === 1} > Delete @@ -590,10 +586,10 @@ function AgentMenu({ data, resetData }) { }} onClick={() => { openTab({ - id: "Agents", + id: 'Agents', name: 'Agents', type: 'Agents', - switchActive: true + switchActive: true, }) }} > @@ -605,8 +601,9 @@ function AgentMenu({ data, resetData }) { open={openConfirm} onClose={handleClose} handleAction={onSubmit} - title={`Delete ${selectedAgentData ? selectedAgentData.name : '' - } agent`} + title={`Delete ${ + selectedAgentData ? selectedAgentData.name : '' + } agent`} submitText="Confirm" children="Do you want to delete this agent?" /> diff --git a/packages/core/shared/src/state/tabs.ts b/packages/core/shared/src/state/tabs.ts index 58ec4a16c1..e75ee326a9 100644 --- a/packages/core/shared/src/state/tabs.ts +++ b/packages/core/shared/src/state/tabs.ts @@ -6,7 +6,7 @@ import { } from '@reduxjs/toolkit' import { getWorkspaceLayout } from '@magickml/layouts' -import { RootState } from '@magickml/state' +import { RootState } from 'client/state' // Workspace map for initializing tabs with layout data export const workspaceMap = { diff --git a/packages/editor/src/DataControls/SpellSelect.tsx b/packages/editor/src/DataControls/SpellSelect.tsx index 72662da01b..2a8636a16d 100644 --- a/packages/editor/src/DataControls/SpellSelect.tsx +++ b/packages/editor/src/DataControls/SpellSelect.tsx @@ -7,8 +7,7 @@ import { useSnackbar } from 'notistack' import { useEffect } from 'react' import { useConfig } from '@magickml/client-core' -import { openTab, spellApi, useAppDispatch } from '@magickml/state' - +import { openTab, spellApi, useAppDispatch } from 'client/state' /** * Component that renders the Select element for selecting and creating modules. diff --git a/packages/editor/src/components/EventHandler.tsx b/packages/editor/src/components/EventHandler.tsx index c0b43db60c..f7a5e16ff7 100644 --- a/packages/editor/src/components/EventHandler.tsx +++ b/packages/editor/src/components/EventHandler.tsx @@ -10,7 +10,11 @@ import { useEditor } from '../contexts/EditorProvider' import { diff } from '../utils/json0' import { useConfig, useFeathers } from '@magickml/client-core' -import { useLazyGetSpellByIdQuery, useSaveSpellMutation, RootState } from '@magickml/state' +import { + useLazyGetSpellByIdQuery, + useSaveSpellMutation, + RootState, +} from 'client/state' import { useSelector } from 'react-redux' /** @@ -26,7 +30,9 @@ const EventHandler = ({ pubSub, tab }) => { const { createOrFocus, windowTypes } = useLayout() const { enqueueSnackbar } = useSnackbar() - const { currentAgentId } = useSelector((state: RootState) => state.globalConfig) + const { currentAgentId } = useSelector( + (state: RootState) => state.globalConfig + ) const [saveSpellMutation] = useSaveSpellMutation() // TODO: is this a bug? @@ -58,7 +64,6 @@ const EventHandler = ({ pubSub, tab }) => { spellRef.current = spell?.data[0] }, [spell]) - useEffect(() => { if (!client.io || !tab.id || !enqueueSnackbar) return @@ -108,7 +113,7 @@ const EventHandler = ({ pubSub, tab }) => { $CLOSE_EDITOR, $PROCESS, $RUN_SPELL, - $RESET_HIGHLIGHTS + $RESET_HIGHLIGHTS, } = events /** @@ -345,7 +350,7 @@ const EventHandler = ({ pubSub, tab }) => { agentId: currentAgentId, projectId: config.projectId, isPlaytest: true, - ..._data + ..._data, } const response = await client.service('agents').run(data) } diff --git a/packages/editor/src/components/MenuBar/OldMenuBar/index.tsx b/packages/editor/src/components/MenuBar/OldMenuBar/index.tsx index 89f18d627e..367d8638d1 100644 --- a/packages/editor/src/components/MenuBar/OldMenuBar/index.tsx +++ b/packages/editor/src/components/MenuBar/OldMenuBar/index.tsx @@ -6,7 +6,13 @@ import { useDispatch, useSelector } from 'react-redux' import { useNavigate } from 'react-router-dom' import { useModal } from '../../../contexts/ModalProvider' import css from '../menuBar.module.css' -import { RootState, Tab, activeTabSelector, changeEditorLayout, toggleAutoSave } from '@magickml/state' +import { + RootState, + Tab, + activeTabSelector, + changeEditorLayout, + toggleAutoSave, +} from 'client/state' /** * MenuBar component diff --git a/packages/editor/src/components/MenuBar/newMenuBar/index.tsx b/packages/editor/src/components/MenuBar/newMenuBar/index.tsx index 4c94c35b87..5113214c27 100644 --- a/packages/editor/src/components/MenuBar/newMenuBar/index.tsx +++ b/packages/editor/src/components/MenuBar/newMenuBar/index.tsx @@ -10,14 +10,20 @@ import MenuIcon from '@mui/icons-material/Menu' import css from '../menuBar.module.css' import { styled } from '@mui/material/styles' import { NestedMenuItem } from 'mui-nested-menu' -import { RootState, Tab, activeTabSelector, changeEditorLayout, toggleAutoSave } from '@magickml/state' +import { + RootState, + Tab, + activeTabSelector, + changeEditorLayout, + toggleAutoSave, +} from 'client/state' /** * MenuBar component * * @returns {JSX.Element} */ -const NewMenuBar = (props) => { +const NewMenuBar = props => { const navigate = useNavigate() const { publish, events } = usePubSub() const dispatch = useDispatch() @@ -497,7 +503,10 @@ const NewMenuBar = (props) => { return (
- + { {menuBarItems[item].items[subMenuKey].hasOwnProperty( 'isActive' ) && ( - - ●{' '} - - )} - {subMenuKey - .replace(/_/g, ' ') - .charAt(0) - .toUpperCase() + subMenuKey.slice(1)} + + ●{' '} + + )} + {subMenuKey.replace(/_/g, ' ').charAt(0).toUpperCase() + + subMenuKey.slice(1)}

{hotKeyLabel && diff --git a/packages/editor/src/components/Modals/EditSpellModal.tsx b/packages/editor/src/components/Modals/EditSpellModal.tsx index 2866ae2082..cc870d4ffc 100644 --- a/packages/editor/src/components/Modals/EditSpellModal.tsx +++ b/packages/editor/src/components/Modals/EditSpellModal.tsx @@ -6,7 +6,7 @@ import { useDispatch } from 'react-redux' import Modal from '../Modal/Modal' import css from './modalForms.module.css' -import { closeTab, openTab, spellApi } from '@magickml/state' +import { closeTab, openTab, spellApi } from 'client/state' /** * Represents a modal to edit spells. * @param {Object} props - properties passed to the component diff --git a/packages/editor/src/components/Modals/SaveAsModal.tsx b/packages/editor/src/components/Modals/SaveAsModal.tsx index 1d2edfe95f..ad56e01319 100644 --- a/packages/editor/src/components/Modals/SaveAsModal.tsx +++ b/packages/editor/src/components/Modals/SaveAsModal.tsx @@ -9,7 +9,7 @@ import { getTemplates } from '@magickml/client-core' import { useConfig } from '@magickml/client-core' import md5 from 'md5' import { v4 as uuidv4 } from 'uuid' -import { spellApi } from '@magickml/state' +import { spellApi } from 'client/state' // Initial graph for the spell const defaultGraph = getTemplates().spells[0].graph diff --git a/packages/editor/src/components/TabBar/TabBar.tsx b/packages/editor/src/components/TabBar/TabBar.tsx index 24ad872a36..81303cc5db 100644 --- a/packages/editor/src/components/TabBar/TabBar.tsx +++ b/packages/editor/src/components/TabBar/TabBar.tsx @@ -8,7 +8,7 @@ import MenuBar from '../MenuBar/MenuBar' import CreateTab from './CreateTab' import css from './tabBar.module.css' import { Icon } from '@magickml/client-core' -import { RootState, changeActive, closeTab, selectAllTabs } from '@magickml/state' +import { RootState, changeActive, closeTab, selectAllTabs } from 'client/state' /** * Tab Component @@ -77,7 +77,9 @@ const TabBar = ({ tabs, activeTabId }) => {
{tabs && - tabs.map((tab) => )} + tabs.map(tab => ( + + ))}
diff --git a/packages/editor/src/components/Workspace.tsx b/packages/editor/src/components/Workspace.tsx index a77fb09df7..8de227eee4 100644 --- a/packages/editor/src/components/Workspace.tsx +++ b/packages/editor/src/components/Workspace.tsx @@ -16,7 +16,7 @@ import Playtest from '../windows/PlaytestWindow' import DebugConsole from '../windows/DebugConsole' import TextEditor from '../windows/TextEditorWindow' -import { RootState, spellApi } from '@magickml/state' +import { RootState, spellApi } from 'client/state' import AgentControls from '../windows/AgentControlWindow' import isEqual from 'lodash/isEqual' diff --git a/packages/editor/src/components/Workspaces.tsx b/packages/editor/src/components/Workspaces.tsx index 5fae009042..86bb835dad 100644 --- a/packages/editor/src/components/Workspaces.tsx +++ b/packages/editor/src/components/Workspaces.tsx @@ -1,35 +1,34 @@ -// DOCUMENTED -import { memo, useEffect } from 'react'; -import isEqual from 'lodash/isEqual'; -import WorkspaceProvider from '../contexts/WorkspaceProvider'; +// DOCUMENTED +import { memo, useEffect } from 'react' +import isEqual from 'lodash/isEqual' +import WorkspaceProvider from '../contexts/WorkspaceProvider' import { ClientPluginManager, pluginManager } from '@magickml/core' -import Composer from './Workspace'; -import { Tab } from '@magickml/state'; +import Composer from './Workspace' +import { Tab } from 'client/state' import Events from '../screens/EventWindow' import Requests from '../screens/RequestWindow' import Settings from '../screens/settings/SettingsWindow' import Documents from '../screens/DocumentWindow' -import Agents from '../screens/agents/AgentManagerWindow'; - +import Agents from '../screens/agents/AgentManagerWindow' type WorkspaceProps = { - pubSub: any; // You might want to provide a more detailed type based on your usage. + pubSub: any // You might want to provide a more detailed type based on your usage. tab: Tab -}; +} const WorkspaceComponent = ({ tab, pubSub, activeTabId }) => { const pluginComponents = [] - ; (pluginManager as ClientPluginManager) - .getGroupedClientRoutes() - .forEach(plugin => { - plugin.routes.map(route => { - pluginComponents.push({ - name: route.path.charAt(1).toUpperCase() + route.path.slice(2), - component: route.component, - }) + ;(pluginManager as ClientPluginManager) + .getGroupedClientRoutes() + .forEach(plugin => { + plugin.routes.map(route => { + pluginComponents.push({ + name: route.path.charAt(1).toUpperCase() + route.path.slice(2), + component: route.component, }) }) + }) const componentMapping = { spell: Composer, @@ -45,15 +44,14 @@ const WorkspaceComponent = ({ tab, pubSub, activeTabId }) => { }, {}), } - - const Workspace = componentMapping[tab.type]; + const Workspace = componentMapping[tab.type] const props = { pubSub, - tab - }; + tab, + } if (!Workspace) { - return null; + return null } const isActive = tab.id === activeTabId @@ -68,7 +66,7 @@ const WorkspaceComponent = ({ tab, pubSub, activeTabId }) => { top: 0, left: 0, bottom: 0, - right: 0 + right: 0, }} > @@ -83,12 +81,19 @@ const WorkspaceComponent = ({ tab, pubSub, activeTabId }) => { const Workspaces = ({ tabs, pubSub, activeTabId }) => { return ( <> - {tabs.map((tab) => { + {tabs.map(tab => { // render the component if it is a component type - return ; + return ( + + ) })} - ); -}; + ) +} -export default Workspaces; \ No newline at end of file +export default Workspaces diff --git a/packages/editor/src/contexts/EditorProvider.tsx b/packages/editor/src/contexts/EditorProvider.tsx index c35e047515..e0f48dd14a 100644 --- a/packages/editor/src/contexts/EditorProvider.tsx +++ b/packages/editor/src/contexts/EditorProvider.tsx @@ -4,7 +4,7 @@ import { EditorContext, GraphData, MagickEditor, - SpellInterface + SpellInterface, } from '@magickml/core' import React, { createContext, @@ -22,7 +22,7 @@ import { zoomAt } from '../plugins/areaPlugin/zoom-at' import { useMagickInterface } from './MagickInterfaceProvider' import styles from './styles.module.scss' import { EngineComponent } from '@magickml/rete' -import { spellApi } from '@magickml/state' +import { spellApi } from 'client/state' /** * MagickTab type definition. @@ -98,7 +98,7 @@ const EditorProvider = ({ children }) => { tab, node: MyNode, client, - spell + spell, }) setEditor(newEditor) diff --git a/packages/editor/src/contexts/LayoutProvider.tsx b/packages/editor/src/contexts/LayoutProvider.tsx index 7e7920091f..d905eec8c8 100644 --- a/packages/editor/src/contexts/LayoutProvider.tsx +++ b/packages/editor/src/contexts/LayoutProvider.tsx @@ -1,6 +1,6 @@ // DOCUMENTED import { LoadingScreen } from '@magickml/client-core' -import { activeTabSelector, saveTabLayout } from '@magickml/state' +import { activeTabSelector, saveTabLayout } from 'client/state' import { Actions, DockLocation, diff --git a/packages/editor/src/contexts/MagickInterfaceProvider.tsx b/packages/editor/src/contexts/MagickInterfaceProvider.tsx index 0afa9cd2a0..af28d2913b 100644 --- a/packages/editor/src/contexts/MagickInterfaceProvider.tsx +++ b/packages/editor/src/contexts/MagickInterfaceProvider.tsx @@ -14,7 +14,7 @@ import { SpellInterface, SupportedLanguages, } from '@magickml/core' -import { spellApi } from '@magickml/state' +import { spellApi } from 'client/state' import { createContext, useContext } from 'react' // Create context for EditorContext type diff --git a/packages/editor/src/main.tsx b/packages/editor/src/main.tsx index 1b355bb507..d362190a1b 100644 --- a/packages/editor/src/main.tsx +++ b/packages/editor/src/main.tsx @@ -3,7 +3,7 @@ * A module which exports a functional component - MagickIDE * @module MagickIDE */ -import 'dockview/dist/styles/dockview.css'; +import 'dockview/dist/styles/dockview.css' import React from 'react' import './wdyr' @@ -20,7 +20,7 @@ import { LocalizationProvider } from '@mui/x-date-pickers' import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs' import { AppConfig } from '@magickml/client-core' import { MagickmlChatbox } from '@magickml/chatbox' -import { createStore } from '@magickml/state' +import { createStore } from 'client/state' /** * Type definition for the props that can be passed to MagickIDE diff --git a/packages/editor/src/routes.tsx b/packages/editor/src/routes.tsx index 238fe143e1..e0c4100605 100644 --- a/packages/editor/src/routes.tsx +++ b/packages/editor/src/routes.tsx @@ -41,6 +41,9 @@ const RenderComp = (props: { element: React.ElementType }) => { const MyRoutes = () => ( } /> + + + }> {(pluginManager as ClientPluginManager) .getGroupedClientRoutes() diff --git a/packages/editor/src/screens/Composer/index.tsx b/packages/editor/src/screens/Composer/index.tsx index 5a8dfd6de0..39686c8eec 100644 --- a/packages/editor/src/screens/Composer/index.tsx +++ b/packages/editor/src/screens/Composer/index.tsx @@ -16,7 +16,7 @@ import Playtest from '../../windows/PlaytestWindow' import DebugConsole from '../../windows/DebugConsole' import TextEditor from '../../windows/TextEditorWindow' -import { RootState, spellApi } from '@magickml/state' +import { RootState, spellApi } from 'client/state' import AgentControls from '../../windows/AgentControlWindow' import { IDockviewPanelProps } from 'dockview' import WorkspaceProvider from '../../contexts/WorkspaceProvider' @@ -127,20 +127,15 @@ const Composer = ({ tab, pubSub }) => { ) } -const Wrapped = (props: IDockviewPanelProps<{ tab: Tab, pubSub: any }>) => { +const Wrapped = (props: IDockviewPanelProps<{ tab: Tab; pubSub: any }>) => { const pubSub = usePubSub() return ( - +
- - +
- ); + ) } -export default Wrapped \ No newline at end of file +export default Wrapped diff --git a/packages/editor/src/screens/HomeScreen/CreateNew.tsx b/packages/editor/src/screens/HomeScreen/CreateNew.tsx index dc9b743f0e..6be1992b78 100644 --- a/packages/editor/src/screens/HomeScreen/CreateNew.tsx +++ b/packages/editor/src/screens/HomeScreen/CreateNew.tsx @@ -18,8 +18,8 @@ import LoadingButton from '@mui/lab/LoadingButton' import emptyImg from './empty.png' import css from './homeScreen.module.css' import { v4 as uuidv4 } from 'uuid' -import { useTreeData } from "../../../../core/client/src/contexts/TreeDataProvider" -import { spellApi } from '@magickml/state' +import { useTreeData } from '../../../../core/client/src/contexts/TreeDataProvider' +import { spellApi } from 'client/state' // Custom configuration for unique name generator const customConfig = { @@ -50,7 +50,7 @@ const CreateNew = () => { const [newSpell] = spellApi.useNewSpellMutation() const [spellExists] = spellApi.useLazyGetSpellQuery() const { register, handleSubmit } = useForm() - const { setIsAdded } = useTreeData(); + const { setIsAdded } = useTreeData() /** * Handle creation process of a new spell. @@ -72,13 +72,13 @@ const CreateNew = () => { }) return } - const response = await newSpell({ + const response = (await newSpell({ id: uuidv4(), graph: selectedTemplate.graph, name, projectId: config.projectId, hash: md5(JSON.stringify(selectedTemplate?.graph.nodes)), - }) as any + })) as any if ('error' in response) { if ('status' in response.error) { @@ -93,8 +93,11 @@ const CreateNew = () => { } setLoading(false) setIsAdded(true) - navigate(`/magick/${response.data.id + '-' + encodeURIComponent(btoa(response.data.name))}`) - + navigate( + `/magick/${ + response.data.id + '-' + encodeURIComponent(btoa(response.data.name)) + }` + ) } catch (err) { console.error('ERROR!', err) } @@ -147,12 +150,13 @@ const CreateNew = () => { cancel CREATE diff --git a/packages/editor/src/screens/HomeScreen/HomeScreen.tsx b/packages/editor/src/screens/HomeScreen/HomeScreen.tsx index 269d557dff..17de529c3f 100644 --- a/packages/editor/src/screens/HomeScreen/HomeScreen.tsx +++ b/packages/editor/src/screens/HomeScreen/HomeScreen.tsx @@ -9,8 +9,16 @@ import CreateNew from './CreateNew' import css from './homeScreen.module.css' import OpenProject from './OpenProject' import { v4 as uuidv4 } from 'uuid' -import { useTreeData } from "../../../../core/client/src/contexts/TreeDataProvider" -import { RootState, closeTab, openTab, selectAllTabs, useDeleteSpellMutation, useGetSpellsQuery, useNewSpellMutation } from '@magickml/state' +import { useTreeData } from '../../../../core/client/src/contexts/TreeDataProvider' +import { + RootState, + closeTab, + openTab, + selectAllTabs, + useDeleteSpellMutation, + useGetSpellsQuery, + useNewSpellMutation, +} from 'client/state' /** * StartScreen component. Displays an overlay with options to open or create new spells. @@ -26,7 +34,7 @@ const StartScreen = (): JSX.Element => { projectId: config.projectId, }) const [newSpell] = useNewSpellMutation() - const { setIsAdded, setToDelete } = useTreeData(); + const { setIsAdded, setToDelete } = useTreeData() const tabs = useSelector((state: RootState) => selectAllTabs(state.tabs)) /** @@ -78,16 +86,16 @@ const StartScreen = (): JSX.Element => { const onDelete = async (spellName: string): Promise => { try { await deleteSpell({ spellName, projectId: config.projectId }) - setIsAdded(true); + setIsAdded(true) // TODO fix this typing // @ts-ignore - setToDelete(spellName); + setToDelete(spellName) const tab = tabs.find(tab => tab.id === spellName) if (tab) { dispatch(closeTab(tab.id)) window.localStorage.removeItem(`zoomValues-${tab.id}`) } - setSelectedSpell("") + setSelectedSpell('') } catch (err) { console.error('Error deleting spell', err) } diff --git a/packages/editor/src/screens/HomeScreen/OpenProject.tsx b/packages/editor/src/screens/HomeScreen/OpenProject.tsx index a9ac3d7fb2..04cc98c914 100644 --- a/packages/editor/src/screens/HomeScreen/OpenProject.tsx +++ b/packages/editor/src/screens/HomeScreen/OpenProject.tsx @@ -8,7 +8,7 @@ import FileInput from '../../components/FileInput' import ProjectRow from '../../components/ProjectRow' import css from './homeScreen.module.css' import banner from './banner.png' -import { RootState, selectAllTabs } from '@magickml/state' +import { RootState, selectAllTabs } from 'client/state' const version = packageJson.version diff --git a/packages/editor/src/screens/Magick/Magick.tsx b/packages/editor/src/screens/Magick/Magick.tsx index c3f82896d2..54d38ece49 100644 --- a/packages/editor/src/screens/Magick/Magick.tsx +++ b/packages/editor/src/screens/Magick/Magick.tsx @@ -7,7 +7,14 @@ import TabBar from '../../components/TabBar/TabBar' import Workspaces from '../../components/Workspaces' import { ClientPluginManager, pluginManager } from '@magickml/core' -import { RootState, activeTabIdSelector, activeTabSelector, changeActive, openTab, selectAllTabs } from '@magickml/state' +import { + RootState, + activeTabIdSelector, + activeTabSelector, + changeActive, + openTab, + selectAllTabs, +} from 'client/state' /** * Magick component * @param empty flag to control whether the workspaces should be rendered or not @@ -24,16 +31,16 @@ const Magick = ({ empty = false }): JSX.Element => { const pubSub = usePubSub() const pluginComponents = [] - ; (pluginManager as ClientPluginManager) - .getGroupedClientRoutes() - .forEach(plugin => { - plugin.routes.map(route => { - pluginComponents.push({ - name: route.path.charAt(1).toUpperCase() + route.path.slice(2), - component: route.component, - }) + ;(pluginManager as ClientPluginManager) + .getGroupedClientRoutes() + .forEach(plugin => { + plugin.routes.map(route => { + pluginComponents.push({ + name: route.path.charAt(1).toUpperCase() + route.path.slice(2), + component: route.component, }) }) + }) // Subscribe to open tab events useEffect(() => { @@ -61,9 +68,9 @@ const Magick = ({ empty = false }): JSX.Element => { <> - {!empty && + {!empty && ( - } + )} ) diff --git a/packages/editor/src/screens/MagickV2/workspaces/composer.tsx b/packages/editor/src/screens/MagickV2/workspaces/composer.tsx index 4c0595d2c1..0957326863 100644 --- a/packages/editor/src/screens/MagickV2/workspaces/composer.tsx +++ b/packages/editor/src/screens/MagickV2/workspaces/composer.tsx @@ -1,13 +1,12 @@ -import { useConfig, useFeathers, usePubSub } from "@magickml/client-core"; +import { useConfig, useFeathers, usePubSub } from '@magickml/client-core' import { DockviewApi, DockviewReact, DockviewReadyEvent, - IDockviewPanelProps -} from "dockview"; -import { useEffect, useRef } from "react"; -import { SpellInterface, spellApi } from "@magickml/core"; - + IDockviewPanelProps, +} from 'dockview' +import { useEffect, useRef } from 'react' +import { SpellInterface, spellApi } from '@magickml/core' import WorkspaceProvider from '../../../contexts/WorkspaceProvider' import { debounce } from '../../../utils/debounce' @@ -21,107 +20,107 @@ import DebugConsole from '../../../windows/DebugConsole' import TextEditor from '../../../windows/TextEditorWindow' import { useEditor } from '../../../contexts/EditorProvider' import { Tab } from '../../../contexts/TabProvider' -import { useSelector } from "react-redux"; -import { RootState } from "@magickml/state"; +import { useSelector } from 'react-redux' +import { RootState } from 'client/state' function loadDefaultLayout(api: DockviewApi, tab) { const panel = api.addPanel({ - id: "panel_1", - component: "default", + id: 'panel_1', + component: 'default', params: { - title: "Panel 1" - } - }); + title: 'Panel 1', + }, + }) - panel.group.locked = true; - panel.group.header.hidden = true; + panel.group.locked = true + panel.group.header.hidden = true api.addPanel({ - id: "Composer", - component: "EditorWindow", + id: 'Composer', + component: 'EditorWindow', params: { - title: "Composer", - tab - } - }); + title: 'Composer', + tab, + }, + }) api .addPanel({ - id: "Inspector", - component: "Inspector", + id: 'Inspector', + component: 'Inspector', params: { - title: "Inspector", - tab + title: 'Inspector', + tab, }, - position: { referencePanel: "Composer", direction: "left" } + position: { referencePanel: 'Composer', direction: 'left' }, }) .api.setSize({ - width: 300 - }); + width: 300, + }) api.addPanel({ - id: "Text Editor", - component: "TextEditor", + id: 'Text Editor', + component: 'TextEditor', params: { - title: "Text Editor", - tab + title: 'Text Editor', + tab, }, - position: { referencePanel: "Inspector", direction: "below" } - }); + position: { referencePanel: 'Inspector', direction: 'below' }, + }) // panel5.group!.model.header.hidden = true; // panel5.group!.model.locked = true; api .addPanel({ - id: "Playtest", - component: "Playtest", + id: 'Playtest', + component: 'Playtest', params: { - title: "Playtest", - tab + title: 'Playtest', + tab, }, - position: { referencePanel: "Composer", direction: "below" } + position: { referencePanel: 'Composer', direction: 'below' }, }) .api.setSize({ - height: 300 - }); + height: 300, + }) api.addPanel({ - id: "Console", - component: "DebugConsole", + id: 'Console', + component: 'DebugConsole', params: { - title: "Console", - tab + title: 'Console', + tab, }, - position: { referencePanel: "Playtest", direction: "right" } - }); + position: { referencePanel: 'Playtest', direction: 'right' }, + }) } const components = { default: (props: IDockviewPanelProps<{ title: string }>) => { return ( -
+
{props.params.title}
- ); + ) }, Playtest: (props: IDockviewPanelProps<{ tab: Tab }>) => { - return ; + return }, Inspector: (props: IDockviewPanelProps<{ tab: Tab }>) => { - return ; + return }, TextEditor: (props: IDockviewPanelProps<{ tab: Tab }>) => { - return ; + return }, EditorWindow: (props: IDockviewPanelProps<{ tab: Tab }>) => { - return ; + return }, DebugConsole: (props: IDockviewPanelProps<{ tab: Tab }>) => { - return ; + return }, // AgentControls -}; +} export const Composer = ({ theme, tab, pubSub }) => { const config = useConfig() @@ -195,9 +194,9 @@ export const Composer = ({ theme, tab, pubSub }) => { // } // if (!success) { - loadDefaultLayout(event.api, tab); + loadDefaultLayout(event.api, tab) // } - }; + } return ( <> @@ -205,27 +204,25 @@ export const Composer = ({ theme, tab, pubSub }) => { - ); -}; + ) +} -const Wrapped = (props: IDockviewPanelProps<{ tab: Tab, theme: string }>) => { +const Wrapped = (props: IDockviewPanelProps<{ tab: Tab; theme: string }>) => { const pubSub = usePubSub() return ( - +
-
- ); + ) } -export default Wrapped; +export default Wrapped diff --git a/packages/editor/src/windows/DebugConsole/index.tsx b/packages/editor/src/windows/DebugConsole/index.tsx index 8177ec8f55..038055c4e1 100644 --- a/packages/editor/src/windows/DebugConsole/index.tsx +++ b/packages/editor/src/windows/DebugConsole/index.tsx @@ -5,7 +5,7 @@ import Terminal from 'react-console-emulator' import ReactJson from 'react-json-view' import { useEditor } from '../../contexts/EditorProvider' import { useSelector } from 'react-redux' -import { RootState } from '@magickml/state' +import { RootState } from 'client/state' /** * The type for debug messages. @@ -61,7 +61,8 @@ const DebugConsole = ({ tab }): JSX.Element => { * @returns {string} Formatted error message. */ const formatErrorMessage = (message): string => - `> Node ${message.nodeId}: Error in ${message.from} component${message.name ? ' ' + message.name : '' + `> Node ${message.nodeId}: Error in ${message.from} component${ + message.name ? ' ' + message.name : '' }.` /** @@ -71,7 +72,8 @@ const DebugConsole = ({ tab }): JSX.Element => { * @returns {string} Formatted log message. */ const formatLogMessage = (message): string => - `> Node ${message.nodeId}: Message from ${message.from} component ${message.name ? ' ' + message.name : '' + `> Node ${message.nodeId}: Message from ${message.from} component ${ + message.name ? ' ' + message.name : '' }.` /** @@ -119,9 +121,9 @@ const DebugConsole = ({ tab }): JSX.Element => { const getMessage = _message => { const message = _message.content ? { - ..._message, - ...JSON.parse(_message.content), - } + ..._message, + ...JSON.parse(_message.content), + } : _message delete message.content @@ -183,9 +185,8 @@ const DebugConsole = ({ tab }): JSX.Element => { command, }) return `Sent agent command ${command} to agent ${currentAgentId}` - } - - } + }, + }, } return ( diff --git a/packages/editor/src/windows/PlaytestWindow.tsx b/packages/editor/src/windows/PlaytestWindow.tsx index 0608e8bc45..ead27dd9c0 100644 --- a/packages/editor/src/windows/PlaytestWindow.tsx +++ b/packages/editor/src/windows/PlaytestWindow.tsx @@ -10,7 +10,14 @@ import { useEditor } from '../contexts/EditorProvider' import { useInspector } from '../contexts/InspectorProvider' import { usePubSub } from '@magickml/client-core' import css from '../screens/Magick/magick.module.css' -import { RootState, addLocalState, selectStateBytabId, spellApi, upsertLocalState, useAppSelector } from '@magickml/state' +import { + RootState, + addLocalState, + selectStateBytabId, + spellApi, + upsertLocalState, + useAppSelector, +} from 'client/state' /** * Input component - Receives and sends playtest input. @@ -46,15 +53,12 @@ const Input = props => { if (ref.current.value !== '') { const index = playtestCache.indexOf(ref.current.value) if (index === -1) { - // if the current value is not in the playtestCache, add it to the playtestCache setPlaytestCache([...playtestCache, ref.current.value]) } else if (index === 0) { - // if the current value is the first item in the playtestCache, do nothing return } else { - // if the current value is in the playtestCache, move up one ref.current.value = playtestCache[index - 1] props.onChange({ target: { value: playtestCache[index - 1] } }) @@ -80,11 +84,9 @@ const Input = props => { if (ref.current.value !== '') { const index = playtestCache.indexOf(ref.current.value) if (index === -1) { - // if the current value is not in the playtestCache, add it to the playtestCache setPlaytestCache([...playtestCache, ref.current.value]) } else if (index === playtestCache.length - 1) { - // handle user moving down back into an empty input ref.current.value = '' // if the current value is the last item in the playtestCache, do nothing @@ -216,10 +218,10 @@ const Playtest = ({ tab }) => { if (!inspectorData || inspectorData.name !== 'Input') return setPlaytestOption( `Input - ` + - (inspectorData.data.inputType && + (inspectorData.data.inputType && inspectorData.data.inputType !== 'Default' - ? inspectorData.data.inputType - : inspectorData.data.inputName) + ? inspectorData.data.inputType + : inspectorData.data.inputName) ) }, [inspectorData]) @@ -238,7 +240,8 @@ const Playtest = ({ tab }) => { })) setPlaytestOptions(options) - if (!playtestOption && options.length > 0) setPlaytestOption(options[0].value) + if (!playtestOption && options.length > 0) + setPlaytestOption(options[0].value) }, [spellData]) // Keep scrollbar at the bottom of its window. @@ -295,8 +298,7 @@ const Playtest = ({ tab }) => { const onSend = async () => { const newMessage: Message = { sender: 'user', - content: `You: ${value}` - + content: `You: ${value}`, } const newHistory = [...history, newMessage] setHistory(newHistory as []) diff --git a/packages/state/README.md b/packages/state/README.md deleted file mode 100644 index 6135205718..0000000000 --- a/packages/state/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# state - -This library was generated with [Nx](https://nx.dev). - -## Building - -Run `nx build state` to build the library. - -## Running unit tests - -Run `nx test state` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/tsconfig.base.json b/tsconfig.base.json index af3c9ff132..8b4bc2ce76 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -198,13 +198,13 @@ "@magickml/rete": ["packages/rete/src/index.ts"], "@magickml/server": ["apps/server/src/index.ts"], "@magickml/server-core": ["packages/core/server/src/index.ts"], - "@magickml/state": ["packages/state/src/index.ts"], "@magickml/types": ["packages/@types/src/index.ts"], "@magickml/ui": ["packages/ui/src/index.ts"], "@magickml/ui/components": ["packages/utils/components/src/index.ts"], "@magickml/ui/utils": ["packages/ui/src/utils.ts"], - "rete": ["packages/rete/src/index.ts"], - "server/event-tracker": ["packages/server/event-tracker/src/index.ts"] + "server/event-tracker": ["packages/server/event-tracker/src/index.ts"], + "client/state": ["packages/client/state/src/index.ts"], + "rete": ["packages/rete/src/index.ts"] } }, "exclude": ["node_modules", "tmp"] From 90d8ee74c49cdc57c396186bd850b34ff7533ed8 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 27 Sep 2023 11:33:09 -0700 Subject: [PATCH 114/349] Move layouts package --- packages/{ => client}/layouts/.eslintrc.json | 2 +- packages/{ => client}/layouts/README.md | 4 +- packages/{ => client}/layouts/package.json | 2 +- packages/{ => client}/layouts/project.json | 12 ++--- .../layouts/src/data/defaultLayout.json | 0 .../layouts/src/data/fullScreenLayout.json | 0 .../src/data/promptEngineeringLayout.json | 0 .../src/data/troubleshootingLayout.json | 0 packages/{ => client}/layouts/src/index.ts | 0 packages/{ => client}/layouts/src/main.ts | 0 packages/{ => client}/layouts/tsconfig.json | 2 +- .../{ => client}/layouts/tsconfig.lib.json | 2 +- packages/{ => client}/layouts/vite.config.ts | 2 +- packages/client/state/src/lib/tabs.ts | 2 +- packages/core/shared/src/state/tabs.ts | 2 +- packages/editor/src/contexts/TabProvider.tsx | 48 ++++++++++--------- tsconfig.base.json | 2 +- 17 files changed, 42 insertions(+), 38 deletions(-) rename packages/{ => client}/layouts/.eslintrc.json (90%) rename packages/{ => client}/layouts/README.md (50%) rename packages/{ => client}/layouts/package.json (80%) rename packages/{ => client}/layouts/project.json (55%) rename packages/{ => client}/layouts/src/data/defaultLayout.json (100%) rename packages/{ => client}/layouts/src/data/fullScreenLayout.json (100%) rename packages/{ => client}/layouts/src/data/promptEngineeringLayout.json (100%) rename packages/{ => client}/layouts/src/data/troubleshootingLayout.json (100%) rename packages/{ => client}/layouts/src/index.ts (100%) rename packages/{ => client}/layouts/src/main.ts (100%) rename packages/{ => client}/layouts/tsconfig.json (90%) rename packages/{ => client}/layouts/tsconfig.lib.json (84%) rename packages/{ => client}/layouts/vite.config.ts (95%) diff --git a/packages/layouts/.eslintrc.json b/packages/client/layouts/.eslintrc.json similarity index 90% rename from packages/layouts/.eslintrc.json rename to packages/client/layouts/.eslintrc.json index adbe7ae2df..3230caf3d2 100644 --- a/packages/layouts/.eslintrc.json +++ b/packages/client/layouts/.eslintrc.json @@ -1,5 +1,5 @@ { - "extends": ["../../.eslintrc.json"], + "extends": ["../../../.eslintrc.json"], "ignorePatterns": ["!**/*"], "overrides": [ { diff --git a/packages/layouts/README.md b/packages/client/layouts/README.md similarity index 50% rename from packages/layouts/README.md rename to packages/client/layouts/README.md index 40b7afe840..431df0ef99 100644 --- a/packages/layouts/README.md +++ b/packages/client/layouts/README.md @@ -1,7 +1,7 @@ -# layouts +# client-layouts This library was generated with [Nx](https://nx.dev). ## Building -Run `nx build layouts` to build the library. +Run `nx build client-layouts` to build the library. diff --git a/packages/layouts/package.json b/packages/client/layouts/package.json similarity index 80% rename from packages/layouts/package.json rename to packages/client/layouts/package.json index 19f9cdc541..ea569298cb 100644 --- a/packages/layouts/package.json +++ b/packages/client/layouts/package.json @@ -1,5 +1,5 @@ { - "name": "@magickml/layouts", + "name": "client/layouts", "version": "0.0.1", "dependencies": {}, "main": "./index.js", diff --git a/packages/layouts/project.json b/packages/client/layouts/project.json similarity index 55% rename from packages/layouts/project.json rename to packages/client/layouts/project.json index 78f58eee5e..f40b247b54 100644 --- a/packages/layouts/project.json +++ b/packages/client/layouts/project.json @@ -1,14 +1,14 @@ { - "name": "layouts", - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "packages/layouts/src", + "name": "client-layouts", + "$schema": "../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "packages/client/layouts/src", "projectType": "library", "targets": { "build": { "executor": "@nx/vite:build", "outputs": ["{options.outputPath}"], "options": { - "outputPath": "dist/packages/layouts" + "outputPath": "dist/packages/client/layouts" } }, "lint": { @@ -16,8 +16,8 @@ "outputs": ["{options.outputFile}"], "options": { "lintFilePatterns": [ - "packages/layouts/**/*.ts", - "packages/layouts/package.json" + "packages/client/layouts/**/*.ts", + "packages/client/layouts/package.json" ] } } diff --git a/packages/layouts/src/data/defaultLayout.json b/packages/client/layouts/src/data/defaultLayout.json similarity index 100% rename from packages/layouts/src/data/defaultLayout.json rename to packages/client/layouts/src/data/defaultLayout.json diff --git a/packages/layouts/src/data/fullScreenLayout.json b/packages/client/layouts/src/data/fullScreenLayout.json similarity index 100% rename from packages/layouts/src/data/fullScreenLayout.json rename to packages/client/layouts/src/data/fullScreenLayout.json diff --git a/packages/layouts/src/data/promptEngineeringLayout.json b/packages/client/layouts/src/data/promptEngineeringLayout.json similarity index 100% rename from packages/layouts/src/data/promptEngineeringLayout.json rename to packages/client/layouts/src/data/promptEngineeringLayout.json diff --git a/packages/layouts/src/data/troubleshootingLayout.json b/packages/client/layouts/src/data/troubleshootingLayout.json similarity index 100% rename from packages/layouts/src/data/troubleshootingLayout.json rename to packages/client/layouts/src/data/troubleshootingLayout.json diff --git a/packages/layouts/src/index.ts b/packages/client/layouts/src/index.ts similarity index 100% rename from packages/layouts/src/index.ts rename to packages/client/layouts/src/index.ts diff --git a/packages/layouts/src/main.ts b/packages/client/layouts/src/main.ts similarity index 100% rename from packages/layouts/src/main.ts rename to packages/client/layouts/src/main.ts diff --git a/packages/layouts/tsconfig.json b/packages/client/layouts/tsconfig.json similarity index 90% rename from packages/layouts/tsconfig.json rename to packages/client/layouts/tsconfig.json index 1f79d516e6..7d00af1073 100644 --- a/packages/layouts/tsconfig.json +++ b/packages/client/layouts/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig.base.json", + "extends": "../../../tsconfig.base.json", "compilerOptions": { "module": "commonjs", "forceConsistentCasingInFileNames": true, diff --git a/packages/layouts/tsconfig.lib.json b/packages/client/layouts/tsconfig.lib.json similarity index 84% rename from packages/layouts/tsconfig.lib.json rename to packages/client/layouts/tsconfig.lib.json index 33eca2c2cd..4befa7f099 100644 --- a/packages/layouts/tsconfig.lib.json +++ b/packages/client/layouts/tsconfig.lib.json @@ -1,7 +1,7 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", + "outDir": "../../../dist/out-tsc", "declaration": true, "types": ["node"] }, diff --git a/packages/layouts/vite.config.ts b/packages/client/layouts/vite.config.ts similarity index 95% rename from packages/layouts/vite.config.ts rename to packages/client/layouts/vite.config.ts index 6cf0760398..319dbd9fd0 100644 --- a/packages/layouts/vite.config.ts +++ b/packages/client/layouts/vite.config.ts @@ -6,7 +6,7 @@ import dts from 'vite-plugin-dts' import * as path from 'path' export default defineConfig({ - cacheDir: '../../node_modules/.vite/layouts', + cacheDir: '../../../node_modules/.vite/layouts', plugins: [ dts({ diff --git a/packages/client/state/src/lib/tabs.ts b/packages/client/state/src/lib/tabs.ts index 2b8a13acda..ad7e1ee877 100644 --- a/packages/client/state/src/lib/tabs.ts +++ b/packages/client/state/src/lib/tabs.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import { getWorkspaceLayout } from '@magickml/layouts' +import { getWorkspaceLayout } from 'client/layouts' import { createDraftSafeSelector, createEntityAdapter, diff --git a/packages/core/shared/src/state/tabs.ts b/packages/core/shared/src/state/tabs.ts index e75ee326a9..aa82853d34 100644 --- a/packages/core/shared/src/state/tabs.ts +++ b/packages/core/shared/src/state/tabs.ts @@ -5,7 +5,7 @@ import { createSlice, } from '@reduxjs/toolkit' -import { getWorkspaceLayout } from '@magickml/layouts' +import { getWorkspaceLayout } from 'client/layouts' import { RootState } from 'client/state' // Workspace map for initializing tabs with layout data diff --git a/packages/editor/src/contexts/TabProvider.tsx b/packages/editor/src/contexts/TabProvider.tsx index aa2f1b9a8f..351925fdab 100644 --- a/packages/editor/src/contexts/TabProvider.tsx +++ b/packages/editor/src/contexts/TabProvider.tsx @@ -1,10 +1,13 @@ -import { createContext, useContext, useEffect, useState } from "react" +import { createContext, useContext, useEffect, useState } from 'react' import { DockviewApi, - DockviewReact, DockviewReadyEvent, IDockviewPanelProps, SerializedDockview, -} from 'dockview'; -import { usePubSub } from "@magickml/client-core"; -import { getWorkspaceLayout } from "@magickml/layouts"; + DockviewReact, + DockviewReadyEvent, + IDockviewPanelProps, + SerializedDockview, +} from 'dockview' +import { usePubSub } from '@magickml/client-core' +import { getWorkspaceLayout } from 'client/layouts' type DockviewTheme = 'dockview-theme-abyss' @@ -18,11 +21,11 @@ export type Tab = { } type DocviewContext = { - theme: DockviewTheme, - setTheme: (theme: DockviewTheme) => void, - api: DockviewApi, - setApi: (api: DockviewApi) => void, - getLayout: () => SerializedDockview | null, + theme: DockviewTheme + setTheme: (theme: DockviewTheme) => void + api: DockviewApi + setApi: (api: DockviewApi) => void + getLayout: () => SerializedDockview | null setLayout: (layout: SerializedDockview) => void // IMPLEMENT THESE @@ -41,7 +44,7 @@ export const useTabLayout = () => useContext(Context) export const TabProvider = ({ children }) => { const [theme, setTheme] = useState('dockview-theme-abyss') - const [api, setApi] = useState(); + const [api, setApi] = useState() const pubSub = usePubSub() const getLayout = () => { @@ -50,7 +53,9 @@ export const TabProvider = ({ children }) => { if (!layout) { return null } - return JSON.parse(localStorage.getItem(TAB_LAYOUT_KEY)) as SerializedDockview + return JSON.parse( + localStorage.getItem(TAB_LAYOUT_KEY) + ) as SerializedDockview } const setLayout = (layout: SerializedDockview) => { @@ -59,17 +64,16 @@ export const TabProvider = ({ children }) => { useEffect(() => { if (!api) { - return; + return } // set up API event handlers api.onDidLayoutChange(() => { - const layout = api.toJSON(); + const layout = api.toJSON() setLayout(layout) - }); - - }, [api]); + }) + }, [api]) const openTab = (_tab: Tab) => { const tab = { @@ -81,9 +85,9 @@ export const TabProvider = ({ children }) => { component: tab.type, params: { tab, - theme - } - }); + theme, + }, + }) } const publicInterface = { @@ -93,7 +97,7 @@ export const TabProvider = ({ children }) => { setApi, getLayout, setLayout, - openTab + openTab, } return {children} -} \ No newline at end of file +} diff --git a/tsconfig.base.json b/tsconfig.base.json index 8b4bc2ce76..02ba524ae4 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -40,7 +40,6 @@ "@magickml/core": ["packages/core/shared/src/index.ts"], "@magickml/docs": ["apps/docs/src/index.ts"], "@magickml/editor": ["packages/editor/src/index.ts"], - "@magickml/layouts": ["packages/layouts/src/index.ts"], "@magickml/plugin-anthropic-client": [ "packages/plugins/anthropic/client/src/index.ts" ], @@ -203,6 +202,7 @@ "@magickml/ui/components": ["packages/utils/components/src/index.ts"], "@magickml/ui/utils": ["packages/ui/src/utils.ts"], "server/event-tracker": ["packages/server/event-tracker/src/index.ts"], + "client/layouts": ["packages/client/layouts/src/index.ts"], "client/state": ["packages/client/state/src/index.ts"], "rete": ["packages/rete/src/index.ts"] } From 7fe5da0bb1a8050070e263926ec6065df92ed2a4 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 27 Sep 2023 11:34:54 -0700 Subject: [PATCH 115/349] Move editor package into client folder --- apps/client/project.json | 2 +- apps/client/src/main.tsx | 20 +- packages/{ => client}/editor/.eslintrc.json | 2 +- packages/{ => client}/editor/.gitignore | 0 packages/{ => client}/editor/.gitkeep | 0 packages/{ => client}/editor/.npmignore | 0 packages/{ => client}/editor/jest.config.ts | 4 +- packages/{ => client}/editor/package.json | 2 +- packages/{ => client}/editor/project.json | 12 +- packages/{ => client}/editor/src/App.css | 0 packages/client/editor/src/App.css.d.ts | 5 + packages/client/editor/src/App.tsx | 16 ++ .../editor/src/DataControls/CheckBox.tsx | 26 +- .../editor/src/DataControls/CodeControl.tsx | 0 .../editor/src/DataControls/DataControls.tsx | 10 +- .../src/DataControls/DropdownSelect.tsx | 2 +- .../editor/src/DataControls/Form.tsx | 0 .../editor/src/DataControls/Info.tsx | 14 +- .../editor/src/DataControls/Input.tsx | 4 +- .../src/DataControls/InputGenerator.tsx | 89 ++++--- .../src/DataControls/LongTextControl.tsx | 16 +- .../src/DataControls/MultiSocketGenerator.tsx | 117 +++++---- .../src/DataControls/OutputGenerator.tsx | 88 +++---- .../src/DataControls/PlaytestControl.tsx | 8 +- .../editor/src/DataControls/SingleElement.tsx | 20 +- .../src/DataControls/SocketGenerator.tsx | 0 .../editor/src/DataControls/SpellSelect.tsx | 0 .../editor/src/DataControls/SwitchControl.tsx | 26 +- .../src/DataControls/datacontrols.module.css | 1 - .../DataControls/datacontrols.module.css.d.ts | 0 .../editor/src/DataControls/index.tsx | 6 +- packages/{ => client}/editor/src/MagickIDE.ts | 0 .../editor/src/components/EventHandler.tsx | 0 .../editor/src/components/FileInput.tsx | 0 .../editor/src/components/MenuBar/MenuBar.tsx | 10 +- .../components/MenuBar/OldMenuBar/index.tsx | 0 .../src/components/MenuBar/menuBar.module.css | 0 .../MenuBar/menuBar.module.css.d.ts | 13 + .../components/MenuBar/newMenuBar/index.tsx | 0 .../editor/src/components/Modal/Modal.tsx | 0 .../src/components/Modal/modal.module.css | 0 .../components/Modal/modal.module.css.d.ts | 14 + .../src/components/Modals/DeleteModal.tsx | 30 ++- .../src/components/Modals/EditSpellModal.tsx | 0 .../src/components/Modals/InfoModal.tsx | 0 .../src/components/Modals/SaveAsModal.tsx | 0 .../editor/src/components/Modals/index.ts | 16 +- .../Modals/loginModal.module.css.d.ts | 10 + .../components/Modals/modalForms.module.css | 0 .../Modals/modalForms.module.css.d.ts | 13 + .../src/components/Node/Node.module.css | 0 .../src/components/Node/Node.module.css.d.ts | 22 ++ .../editor/src/components/Node/Node.tsx | 10 +- .../editor/src/components/ProjectRow.tsx | 5 +- .../src/components/TabBar/CreateTab.tsx | 0 .../components/TabBar/MAGICK-whitelogo@4x.png | Bin .../editor/src/components/TabBar/TabBar.tsx | 0 .../src/components/TabBar/tabBar.module.css | 0 .../components/TabBar/tabBar.module.css.d.ts | 13 + .../components/TabBar/white-logomark@4x.png | Bin .../editor/src/components/TemplatePanel.tsx | 0 .../editor/src/components/VideoInput.tsx | 28 +- .../editor/src/components/WindowMessage.tsx | 10 +- .../editor/src/components/Workspace.tsx | 0 .../editor/src/components/Workspaces.tsx | 0 .../src/components/windowMessage.module.css | 0 .../editor/src/contexts/AppProviders.tsx | 34 +-- .../editor/src/contexts/EditorProvider.tsx | 0 .../src/contexts/GlobalLayoutProvider.tsx | 42 +-- .../editor/src/contexts/InspectorProvider.tsx | 14 +- .../editor/src/contexts/LayoutProvider.tsx | 0 .../src/contexts/MagickInterfaceProvider.tsx | 0 .../editor/src/contexts/ModalProvider.tsx | 54 ++-- .../editor/src/contexts/TabProvider.tsx | 0 .../editor/src/contexts/ToastProvider.tsx | 10 +- .../editor/src/contexts/WorkspaceProvider.tsx | 26 +- .../editor/src/contexts/styles.module.scss | 0 .../src/design-globals/design-globals.css | 0 .../design-globals/design-globals.css.d.ts | 8 +- packages/{ => client}/editor/src/editor.ts | 0 packages/{ => client}/editor/src/global.d.ts | 0 packages/{ => client}/editor/src/grid.png | Bin .../{ => client}/editor/src/hooks/useQuery.ts | 8 +- packages/{ => client}/editor/src/index.ts | 4 +- .../MagickPageLayout/MagickPageLayout.tsx | 0 .../MagickPageLayout/pagewrapper.module.css | 0 .../pagewrapper.module.css.d.ts} | 6 +- .../src/layouts/MainLayout/MainLayout.tsx | 0 packages/{ => client}/editor/src/main.tsx | 0 .../src/plugins/areaPlugin/background.js | 0 .../editor/src/plugins/areaPlugin/index.js | 0 .../src/plugins/areaPlugin/restrictor.js | 4 +- .../editor/src/plugins/areaPlugin/snap.ts | 0 .../editor/src/plugins/areaPlugin/style.css | 0 .../src/plugins/areaPlugin}/style.css.d.ts | 2 +- .../editor/src/plugins/areaPlugin/utils.js | 15 +- .../editor/src/plugins/areaPlugin/zoom-at.js | 0 .../plugins/autoArrangePlugin/auto-arrange.js | 12 +- .../src/plugins/autoArrangePlugin/board.js | 19 ++ .../src/plugins/autoArrangePlugin/cache.js | 10 + .../src/plugins/autoArrangePlugin/index.js | 0 .../src/plugins/commentPlugin/comment.js | 0 .../src/plugins/commentPlugin/draggable.js | 16 +- .../plugins/commentPlugin/frame-comment.js | 0 .../editor/src/plugins/commentPlugin/index.js | 0 .../plugins/commentPlugin/inline-comment.js | 0 .../src/plugins/commentPlugin/manager.js | 2 +- .../src/plugins/commentPlugin/style.css | 0 .../src/plugins/commentPlugin}/style.css.d.ts | 6 +- .../editor/src/plugins/commentPlugin/utils.js | 0 .../src/plugins/connectionPlugin/events.ts | 0 .../src/plugins/connectionPlugin/flow.ts | 0 .../src/plugins/connectionPlugin/index.css | 0 .../src/plugins/connectionPlugin/index.sass | 0 .../src/plugins/connectionPlugin/index.ts | 0 .../plugins/connectionPlugin/picker/index.ts | 0 .../plugins/connectionPlugin/picker/view.ts | 0 .../src/plugins/connectionPlugin/utils.ts | 0 .../editor/src/plugins/contextMenu/index.ts | 0 .../src/plugins/contextMenu/main-menu.ts | 0 .../editor/src/plugins/contextMenu/menu.ts | 0 .../src/plugins/contextMenu/node-menu.ts | 0 .../plugins/contextMenu/react-menu/Item.tsx | 54 ++-- .../plugins/contextMenu/react-menu/Menu.tsx | 57 ++-- .../plugins/contextMenu/react-menu/context.ts | 16 +- .../plugins/contextMenu/react-menu/index.tsx | 66 ++--- .../contextMenu/react-menu/style.module.scss | 0 .../src/plugins/contextMenu/style.module.scss | 0 .../editor/src/plugins/contextMenu/utils.ts | 0 .../editor/src/plugins/contextMenu/vars.scss | 2 +- .../src/plugins/highlightPlugin/index.ts | 0 .../src/plugins/highlightPlugin/utils.ts | 0 .../src/plugins/reactRenderPlugin/Control.tsx | 28 +- .../src/plugins/reactRenderPlugin/Image.tsx | 8 +- .../src/plugins/reactRenderPlugin/Node.tsx | 4 +- .../src/plugins/reactRenderPlugin/Socket.tsx | 30 +-- .../src/plugins/reactRenderPlugin/Upload.tsx | 0 .../src/plugins/reactRenderPlugin/index.tsx | 82 +++--- .../src/plugins/reactRenderPlugin/styles.css | 0 .../plugins/reactRenderPlugin/styles.css.d.ts | 4 +- .../src/plugins/reactRenderPlugin/utils.js | 0 .../src/plugins/reactRenderPlugin/vars.sass | 0 packages/{ => client}/editor/src/routes.tsx | 2 - .../editor/src/screens/Composer/index.tsx | 0 .../DocumentWindow/DocContentModal.tsx | 14 +- .../screens/DocumentWindow/DocumentModal.tsx | 205 +++++++++++++++ .../screens/DocumentWindow/DocumentTable.tsx | 119 +++++---- .../src/screens/DocumentWindow/document.ts | 14 +- .../DocumentWindow/documentconvert.tsx | 243 ++++++++++++++++++ .../screens/DocumentWindow/index.module.scss | 0 .../src/screens/DocumentWindow/index.tsx | 5 +- .../src/screens/EventWindow/EventTable.tsx | 79 +++--- .../editor/src/screens/EventWindow/event.ts | 0 .../src/screens/EventWindow/index.module.scss | 0 .../editor/src/screens/EventWindow/index.tsx | 0 .../src/screens/HomeScreen/AllProjects.tsx | 0 .../src/screens/HomeScreen/CreateNew.tsx | 0 .../src/screens/HomeScreen/HomeScreen.tsx | 0 .../src/screens/HomeScreen/OpenProject.tsx | 0 .../editor/src/screens/HomeScreen/banner.png | Bin .../editor/src/screens/HomeScreen/empty.png | Bin .../screens/HomeScreen/homeScreen.module.css | 0 .../HomeScreen/homeScreen.module.css.d.ts | 0 .../editor/src/screens/Magick/Magick.tsx | 0 .../src/screens/Magick/magick.module.css | 0 .../src/screens/Magick/magick.module.css.d.ts | 20 ++ .../editor/src/screens/MagickV2/index.tsx | 31 ++- .../screens/MagickV2/panels/fileDrawer.tsx | 98 +++++++ .../src/screens/MagickV2/panels/mainPanel.tsx | 52 ++-- .../screens/MagickV2/workspaces/composer.tsx | 0 .../screens/RequestWindow/RequestTable.tsx | 98 ++++--- .../screens/RequestWindow/index.module.scss | 0 .../src/screens/RequestWindow/index.tsx | 0 .../src/screens/RequestWindow/requests.ts | 56 ++++ .../src/screens/agents/AgentManagerWindow.tsx | 39 ++- .../screens/agents/AgentWindow/Accordion.tsx | 38 +-- .../agents/AgentWindow/AgentDetails.tsx | 121 ++++----- .../screens/agents/AgentWindow/AgentItem.tsx | 50 ++-- .../agents/AgentWindow/AgentPubVariables.tsx | 10 +- .../agents/AgentWindow/index.module.scss | 0 .../src/screens/agents/AgentWindow/index.tsx | 0 .../agents/AgentWindow/spellValidator.ts | 0 .../agents/AgentWindow/tooltip_texts.ts | 9 + .../agents/AgentWindowStyle.module.css | 0 .../src/screens/settings/SettingsWindow.tsx | 72 +++--- .../src/screens/settings/styles.module.scss | 4 +- .../{ => client}/editor/src/types/index.ts | 0 .../{ => client}/editor/src/types/openai.ts | 7 +- .../editor/src/types/styles/globals.css | 0 .../editor/src/utils/AsyncStorage.ts | 4 +- packages/client/editor/src/utils/app/clean.ts | 43 ++++ .../editor/src/utils/app/conversation.ts | 35 +++ packages/client/editor/src/utils/app/data.ts | 66 +++++ .../{ => client}/editor/src/utils/debounce.js | 0 .../{ => client}/editor/src/utils/json0.ts | 12 +- .../client/editor/src/utils/speechUtils.d.ts | 29 +++ .../editor/src/utils/speechUtils.ts | 0 .../{ => client}/editor/src/vite-env.d.ts | 0 packages/{ => client}/editor/src/wagmi.ts | 2 +- packages/{ => client}/editor/src/wdyr.ts | 0 .../editor/src/windows/AgentControlWindow.tsx | 0 .../editor/src/windows/DebugConsole/index.tsx | 0 .../EditorWindow/editorwindow.module.css | 0 .../EditorWindow/editorwindow.module.css.d.ts | 16 ++ .../editor/src/windows/EditorWindow/index.tsx | 16 +- .../editor/src/windows/InspectorWindow.tsx | 17 +- .../editor/src/windows/PlaytestWindow.tsx | 0 .../src/windows/TextEditorWindow/index.tsx | 0 .../src/windows/TextEditorWindow/utils.tsx | 0 packages/{ => client}/editor/tsconfig.json | 9 +- .../{ => client}/editor/tsconfig.lib.json | 2 +- .../{ => client}/editor/tsconfig.spec.json | 2 +- packages/{ => client}/editor/vite.config.ts | 4 +- packages/editor/src/App.tsx | 18 -- .../MenuBar/menuBar.module.css.d.ts | 13 - .../components/Modal/modal.module.css.d.ts | 14 - .../Modals/loginModal.module.css.d.ts | 10 - .../Modals/modalForms.module.css.d.ts | 13 - .../src/components/Node/Node.module.css.d.ts | 22 -- .../components/TabBar/tabBar.module.css.d.ts | 13 - .../pagewrapper.module.css.d.ts | 7 - .../src/plugins/autoArrangePlugin/board.js | 19 -- .../src/plugins/autoArrangePlugin/cache.js | 10 - .../DocumentWindow/documentconvert.tsx | 229 ----------------- .../src/screens/Magick/magick.module.css.d.ts | 20 -- .../screens/MagickV2/panels/fileDrawer.tsx | 100 ------- .../src/screens/RequestWindow/requests.ts | 58 ----- .../agents/AgentWindow/tooltip_texts.ts | 8 - packages/editor/src/utils/app/clean.ts | 43 ---- packages/editor/src/utils/app/conversation.ts | 29 --- packages/editor/src/utils/app/data.ts | 64 ----- packages/editor/src/utils/speechUtils.d.ts | 26 -- .../EditorWindow/editorwindow.module.css.d.ts | 16 -- tsconfig.base.json | 2 +- 234 files changed, 1991 insertions(+), 1713 deletions(-) rename packages/{ => client}/editor/.eslintrc.json (90%) rename packages/{ => client}/editor/.gitignore (100%) rename packages/{ => client}/editor/.gitkeep (100%) rename packages/{ => client}/editor/.npmignore (100%) rename packages/{ => client}/editor/jest.config.ts (73%) rename packages/{ => client}/editor/package.json (81%) rename packages/{ => client}/editor/project.json (74%) rename packages/{ => client}/editor/src/App.css (100%) create mode 100644 packages/client/editor/src/App.css.d.ts create mode 100644 packages/client/editor/src/App.tsx rename packages/{ => client}/editor/src/DataControls/CheckBox.tsx (79%) rename packages/{ => client}/editor/src/DataControls/CodeControl.tsx (100%) rename packages/{ => client}/editor/src/DataControls/DataControls.tsx (96%) rename packages/{ => client}/editor/src/DataControls/DropdownSelect.tsx (99%) rename packages/{ => client}/editor/src/DataControls/Form.tsx (100%) rename packages/{ => client}/editor/src/DataControls/Info.tsx (70%) rename packages/{ => client}/editor/src/DataControls/Input.tsx (97%) rename packages/{ => client}/editor/src/DataControls/InputGenerator.tsx (64%) rename packages/{ => client}/editor/src/DataControls/LongTextControl.tsx (50%) rename packages/{ => client}/editor/src/DataControls/MultiSocketGenerator.tsx (65%) rename packages/{ => client}/editor/src/DataControls/OutputGenerator.tsx (66%) rename packages/{ => client}/editor/src/DataControls/PlaytestControl.tsx (94%) rename packages/{ => client}/editor/src/DataControls/SingleElement.tsx (83%) rename packages/{ => client}/editor/src/DataControls/SocketGenerator.tsx (100%) rename packages/{ => client}/editor/src/DataControls/SpellSelect.tsx (100%) rename packages/{ => client}/editor/src/DataControls/SwitchControl.tsx (76%) rename packages/{ => client}/editor/src/DataControls/datacontrols.module.css (99%) rename packages/{ => client}/editor/src/DataControls/datacontrols.module.css.d.ts (100%) rename packages/{ => client}/editor/src/DataControls/index.tsx (54%) rename packages/{ => client}/editor/src/MagickIDE.ts (100%) rename packages/{ => client}/editor/src/components/EventHandler.tsx (100%) rename packages/{ => client}/editor/src/components/FileInput.tsx (100%) rename packages/{ => client}/editor/src/components/MenuBar/MenuBar.tsx (70%) rename packages/{ => client}/editor/src/components/MenuBar/OldMenuBar/index.tsx (100%) rename packages/{ => client}/editor/src/components/MenuBar/menuBar.module.css (100%) create mode 100644 packages/client/editor/src/components/MenuBar/menuBar.module.css.d.ts rename packages/{ => client}/editor/src/components/MenuBar/newMenuBar/index.tsx (100%) rename packages/{ => client}/editor/src/components/Modal/Modal.tsx (100%) rename packages/{ => client}/editor/src/components/Modal/modal.module.css (100%) create mode 100644 packages/client/editor/src/components/Modal/modal.module.css.d.ts rename packages/{ => client}/editor/src/components/Modals/DeleteModal.tsx (75%) rename packages/{ => client}/editor/src/components/Modals/EditSpellModal.tsx (100%) rename packages/{ => client}/editor/src/components/Modals/InfoModal.tsx (100%) rename packages/{ => client}/editor/src/components/Modals/SaveAsModal.tsx (100%) rename packages/{ => client}/editor/src/components/Modals/index.ts (69%) create mode 100644 packages/client/editor/src/components/Modals/loginModal.module.css.d.ts rename packages/{ => client}/editor/src/components/Modals/modalForms.module.css (100%) create mode 100644 packages/client/editor/src/components/Modals/modalForms.module.css.d.ts rename packages/{ => client}/editor/src/components/Node/Node.module.css (100%) create mode 100644 packages/client/editor/src/components/Node/Node.module.css.d.ts rename packages/{ => client}/editor/src/components/Node/Node.tsx (96%) rename packages/{ => client}/editor/src/components/ProjectRow.tsx (95%) rename packages/{ => client}/editor/src/components/TabBar/CreateTab.tsx (100%) rename packages/{ => client}/editor/src/components/TabBar/MAGICK-whitelogo@4x.png (100%) rename packages/{ => client}/editor/src/components/TabBar/TabBar.tsx (100%) rename packages/{ => client}/editor/src/components/TabBar/tabBar.module.css (100%) create mode 100644 packages/client/editor/src/components/TabBar/tabBar.module.css.d.ts rename packages/{ => client}/editor/src/components/TabBar/white-logomark@4x.png (100%) rename packages/{ => client}/editor/src/components/TemplatePanel.tsx (100%) rename packages/{ => client}/editor/src/components/VideoInput.tsx (70%) rename packages/{ => client}/editor/src/components/WindowMessage.tsx (76%) rename packages/{ => client}/editor/src/components/Workspace.tsx (100%) rename packages/{ => client}/editor/src/components/Workspaces.tsx (100%) rename packages/{ => client}/editor/src/components/windowMessage.module.css (100%) rename packages/{ => client}/editor/src/contexts/AppProviders.tsx (72%) rename packages/{ => client}/editor/src/contexts/EditorProvider.tsx (100%) rename packages/{ => client}/editor/src/contexts/GlobalLayoutProvider.tsx (79%) rename packages/{ => client}/editor/src/contexts/InspectorProvider.tsx (95%) rename packages/{ => client}/editor/src/contexts/LayoutProvider.tsx (100%) rename packages/{ => client}/editor/src/contexts/MagickInterfaceProvider.tsx (100%) rename packages/{ => client}/editor/src/contexts/ModalProvider.tsx (67%) rename packages/{ => client}/editor/src/contexts/TabProvider.tsx (100%) rename packages/{ => client}/editor/src/contexts/ToastProvider.tsx (92%) rename packages/{ => client}/editor/src/contexts/WorkspaceProvider.tsx (74%) rename packages/{ => client}/editor/src/contexts/styles.module.scss (100%) rename packages/{ => client}/editor/src/design-globals/design-globals.css (100%) rename packages/{ => client}/editor/src/design-globals/design-globals.css.d.ts (61%) rename packages/{ => client}/editor/src/editor.ts (100%) rename packages/{ => client}/editor/src/global.d.ts (100%) rename packages/{ => client}/editor/src/grid.png (100%) rename packages/{ => client}/editor/src/hooks/useQuery.ts (69%) rename packages/{ => client}/editor/src/index.ts (62%) rename packages/{ => client}/editor/src/layouts/MagickPageLayout/MagickPageLayout.tsx (100%) rename packages/{ => client}/editor/src/layouts/MagickPageLayout/pagewrapper.module.css (100%) rename packages/{editor/src/App.css.d.ts => client/editor/src/layouts/MagickPageLayout/pagewrapper.module.css.d.ts} (55%) rename packages/{ => client}/editor/src/layouts/MainLayout/MainLayout.tsx (100%) rename packages/{ => client}/editor/src/main.tsx (100%) rename packages/{ => client}/editor/src/plugins/areaPlugin/background.js (100%) mode change 100755 => 100644 rename packages/{ => client}/editor/src/plugins/areaPlugin/index.js (100%) mode change 100755 => 100644 rename packages/{ => client}/editor/src/plugins/areaPlugin/restrictor.js (93%) mode change 100755 => 100644 rename packages/{ => client}/editor/src/plugins/areaPlugin/snap.ts (100%) mode change 100755 => 100644 rename packages/{ => client}/editor/src/plugins/areaPlugin/style.css (100%) mode change 100755 => 100644 rename packages/{editor/src/plugins/commentPlugin => client/editor/src/plugins/areaPlugin}/style.css.d.ts (85%) rename packages/{ => client}/editor/src/plugins/areaPlugin/utils.js (75%) mode change 100755 => 100644 rename packages/{ => client}/editor/src/plugins/areaPlugin/zoom-at.js (100%) mode change 100755 => 100644 rename packages/{ => client}/editor/src/plugins/autoArrangePlugin/auto-arrange.js (96%) create mode 100644 packages/client/editor/src/plugins/autoArrangePlugin/board.js create mode 100644 packages/client/editor/src/plugins/autoArrangePlugin/cache.js rename packages/{ => client}/editor/src/plugins/autoArrangePlugin/index.js (100%) rename packages/{ => client}/editor/src/plugins/commentPlugin/comment.js (100%) rename packages/{ => client}/editor/src/plugins/commentPlugin/draggable.js (87%) rename packages/{ => client}/editor/src/plugins/commentPlugin/frame-comment.js (100%) rename packages/{ => client}/editor/src/plugins/commentPlugin/index.js (100%) rename packages/{ => client}/editor/src/plugins/commentPlugin/inline-comment.js (100%) rename packages/{ => client}/editor/src/plugins/commentPlugin/manager.js (97%) rename packages/{ => client}/editor/src/plugins/commentPlugin/style.css (100%) rename packages/{editor/src/plugins/areaPlugin => client/editor/src/plugins/commentPlugin}/style.css.d.ts (69%) rename packages/{ => client}/editor/src/plugins/commentPlugin/utils.js (100%) rename packages/{ => client}/editor/src/plugins/connectionPlugin/events.ts (100%) rename packages/{ => client}/editor/src/plugins/connectionPlugin/flow.ts (100%) rename packages/{ => client}/editor/src/plugins/connectionPlugin/index.css (100%) rename packages/{ => client}/editor/src/plugins/connectionPlugin/index.sass (100%) rename packages/{ => client}/editor/src/plugins/connectionPlugin/index.ts (100%) rename packages/{ => client}/editor/src/plugins/connectionPlugin/picker/index.ts (100%) rename packages/{ => client}/editor/src/plugins/connectionPlugin/picker/view.ts (100%) rename packages/{ => client}/editor/src/plugins/connectionPlugin/utils.ts (100%) rename packages/{ => client}/editor/src/plugins/contextMenu/index.ts (100%) mode change 100755 => 100644 rename packages/{ => client}/editor/src/plugins/contextMenu/main-menu.ts (100%) rename packages/{ => client}/editor/src/plugins/contextMenu/menu.ts (100%) rename packages/{ => client}/editor/src/plugins/contextMenu/node-menu.ts (100%) mode change 100755 => 100644 rename packages/{ => client}/editor/src/plugins/contextMenu/react-menu/Item.tsx (71%) rename packages/{ => client}/editor/src/plugins/contextMenu/react-menu/Menu.tsx (78%) rename packages/{ => client}/editor/src/plugins/contextMenu/react-menu/context.ts (73%) rename packages/{ => client}/editor/src/plugins/contextMenu/react-menu/index.tsx (62%) rename packages/{ => client}/editor/src/plugins/contextMenu/react-menu/style.module.scss (100%) rename packages/{ => client}/editor/src/plugins/contextMenu/style.module.scss (100%) rename packages/{ => client}/editor/src/plugins/contextMenu/utils.ts (100%) rename packages/{ => client}/editor/src/plugins/contextMenu/vars.scss (50%) rename packages/{ => client}/editor/src/plugins/highlightPlugin/index.ts (100%) rename packages/{ => client}/editor/src/plugins/highlightPlugin/utils.ts (100%) rename packages/{ => client}/editor/src/plugins/reactRenderPlugin/Control.tsx (61%) rename packages/{ => client}/editor/src/plugins/reactRenderPlugin/Image.tsx (80%) rename packages/{ => client}/editor/src/plugins/reactRenderPlugin/Node.tsx (99%) rename packages/{ => client}/editor/src/plugins/reactRenderPlugin/Socket.tsx (72%) rename packages/{ => client}/editor/src/plugins/reactRenderPlugin/Upload.tsx (100%) rename packages/{ => client}/editor/src/plugins/reactRenderPlugin/index.tsx (58%) rename packages/{ => client}/editor/src/plugins/reactRenderPlugin/styles.css (100%) rename packages/{ => client}/editor/src/plugins/reactRenderPlugin/styles.css.d.ts (84%) rename packages/{ => client}/editor/src/plugins/reactRenderPlugin/utils.js (100%) rename packages/{ => client}/editor/src/plugins/reactRenderPlugin/vars.sass (100%) rename packages/{ => client}/editor/src/routes.tsx (99%) rename packages/{ => client}/editor/src/screens/Composer/index.tsx (100%) rename packages/{ => client}/editor/src/screens/DocumentWindow/DocContentModal.tsx (71%) create mode 100644 packages/client/editor/src/screens/DocumentWindow/DocumentModal.tsx rename packages/{ => client}/editor/src/screens/DocumentWindow/DocumentTable.tsx (85%) rename packages/{ => client}/editor/src/screens/DocumentWindow/document.ts (65%) create mode 100644 packages/client/editor/src/screens/DocumentWindow/documentconvert.tsx rename packages/{ => client}/editor/src/screens/DocumentWindow/index.module.scss (100%) rename packages/{ => client}/editor/src/screens/DocumentWindow/index.tsx (93%) rename packages/{ => client}/editor/src/screens/EventWindow/EventTable.tsx (88%) rename packages/{ => client}/editor/src/screens/EventWindow/event.ts (100%) rename packages/{ => client}/editor/src/screens/EventWindow/index.module.scss (100%) rename packages/{ => client}/editor/src/screens/EventWindow/index.tsx (100%) rename packages/{ => client}/editor/src/screens/HomeScreen/AllProjects.tsx (100%) rename packages/{ => client}/editor/src/screens/HomeScreen/CreateNew.tsx (100%) rename packages/{ => client}/editor/src/screens/HomeScreen/HomeScreen.tsx (100%) rename packages/{ => client}/editor/src/screens/HomeScreen/OpenProject.tsx (100%) rename packages/{ => client}/editor/src/screens/HomeScreen/banner.png (100%) rename packages/{ => client}/editor/src/screens/HomeScreen/empty.png (100%) rename packages/{ => client}/editor/src/screens/HomeScreen/homeScreen.module.css (100%) rename packages/{ => client}/editor/src/screens/HomeScreen/homeScreen.module.css.d.ts (100%) rename packages/{ => client}/editor/src/screens/Magick/Magick.tsx (100%) rename packages/{ => client}/editor/src/screens/Magick/magick.module.css (100%) create mode 100644 packages/client/editor/src/screens/Magick/magick.module.css.d.ts rename packages/{ => client}/editor/src/screens/MagickV2/index.tsx (83%) create mode 100644 packages/client/editor/src/screens/MagickV2/panels/fileDrawer.tsx rename packages/{ => client}/editor/src/screens/MagickV2/panels/mainPanel.tsx (67%) rename packages/{ => client}/editor/src/screens/MagickV2/workspaces/composer.tsx (100%) rename packages/{ => client}/editor/src/screens/RequestWindow/RequestTable.tsx (89%) rename packages/{ => client}/editor/src/screens/RequestWindow/index.module.scss (100%) rename packages/{ => client}/editor/src/screens/RequestWindow/index.tsx (100%) create mode 100644 packages/client/editor/src/screens/RequestWindow/requests.ts rename packages/{ => client}/editor/src/screens/agents/AgentManagerWindow.tsx (92%) rename packages/{ => client}/editor/src/screens/agents/AgentWindow/Accordion.tsx (85%) rename packages/{ => client}/editor/src/screens/agents/AgentWindow/AgentDetails.tsx (84%) rename packages/{ => client}/editor/src/screens/agents/AgentWindow/AgentItem.tsx (62%) rename packages/{ => client}/editor/src/screens/agents/AgentWindow/AgentPubVariables.tsx (90%) rename packages/{ => client}/editor/src/screens/agents/AgentWindow/index.module.scss (100%) rename packages/{ => client}/editor/src/screens/agents/AgentWindow/index.tsx (100%) rename packages/{ => client}/editor/src/screens/agents/AgentWindow/spellValidator.ts (100%) create mode 100644 packages/client/editor/src/screens/agents/AgentWindow/tooltip_texts.ts rename packages/{ => client}/editor/src/screens/agents/AgentWindowStyle.module.css (100%) rename packages/{ => client}/editor/src/screens/settings/SettingsWindow.tsx (76%) rename packages/{ => client}/editor/src/screens/settings/styles.module.scss (97%) rename packages/{ => client}/editor/src/types/index.ts (100%) rename packages/{ => client}/editor/src/types/openai.ts (68%) rename packages/{ => client}/editor/src/types/styles/globals.css (100%) rename packages/{ => client}/editor/src/utils/AsyncStorage.ts (98%) create mode 100644 packages/client/editor/src/utils/app/clean.ts create mode 100644 packages/client/editor/src/utils/app/conversation.ts create mode 100644 packages/client/editor/src/utils/app/data.ts rename packages/{ => client}/editor/src/utils/debounce.js (100%) rename packages/{ => client}/editor/src/utils/json0.ts (67%) create mode 100644 packages/client/editor/src/utils/speechUtils.d.ts rename packages/{ => client}/editor/src/utils/speechUtils.ts (100%) rename packages/{ => client}/editor/src/vite-env.d.ts (100%) rename packages/{ => client}/editor/src/wagmi.ts (99%) rename packages/{ => client}/editor/src/wdyr.ts (100%) rename packages/{ => client}/editor/src/windows/AgentControlWindow.tsx (100%) rename packages/{ => client}/editor/src/windows/DebugConsole/index.tsx (100%) rename packages/{ => client}/editor/src/windows/EditorWindow/editorwindow.module.css (100%) create mode 100644 packages/client/editor/src/windows/EditorWindow/editorwindow.module.css.d.ts rename packages/{ => client}/editor/src/windows/EditorWindow/index.tsx (96%) rename packages/{ => client}/editor/src/windows/InspectorWindow.tsx (92%) rename packages/{ => client}/editor/src/windows/PlaytestWindow.tsx (100%) rename packages/{ => client}/editor/src/windows/TextEditorWindow/index.tsx (100%) rename packages/{ => client}/editor/src/windows/TextEditorWindow/utils.tsx (100%) rename packages/{ => client}/editor/tsconfig.json (79%) rename packages/{ => client}/editor/tsconfig.lib.json (91%) rename packages/{ => client}/editor/tsconfig.spec.json (91%) rename packages/{ => client}/editor/vite.config.ts (96%) delete mode 100644 packages/editor/src/App.tsx delete mode 100644 packages/editor/src/components/MenuBar/menuBar.module.css.d.ts delete mode 100644 packages/editor/src/components/Modal/modal.module.css.d.ts delete mode 100644 packages/editor/src/components/Modals/loginModal.module.css.d.ts delete mode 100644 packages/editor/src/components/Modals/modalForms.module.css.d.ts delete mode 100644 packages/editor/src/components/Node/Node.module.css.d.ts delete mode 100644 packages/editor/src/components/TabBar/tabBar.module.css.d.ts delete mode 100644 packages/editor/src/layouts/MagickPageLayout/pagewrapper.module.css.d.ts delete mode 100644 packages/editor/src/plugins/autoArrangePlugin/board.js delete mode 100644 packages/editor/src/plugins/autoArrangePlugin/cache.js delete mode 100644 packages/editor/src/screens/DocumentWindow/documentconvert.tsx delete mode 100644 packages/editor/src/screens/Magick/magick.module.css.d.ts delete mode 100644 packages/editor/src/screens/MagickV2/panels/fileDrawer.tsx delete mode 100644 packages/editor/src/screens/RequestWindow/requests.ts delete mode 100644 packages/editor/src/screens/agents/AgentWindow/tooltip_texts.ts delete mode 100644 packages/editor/src/utils/app/clean.ts delete mode 100644 packages/editor/src/utils/app/conversation.ts delete mode 100644 packages/editor/src/utils/app/data.ts delete mode 100644 packages/editor/src/utils/speechUtils.d.ts delete mode 100644 packages/editor/src/windows/EditorWindow/editorwindow.module.css.d.ts diff --git a/apps/client/project.json b/apps/client/project.json index 2eea98481e..5a0de8c101 100644 --- a/apps/client/project.json +++ b/apps/client/project.json @@ -3,7 +3,7 @@ "$schema": "../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "apps/client/src", "projectType": "application", - "implicitDependencies": ["@magickml/editor", "@magickml/core"], + "implicitDependencies": ["client-editor", "@magickml/core"], "targets": { "build": { "executor": "@nx/vite:build", diff --git a/apps/client/src/main.tsx b/apps/client/src/main.tsx index b82e0e6531..e8413169ed 100644 --- a/apps/client/src/main.tsx +++ b/apps/client/src/main.tsx @@ -1,6 +1,6 @@ // DOCUMENTED import { createRoot } from 'react-dom/client' -import { MagickIDE } from '@magickml/editor' +import { MagickIDE } from 'client/editor' import { AppConfig } from '@magickml/client-core' import { DEFAULT_PROJECT_ID, @@ -19,7 +19,7 @@ import plugins from './plugins' // We want to add this back in eventually, but it's causing some visual bugs //import './globals.css' -initLogger({ name: "AIDE" }) +initLogger({ name: 'AIDE' }) const logger = getLogger() @@ -28,12 +28,12 @@ logger.info('loaded with plugins %o', plugins) * Initialize and render the MagickIDE component when running as a standalone editor (not inside an iframe) */ if (window === window.parent) { - logger.info("not in iframe") + logger.info('not in iframe') if (STANDALONE) { - logger.info("standalone") + logger.info('standalone') const container = document.getElementById('root') as Element const root = createRoot(container) // createRoot(container!) if you use TypeScript - ; (window as any).root = root + ;(window as any).root = root // Check URL parameters for projectId and apiUrl const projectId = @@ -56,7 +56,7 @@ if (window === window.parent) { root.render() } } else { - logger.info("iframe: In iframe") + logger.info('iframe: In iframe') /** * If the editor is loaded in an iframe, listen for messages from the parent to initialize and render the MagickIDE component */ @@ -72,11 +72,17 @@ if (window === window.parent) { event.origin !== window.location.origin && !TRUSTED_PARENT_URLS.includes(event.origin) ) { +<<<<<<< HEAD logger.error('Untrusted origin %s', event.origin); // Log the trusted origins for debugging purposes TRUSTED_PARENT_URLS.forEach(trustedUrl => { logger.error('Trusted origin is %s', trustedUrl); }); +======= + logger.error('untrusted origin %s', event.origin) + logger.error('cloudUrl is %s', cloudUrl) + logger.error('TRUSTED_PARENT_URL is %s', TRUSTED_PARENT_URL) +>>>>>>> 950214186 (Move editor package into client folder) return; } @@ -108,7 +114,7 @@ if (window === window.parent) { } const container = document.getElementById('root') as Element const root = createRoot(container) // createRoot(container!) if you use TypeScript - ; (window as any).root = root + ;(window as any).root = root logger.info('iframe: rendering root') root.render() diff --git a/packages/editor/.eslintrc.json b/packages/client/editor/.eslintrc.json similarity index 90% rename from packages/editor/.eslintrc.json rename to packages/client/editor/.eslintrc.json index 00144900ed..c2b9bab695 100644 --- a/packages/editor/.eslintrc.json +++ b/packages/client/editor/.eslintrc.json @@ -1,5 +1,5 @@ { - "extends": ["plugin:@nx/react", "../../.eslintrc.json"], + "extends": ["plugin:@nx/react", "../../../.eslintrc.json"], "ignorePatterns": ["!**/*"], "overrides": [ { diff --git a/packages/editor/.gitignore b/packages/client/editor/.gitignore similarity index 100% rename from packages/editor/.gitignore rename to packages/client/editor/.gitignore diff --git a/packages/editor/.gitkeep b/packages/client/editor/.gitkeep similarity index 100% rename from packages/editor/.gitkeep rename to packages/client/editor/.gitkeep diff --git a/packages/editor/.npmignore b/packages/client/editor/.npmignore similarity index 100% rename from packages/editor/.npmignore rename to packages/client/editor/.npmignore diff --git a/packages/editor/jest.config.ts b/packages/client/editor/jest.config.ts similarity index 73% rename from packages/editor/jest.config.ts rename to packages/client/editor/jest.config.ts index e345afedf0..5dc2173499 100644 --- a/packages/editor/jest.config.ts +++ b/packages/client/editor/jest.config.ts @@ -1,11 +1,11 @@ /* eslint-disable */ export default { displayName: 'editor', - preset: '../../jest.preset.js', + preset: '../../../jest.preset.js', transform: { '^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest', '^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nx/react/babel'] }], }, moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], - coverageDirectory: '../../coverage/packages/editor', + coverageDirectory: '../../../coverage/packages/client/editor', } diff --git a/packages/editor/package.json b/packages/client/editor/package.json similarity index 81% rename from packages/editor/package.json rename to packages/client/editor/package.json index 68b1c2c207..f61be93e9b 100644 --- a/packages/editor/package.json +++ b/packages/client/editor/package.json @@ -1,5 +1,5 @@ { - "name": "@magickml/editor", + "name": "client/editor", "version": "0.1.0", "main": "dist/index.js", "scripts": { diff --git a/packages/editor/project.json b/packages/client/editor/project.json similarity index 74% rename from packages/editor/project.json rename to packages/client/editor/project.json index fc6ad1b096..3fd95b0d76 100644 --- a/packages/editor/project.json +++ b/packages/client/editor/project.json @@ -1,7 +1,7 @@ { - "name": "@magickml/editor", + "name": "client-editor", "$schema": "../../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "packages/editor/src", + "sourceRoot": "packages/client/editor/src", "projectType": "library", "implicitDependencies": ["@magickml/core"], "tags": [], @@ -10,16 +10,16 @@ "executor": "@nx/linter:eslint", "outputs": ["{options.outputFile}"], "options": { - "lintFilePatterns": ["packages/editor/**/*.{ts,tsx,js,jsx}"] + "lintFilePatterns": ["packages/client/editor/**/*.{ts,tsx,js,jsx}"] } }, "build": { "executor": "@nx/vite:build", "outputs": ["{options.outputPath}"], - "configFile": "packages/editor/vite.config.ts", + "configFile": "packages/client/editor/vite.config.ts", "defaultConfiguration": "production", "options": { - "outputPath": "dist/packages/editor" + "outputPath": "dist/packages/client/editor" }, "configurations": { "development": { @@ -34,7 +34,7 @@ "executor": "@nx/jest:jest", "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], "options": { - "jestConfig": "packages/editor/jest.config.ts", + "jestConfig": "packages/client/editor/jest.config.ts", "passWithNoTests": true }, "configurations": { diff --git a/packages/editor/src/App.css b/packages/client/editor/src/App.css similarity index 100% rename from packages/editor/src/App.css rename to packages/client/editor/src/App.css diff --git a/packages/client/editor/src/App.css.d.ts b/packages/client/editor/src/App.css.d.ts new file mode 100644 index 0000000000..e8c5f269e2 --- /dev/null +++ b/packages/client/editor/src/App.css.d.ts @@ -0,0 +1,5 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports {} +export const cssExports: CssExports +export default cssExports diff --git a/packages/client/editor/src/App.tsx b/packages/client/editor/src/App.tsx new file mode 100644 index 0000000000..96233b629a --- /dev/null +++ b/packages/client/editor/src/App.tsx @@ -0,0 +1,16 @@ +// DOCUMENTED +/** + * A functional component that renders the 'Routes' component. + */ +import React from 'react' +import Routes from './routes' +import './App.css' +import enableWhyDidYouRender from './wdyr' + +enableWhyDidYouRender(React) + +function App(): JSX.Element { + return +} + +export default App diff --git a/packages/editor/src/DataControls/CheckBox.tsx b/packages/client/editor/src/DataControls/CheckBox.tsx similarity index 79% rename from packages/editor/src/DataControls/CheckBox.tsx rename to packages/client/editor/src/DataControls/CheckBox.tsx index bd4af39c7d..b6d7d0b846 100644 --- a/packages/editor/src/DataControls/CheckBox.tsx +++ b/packages/client/editor/src/DataControls/CheckBox.tsx @@ -1,4 +1,4 @@ -// DOCUMENTED +// DOCUMENTED /** * A control component that renders a checkbox and updates data based on user input. * This component uses the MUI Checkbox and FormControlLabel components. @@ -9,27 +9,27 @@ * @param {Boolean} props.initialValue - The initial value of the checkbox. * @returns {JSX.Element} - The JSX code that renders the CheckboxControl component. */ -import { useState } from 'react'; -import { Checkbox, FormControlLabel, FormGroup } from '@mui/material'; +import { useState } from 'react' +import { Checkbox, FormControlLabel, FormGroup } from '@mui/material' const CheckBoxControl = ({ control, updateData, initialValue }) => { // Extract relevant properties from props - const { dataKey, data } = control; + const { dataKey, data } = control // Initialize the checked state with the initialValue prop - const [checked, setChecked] = useState(initialValue); + const [checked, setChecked] = useState(initialValue) /** * Handle the onChange event of the checkbox. * @param {Object} e - The event object. * @returns {void} */ - const onChange = (e) => { - const isChecked = e.target.checked; + const onChange = e => { + const isChecked = e.target.checked // Update the checked state - setChecked(isChecked); + setChecked(isChecked) // Update the data using the updateData prop method - updateData({ [dataKey]: isChecked }); - }; + updateData({ [dataKey]: isChecked }) + } return ( @@ -40,7 +40,7 @@ const CheckBoxControl = ({ control, updateData, initialValue }) => { /> - ); -}; + ) +} -export default CheckBoxControl; \ No newline at end of file +export default CheckBoxControl diff --git a/packages/editor/src/DataControls/CodeControl.tsx b/packages/client/editor/src/DataControls/CodeControl.tsx similarity index 100% rename from packages/editor/src/DataControls/CodeControl.tsx rename to packages/client/editor/src/DataControls/CodeControl.tsx diff --git a/packages/editor/src/DataControls/DataControls.tsx b/packages/client/editor/src/DataControls/DataControls.tsx similarity index 96% rename from packages/editor/src/DataControls/DataControls.tsx rename to packages/client/editor/src/DataControls/DataControls.tsx index e7d1f16da5..c7c996d275 100644 --- a/packages/editor/src/DataControls/DataControls.tsx +++ b/packages/client/editor/src/DataControls/DataControls.tsx @@ -14,9 +14,7 @@ import SwitchControl from './SwitchControl' import SpellSelect from './SpellSelect' import CheckBoxControl from './CheckBox' import { ControlData } from '@magickml/core' -import {Tooltip } from '@mui/material' - - +import { Tooltip } from '@mui/material' /** * Stub component for unknown control types. @@ -125,9 +123,9 @@ const DataControls = ({ > -

- {control.name || key} -

+

+ {control.name || key} +

diff --git a/packages/editor/src/DataControls/DropdownSelect.tsx b/packages/client/editor/src/DataControls/DropdownSelect.tsx similarity index 99% rename from packages/editor/src/DataControls/DropdownSelect.tsx rename to packages/client/editor/src/DataControls/DropdownSelect.tsx index e231c9e315..a110af9723 100644 --- a/packages/editor/src/DataControls/DropdownSelect.tsx +++ b/packages/client/editor/src/DataControls/DropdownSelect.tsx @@ -1,4 +1,4 @@ -// DOCUMENTED +// DOCUMENTED /** * A component that displays a dropdown select menu based on some control object * @param control - The control object that contains the dataKey, data, etc. diff --git a/packages/editor/src/DataControls/Form.tsx b/packages/client/editor/src/DataControls/Form.tsx similarity index 100% rename from packages/editor/src/DataControls/Form.tsx rename to packages/client/editor/src/DataControls/Form.tsx diff --git a/packages/editor/src/DataControls/Info.tsx b/packages/client/editor/src/DataControls/Info.tsx similarity index 70% rename from packages/editor/src/DataControls/Info.tsx rename to packages/client/editor/src/DataControls/Info.tsx index 7951d40146..9257cc1997 100644 --- a/packages/editor/src/DataControls/Info.tsx +++ b/packages/client/editor/src/DataControls/Info.tsx @@ -1,15 +1,19 @@ -// DOCUMENTED +// DOCUMENTED /** * A functional component that renders information in a div element. * @param {object} control - The control object that contains the information to be displayed. * @returns {JSX.Element} - The JSX representation of the component. */ -const InfoControl = ({ control }: { control: { data: { info: string } } }): JSX.Element => { +const InfoControl = ({ + control, +}: { + control: { data: { info: string } } +}): JSX.Element => { return (

{control.data.info}

- ); -}; + ) +} -export default InfoControl; \ No newline at end of file +export default InfoControl diff --git a/packages/editor/src/DataControls/Input.tsx b/packages/client/editor/src/DataControls/Input.tsx similarity index 97% rename from packages/editor/src/DataControls/Input.tsx rename to packages/client/editor/src/DataControls/Input.tsx index a8ea4c45cf..365544b3f6 100644 --- a/packages/editor/src/DataControls/Input.tsx +++ b/packages/client/editor/src/DataControls/Input.tsx @@ -1,4 +1,4 @@ -// DOCUMENTED +// DOCUMENTED /** * InputControl is a reusable React component that allows the user to create an input control with optional initial value, * and a callback function that gets called every time the value of the input is changed. @@ -41,4 +41,4 @@ const InputControl: React.FC<{ ) } -export default InputControl \ No newline at end of file +export default InputControl diff --git a/packages/editor/src/DataControls/InputGenerator.tsx b/packages/client/editor/src/DataControls/InputGenerator.tsx similarity index 64% rename from packages/editor/src/DataControls/InputGenerator.tsx rename to packages/client/editor/src/DataControls/InputGenerator.tsx index 538ff1cf2a..3ae8245ed5 100644 --- a/packages/editor/src/DataControls/InputGenerator.tsx +++ b/packages/client/editor/src/DataControls/InputGenerator.tsx @@ -1,4 +1,4 @@ -// DOCUMENTED +// DOCUMENTED /** * A component that generates multiple inputs based on the `initialValue`. * @param {Object} props - Component props. @@ -8,28 +8,28 @@ * @returns {JSX.Element} A component that generates multiple input fields. */ -import React, { useState, useEffect } from 'react'; -import PropTypes from 'prop-types'; -import Form from './Form'; -import SingleElement from './SingleElement'; +import React, { useState, useEffect } from 'react' +import PropTypes from 'prop-types' +import Form from './Form' +import SingleElement from './SingleElement' const AddNewInput = ({ addInput }) => { - const [value, setValue] = useState(''); + const [value, setValue] = useState('') - const onChange = (e) => { - setValue(e.target.value); - }; + const onChange = e => { + setValue(e.target.value) + } - const onAdd = (e) => { - e.preventDefault(); + const onAdd = e => { + e.preventDefault() if (!value) { - return; + return } - addInput(value); - setValue(''); - }; + addInput(value) + setValue('') + } return (
{ onChange={onChange} onAdd={onAdd} /> - ); -}; + ) +} AddNewInput.propTypes = { addInput: PropTypes.func.isRequired, -}; +} const InputGenerator = ({ updateData, control, initialValue }) => { - const [inputs, setInputs] = useState([]); - const { data, dataKey } = control; + const [inputs, setInputs] = useState([]) + const { data, dataKey } = control useEffect(() => { if (!initialValue) { - return; + return } const newInputs = initialValue.filter( - (input) => - !data.ignored.some((ignored) => ignored.name === input.name) - ); + input => !data.ignored.some(ignored => ignored.name === input.name) + ) - setInputs(newInputs); - }, [data.ignored, initialValue]); + setInputs(newInputs) + }, [data.ignored, initialValue]) - const update = (update) => { - updateData({ [dataKey]: update }); - }; + const update = update => { + updateData({ [dataKey]: update }) + } - const onDelete = (name) => { - const newInputs = inputs.filter((input) => input.name !== name); - setInputs(newInputs); - update(newInputs); - }; + const onDelete = name => { + const newInputs = inputs.filter(input => input.name !== name) + setInputs(newInputs) + update(newInputs) + } - const addInput = (input) => { + const addInput = input => { const newInput = { name: input, socketType: data.socketType, - }; + } - const newInputs = [...inputs, newInput]; - setInputs(newInputs); + const newInputs = [...inputs, newInput] + setInputs(newInputs) - update(newInputs); - }; + update(newInputs) + } return (
@@ -96,8 +95,8 @@ const InputGenerator = ({ updateData, control, initialValue }) => { ))}
- ); -}; + ) +} InputGenerator.propTypes = { updateData: PropTypes.func.isRequired, @@ -118,10 +117,10 @@ InputGenerator.propTypes = { socketType: PropTypes.string.isRequired, }) ), -}; +} InputGenerator.defaultProps = { initialValue: [], -}; +} -export default InputGenerator; \ No newline at end of file +export default InputGenerator diff --git a/packages/editor/src/DataControls/LongTextControl.tsx b/packages/client/editor/src/DataControls/LongTextControl.tsx similarity index 50% rename from packages/editor/src/DataControls/LongTextControl.tsx rename to packages/client/editor/src/DataControls/LongTextControl.tsx index 011db57531..9c6be1db1c 100644 --- a/packages/editor/src/DataControls/LongTextControl.tsx +++ b/packages/client/editor/src/DataControls/LongTextControl.tsx @@ -1,10 +1,10 @@ -// DOCUMENTED +// DOCUMENTED /** * Imports */ -import React from 'react'; -import { Button } from '@magickml/client-core'; -import { useLayout } from '../contexts/LayoutProvider'; +import React from 'react' +import { Button } from '@magickml/client-core' +import { useLayout } from '../contexts/LayoutProvider' /** * LongText component @@ -13,22 +13,22 @@ const LongText = (): JSX.Element => { /** * Destructuring the createOrFocus and windowTypes functions from the useLayout hook */ - const { createOrFocus, windowTypes } = useLayout(); + const { createOrFocus, windowTypes } = useLayout() /** * Function that is called when the button is clicked */ const onClick = (): void => { - createOrFocus(windowTypes.TEXT_EDITOR, 'Text Editor'); + createOrFocus(windowTypes.TEXT_EDITOR, 'Text Editor') } /** * Render component */ - return ; + return } /** * Export component */ -export default LongText; \ No newline at end of file +export default LongText diff --git a/packages/editor/src/DataControls/MultiSocketGenerator.tsx b/packages/client/editor/src/DataControls/MultiSocketGenerator.tsx similarity index 65% rename from packages/editor/src/DataControls/MultiSocketGenerator.tsx rename to packages/client/editor/src/DataControls/MultiSocketGenerator.tsx index 6f6f57835c..2d065912df 100644 --- a/packages/editor/src/DataControls/MultiSocketGenerator.tsx +++ b/packages/client/editor/src/DataControls/MultiSocketGenerator.tsx @@ -1,7 +1,7 @@ -// DOCUMENTED -import { useState, useEffect } from 'react'; -import Form from './Form'; -import SingleElement from './SingleElement'; +// DOCUMENTED +import { useState, useEffect } from 'react' +import Form from './Form' +import SingleElement from './SingleElement' /** * Renders a single socket component. @@ -9,10 +9,10 @@ import SingleElement from './SingleElement'; * @returns {JSX.Element} - Single socket JSX element. */ const SingleSocket = (props: { - name: string; - delete: (name: string) => void; - type: string; - last: boolean; + name: string + delete: (name: string) => void + type: string + last: boolean }) => { return props.delete ? ( @@ -20,8 +20,8 @@ const SingleSocket = (props: {

{props.name}

- ); -}; + ) +} /** * Renders an AddNewSocket component. @@ -29,16 +29,16 @@ const SingleSocket = (props: { * @returns {JSX.Element} - Add new socket JSX element. */ const AddNewSocket = (props: { addSocket: Function }) => { - const [value, setValue] = useState(''); + const [value, setValue] = useState('') const onChange = (e: React.ChangeEvent) => { - setValue(e.target.value); - }; + setValue(e.target.value) + } const onAdd = () => { - props.addSocket(value); - setValue(''); - }; + props.addSocket(value) + setValue('') + } return ( { onChange={onChange} onAdd={onAdd} /> - ); -}; + ) +} /** * MultiSocketGenerator component that generates sockets. @@ -60,41 +60,40 @@ const MultiSocketGenerator = ({ control, initialValue, }: { - updateData: Function; - control: any; - initialValue: any[]; + updateData: Function + control: any + initialValue: any[] }) => { - const [sockets, setSockets] = useState([...initialValue]); - const { data, dataKey } = control; + const [sockets, setSockets] = useState([...initialValue]) + const { data, dataKey } = control useEffect(() => { - if (!initialValue) return; + if (!initialValue) return const newSockets = initialValue.filter( - (socket) => - !data.ignored.some((ignored) => ignored.name === socket.name) - ); - setSockets(newSockets); - }, [initialValue, data.ignored]); + socket => !data.ignored.some(ignored => ignored.name === socket.name) + ) + setSockets(newSockets) + }, [initialValue, data.ignored]) const onDelete = (name: string) => { - const shortName = name.split(' ')[0]; + const shortName = name.split(' ')[0] const newSockets = sockets.filter( - (socket) => !socket.name.includes(shortName) - ); - setSockets(newSockets); - update(newSockets); - }; + socket => !socket.name.includes(shortName) + ) + setSockets(newSockets) + update(newSockets) + } const update = (update: any) => { - updateData({ [dataKey]: update }); - }; + updateData({ [dataKey]: update }) + } const addSocket = (socket: string) => { - const socketTypes = data.socketTypes; - const newSockets = [...sockets]; + const socketTypes = data.socketTypes + const newSockets = [...sockets] - const socketTypesMap: { [key: string]: number } = {}; + const socketTypesMap: { [key: string]: number } = {} // for each socketType, create a newSocket and add it to the sockets array socketTypes.forEach((socketType: string, i: number) => { @@ -102,12 +101,12 @@ const MultiSocketGenerator = ({ // if it doesn't, add the key and set the value to 0 // if it does, increment the value if (!socketTypesMap[socketType]) { - socketTypesMap[socketType] = 0; + socketTypesMap[socketType] = 0 } else { - socketTypesMap[socketType]++; + socketTypesMap[socketType]++ } - const index = socketTypesMap[socketType]; + const index = socketTypesMap[socketType] const newSocket = { name: @@ -127,28 +126,28 @@ const MultiSocketGenerator = ({ (index > 0 ? ' ' + index : ''), connectionType: data.connectionType, socketType: socketType, - }; + } - newSockets.push(newSocket); - }); + newSockets.push(newSocket) + }) - setSockets(newSockets); - update(newSockets); - }; + setSockets(newSockets) + update(newSockets) + } - const socketNames: string[] = []; + const socketNames: string[] = [] return (
{sockets.map((socket, i) => { - const shortName = socket.name.split(' ')[0]; - const hasSocket = socketNames.includes(shortName); - if (!socketNames.includes(shortName)) socketNames.push(shortName); + const shortName = socket.name.split(' ')[0] + const hasSocket = socketNames.includes(shortName) + if (!socketNames.includes(shortName)) socketNames.push(shortName) const nextShortName = sockets[i + 1] ? sockets[i + 1].name.split(' ')[0] - : ''; - const isLast = i === sockets.length - 1 || nextShortName !== shortName; + : '' + const isLast = i === sockets.length - 1 || nextShortName !== shortName return ( - ); + ) })}
- ); -}; + ) +} -export default MultiSocketGenerator; \ No newline at end of file +export default MultiSocketGenerator diff --git a/packages/editor/src/DataControls/OutputGenerator.tsx b/packages/client/editor/src/DataControls/OutputGenerator.tsx similarity index 66% rename from packages/editor/src/DataControls/OutputGenerator.tsx rename to packages/client/editor/src/DataControls/OutputGenerator.tsx index 3a9b584bd3..162182480a 100644 --- a/packages/editor/src/DataControls/OutputGenerator.tsx +++ b/packages/client/editor/src/DataControls/OutputGenerator.tsx @@ -1,35 +1,35 @@ -// DOCUMENTED +// DOCUMENTED /** * Imports */ -import { useState, useEffect } from 'react'; -import Form from './Form'; -import SingleElement from './SingleElement'; +import { useState, useEffect } from 'react' +import Form from './Form' +import SingleElement from './SingleElement' /** * Add new output component * * @param {Object} props - The props object * @param {Function} props.addOutput - The function to add new outputs to the component - * + * * @returns {JSX.Element} The add new output component */ const AddNewOutput = ({ addOutput }) => { /* * State */ - const [value, setValue] = useState(''); + const [value, setValue] = useState('') /** * Handles the onChange event * * @param {Object} e - The event object - * + * * @returns {void} */ - const onChange = (e) => { - setValue(e.target.value); - }; + const onChange = e => { + setValue(e.target.value) + } /** * Handles the onAdd event @@ -37,9 +37,9 @@ const AddNewOutput = ({ addOutput }) => { * @returns {void} */ const onAdd = () => { - addOutput(value); - setValue(''); - }; + addOutput(value) + setValue('') + } return ( { onChange={onChange} onAdd={onAdd} /> - ); -}; + ) +} /** * Output Generator component @@ -58,71 +58,71 @@ const AddNewOutput = ({ addOutput }) => { * @param {Function} props.updateData - The function to update the component data * @param {Object} props.control - The control object * @param {Array} props.initialValue - The initial value of the outputs array - * + * * @returns {JSX.Element} The output generator component */ const OutputGenerator = ({ updateData, control, initialValue }) => { /* * State */ - const [outputs, setOutputs] = useState([...initialValue]); - const { data, dataKey } = control; + const [outputs, setOutputs] = useState([...initialValue]) + const { data, dataKey } = control /** * Handles the onDelete event * * @param {string} name - The name of the output item to delete - * + * * @returns {void} */ - const onDelete = (name) => { - const newOutputs = outputs.filter((output) => output.name !== name); - setOutputs(newOutputs); - update(newOutputs); - }; + const onDelete = name => { + const newOutputs = outputs.filter(output => output.name !== name) + setOutputs(newOutputs) + update(newOutputs) + } /** * Handles the update event * * @param {Array} update - The new updates to apply - * + * * @returns {void} */ - const update = (update) => { - updateData({ [dataKey]: update }); - }; + const update = update => { + updateData({ [dataKey]: update }) + } /** * Handles the adding of new outputs * * @param {string} output - The name of the new output item - * + * * @returns {void} */ - const addOutput = (output) => { + const addOutput = output => { const newOutput = { name: output, socketType: data.socketType, taskType: data.taskType || 'output', - }; + } - const newOutputs = [...outputs, newOutput]; - setOutputs(newOutputs); - update(newOutputs); - }; + const newOutputs = [...outputs, newOutput] + setOutputs(newOutputs) + update(newOutputs) + } /** * Component did mount effect * Filters out ignored outputs */ useEffect(() => { - if (!initialValue) return; + if (!initialValue) return const newOutputs = initialValue.filter( - (output) => - !control.data.ignored.some((ignored) => ignored.name === output.name) - ); - setOutputs(newOutputs); - }, [initialValue, control]); + output => + !control.data.ignored.some(ignored => ignored.name === output.name) + ) + setOutputs(newOutputs) + }, [initialValue, control]) return (
@@ -136,7 +136,7 @@ const OutputGenerator = ({ updateData, control, initialValue }) => { ))}
- ); -}; + ) +} -export default OutputGenerator; +export default OutputGenerator diff --git a/packages/editor/src/DataControls/PlaytestControl.tsx b/packages/client/editor/src/DataControls/PlaytestControl.tsx similarity index 94% rename from packages/editor/src/DataControls/PlaytestControl.tsx rename to packages/client/editor/src/DataControls/PlaytestControl.tsx index dbadfd2b28..6c00cbf018 100644 --- a/packages/editor/src/DataControls/PlaytestControl.tsx +++ b/packages/client/editor/src/DataControls/PlaytestControl.tsx @@ -1,6 +1,6 @@ -// DOCUMENTED +// DOCUMENTED -import { useState } from "react" +import { useState } from 'react' import { Switch } from '@magickml/client-core' /** @@ -14,7 +14,7 @@ const SwitchControl = ({ control, updateData, initialValue }) => { // Destructure necessary properties from control and initialValue. const { dataKey, data } = control const { receivePlaytest } = initialValue - + // Set the initial state of the switch based on receivePlaytest. const initial = typeof receivePlaytest === 'boolean' @@ -45,4 +45,4 @@ const SwitchControl = ({ control, updateData, initialValue }) => { ) } -export default SwitchControl; \ No newline at end of file +export default SwitchControl diff --git a/packages/editor/src/DataControls/SingleElement.tsx b/packages/client/editor/src/DataControls/SingleElement.tsx similarity index 83% rename from packages/editor/src/DataControls/SingleElement.tsx rename to packages/client/editor/src/DataControls/SingleElement.tsx index 913f57f407..ce3634ae42 100644 --- a/packages/editor/src/DataControls/SingleElement.tsx +++ b/packages/client/editor/src/DataControls/SingleElement.tsx @@ -1,7 +1,7 @@ -// DOCUMENTED -import { GridViewRounded } from '@mui/icons-material'; -import { Icon, IconBtn } from '@magickml/client-core'; -import styles from './datacontrols.module.css'; +// DOCUMENTED +import { GridViewRounded } from '@mui/icons-material' +import { Icon, IconBtn } from '@magickml/client-core' +import styles from './datacontrols.module.css' /** * @typedef Props @@ -11,11 +11,11 @@ import styles from './datacontrols.module.css'; * @property {(name: string) => void} delete - Function to handle deletion of the element. */ type Props = { - name: string; - delete: (name: string) => void; + name: string + delete: (name: string) => void socketType?: string type?: string -}; +} /** * `SingleElement` renders a single line item of of a socket that has been added by the socket generator. @@ -44,7 +44,7 @@ const SingleElement = ({ name, delete: handleDelete }: Props): JSX.Element => { />
- ); -}; + ) +} -export default SingleElement; \ No newline at end of file +export default SingleElement diff --git a/packages/editor/src/DataControls/SocketGenerator.tsx b/packages/client/editor/src/DataControls/SocketGenerator.tsx similarity index 100% rename from packages/editor/src/DataControls/SocketGenerator.tsx rename to packages/client/editor/src/DataControls/SocketGenerator.tsx diff --git a/packages/editor/src/DataControls/SpellSelect.tsx b/packages/client/editor/src/DataControls/SpellSelect.tsx similarity index 100% rename from packages/editor/src/DataControls/SpellSelect.tsx rename to packages/client/editor/src/DataControls/SpellSelect.tsx diff --git a/packages/editor/src/DataControls/SwitchControl.tsx b/packages/client/editor/src/DataControls/SwitchControl.tsx similarity index 76% rename from packages/editor/src/DataControls/SwitchControl.tsx rename to packages/client/editor/src/DataControls/SwitchControl.tsx index b26c61b6b3..3f95f7d202 100644 --- a/packages/editor/src/DataControls/SwitchControl.tsx +++ b/packages/client/editor/src/DataControls/SwitchControl.tsx @@ -1,30 +1,30 @@ -// DOCUMENTED +// DOCUMENTED /** * SwitchControl component that returns a toggle switch. - * + * * @param control an object that contains dataKey and data properties. * @param updateData a function that takes an object as its parameter. - * @param initialValue a boolean that represents the initial value of the switch. + * @param initialValue a boolean that represents the initial value of the switch. */ -import { useState } from 'react'; -import { Switch } from '@magickml/client-core'; +import { useState } from 'react' +import { Switch } from '@magickml/client-core' const SwitchControl = ({ control, updateData, initialValue }) => { // Destructure the dataKey and data properties from the control object. - const { dataKey, data } = control; + const { dataKey, data } = control // Set up the checked state with the initial value passed as a prop. - const [checked, setChecked] = useState(initialValue); + const [checked, setChecked] = useState(initialValue) - /** + /** * Function that updates the value of the checked state and calls the updateData prop function. * @param e SyntheticEvent originated from DOM element onChange event. */ const onChange = e => { - setChecked(e.target.checked); + setChecked(e.target.checked) updateData({ [dataKey]: e.target.checked, - }); + }) } return ( @@ -32,7 +32,7 @@ const SwitchControl = ({ control, updateData, initialValue }) => {
- ); -}; + ) +} -export default SwitchControl; \ No newline at end of file +export default SwitchControl diff --git a/packages/editor/src/DataControls/datacontrols.module.css b/packages/client/editor/src/DataControls/datacontrols.module.css similarity index 99% rename from packages/editor/src/DataControls/datacontrols.module.css rename to packages/client/editor/src/DataControls/datacontrols.module.css index 4a62bd2a4c..f7e2ab18dc 100644 --- a/packages/editor/src/DataControls/datacontrols.module.css +++ b/packages/client/editor/src/DataControls/datacontrols.module.css @@ -6,7 +6,6 @@ opacity: 0.25; } - .flexCenterBtn { display: flex; align-items: center; diff --git a/packages/editor/src/DataControls/datacontrols.module.css.d.ts b/packages/client/editor/src/DataControls/datacontrols.module.css.d.ts similarity index 100% rename from packages/editor/src/DataControls/datacontrols.module.css.d.ts rename to packages/client/editor/src/DataControls/datacontrols.module.css.d.ts diff --git a/packages/editor/src/DataControls/index.tsx b/packages/client/editor/src/DataControls/index.tsx similarity index 54% rename from packages/editor/src/DataControls/index.tsx rename to packages/client/editor/src/DataControls/index.tsx index 1cc9e7e8c6..c104ef9d76 100644 --- a/packages/editor/src/DataControls/index.tsx +++ b/packages/client/editor/src/DataControls/index.tsx @@ -1,8 +1,8 @@ -// DOCUMENTED +// DOCUMENTED /** * This module exports the DataControls class from './DataControls'. * @module DataControls */ -import DataControls from './DataControls'; +import DataControls from './DataControls' -export default DataControls; \ No newline at end of file +export default DataControls diff --git a/packages/editor/src/MagickIDE.ts b/packages/client/editor/src/MagickIDE.ts similarity index 100% rename from packages/editor/src/MagickIDE.ts rename to packages/client/editor/src/MagickIDE.ts diff --git a/packages/editor/src/components/EventHandler.tsx b/packages/client/editor/src/components/EventHandler.tsx similarity index 100% rename from packages/editor/src/components/EventHandler.tsx rename to packages/client/editor/src/components/EventHandler.tsx diff --git a/packages/editor/src/components/FileInput.tsx b/packages/client/editor/src/components/FileInput.tsx similarity index 100% rename from packages/editor/src/components/FileInput.tsx rename to packages/client/editor/src/components/FileInput.tsx diff --git a/packages/editor/src/components/MenuBar/MenuBar.tsx b/packages/client/editor/src/components/MenuBar/MenuBar.tsx similarity index 70% rename from packages/editor/src/components/MenuBar/MenuBar.tsx rename to packages/client/editor/src/components/MenuBar/MenuBar.tsx index 0627ae177a..4b067f5f99 100644 --- a/packages/editor/src/components/MenuBar/MenuBar.tsx +++ b/packages/client/editor/src/components/MenuBar/MenuBar.tsx @@ -12,7 +12,15 @@ import { FEATURE_FLAGS } from '@magickml/config' const MenuBar = () => { const showNavBarFlag = useFeatureFlagEnabled('ide-new-sidebar') - return <>{showNavBarFlag || FEATURE_FLAGS.SHOW_NAVBAR ? : } + return ( + <> + {showNavBarFlag || FEATURE_FLAGS.SHOW_NAVBAR ? ( + + ) : ( + + )} + + ) } export default MenuBar diff --git a/packages/editor/src/components/MenuBar/OldMenuBar/index.tsx b/packages/client/editor/src/components/MenuBar/OldMenuBar/index.tsx similarity index 100% rename from packages/editor/src/components/MenuBar/OldMenuBar/index.tsx rename to packages/client/editor/src/components/MenuBar/OldMenuBar/index.tsx diff --git a/packages/editor/src/components/MenuBar/menuBar.module.css b/packages/client/editor/src/components/MenuBar/menuBar.module.css similarity index 100% rename from packages/editor/src/components/MenuBar/menuBar.module.css rename to packages/client/editor/src/components/MenuBar/menuBar.module.css diff --git a/packages/client/editor/src/components/MenuBar/menuBar.module.css.d.ts b/packages/client/editor/src/components/MenuBar/menuBar.module.css.d.ts new file mode 100644 index 0000000000..08e6fffef5 --- /dev/null +++ b/packages/client/editor/src/components/MenuBar/menuBar.module.css.d.ts @@ -0,0 +1,13 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'folder-arrow': string + 'list-item': string + 'menu-bar': string + 'menu-bar-item': string + 'menu-panel': string + 'preference-active': string + 'preference-notActive': string +} +export const cssExports: CssExports +export default cssExports diff --git a/packages/editor/src/components/MenuBar/newMenuBar/index.tsx b/packages/client/editor/src/components/MenuBar/newMenuBar/index.tsx similarity index 100% rename from packages/editor/src/components/MenuBar/newMenuBar/index.tsx rename to packages/client/editor/src/components/MenuBar/newMenuBar/index.tsx diff --git a/packages/editor/src/components/Modal/Modal.tsx b/packages/client/editor/src/components/Modal/Modal.tsx similarity index 100% rename from packages/editor/src/components/Modal/Modal.tsx rename to packages/client/editor/src/components/Modal/Modal.tsx diff --git a/packages/editor/src/components/Modal/modal.module.css b/packages/client/editor/src/components/Modal/modal.module.css similarity index 100% rename from packages/editor/src/components/Modal/modal.module.css rename to packages/client/editor/src/components/Modal/modal.module.css diff --git a/packages/client/editor/src/components/Modal/modal.module.css.d.ts b/packages/client/editor/src/components/Modal/modal.module.css.d.ts new file mode 100644 index 0000000000..10e87dd81c --- /dev/null +++ b/packages/client/editor/src/components/Modal/modal.module.css.d.ts @@ -0,0 +1,14 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + modal: string + 'modal-action-strip': string + 'modal-bg': string + 'modal-main-div': string + 'modal-panel': string + 'modal-panel-content': string + 'modal-title': string + vertical: string +} +export const cssExports: CssExports +export default cssExports diff --git a/packages/editor/src/components/Modals/DeleteModal.tsx b/packages/client/editor/src/components/Modals/DeleteModal.tsx similarity index 75% rename from packages/editor/src/components/Modals/DeleteModal.tsx rename to packages/client/editor/src/components/Modals/DeleteModal.tsx index 2c3a56269a..cc51535b39 100644 --- a/packages/editor/src/components/Modals/DeleteModal.tsx +++ b/packages/client/editor/src/components/Modals/DeleteModal.tsx @@ -1,4 +1,4 @@ -// DOCUMENTED +// DOCUMENTED /** * This module contains the DeleteModal component which displays a modal with * confirmation of deletion and handles user input using react-hook-form @@ -7,9 +7,9 @@ * @module components/ModalForms/DeleteModal */ -import Modal from '../Modal/Modal'; -import css from './modalForms.module.css'; -import { useForm } from 'react-hook-form'; +import Modal from '../Modal/Modal' +import css from './modalForms.module.css' +import { useForm } from 'react-hook-form' /** * Props object for the DeleteModal component @@ -29,22 +29,24 @@ import { useForm } from 'react-hook-form'; */ const DeleteModal = ({ closeModal, handledelete, id }) => { if (!closeModal || !handledelete || !id) { - throw new Error('Required props closeModal, handledelete, and id not passed to DeleteModal component'); + throw new Error( + 'Required props closeModal, handledelete, and id not passed to DeleteModal component' + ) } - const { handleSubmit } = useForm(); + const { handleSubmit } = useForm() const onSubmit = handleSubmit(async () => { - handledelete(id); - closeModal(); - }); + handledelete(id) + closeModal() + }) const options = [ { className: css['delete-btn'], label: 'Delete', - onClick: onSubmit - } - ]; + onClick: onSubmit, + }, + ] return ( { icon="info" className={css['delete-modal']} /> - ); + ) } -export default DeleteModal; \ No newline at end of file +export default DeleteModal diff --git a/packages/editor/src/components/Modals/EditSpellModal.tsx b/packages/client/editor/src/components/Modals/EditSpellModal.tsx similarity index 100% rename from packages/editor/src/components/Modals/EditSpellModal.tsx rename to packages/client/editor/src/components/Modals/EditSpellModal.tsx diff --git a/packages/editor/src/components/Modals/InfoModal.tsx b/packages/client/editor/src/components/Modals/InfoModal.tsx similarity index 100% rename from packages/editor/src/components/Modals/InfoModal.tsx rename to packages/client/editor/src/components/Modals/InfoModal.tsx diff --git a/packages/editor/src/components/Modals/SaveAsModal.tsx b/packages/client/editor/src/components/Modals/SaveAsModal.tsx similarity index 100% rename from packages/editor/src/components/Modals/SaveAsModal.tsx rename to packages/client/editor/src/components/Modals/SaveAsModal.tsx diff --git a/packages/editor/src/components/Modals/index.ts b/packages/client/editor/src/components/Modals/index.ts similarity index 69% rename from packages/editor/src/components/Modals/index.ts rename to packages/client/editor/src/components/Modals/index.ts index 357678a998..caa21fcedd 100644 --- a/packages/editor/src/components/Modals/index.ts +++ b/packages/client/editor/src/components/Modals/index.ts @@ -1,11 +1,11 @@ -// DOCUMENTED +// DOCUMENTED /** * Represents a collection of modals for handling different interactions. */ -import InfoModal from './InfoModal'; -import EditSpellModal from './EditSpellModal'; -import SaveAsModal from './SaveAsModal'; -import DeleteModal from './DeleteModal'; +import InfoModal from './InfoModal' +import EditSpellModal from './EditSpellModal' +import SaveAsModal from './SaveAsModal' +import DeleteModal from './DeleteModal' // A dictionary of modals with their names and components const modals = { @@ -13,12 +13,12 @@ const modals = { editSpellModal: EditSpellModal, saveAsModal: SaveAsModal, deleteModal: DeleteModal, -}; +} /** * Returns a collection of modals with their names and components. * @returns {Object} A dictionary of modals with their names and components. */ export const getModals = (): any => { - return modals; -}; \ No newline at end of file + return modals +} diff --git a/packages/client/editor/src/components/Modals/loginModal.module.css.d.ts b/packages/client/editor/src/components/Modals/loginModal.module.css.d.ts new file mode 100644 index 0000000000..880b6e2b7b --- /dev/null +++ b/packages/client/editor/src/components/Modals/loginModal.module.css.d.ts @@ -0,0 +1,10 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'error-message': string + input: string + 'input-container': string + 'login-container': string +} +export const cssExports: CssExports +export default cssExports diff --git a/packages/editor/src/components/Modals/modalForms.module.css b/packages/client/editor/src/components/Modals/modalForms.module.css similarity index 100% rename from packages/editor/src/components/Modals/modalForms.module.css rename to packages/client/editor/src/components/Modals/modalForms.module.css diff --git a/packages/client/editor/src/components/Modals/modalForms.module.css.d.ts b/packages/client/editor/src/components/Modals/modalForms.module.css.d.ts new file mode 100644 index 0000000000..64f00788ef --- /dev/null +++ b/packages/client/editor/src/components/Modals/modalForms.module.css.d.ts @@ -0,0 +1,13 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'delete-btn': string + 'delete-modal': string + 'error-message': string + input: string + 'input-container': string + 'login-container': string + select: string +} +export const cssExports: CssExports +export default cssExports diff --git a/packages/editor/src/components/Node/Node.module.css b/packages/client/editor/src/components/Node/Node.module.css similarity index 100% rename from packages/editor/src/components/Node/Node.module.css rename to packages/client/editor/src/components/Node/Node.module.css diff --git a/packages/client/editor/src/components/Node/Node.module.css.d.ts b/packages/client/editor/src/components/Node/Node.module.css.d.ts new file mode 100644 index 0000000000..c7beed62ee --- /dev/null +++ b/packages/client/editor/src/components/Node/Node.module.css.d.ts @@ -0,0 +1,22 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'bottom-container': string + 'connection-container': string + 'connections-container': string + control: string + error: string + input: string + node: string + 'node-depricated': string + 'node-id': string + 'node-locked': string + 'node-title': string + nodeGenesis: string + out: string + output: string + selected: string + success: string +} +export const cssExports: CssExports +export default cssExports diff --git a/packages/editor/src/components/Node/Node.tsx b/packages/client/editor/src/components/Node/Node.tsx similarity index 96% rename from packages/editor/src/components/Node/Node.tsx rename to packages/client/editor/src/components/Node/Node.tsx index 0459786f49..eaf67a9335 100644 --- a/packages/editor/src/components/Node/Node.tsx +++ b/packages/client/editor/src/components/Node/Node.tsx @@ -46,6 +46,10 @@ const sortSockets = (a: any, b: any) => { * Custom Node component for rendering nodes with specific functionality. * Inherits from the base Node class. */ +<<<<<<< HEAD:packages/editor/src/components/Node/Node.tsx +======= + +>>>>>>> 950214186 (Move editor package into client folder):packages/client/editor/src/components/Node/Node.tsx export class MyNode extends Node { declare props: any declare state: any @@ -92,7 +96,7 @@ export class MyNode extends Node { }) } const StyleTooltip = styled(Tooltip)` - width: initial; + width: initial; ` return ( @@ -141,8 +145,8 @@ export class MyNode extends Node {
{input.name}
@@ -169,8 +173,8 @@ export class MyNode extends Node {
{output.name}
diff --git a/packages/editor/src/components/ProjectRow.tsx b/packages/client/editor/src/components/ProjectRow.tsx similarity index 95% rename from packages/editor/src/components/ProjectRow.tsx rename to packages/client/editor/src/components/ProjectRow.tsx index 2214ae2240..a595f39217 100644 --- a/packages/editor/src/components/ProjectRow.tsx +++ b/packages/client/editor/src/components/ProjectRow.tsx @@ -57,8 +57,9 @@ const ProjectRow = ({ return (
{ onClick(e) }} diff --git a/packages/editor/src/components/TabBar/CreateTab.tsx b/packages/client/editor/src/components/TabBar/CreateTab.tsx similarity index 100% rename from packages/editor/src/components/TabBar/CreateTab.tsx rename to packages/client/editor/src/components/TabBar/CreateTab.tsx diff --git a/packages/editor/src/components/TabBar/MAGICK-whitelogo@4x.png b/packages/client/editor/src/components/TabBar/MAGICK-whitelogo@4x.png similarity index 100% rename from packages/editor/src/components/TabBar/MAGICK-whitelogo@4x.png rename to packages/client/editor/src/components/TabBar/MAGICK-whitelogo@4x.png diff --git a/packages/editor/src/components/TabBar/TabBar.tsx b/packages/client/editor/src/components/TabBar/TabBar.tsx similarity index 100% rename from packages/editor/src/components/TabBar/TabBar.tsx rename to packages/client/editor/src/components/TabBar/TabBar.tsx diff --git a/packages/editor/src/components/TabBar/tabBar.module.css b/packages/client/editor/src/components/TabBar/tabBar.module.css similarity index 100% rename from packages/editor/src/components/TabBar/tabBar.module.css rename to packages/client/editor/src/components/TabBar/tabBar.module.css diff --git a/packages/client/editor/src/components/TabBar/tabBar.module.css.d.ts b/packages/client/editor/src/components/TabBar/tabBar.module.css.d.ts new file mode 100644 index 0000000000..0c1dea0b2b --- /dev/null +++ b/packages/client/editor/src/components/TabBar/tabBar.module.css.d.ts @@ -0,0 +1,13 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + active: string + 'create-spell-tab': string + inactive: string + 'tabbar-section': string + 'tabbar-tab': string + 'tabbar-user': string + 'th-tabbar': string +} +export const cssExports: CssExports +export default cssExports diff --git a/packages/editor/src/components/TabBar/white-logomark@4x.png b/packages/client/editor/src/components/TabBar/white-logomark@4x.png similarity index 100% rename from packages/editor/src/components/TabBar/white-logomark@4x.png rename to packages/client/editor/src/components/TabBar/white-logomark@4x.png diff --git a/packages/editor/src/components/TemplatePanel.tsx b/packages/client/editor/src/components/TemplatePanel.tsx similarity index 100% rename from packages/editor/src/components/TemplatePanel.tsx rename to packages/client/editor/src/components/TemplatePanel.tsx diff --git a/packages/editor/src/components/VideoInput.tsx b/packages/client/editor/src/components/VideoInput.tsx similarity index 70% rename from packages/editor/src/components/VideoInput.tsx rename to packages/client/editor/src/components/VideoInput.tsx index 5236cd5139..b0dfc10076 100644 --- a/packages/editor/src/components/VideoInput.tsx +++ b/packages/client/editor/src/components/VideoInput.tsx @@ -1,30 +1,30 @@ -// DOCUMENTED +// DOCUMENTED /** * A React component that allows the user to import a video file. */ -import React from 'react'; -import { Icon } from '@magickml/client-core'; +import React from 'react' +import { Icon } from '@magickml/client-core' interface Props { /** * A callback function that will be called once a file has been loaded. * @param file - The file that has been loaded. */ - loadFile: (file: File) => void; + loadFile: (file: File) => void } const VideoInput: React.FC = ({ loadFile }) => { - const hiddenFileInputRef = React.useRef(null); + const hiddenFileInputRef = React.useRef(null) const handleClick = (): void => { - hiddenFileInputRef.current?.click(); - }; + hiddenFileInputRef.current?.click() + } const handleChange = (event: React.ChangeEvent): void => { - const fileUploaded = event.target.files![0]; // ! operator because TS does not recognise if check. - loadFile(fileUploaded); - }; - + const fileUploaded = event.target.files![0] // ! operator because TS does not recognise if check. + loadFile(fileUploaded) + } + return ( <>
- ); + ) }, } } @@ -48,11 +51,11 @@ const getComponents = () => { type DockviewTheme = 'dockview-theme-abyss' type DocviewContext = { - theme: DockviewTheme, - setTheme: (theme: DockviewTheme) => void, - api: DockviewApi, - setApi: (api: DockviewApi) => void, - getLayout: () => SerializedDockview | null, + theme: DockviewTheme + setTheme: (theme: DockviewTheme) => void + api: DockviewApi + setApi: (api: DockviewApi) => void + getLayout: () => SerializedDockview | null setLayout: (layout: SerializedDockview) => void } @@ -66,7 +69,7 @@ export const useGlobalLayout = () => useContext(Context) export const GlobalLayoutProvider = ({ children }) => { const [theme, setTheme] = useState('dockview-theme-abyss') - const [api, setApi] = useState(); + const [api, setApi] = useState() const getLayout = () => { const layout = localStorage.getItem(LAYOUT_KEY) @@ -83,17 +86,16 @@ export const GlobalLayoutProvider = ({ children }) => { useEffect(() => { if (!api) { - return; + return } // set up API event handlers api.onDidLayoutChange(() => { - const layout = api.toJSON(); + const layout = api.toJSON() setLayout(layout) - }); - - }, [api]); + }) + }, [api]) const publicInterface = { theme, @@ -104,4 +106,4 @@ export const GlobalLayoutProvider = ({ children }) => { setLayout, } return {children} -} \ No newline at end of file +} diff --git a/packages/editor/src/contexts/InspectorProvider.tsx b/packages/client/editor/src/contexts/InspectorProvider.tsx similarity index 95% rename from packages/editor/src/contexts/InspectorProvider.tsx rename to packages/client/editor/src/contexts/InspectorProvider.tsx index c1e8d813aa..fc8fc7d7e3 100644 --- a/packages/editor/src/contexts/InspectorProvider.tsx +++ b/packages/client/editor/src/contexts/InspectorProvider.tsx @@ -1,17 +1,17 @@ // DOCUMENTED -import { usePubSub } from '@magickml/client-core'; -import { InspectorData, SupportedLanguages } from '@magickml/core'; -import { createContext, useContext, useEffect, useState } from 'react'; +import { usePubSub } from '@magickml/client-core' +import { InspectorData, SupportedLanguages } from '@magickml/core' +import { createContext, useContext, useEffect, useState } from 'react' /** * TextEditorData represents the state and options for the text editor. */ export type TextEditorData = { options?: - | Record - | (undefined & { - language?: SupportedLanguages - }) + | Record + | (undefined & { + language?: SupportedLanguages + }) data?: string control?: Record | undefined name?: string diff --git a/packages/editor/src/contexts/LayoutProvider.tsx b/packages/client/editor/src/contexts/LayoutProvider.tsx similarity index 100% rename from packages/editor/src/contexts/LayoutProvider.tsx rename to packages/client/editor/src/contexts/LayoutProvider.tsx diff --git a/packages/editor/src/contexts/MagickInterfaceProvider.tsx b/packages/client/editor/src/contexts/MagickInterfaceProvider.tsx similarity index 100% rename from packages/editor/src/contexts/MagickInterfaceProvider.tsx rename to packages/client/editor/src/contexts/MagickInterfaceProvider.tsx diff --git a/packages/editor/src/contexts/ModalProvider.tsx b/packages/client/editor/src/contexts/ModalProvider.tsx similarity index 67% rename from packages/editor/src/contexts/ModalProvider.tsx rename to packages/client/editor/src/contexts/ModalProvider.tsx index 84398e58b9..1915ecbffe 100644 --- a/packages/editor/src/contexts/ModalProvider.tsx +++ b/packages/client/editor/src/contexts/ModalProvider.tsx @@ -1,18 +1,18 @@ -// DOCUMENTED +// DOCUMENTED -import React, { useState } from 'react'; +import React, { useState } from 'react' -import { getModals } from '../components/Modals'; +import { getModals } from '../components/Modals' /** * Type for the context object used throughout the application regarding modals */ type MyContextType = { - activeModal: object; - modalName: string; - openModal: (options: object) => void; - closeModal: () => void; -}; + activeModal: object + modalName: string + openModal: (options: object) => void + closeModal: () => void +} /** * Default context values @@ -20,19 +20,23 @@ type MyContextType = { const defaultContext: MyContextType = { activeModal: {}, modalName: '', - openModal: (options: object) => { /* null */}, - closeModal: () => { /* null */}, -}; + openModal: (options: object) => { + /* null */ + }, + closeModal: () => { + /* null */ + }, +} /** * Context object declaration */ -const Context = React.createContext(defaultContext); +const Context = React.createContext(defaultContext) /** * Custom hook for using the Modal context */ -export const useModal = () => React.useContext(Context); +export const useModal = () => React.useContext(Context) /** * ModalContext component responsible for managing the application modals @@ -43,27 +47,27 @@ const ModalContext: React.FC> = ({ children, }) => { // Initialize modal list - const modalList = getModals(); + const modalList = getModals() // Declare state for active modal and modal name const [activeModal, setActiveModal] = useState | null>( null - ); - const [modalName, setModalName] = useState(''); + ) + const [modalName, setModalName] = useState('') // Open the modal with the specified options and attach closeModal function const openModal = (modalOptions: { modal: string }) => { - setModalName(modalOptions.modal); - setActiveModal({ ...modalOptions, closeModal }); - }; + setModalName(modalOptions.modal) + setActiveModal({ ...modalOptions, closeModal }) + } // Close the currently active modal const closeModal = () => { - setActiveModal(null); - }; + setActiveModal(null) + } // Get the Modal component by its name - const Modal = modalList[modalName]; + const Modal = modalList[modalName] return ( > = ({ {activeModal && } {children} - ); -}; + ) +} -export default ModalContext; +export default ModalContext diff --git a/packages/editor/src/contexts/TabProvider.tsx b/packages/client/editor/src/contexts/TabProvider.tsx similarity index 100% rename from packages/editor/src/contexts/TabProvider.tsx rename to packages/client/editor/src/contexts/TabProvider.tsx diff --git a/packages/editor/src/contexts/ToastProvider.tsx b/packages/client/editor/src/contexts/ToastProvider.tsx similarity index 92% rename from packages/editor/src/contexts/ToastProvider.tsx rename to packages/client/editor/src/contexts/ToastProvider.tsx index 516e06a51f..84bfcb1e0f 100644 --- a/packages/editor/src/contexts/ToastProvider.tsx +++ b/packages/client/editor/src/contexts/ToastProvider.tsx @@ -1,5 +1,5 @@ -// DOCUMENTED -import { SnackbarProvider } from 'notistack'; +// DOCUMENTED +import { SnackbarProvider } from 'notistack' // /** // * Styles for snackbars with success, error, warning, and info variant @@ -44,8 +44,8 @@ out but can be utilized if desired. * @returns {React.Element} The ToastProvider component within SnackbarProvider */ const ToastProvider = ({ children }) => { - return {children}; -}; + return {children} +} // Export ToastProvider component as default -export default ToastProvider; \ No newline at end of file +export default ToastProvider diff --git a/packages/editor/src/contexts/WorkspaceProvider.tsx b/packages/client/editor/src/contexts/WorkspaceProvider.tsx similarity index 74% rename from packages/editor/src/contexts/WorkspaceProvider.tsx rename to packages/client/editor/src/contexts/WorkspaceProvider.tsx index 62c2b7524d..1e2a7ca7c8 100644 --- a/packages/editor/src/contexts/WorkspaceProvider.tsx +++ b/packages/client/editor/src/contexts/WorkspaceProvider.tsx @@ -1,8 +1,8 @@ -// DOCUMENTED -import EditorProvider from './EditorProvider'; -import LayoutProvider from './LayoutProvider'; -import MagickInterfaceProvider from './MagickInterfaceProvider'; -import InspectorProvider from './InspectorProvider'; +// DOCUMENTED +import EditorProvider from './EditorProvider' +import LayoutProvider from './LayoutProvider' +import MagickInterfaceProvider from './MagickInterfaceProvider' +import InspectorProvider from './InspectorProvider' /** An array of providers used in the application */ const providers = [ @@ -10,7 +10,7 @@ const providers = [ EditorProvider, LayoutProvider, InspectorProvider, -]; +] /** * Composes providers for react application @@ -20,20 +20,20 @@ const providers = [ * @param {Object} params.parentProps - Parent components properties */ function ComposeProviders({ providers, children, ...parentProps }) { - const _providers = [...providers].reverse(); + const _providers = [...providers].reverse() return _providers.reduce((acc, current) => { const [Provider, props] = Array.isArray(current) ? [current[0], current[1]] - : [current, {}]; + : [current, {}] const componentProps = { ...props, ...parentProps, - }; + } - return {acc}; - }, children); + return {acc} + }, children) } /** @@ -47,6 +47,6 @@ const WorkspaceProvider = ({ children, ...props }) => ( {children} -); +) -export default WorkspaceProvider \ No newline at end of file +export default WorkspaceProvider diff --git a/packages/editor/src/contexts/styles.module.scss b/packages/client/editor/src/contexts/styles.module.scss similarity index 100% rename from packages/editor/src/contexts/styles.module.scss rename to packages/client/editor/src/contexts/styles.module.scss diff --git a/packages/editor/src/design-globals/design-globals.css b/packages/client/editor/src/design-globals/design-globals.css similarity index 100% rename from packages/editor/src/design-globals/design-globals.css rename to packages/client/editor/src/design-globals/design-globals.css diff --git a/packages/editor/src/design-globals/design-globals.css.d.ts b/packages/client/editor/src/design-globals/design-globals.css.d.ts similarity index 61% rename from packages/editor/src/design-globals/design-globals.css.d.ts rename to packages/client/editor/src/design-globals/design-globals.css.d.ts index 07a781a257..36c82e360a 100644 --- a/packages/editor/src/design-globals/design-globals.css.d.ts +++ b/packages/client/editor/src/design-globals/design-globals.css.d.ts @@ -1,8 +1,6 @@ // This file is automatically generated. // Please do not change this file! // eslint-disable-next-line @typescript-eslint/no-empty-interface -interface CssExports { - -} -export const cssExports: CssExports; -export default cssExports; +interface CssExports {} +export const cssExports: CssExports +export default cssExports diff --git a/packages/editor/src/editor.ts b/packages/client/editor/src/editor.ts similarity index 100% rename from packages/editor/src/editor.ts rename to packages/client/editor/src/editor.ts diff --git a/packages/editor/src/global.d.ts b/packages/client/editor/src/global.d.ts similarity index 100% rename from packages/editor/src/global.d.ts rename to packages/client/editor/src/global.d.ts diff --git a/packages/editor/src/grid.png b/packages/client/editor/src/grid.png similarity index 100% rename from packages/editor/src/grid.png rename to packages/client/editor/src/grid.png diff --git a/packages/editor/src/hooks/useQuery.ts b/packages/client/editor/src/hooks/useQuery.ts similarity index 69% rename from packages/editor/src/hooks/useQuery.ts rename to packages/client/editor/src/hooks/useQuery.ts index 932fb37143..ae21f7e912 100644 --- a/packages/editor/src/hooks/useQuery.ts +++ b/packages/client/editor/src/hooks/useQuery.ts @@ -1,11 +1,11 @@ -// DOCUMENTED +// DOCUMENTED /** * a utility function that extracts and returns query parameters from the URL of the current page * @returns {URLSearchParams} a URL search Params object containing the query parameters of the current URL */ -import { useLocation } from "react-router-dom"; +import { useLocation } from 'react-router-dom' export const useQuery = (): URLSearchParams => { - return new URLSearchParams(useLocation().search); -}; \ No newline at end of file + return new URLSearchParams(useLocation().search) +} diff --git a/packages/editor/src/index.ts b/packages/client/editor/src/index.ts similarity index 62% rename from packages/editor/src/index.ts rename to packages/client/editor/src/index.ts index 31ac90c570..7b800a2ddb 100644 --- a/packages/editor/src/index.ts +++ b/packages/client/editor/src/index.ts @@ -1,6 +1,4 @@ /** * This exports the MagickIDE class from './main' file. */ -export { - MagickIDE -} from './main'; +export { MagickIDE } from './main' diff --git a/packages/editor/src/layouts/MagickPageLayout/MagickPageLayout.tsx b/packages/client/editor/src/layouts/MagickPageLayout/MagickPageLayout.tsx similarity index 100% rename from packages/editor/src/layouts/MagickPageLayout/MagickPageLayout.tsx rename to packages/client/editor/src/layouts/MagickPageLayout/MagickPageLayout.tsx diff --git a/packages/editor/src/layouts/MagickPageLayout/pagewrapper.module.css b/packages/client/editor/src/layouts/MagickPageLayout/pagewrapper.module.css similarity index 100% rename from packages/editor/src/layouts/MagickPageLayout/pagewrapper.module.css rename to packages/client/editor/src/layouts/MagickPageLayout/pagewrapper.module.css diff --git a/packages/editor/src/App.css.d.ts b/packages/client/editor/src/layouts/MagickPageLayout/pagewrapper.module.css.d.ts similarity index 55% rename from packages/editor/src/App.css.d.ts rename to packages/client/editor/src/layouts/MagickPageLayout/pagewrapper.module.css.d.ts index 132b232e89..f4ed3504dd 100644 --- a/packages/editor/src/App.css.d.ts +++ b/packages/client/editor/src/layouts/MagickPageLayout/pagewrapper.module.css.d.ts @@ -1,7 +1,7 @@ // This file is automatically generated. // Please do not change this file! interface CssExports { - + wrapper: string } -export const cssExports: CssExports; -export default cssExports; +export const cssExports: CssExports +export default cssExports diff --git a/packages/editor/src/layouts/MainLayout/MainLayout.tsx b/packages/client/editor/src/layouts/MainLayout/MainLayout.tsx similarity index 100% rename from packages/editor/src/layouts/MainLayout/MainLayout.tsx rename to packages/client/editor/src/layouts/MainLayout/MainLayout.tsx diff --git a/packages/editor/src/main.tsx b/packages/client/editor/src/main.tsx similarity index 100% rename from packages/editor/src/main.tsx rename to packages/client/editor/src/main.tsx diff --git a/packages/editor/src/plugins/areaPlugin/background.js b/packages/client/editor/src/plugins/areaPlugin/background.js old mode 100755 new mode 100644 similarity index 100% rename from packages/editor/src/plugins/areaPlugin/background.js rename to packages/client/editor/src/plugins/areaPlugin/background.js diff --git a/packages/editor/src/plugins/areaPlugin/index.js b/packages/client/editor/src/plugins/areaPlugin/index.js old mode 100755 new mode 100644 similarity index 100% rename from packages/editor/src/plugins/areaPlugin/index.js rename to packages/client/editor/src/plugins/areaPlugin/index.js diff --git a/packages/editor/src/plugins/areaPlugin/restrictor.js b/packages/client/editor/src/plugins/areaPlugin/restrictor.js old mode 100755 new mode 100644 similarity index 93% rename from packages/editor/src/plugins/areaPlugin/restrictor.js rename to packages/client/editor/src/plugins/areaPlugin/restrictor.js index 3959c49755..0cc5de05b6 --- a/packages/editor/src/plugins/areaPlugin/restrictor.js +++ b/packages/client/editor/src/plugins/areaPlugin/restrictor.js @@ -24,7 +24,9 @@ export class Restrictor { else if (this.lastZoom > se.max) this.lastZoom = se.max // lerp from lastZoom to zoom, weighted 1/3 toward zoom - const avgZoom = (data.zoom * this.zoomLerpFactor) + (this.lastZoom * (1 - this.zoomLerpFactor)) + const avgZoom = + data.zoom * this.zoomLerpFactor + + this.lastZoom * (1 - this.zoomLerpFactor) this.lastZoom = avgZoom data.zoom = avgZoom diff --git a/packages/editor/src/plugins/areaPlugin/snap.ts b/packages/client/editor/src/plugins/areaPlugin/snap.ts old mode 100755 new mode 100644 similarity index 100% rename from packages/editor/src/plugins/areaPlugin/snap.ts rename to packages/client/editor/src/plugins/areaPlugin/snap.ts diff --git a/packages/editor/src/plugins/areaPlugin/style.css b/packages/client/editor/src/plugins/areaPlugin/style.css old mode 100755 new mode 100644 similarity index 100% rename from packages/editor/src/plugins/areaPlugin/style.css rename to packages/client/editor/src/plugins/areaPlugin/style.css diff --git a/packages/editor/src/plugins/commentPlugin/style.css.d.ts b/packages/client/editor/src/plugins/areaPlugin/style.css.d.ts similarity index 85% rename from packages/editor/src/plugins/commentPlugin/style.css.d.ts rename to packages/client/editor/src/plugins/areaPlugin/style.css.d.ts index 9107f844c1..36c82e360a 100644 --- a/packages/editor/src/plugins/commentPlugin/style.css.d.ts +++ b/packages/client/editor/src/plugins/areaPlugin/style.css.d.ts @@ -1,6 +1,6 @@ // This file is automatically generated. // Please do not change this file! // eslint-disable-next-line @typescript-eslint/no-empty-interface -interface CssExports {/* null */} +interface CssExports {} export const cssExports: CssExports export default cssExports diff --git a/packages/editor/src/plugins/areaPlugin/utils.js b/packages/client/editor/src/plugins/areaPlugin/utils.js old mode 100755 new mode 100644 similarity index 75% rename from packages/editor/src/plugins/areaPlugin/utils.js rename to packages/client/editor/src/plugins/areaPlugin/utils.js index cbf18c495c..20bfa98bd8 --- a/packages/editor/src/plugins/areaPlugin/utils.js +++ b/packages/client/editor/src/plugins/areaPlugin/utils.js @@ -6,12 +6,15 @@ export function nodesBBox(editor, nodes) { const top = min(nodes.map(node => node.position[1])) const right = max( nodes.map( - node => node.position[0] + (editor.view?.nodes?.get(node)?.el?.clientWidth || 0) + node => + node.position[0] + (editor.view?.nodes?.get(node)?.el?.clientWidth || 0) ) ) const bottom = max( nodes.map( - node => node.position[1] + (editor.view?.nodes?.get(node)?.el?.clientHeight || 0) + node => + node.position[1] + + (editor.view?.nodes?.get(node)?.el?.clientHeight || 0) ) ) @@ -28,7 +31,7 @@ export function nodesBBox(editor, nodes) { } } -export function refreshNodeEditor(id){ +export function refreshNodeEditor(id) { setTimeout(() => { const element = document.getElementById(`editor-container-${id}`) const event = new MouseEvent('dblclick', { @@ -42,8 +45,8 @@ export function refreshNodeEditor(id){ }, 10) } -export function getLocalStorage(key){ +export function getLocalStorage(key) { const value = localStorage.getItem(key) - if(value) return JSON.parse(value) + if (value) return JSON.parse(value) return undefined -} \ No newline at end of file +} diff --git a/packages/editor/src/plugins/areaPlugin/zoom-at.js b/packages/client/editor/src/plugins/areaPlugin/zoom-at.js old mode 100755 new mode 100644 similarity index 100% rename from packages/editor/src/plugins/areaPlugin/zoom-at.js rename to packages/client/editor/src/plugins/areaPlugin/zoom-at.js diff --git a/packages/editor/src/plugins/autoArrangePlugin/auto-arrange.js b/packages/client/editor/src/plugins/autoArrangePlugin/auto-arrange.js similarity index 96% rename from packages/editor/src/plugins/autoArrangePlugin/auto-arrange.js rename to packages/client/editor/src/plugins/autoArrangePlugin/auto-arrange.js index 73138c8d44..ab78a4c287 100644 --- a/packages/editor/src/plugins/autoArrangePlugin/auto-arrange.js +++ b/packages/client/editor/src/plugins/autoArrangePlugin/auto-arrange.js @@ -55,13 +55,13 @@ export class AutoArrange { return vertical ? { - height: el.clientWidth, - width: el.clientHeight, - } + height: el.clientWidth, + width: el.clientHeight, + } : { - width: el.clientWidth, - height: el.clientHeight, - } + width: el.clientWidth, + height: el.clientHeight, + } } translateNode(node, { x, y, vertical = this.vertical }) { diff --git a/packages/client/editor/src/plugins/autoArrangePlugin/board.js b/packages/client/editor/src/plugins/autoArrangePlugin/board.js new file mode 100644 index 0000000000..4f7f01cd08 --- /dev/null +++ b/packages/client/editor/src/plugins/autoArrangePlugin/board.js @@ -0,0 +1,19 @@ +export class Board { + constructor() { + this._cols = [] + } + + add(columnIndex, value) { + if (!this._cols[columnIndex]) this._cols[columnIndex] = [] + + this._cols[columnIndex].push(value) + } + + toArray() { + const normalized = Object.keys(this._cols) + .sort((i1, i2) => +i1 - +i2) + .map(key => this._cols[key]) + + return normalized + } +} diff --git a/packages/client/editor/src/plugins/autoArrangePlugin/cache.js b/packages/client/editor/src/plugins/autoArrangePlugin/cache.js new file mode 100644 index 0000000000..95bfd74b37 --- /dev/null +++ b/packages/client/editor/src/plugins/autoArrangePlugin/cache.js @@ -0,0 +1,10 @@ +export class Cache { + constructor() { + this._map = new WeakMap() + } + + track(value) { + if (this._map.has(value)) return true + this._map.set(value, true) + } +} diff --git a/packages/editor/src/plugins/autoArrangePlugin/index.js b/packages/client/editor/src/plugins/autoArrangePlugin/index.js similarity index 100% rename from packages/editor/src/plugins/autoArrangePlugin/index.js rename to packages/client/editor/src/plugins/autoArrangePlugin/index.js diff --git a/packages/editor/src/plugins/commentPlugin/comment.js b/packages/client/editor/src/plugins/commentPlugin/comment.js similarity index 100% rename from packages/editor/src/plugins/commentPlugin/comment.js rename to packages/client/editor/src/plugins/commentPlugin/comment.js diff --git a/packages/editor/src/plugins/commentPlugin/draggable.js b/packages/client/editor/src/plugins/commentPlugin/draggable.js similarity index 87% rename from packages/editor/src/plugins/commentPlugin/draggable.js rename to packages/client/editor/src/plugins/commentPlugin/draggable.js index c90ded2844..eeefcf69fa 100644 --- a/packages/editor/src/plugins/commentPlugin/draggable.js +++ b/packages/client/editor/src/plugins/commentPlugin/draggable.js @@ -3,9 +3,15 @@ import { listenWindow } from './utils' export default class Draggable { constructor( el, - onStart = () => {/* null */}, - onTranslate = () => {/* null */}, - onDrag = () => {/* null */} + onStart = () => { + /* null */ + }, + onTranslate = () => { + /* null */ + }, + onDrag = () => { + /* null */ + } ) { this.mouseStart = null @@ -65,5 +71,7 @@ export default class Draggable { } // mutable method - destroy() {/* null */} + destroy() { + /* null */ + } } diff --git a/packages/editor/src/plugins/commentPlugin/frame-comment.js b/packages/client/editor/src/plugins/commentPlugin/frame-comment.js similarity index 100% rename from packages/editor/src/plugins/commentPlugin/frame-comment.js rename to packages/client/editor/src/plugins/commentPlugin/frame-comment.js diff --git a/packages/editor/src/plugins/commentPlugin/index.js b/packages/client/editor/src/plugins/commentPlugin/index.js similarity index 100% rename from packages/editor/src/plugins/commentPlugin/index.js rename to packages/client/editor/src/plugins/commentPlugin/index.js diff --git a/packages/editor/src/plugins/commentPlugin/inline-comment.js b/packages/client/editor/src/plugins/commentPlugin/inline-comment.js similarity index 100% rename from packages/editor/src/plugins/commentPlugin/inline-comment.js rename to packages/client/editor/src/plugins/commentPlugin/inline-comment.js diff --git a/packages/editor/src/plugins/commentPlugin/manager.js b/packages/client/editor/src/plugins/commentPlugin/manager.js similarity index 97% rename from packages/editor/src/plugins/commentPlugin/manager.js rename to packages/client/editor/src/plugins/commentPlugin/manager.js index 2f7ff6d25e..dc25f4270b 100644 --- a/packages/editor/src/plugins/commentPlugin/manager.js +++ b/packages/client/editor/src/plugins/commentPlugin/manager.js @@ -57,7 +57,7 @@ export default class CommentManager { } deleteComments() { - [...this.comments].map(c => this.deleteComment(c)) + ;[...this.comments].map(c => this.deleteComment(c)) } toJSON() { diff --git a/packages/editor/src/plugins/commentPlugin/style.css b/packages/client/editor/src/plugins/commentPlugin/style.css similarity index 100% rename from packages/editor/src/plugins/commentPlugin/style.css rename to packages/client/editor/src/plugins/commentPlugin/style.css diff --git a/packages/editor/src/plugins/areaPlugin/style.css.d.ts b/packages/client/editor/src/plugins/commentPlugin/style.css.d.ts similarity index 69% rename from packages/editor/src/plugins/areaPlugin/style.css.d.ts rename to packages/client/editor/src/plugins/commentPlugin/style.css.d.ts index 07a781a257..869cc81670 100644 --- a/packages/editor/src/plugins/areaPlugin/style.css.d.ts +++ b/packages/client/editor/src/plugins/commentPlugin/style.css.d.ts @@ -2,7 +2,7 @@ // Please do not change this file! // eslint-disable-next-line @typescript-eslint/no-empty-interface interface CssExports { - + /* null */ } -export const cssExports: CssExports; -export default cssExports; +export const cssExports: CssExports +export default cssExports diff --git a/packages/editor/src/plugins/commentPlugin/utils.js b/packages/client/editor/src/plugins/commentPlugin/utils.js similarity index 100% rename from packages/editor/src/plugins/commentPlugin/utils.js rename to packages/client/editor/src/plugins/commentPlugin/utils.js diff --git a/packages/editor/src/plugins/connectionPlugin/events.ts b/packages/client/editor/src/plugins/connectionPlugin/events.ts similarity index 100% rename from packages/editor/src/plugins/connectionPlugin/events.ts rename to packages/client/editor/src/plugins/connectionPlugin/events.ts diff --git a/packages/editor/src/plugins/connectionPlugin/flow.ts b/packages/client/editor/src/plugins/connectionPlugin/flow.ts similarity index 100% rename from packages/editor/src/plugins/connectionPlugin/flow.ts rename to packages/client/editor/src/plugins/connectionPlugin/flow.ts diff --git a/packages/editor/src/plugins/connectionPlugin/index.css b/packages/client/editor/src/plugins/connectionPlugin/index.css similarity index 100% rename from packages/editor/src/plugins/connectionPlugin/index.css rename to packages/client/editor/src/plugins/connectionPlugin/index.css diff --git a/packages/editor/src/plugins/connectionPlugin/index.sass b/packages/client/editor/src/plugins/connectionPlugin/index.sass similarity index 100% rename from packages/editor/src/plugins/connectionPlugin/index.sass rename to packages/client/editor/src/plugins/connectionPlugin/index.sass diff --git a/packages/editor/src/plugins/connectionPlugin/index.ts b/packages/client/editor/src/plugins/connectionPlugin/index.ts similarity index 100% rename from packages/editor/src/plugins/connectionPlugin/index.ts rename to packages/client/editor/src/plugins/connectionPlugin/index.ts diff --git a/packages/editor/src/plugins/connectionPlugin/picker/index.ts b/packages/client/editor/src/plugins/connectionPlugin/picker/index.ts similarity index 100% rename from packages/editor/src/plugins/connectionPlugin/picker/index.ts rename to packages/client/editor/src/plugins/connectionPlugin/picker/index.ts diff --git a/packages/editor/src/plugins/connectionPlugin/picker/view.ts b/packages/client/editor/src/plugins/connectionPlugin/picker/view.ts similarity index 100% rename from packages/editor/src/plugins/connectionPlugin/picker/view.ts rename to packages/client/editor/src/plugins/connectionPlugin/picker/view.ts diff --git a/packages/editor/src/plugins/connectionPlugin/utils.ts b/packages/client/editor/src/plugins/connectionPlugin/utils.ts similarity index 100% rename from packages/editor/src/plugins/connectionPlugin/utils.ts rename to packages/client/editor/src/plugins/connectionPlugin/utils.ts diff --git a/packages/editor/src/plugins/contextMenu/index.ts b/packages/client/editor/src/plugins/contextMenu/index.ts old mode 100755 new mode 100644 similarity index 100% rename from packages/editor/src/plugins/contextMenu/index.ts rename to packages/client/editor/src/plugins/contextMenu/index.ts diff --git a/packages/editor/src/plugins/contextMenu/main-menu.ts b/packages/client/editor/src/plugins/contextMenu/main-menu.ts similarity index 100% rename from packages/editor/src/plugins/contextMenu/main-menu.ts rename to packages/client/editor/src/plugins/contextMenu/main-menu.ts diff --git a/packages/editor/src/plugins/contextMenu/menu.ts b/packages/client/editor/src/plugins/contextMenu/menu.ts similarity index 100% rename from packages/editor/src/plugins/contextMenu/menu.ts rename to packages/client/editor/src/plugins/contextMenu/menu.ts diff --git a/packages/editor/src/plugins/contextMenu/node-menu.ts b/packages/client/editor/src/plugins/contextMenu/node-menu.ts old mode 100755 new mode 100644 similarity index 100% rename from packages/editor/src/plugins/contextMenu/node-menu.ts rename to packages/client/editor/src/plugins/contextMenu/node-menu.ts diff --git a/packages/editor/src/plugins/contextMenu/react-menu/Item.tsx b/packages/client/editor/src/plugins/contextMenu/react-menu/Item.tsx similarity index 71% rename from packages/editor/src/plugins/contextMenu/react-menu/Item.tsx rename to packages/client/editor/src/plugins/contextMenu/react-menu/Item.tsx index 56ab883250..513eb9a766 100644 --- a/packages/editor/src/plugins/contextMenu/react-menu/Item.tsx +++ b/packages/client/editor/src/plugins/contextMenu/react-menu/Item.tsx @@ -1,7 +1,7 @@ -// DOCUMENTED -import Context from './context'; -import styles from './style.module.scss'; -import React, { Component } from 'react'; +// DOCUMENTED +import Context from './context' +import styles from './style.module.scss' +import React, { Component } from 'react' /** * Represents an item with optional subitems. @@ -25,27 +25,25 @@ type ItemType = { subitems: ItemType[] } +type State = { + visibleSubitems: boolean +} -type State = - { - visibleSubitems: boolean - } - -type Props = { item: ItemType, search?: string } +type Props = { item: ItemType; search?: string } /** * Class representing an item with optional subitems. * @class Item * @extends {Component} */ class Item extends Component { - static contextType = Context; + static contextType = Context /** * Creates a new Item instance. * @param {ItemProps} props - The properties of the Item component. */ constructor(props) { - super(props); + super(props) this.state = { visibleSubitems: false, } @@ -55,20 +53,20 @@ class Item extends Component { * Handles the click event of the item. * @param {React.MouseEvent} e - The click event. */ - onClick = (e) => { + onClick = e => { const { item: { onClick }, } = this.props // Doing this for now since we will be converting to functional components // @ts-ignore - const { args, onClose } = this.context; + const { args, onClose } = this.context - e.stopPropagation(); + e.stopPropagation() - if (onClick) onClick(args); - onClose(); - }; + if (onClick) onClick(args) + onClose() + } /** * Renders the Item component. @@ -78,12 +76,14 @@ class Item extends Component { const { item: { title, subitems }, search = '', - } = this.props; - const { visibleSubitems } = this.state; + } = this.props + const { visibleSubitems } = this.state return (
this.setState({ visibleSubitems: true })} onMouseLeave={() => this.setState({ visibleSubitems: false })} @@ -91,19 +91,21 @@ class Item extends Component { {title} {subitems && visibleSubitems && (
- {subitems.map((subitem) => + {subitems.map(subitem => search !== '' && - !subitem.title.toLowerCase().includes(search.toLowerCase()) ? null : ( + !subitem.title + .toLowerCase() + .includes(search.toLowerCase()) ? null : ( ) )}
)}
- ); + ) } } -Item.contextType = Context; +Item.contextType = Context -export default Item; \ No newline at end of file +export default Item diff --git a/packages/editor/src/plugins/contextMenu/react-menu/Menu.tsx b/packages/client/editor/src/plugins/contextMenu/react-menu/Menu.tsx similarity index 78% rename from packages/editor/src/plugins/contextMenu/react-menu/Menu.tsx rename to packages/client/editor/src/plugins/contextMenu/react-menu/Menu.tsx index df2aee8f5c..1ec5fdaf59 100644 --- a/packages/editor/src/plugins/contextMenu/react-menu/Menu.tsx +++ b/packages/client/editor/src/plugins/contextMenu/react-menu/Menu.tsx @@ -19,45 +19,43 @@ import { useEffect, useRef, useState } from 'react' function flattenItems(items, search) { // Break out of recursion if there are no items - if (!items || items.length === 0) return []; + if (!items || items.length === 0) return [] - let flatList = []; - const seenTitles = new Set(); // to track seen titles + let flatList = [] + const seenTitles = new Set() // to track seen titles flatList = items.reduce((acc, item) => { - if (!item.subitems) return [...acc, item]; - if (item.subitems.length === 0) return [...acc, item]; + if (!item.subitems) return [...acc, item] + if (item.subitems.length === 0) return [...acc, item] // Flatten subitems if (item.subitems) { - return [...acc, item, ...flattenItems(item.subitems, search)]; + return [...acc, item, ...flattenItems(item.subitems, search)] } - }, []); + }, []) // Filter the flat list if there is a search term if (search) { flatList.map(item => { - item.title = item.title.split('/').pop(); - return item; - }); + item.title = item.title.split('/').pop() + return item + }) flatList = flatList.filter(item => item.title.toLowerCase().includes(search.toLowerCase()) - ); + ) // Remove duplicates flatList = flatList.filter(item => { - const titleSegment = item.title.split('/').pop().toLowerCase(); + const titleSegment = item.title.split('/').pop().toLowerCase() if (seenTitles.has(titleSegment)) { - return false; // this title is a duplicate + return false // this title is a duplicate } - seenTitles.add(titleSegment); - return true; // keep this item - }); + seenTitles.add(titleSegment) + return true // keep this item + }) } - - - return flatList; + return flatList } export default function ContextMenu({ @@ -84,7 +82,9 @@ export default function ContextMenu({ useEffect(() => { if (visible) { - const searchbar = document?.querySelector('.context-menu-search-bar') as HTMLElement + const searchbar = document?.querySelector( + '.context-menu-search-bar' + ) as HTMLElement if (searchbar) searchbar.focus() } else { setSearch('') @@ -93,7 +93,7 @@ export default function ContextMenu({ if (!visible) return null - const displayedItems = search ? flattenItems(items, search) : items; + const displayedItems = search ? flattenItems(items, search) : items return ( @@ -116,15 +116,18 @@ export default function ContextMenu({ if (search === '') return - const subitems = item?.subitems && item?.subitems.map(subItem => { - return subItem.title - }) + const subitems = + item?.subitems && + item?.subitems.map(subItem => { + return subItem.title + }) if ( item.title.toLowerCase().includes(search.toLowerCase()) || - (subitems && subitems.some(subItem => - subItem.toLowerCase().includes(search.toLowerCase()) - )) + (subitems && + subitems.some(subItem => + subItem.toLowerCase().includes(search.toLowerCase()) + )) ) return diff --git a/packages/editor/src/plugins/contextMenu/react-menu/context.ts b/packages/client/editor/src/plugins/contextMenu/react-menu/context.ts similarity index 73% rename from packages/editor/src/plugins/contextMenu/react-menu/context.ts rename to packages/client/editor/src/plugins/contextMenu/react-menu/context.ts index 506d60b4fd..cff024be5f 100644 --- a/packages/editor/src/plugins/contextMenu/react-menu/context.ts +++ b/packages/client/editor/src/plugins/contextMenu/react-menu/context.ts @@ -1,6 +1,6 @@ -// DOCUMENTED +// DOCUMENTED -import { createContext } from 'react'; +import { createContext } from 'react' /** * Context for handling closure and passing arguments for a certain component. @@ -9,8 +9,8 @@ import { createContext } from 'react'; * @interface CloseArgsContextType */ export interface CloseArgsContextType { - onClose: () => void; - args: unknown; + onClose: () => void + args: unknown } /** @@ -21,8 +21,10 @@ export interface CloseArgsContextType { * The actual implementation of onClose and args should be provided by the consumer of this context. */ const CloseArgsContext = createContext({ - onClose: () => { /* null */}, // Default implementation of onClose - does nothing + onClose: () => { + /* null */ + }, // Default implementation of onClose - does nothing args: null, // Default value for args - can be overridden by consumer -}); +}) -export default CloseArgsContext; +export default CloseArgsContext diff --git a/packages/editor/src/plugins/contextMenu/react-menu/index.tsx b/packages/client/editor/src/plugins/contextMenu/react-menu/index.tsx similarity index 62% rename from packages/editor/src/plugins/contextMenu/react-menu/index.tsx rename to packages/client/editor/src/plugins/contextMenu/react-menu/index.tsx index bb1d301a82..c9948aa3d0 100644 --- a/packages/editor/src/plugins/contextMenu/react-menu/index.tsx +++ b/packages/client/editor/src/plugins/contextMenu/react-menu/index.tsx @@ -1,22 +1,22 @@ -// DOCUMENTED -import React from 'react'; -import ReactDOM from 'react-dom'; -import ReactMenu from './Menu'; -import Menu from '../menu'; -import { injectItem } from '../utils'; +// DOCUMENTED +import React from 'react' +import ReactDOM from 'react-dom' +import ReactMenu from './Menu' +import Menu from '../menu' +import { injectItem } from '../utils' /** * Custom Menu class extending the base Menu class * provides additional methods to add items, show and hide the menu, and render the menu */ export default class CustomMenu extends Menu { - items: any[]; - position: number[]; - visible: boolean; - el: HTMLDivElement; - args: any; - props: any; - type: string; + items: any[] + position: number[] + visible: boolean + el: HTMLDivElement + args: any + props: any + type: string /** * CustomMenu constructor @@ -24,16 +24,16 @@ export default class CustomMenu extends Menu { * @param {object} props - The properties for CustomMenu */ constructor(editor, props) { - super(editor, props); - this.props = props; - this.items = []; - this.position = [0, 0]; - this.visible = false; - this.type = props.type; - this.el = document.createElement('div'); - editor.view.container.appendChild(this.el); + super(editor, props) + this.props = props + this.items = [] + this.position = [0, 0] + this.visible = false + this.type = props.type + this.el = document.createElement('div') + editor.view.container.appendChild(this.el) - this.render(); + this.render() } /** @@ -43,8 +43,8 @@ export default class CustomMenu extends Menu { * @param {Array} path - The path for the menu item, default is an empty array */ addItem(title: string, onClick: (args) => void, path: string[] = []) { - injectItem(this.items, title, onClick, path); - this.render(); + injectItem(this.items, title, onClick, path) + this.render() } /** @@ -54,18 +54,18 @@ export default class CustomMenu extends Menu { * @param {any} args - The arguments for the CustomMenu */ show(x, y, args) { - this.position = [x, y]; - this.args = args; - this.visible = true; - this.render(); + this.position = [x, y] + this.args = args + this.visible = true + this.render() } /** - * Hide the CustomMenu + * Hide the CustomMenu */ hide() { - this.visible = false; - this.render(); + this.visible = false + this.render() } /** @@ -83,8 +83,8 @@ export default class CustomMenu extends Menu { type={this.type} />, this.el - ); + ) } } -export { Menu }; \ No newline at end of file +export { Menu } diff --git a/packages/editor/src/plugins/contextMenu/react-menu/style.module.scss b/packages/client/editor/src/plugins/contextMenu/react-menu/style.module.scss similarity index 100% rename from packages/editor/src/plugins/contextMenu/react-menu/style.module.scss rename to packages/client/editor/src/plugins/contextMenu/react-menu/style.module.scss diff --git a/packages/editor/src/plugins/contextMenu/style.module.scss b/packages/client/editor/src/plugins/contextMenu/style.module.scss similarity index 100% rename from packages/editor/src/plugins/contextMenu/style.module.scss rename to packages/client/editor/src/plugins/contextMenu/style.module.scss diff --git a/packages/editor/src/plugins/contextMenu/utils.ts b/packages/client/editor/src/plugins/contextMenu/utils.ts similarity index 100% rename from packages/editor/src/plugins/contextMenu/utils.ts rename to packages/client/editor/src/plugins/contextMenu/utils.ts diff --git a/packages/editor/src/plugins/contextMenu/vars.scss b/packages/client/editor/src/plugins/contextMenu/vars.scss similarity index 50% rename from packages/editor/src/plugins/contextMenu/vars.scss rename to packages/client/editor/src/plugins/contextMenu/vars.scss index bcd185ff86..1fd0959869 100644 --- a/packages/editor/src/plugins/contextMenu/vars.scss +++ b/packages/client/editor/src/plugins/contextMenu/vars.scss @@ -1,3 +1,3 @@ -$context-color: rgba(50, 51, 56, .97); +$context-color: rgba(50, 51, 56, 0.97); $context-menu-round: 0px; $width: 200px; diff --git a/packages/editor/src/plugins/highlightPlugin/index.ts b/packages/client/editor/src/plugins/highlightPlugin/index.ts similarity index 100% rename from packages/editor/src/plugins/highlightPlugin/index.ts rename to packages/client/editor/src/plugins/highlightPlugin/index.ts diff --git a/packages/editor/src/plugins/highlightPlugin/utils.ts b/packages/client/editor/src/plugins/highlightPlugin/utils.ts similarity index 100% rename from packages/editor/src/plugins/highlightPlugin/utils.ts rename to packages/client/editor/src/plugins/highlightPlugin/utils.ts diff --git a/packages/editor/src/plugins/reactRenderPlugin/Control.tsx b/packages/client/editor/src/plugins/reactRenderPlugin/Control.tsx similarity index 61% rename from packages/editor/src/plugins/reactRenderPlugin/Control.tsx rename to packages/client/editor/src/plugins/reactRenderPlugin/Control.tsx index 7dbeb34730..b2a6b087db 100644 --- a/packages/editor/src/plugins/reactRenderPlugin/Control.tsx +++ b/packages/client/editor/src/plugins/reactRenderPlugin/Control.tsx @@ -1,14 +1,14 @@ -// DOCUMENTED +// DOCUMENTED // Required import -import React from 'react'; +import React from 'react' /** * Interface for ControlProps type */ interface ControlProps { - innerRef: (el: any, control: any) => void; - className: string; - control: any; + innerRef: (el: any, control: any) => void + className: string + control: any } /** @@ -25,10 +25,10 @@ export class Control extends React.Component { * @param {any} el - The `div` element */ createRef = (el: any): void => { - const { innerRef, control } = this.props; + const { innerRef, control } = this.props - el && innerRef(el, control); - }; + el && innerRef(el, control) + } /** * Renders the Control component @@ -37,14 +37,10 @@ export class Control extends React.Component { * @returns {React.ReactNode} */ render(): React.ReactNode { - const { className, control } = this.props; + const { className, control } = this.props return ( -
- ); +
+ ) } -} \ No newline at end of file +} diff --git a/packages/editor/src/plugins/reactRenderPlugin/Image.tsx b/packages/client/editor/src/plugins/reactRenderPlugin/Image.tsx similarity index 80% rename from packages/editor/src/plugins/reactRenderPlugin/Image.tsx rename to packages/client/editor/src/plugins/reactRenderPlugin/Image.tsx index cb979c0cd7..dc435e313c 100644 --- a/packages/editor/src/plugins/reactRenderPlugin/Image.tsx +++ b/packages/client/editor/src/plugins/reactRenderPlugin/Image.tsx @@ -1,4 +1,4 @@ -// DOCUMENTED +// DOCUMENTED /** * Props that represent the data to be passed to Image component */ @@ -13,6 +13,6 @@ type ImageProps = { * @returns Image component. */ export default function Image(props: ImageProps): JSX.Element { - const { imgSRC } = props; - return Preview; -} \ No newline at end of file + const { imgSRC } = props + return Preview +} diff --git a/packages/editor/src/plugins/reactRenderPlugin/Node.tsx b/packages/client/editor/src/plugins/reactRenderPlugin/Node.tsx similarity index 99% rename from packages/editor/src/plugins/reactRenderPlugin/Node.tsx rename to packages/client/editor/src/plugins/reactRenderPlugin/Node.tsx index e7c2e5dd13..7182377ac5 100644 --- a/packages/editor/src/plugins/reactRenderPlugin/Node.tsx +++ b/packages/client/editor/src/plugins/reactRenderPlugin/Node.tsx @@ -1,4 +1,4 @@ -// DOCUMENTED +// DOCUMENTED import React from 'react' import { Control } from './Control' @@ -100,4 +100,4 @@ export class Node extends React.Component {
) } -} \ No newline at end of file +} diff --git a/packages/editor/src/plugins/reactRenderPlugin/Socket.tsx b/packages/client/editor/src/plugins/reactRenderPlugin/Socket.tsx similarity index 72% rename from packages/editor/src/plugins/reactRenderPlugin/Socket.tsx rename to packages/client/editor/src/plugins/reactRenderPlugin/Socket.tsx index e743753b1d..743fa023cd 100644 --- a/packages/editor/src/plugins/reactRenderPlugin/Socket.tsx +++ b/packages/client/editor/src/plugins/reactRenderPlugin/Socket.tsx @@ -1,10 +1,10 @@ -// DOCUMENTED +// DOCUMENTED /** * Represents a draggable socket that can be connected to other sockets. */ -import React from 'react'; +import React from 'react' -import { kebab } from './utils'; +import { kebab } from './utils' type SocketProps = { /** @@ -13,16 +13,16 @@ type SocketProps = { * @param type The type of the socket. * @param io The IO instance. */ - innerRef: (el: HTMLDivElement | null, type: string, io: any) => void; + innerRef: (el: HTMLDivElement | null, type: string, io: any) => void /** The type of the socket. */ - type: string; + type: string /** The IO instance. */ - io: any; + io: any /** The socket's name. */ socket: { - name: string; - }; -}; + name: string + } +} export class Socket extends React.Component { /** @@ -30,20 +30,20 @@ export class Socket extends React.Component { * @param el The DOM element. */ createRef = (el: HTMLDivElement | null, innerRef, type, io) => { - el && innerRef(el, type, io); - }; + el && innerRef(el, type, io) + } render() { - const { socket, type, io, innerRef } = this.props; + const { socket, type, io, innerRef } = this.props return (
this.createRef(e, innerRef, type, io)} // force update for new IO with a same key + ref={e => this.createRef(e, innerRef, type, io)} // force update for new IO with a same key >
- ); + ) } -} \ No newline at end of file +} diff --git a/packages/editor/src/plugins/reactRenderPlugin/Upload.tsx b/packages/client/editor/src/plugins/reactRenderPlugin/Upload.tsx similarity index 100% rename from packages/editor/src/plugins/reactRenderPlugin/Upload.tsx rename to packages/client/editor/src/plugins/reactRenderPlugin/Upload.tsx diff --git a/packages/editor/src/plugins/reactRenderPlugin/index.tsx b/packages/client/editor/src/plugins/reactRenderPlugin/index.tsx similarity index 58% rename from packages/editor/src/plugins/reactRenderPlugin/index.tsx rename to packages/client/editor/src/plugins/reactRenderPlugin/index.tsx index a93ad6dc51..c2d69582b9 100644 --- a/packages/editor/src/plugins/reactRenderPlugin/index.tsx +++ b/packages/client/editor/src/plugins/reactRenderPlugin/index.tsx @@ -1,10 +1,10 @@ -// DOCUMENTED -import React from 'react'; -import ReactDOM from 'react-dom'; -import { Node } from './Node'; +// DOCUMENTED +import React from 'react' +import ReactDOM from 'react-dom' +import { Node } from './Node' -const SUPPRESSED_WARNINGS = ['ReactDOM.render']; -const consoleError = console.error; +const SUPPRESSED_WARNINGS = ['ReactDOM.render'] +const consoleError = console.error /** * Filter warnings to suppress specific warnings while keeping others @@ -12,41 +12,41 @@ const consoleError = console.error; console.error = function filterWarnings(msg, ...args) { if ( typeof msg === 'string' && - SUPPRESSED_WARNINGS.some((entry) => msg.includes(entry)) + SUPPRESSED_WARNINGS.some(entry => msg.includes(entry)) ) { - return; + return } - consoleError(msg, ...args); -}; + consoleError(msg, ...args) +} /** * Types of options for ReactRenderPlugin */ export type ReactRenderPluginOptions = { - component?: Node; - createRoot?: Function; -}; + component?: Node + createRoot?: Function +} /** * Install the ReactRenderPlugin with given options */ function install(editor, { component: NodeComponent = Node, createRoot }) { - const roots = new Map(); + const roots = new Map() const render = createRoot ? (element, container) => { - if (!roots.has(container)) roots.set(container, createRoot(container)); - const root = roots.get(container); + if (!roots.has(container)) roots.set(container, createRoot(container)) + const root = roots.get(container) - root.render(element); - } - : ReactDOM.render; + root.render(element) + } + : ReactDOM.render // Handle rendering nodes editor.on( 'rendernode', ({ el, node, component, bindSocket, bindControl }) => { - if (component.render && component.render !== 'react') return; - const Component = component.component || NodeComponent; + if (component.render && component.render !== 'react') return + const Component = component.component || NodeComponent node.update = () => new Promise(resolve => { @@ -61,43 +61,43 @@ function install(editor, { component: NodeComponent = Node, createRoot }) { ) as any, el, () => resolve() - ); - }); - node._reactComponent = true; - node.update(); + ) + }) + node._reactComponent = true + node.update() } - ); + ) // Handle rendering controls editor.on('rendercontrol', ({ el, control }) => { - if (control.render && control.render !== 'react') return; - const Component = control.component; + if (control.render && control.render !== 'react') return + const Component = control.component control.update = () => new Promise(res => { - render(, el, res); - }); - control.update(); - }); + render(, el, res) + }) + control.update() + }) // Update affected nodes for connection created or removed editor.on('connectioncreated connectionremoved', connection => { - connection.output.node.update(); - connection.input.node.update(); - }); + connection.output.node.update() + connection.input.node.update() + }) // Update nodes when node is selected editor.on('nodeselected', () => { - editor.nodes.filter(n => n._reactComponent).map(node => node.update()); - }); + editor.nodes.filter(n => n._reactComponent).map(node => node.update()) + }) } -export { Node } from './Node'; -export { Socket } from './Socket'; -export { Control } from './Control'; +export { Node } from './Node' +export { Socket } from './Socket' +export { Control } from './Control' /** Exports the ReactRenderPlugin with name and install function **/ export default { name: 'react-render', install, -}; +} diff --git a/packages/editor/src/plugins/reactRenderPlugin/styles.css b/packages/client/editor/src/plugins/reactRenderPlugin/styles.css similarity index 100% rename from packages/editor/src/plugins/reactRenderPlugin/styles.css rename to packages/client/editor/src/plugins/reactRenderPlugin/styles.css diff --git a/packages/editor/src/plugins/reactRenderPlugin/styles.css.d.ts b/packages/client/editor/src/plugins/reactRenderPlugin/styles.css.d.ts similarity index 84% rename from packages/editor/src/plugins/reactRenderPlugin/styles.css.d.ts rename to packages/client/editor/src/plugins/reactRenderPlugin/styles.css.d.ts index 9107f844c1..869cc81670 100644 --- a/packages/editor/src/plugins/reactRenderPlugin/styles.css.d.ts +++ b/packages/client/editor/src/plugins/reactRenderPlugin/styles.css.d.ts @@ -1,6 +1,8 @@ // This file is automatically generated. // Please do not change this file! // eslint-disable-next-line @typescript-eslint/no-empty-interface -interface CssExports {/* null */} +interface CssExports { + /* null */ +} export const cssExports: CssExports export default cssExports diff --git a/packages/editor/src/plugins/reactRenderPlugin/utils.js b/packages/client/editor/src/plugins/reactRenderPlugin/utils.js similarity index 100% rename from packages/editor/src/plugins/reactRenderPlugin/utils.js rename to packages/client/editor/src/plugins/reactRenderPlugin/utils.js diff --git a/packages/editor/src/plugins/reactRenderPlugin/vars.sass b/packages/client/editor/src/plugins/reactRenderPlugin/vars.sass similarity index 100% rename from packages/editor/src/plugins/reactRenderPlugin/vars.sass rename to packages/client/editor/src/plugins/reactRenderPlugin/vars.sass diff --git a/packages/editor/src/routes.tsx b/packages/client/editor/src/routes.tsx similarity index 99% rename from packages/editor/src/routes.tsx rename to packages/client/editor/src/routes.tsx index e0c4100605..660423fddc 100644 --- a/packages/editor/src/routes.tsx +++ b/packages/client/editor/src/routes.tsx @@ -42,8 +42,6 @@ const MyRoutes = () => ( } /> - - }> {(pluginManager as ClientPluginManager) .getGroupedClientRoutes() diff --git a/packages/editor/src/screens/Composer/index.tsx b/packages/client/editor/src/screens/Composer/index.tsx similarity index 100% rename from packages/editor/src/screens/Composer/index.tsx rename to packages/client/editor/src/screens/Composer/index.tsx diff --git a/packages/editor/src/screens/DocumentWindow/DocContentModal.tsx b/packages/client/editor/src/screens/DocumentWindow/DocContentModal.tsx similarity index 71% rename from packages/editor/src/screens/DocumentWindow/DocContentModal.tsx rename to packages/client/editor/src/screens/DocumentWindow/DocContentModal.tsx index d81f117325..dea6e1c920 100644 --- a/packages/editor/src/screens/DocumentWindow/DocContentModal.tsx +++ b/packages/client/editor/src/screens/DocumentWindow/DocContentModal.tsx @@ -1,17 +1,19 @@ import { Modal, useTreeData } from '@magickml/client-core' -import { - Typography, -} from '@mui/material' +import { Typography } from '@mui/material' import styles from './index.module.scss' - function DocContentModal({ contentModal, setContentModal, document }) { const { setOpenDoc } = useTreeData() return ( - { setOpenDoc(''); setContentModal(false) }}> + { + setOpenDoc('') + setContentModal(false) + }} + >
- {document}
diff --git a/packages/client/editor/src/screens/DocumentWindow/DocumentModal.tsx b/packages/client/editor/src/screens/DocumentWindow/DocumentModal.tsx new file mode 100644 index 0000000000..f01f0308df --- /dev/null +++ b/packages/client/editor/src/screens/DocumentWindow/DocumentModal.tsx @@ -0,0 +1,205 @@ +import { Modal } from '@magickml/client-core' +import { + Backdrop, + Button, + CircularProgress, + Grid, + MenuItem, + Select, + Typography, +} from '@mui/material' +import TextField from '@mui/material/TextField' +import { useEffect, useState } from 'react' +import styles from './index.module.scss' +import { useSnackbar } from 'notistack' + +const DocumentModal = ({ + createMode, + setCreateMode, + handleSave, + setNewDocument, + providerList, +}) => { + const [loading, setLoading] = useState(false) + const { enqueueSnackbar } = useSnackbar() + const [newDocument, setDocument] = useState({ + type: '', + content: '', + files: [], + }) + + useEffect(() => { + setNewDocument(newDocument) + }, [newDocument]) + + function handleFileUpload() { + const inputElement = document.createElement('input') + inputElement.type = 'file' + inputElement.accept = + '.eml,.html,.json,.md,.msg,.rst,.rtf,.txt,.xml,.jpeg,.jpg,.png,.csv,.doc,.docx,.epub,.odt,.pdf,.ppt,.pptx,.tsv,.xlsx' // Specify the file formats to accept, if needed + inputElement.click() + inputElement.addEventListener('change', async (event: Event) => { + const files = (event.target as HTMLInputElement).files + + if (files && files.length > 0) { + setLoading(true) + const newfiles = [] + for (const file of files) { + newfiles.push(file) + } + setDocument({ ...newDocument, files: newfiles }) + setLoading(false) + } + }) + } + + const [selectedModel, setSelectedModel] = useState(null) + + const handleModelChange = event => { + const selectedModelValue = event.target.value + const selectedObject = providerList.find(provider => + provider.models.includes(selectedModelValue) + ) + setSelectedModel({ model: selectedModelValue, object: selectedObject }) + } + + const handleSaveDocument = async () => { + setLoading(true) + if (newDocument.type) { + await handleSave(selectedModel) + setLoading(false) + } else { + setLoading(false) + enqueueSnackbar('Please fill in all required fields.', { + variant: 'error', + }) + } + } + + return ( + { + setCreateMode(!createMode) + }} + submitText="Generate Embeddings and Save" + handleAction={handleSaveDocument} + > + {loading && ( + theme.zIndex.drawer + 1 }} + > + + + )} + + + + + Add Document + + + + + + {/* + Name + setDocument({ ...newDocument, name: e.target.value })} + required + /> + */} + + + Select Model + + + + + + Type + + + setDocument({ ...newDocument, type: e.target.value }) + } + required + /> + + + + + Content + + + setDocument({ ...newDocument, content: e.target.value }) + } + required + multiline + rows={5} + /> + + + + Add <<BREAK>> anywhere in your content to force a chunk + break at this point + + + + + ) +} + +export default DocumentModal diff --git a/packages/editor/src/screens/DocumentWindow/DocumentTable.tsx b/packages/client/editor/src/screens/DocumentWindow/DocumentTable.tsx similarity index 85% rename from packages/editor/src/screens/DocumentWindow/DocumentTable.tsx rename to packages/client/editor/src/screens/DocumentWindow/DocumentTable.tsx index 843a8d423a..75f49f31ea 100644 --- a/packages/editor/src/screens/DocumentWindow/DocumentTable.tsx +++ b/packages/client/editor/src/screens/DocumentWindow/DocumentTable.tsx @@ -31,7 +31,7 @@ import { import { DocumentData, columns } from './document' import styles from './index.module.scss' import DocumentModal from './DocumentModal' -import { useTreeData } from "../../../../core/client/src/contexts/TreeDataProvider" +import { useTreeData } from '../../../../core/client/src/contexts/TreeDataProvider' import DocContentModal from './DocContentModal' /** * GlobalFilter component for applying search filter on the whole table. @@ -157,29 +157,36 @@ function DocumentTable({ documents, updateCallback }) { ) // Initialize the table with hooks - const { page, flatRows, pageOptions, gotoPage, setGlobalFilter, state: { sortBy, globalFilter }, - setSortBy } = - useTable( - { - columns: defaultColumns, - data: documents, - initialState: { - // todo we need to pass a proper generic into the useTable hook to fix this type error - // @ts-ignore - pageIndex: currentPage - } + const { + page, + flatRows, + pageOptions, + gotoPage, + setGlobalFilter, + state: { sortBy, globalFilter }, + setSortBy, + } = useTable( + { + columns: defaultColumns, + data: documents, + initialState: { + // todo we need to pass a proper generic into the useTable hook to fix this type error + // @ts-ignore + pageIndex: currentPage, }, - useFilters, - useGlobalFilter, - useSortBy, - usePagination - ) as TableInstance & any //TODO: FIX Type + }, + useFilters, + useGlobalFilter, + useSortBy, + usePagination + ) as TableInstance & any //TODO: FIX Type // Function to handle sorting when a column header is clicked - const handleSort = (column) => { - const isAsc = sortBy && sortBy[0] && sortBy[0].id === column && !sortBy[0].desc; - setSortBy([{ id: column, desc: isAsc ? isAsc : false }]); - }; + const handleSort = column => { + const isAsc = + sortBy && sortBy[0] && sortBy[0].id === column && !sortBy[0].desc + setSortBy([{ id: column, desc: isAsc ? isAsc : false }]) + } const rows = page.map(el => { return createData( @@ -207,18 +214,20 @@ function DocumentTable({ documents, updateCallback }) { // Handle document deletion const handleDocumentDelete = async (document: any) => { if (!selectedRow) return - const isDeleted = await fetch(`${API_ROOT_URL}/documents/${selectedRow.id}`, { - method: 'DELETE', - headers: { - Authorization: `Bearer ${token}`, - }, - }) + const isDeleted = await fetch( + `${API_ROOT_URL}/documents/${selectedRow.id}`, + { + method: 'DELETE', + headers: { + Authorization: `Bearer ${token}`, + }, + } + ) if (isDeleted) { enqueueSnackbar('document deleted', { variant: 'success' }) setToDelete(selectedRow.id) - setDocState(true); - } - else enqueueSnackbar('Error deleting document', { variant: 'error' }) + setDocState(true) + } else enqueueSnackbar('Error deleting document', { variant: 'error' }) if (page.length === 1) { const pageIndex = currentPage - 1 @@ -246,14 +255,14 @@ function DocumentTable({ documents, updateCallback }) { projectId: '', date: new Date().toISOString(), embedding: '', - files: [] + files: [], }) // Handle save action - const handleSave = async (selectedModel) => { + const handleSave = async selectedModel => { const { files, ...body } = newDocument // call documents endpoint - const formData = new FormData(); + const formData = new FormData() formData.append('date', new Date().toISOString()) formData.append('projectId', config.projectId) formData.append('modelName', selectedModel.model) @@ -269,7 +278,7 @@ function DocumentTable({ documents, updateCallback }) { Authorization: `Bearer ${token}`, }, body: formData, - }); + }) // Check if the save operation was successful if (result.ok) { // Reset newDocument @@ -279,33 +288,31 @@ function DocumentTable({ documents, updateCallback }) { projectId: '', date: '', embedding: '', - files: [] - }); - enqueueSnackbar('Document saved successfully', { variant: 'success' }); - + files: [], + }) + enqueueSnackbar('Document saved successfully', { variant: 'success' }) // Close the modal by setting createMode to false after a delay setTimeout(() => { - setDocState(true); - setCreateMode(false); - }, 2000); + setDocState(true) + setCreateMode(false) + }, 2000) // Trigger the updateCallback function to update the table after a delay - updateCallback(); - + updateCallback() } else { - enqueueSnackbar('Error saving document', { variant: 'error' }); + enqueueSnackbar('Error saving document', { variant: 'error' }) } - }; + } // Show create modal const showCreateModal = () => { setCreateMode(true) } - const handleFindDoc = (doc) => { - //fetch the document + const handleFindDoc = doc => { + //fetch the document fetch(`${API_ROOT_URL}/documents/${doc}`, { method: 'GET', headers: { @@ -313,22 +320,21 @@ function DocumentTable({ documents, updateCallback }) { }, }) .then(res => res.json()) - .then((res) => { + .then(res => { setDocument(res.content) setContentModal(true) }) - .catch((err) => { + .catch(err => { console.log(err) }) } - // trigger updateCallback when createMode changes useEffect(() => { if (!createMode) { - updateCallback(); + updateCallback() } - }, [createMode]); + }, [createMode]) useEffect(() => { if (openDoc) { @@ -338,7 +344,7 @@ function DocumentTable({ documents, updateCallback }) { } }, [openDoc]) - console.log(document); + console.log(document) return ( <>{createMode && ( @@ -383,7 +389,11 @@ function DocumentTable({ documents, updateCallback }) { > Create New - +
) } diff --git a/packages/editor/src/screens/EventWindow/EventTable.tsx b/packages/client/editor/src/screens/EventWindow/EventTable.tsx similarity index 88% rename from packages/editor/src/screens/EventWindow/EventTable.tsx rename to packages/client/editor/src/screens/EventWindow/EventTable.tsx index e7b30ca16c..e6a659467d 100644 --- a/packages/editor/src/screens/EventWindow/EventTable.tsx +++ b/packages/client/editor/src/screens/EventWindow/EventTable.tsx @@ -82,7 +82,7 @@ function EventTable({ events, updateCallback }) { const [selectedRows, setSelectedRows] = useState([]) const [currentPage, setCurrentPage] = useState(0) - const { client: feathersClient } = useFeathers(); + const { client: feathersClient } = useFeathers() const handleActionClick = (event, row) => { setAnchorEl(event.currentTarget) @@ -177,34 +177,40 @@ function EventTable({ events, updateCallback }) { ) // Initialize the table with hooks - const tableInstance = - useTable( - { - columns: defaultColumns, - data: events, - initialState: { - // todo we need to pass ageneric into useTable to fix this type error - // @ts-ignore - pageIndex: currentPage - } + const tableInstance = useTable( + { + columns: defaultColumns, + data: events, + initialState: { + // todo we need to pass ageneric into useTable to fix this type error + // @ts-ignore + pageIndex: currentPage, }, - useFilters, - useGlobalFilter, - useSortBy, - usePagination - ) + }, + useFilters, + useGlobalFilter, + useSortBy, + usePagination + ) // tableInstance as any here is a workaround for the type error // for some reason the type of tableInstance is not being inferred correctly, and documentation sucks - const { page, flatRows, pageOptions, gotoPage, setGlobalFilter, state: { sortBy, globalFilter }, - setSortBy } = tableInstance as any - + const { + page, + flatRows, + pageOptions, + gotoPage, + setGlobalFilter, + state: { sortBy, globalFilter }, + setSortBy, + } = tableInstance as any // Function to handle sorting when a column header is clicked - const handleSort = (column) => { - const isAsc = sortBy && sortBy[0] && sortBy[0].id === column && !sortBy[0].desc; - setSortBy([{ id: column, desc: isAsc ? isAsc : false }]); - }; + const handleSort = column => { + const isAsc = + sortBy && sortBy[0] && sortBy[0].id === column && !sortBy[0].desc + setSortBy([{ id: column, desc: isAsc ? isAsc : false }]) + } const rows = page.map(el => { return createData( @@ -239,28 +245,27 @@ function EventTable({ events, updateCallback }) { $in: selectedRows, }, }, - }); + }) if (isDeleted) { - enqueueSnackbar('Events deleted', { variant: 'success' }); + enqueueSnackbar('Events deleted', { variant: 'success' }) // Update the table data with the updated data from the server - updateCallback(); + updateCallback() // Clear the selected rows - setSelectedRows([]); + setSelectedRows([]) - const updatedPageLength = page.length - selectedRows.length; + const updatedPageLength = page.length - selectedRows.length // Check if there are no more documents on the current page if (updatedPageLength === 0 && currentPage > 0) { - const pageIndex = currentPage - 1; - setCurrentPage(pageIndex); + const pageIndex = currentPage - 1 + setCurrentPage(pageIndex) // Go to the previous page - gotoPage(pageIndex); + gotoPage(pageIndex) } } else { - enqueueSnackbar('Error deleting Event', { variant: 'error' }); + enqueueSnackbar('Error deleting Event', { variant: 'error' }) } - }; - + } // Handle event deletion const handleEventDelete = async (event: any) => { @@ -280,7 +285,6 @@ function EventTable({ events, updateCallback }) { gotoPage(pageIndex) } - // close the action menu handleActionClose() updateCallback() @@ -326,8 +330,9 @@ function EventTable({ events, updateCallback }) {
- ); + ) }, -}; +} const loadDefaultLayout = (api: GridviewApi) => { - // Bottom status bar api.addPanel({ id: 'panel_1', @@ -32,7 +36,7 @@ const loadDefaultLayout = (api: GridviewApi) => { }, maximumHeight: 15, minimumHeight: 15, - }); + }) // Left side file drawer api.addPanel({ @@ -42,7 +46,7 @@ const loadDefaultLayout = (api: GridviewApi) => { params: { title: 'Panel 3', }, - }); + }) // Main panel in the in the middle api.addPanel({ @@ -68,10 +72,9 @@ const loadDefaultLayout = (api: GridviewApi) => { } const MagickV2 = () => { - const onReady = (event: GridviewReadyEvent) => { - loadDefaultLayout(event.api); - }; + loadDefaultLayout(event.api) + } return ( { orientation={Orientation.VERTICAL} className="dockview-theme-abyss" /> - ); + ) } -export default MagickV2 \ No newline at end of file +export default MagickV2 diff --git a/packages/client/editor/src/screens/MagickV2/panels/fileDrawer.tsx b/packages/client/editor/src/screens/MagickV2/panels/fileDrawer.tsx new file mode 100644 index 0000000000..1912b9aefa --- /dev/null +++ b/packages/client/editor/src/screens/MagickV2/panels/fileDrawer.tsx @@ -0,0 +1,98 @@ +import { NewSidebar, TreeDataProvider, usePubSub } from '@magickml/client-core' +import { IGridviewPanelProps } from 'dockview' +import { useEffect, useState } from 'react' +import { useHotkeys } from 'react-hotkeys-hook' + +const ANIMATION_DURATION = 50 + +const FileDrawer = (props: IGridviewPanelProps<{ title: string }>) => { + const [isAnimating, setIsAnimating] = useState(false) + const [currentWidth, setCurrentWidth] = useState(0) + const [targetWidth, setTargetWidth] = useState(0) + const { events, subscribe } = usePubSub() + + const { TOGGLE_FILE_DRAWER } = events + + useHotkeys('ctrl+b', () => { + if (currentWidth > 0) { + close() + } else { + open() + } + }) + + const animateSize = (initialWidth: number, targetWidth: number) => { + let startTimestamp: number | null = null + + const frame = (timestamp: number) => { + if (!startTimestamp) startTimestamp = timestamp + + const elapsed = timestamp - startTimestamp + const progress = Math.min(elapsed / ANIMATION_DURATION, 1) + + const currentWidth = + initialWidth + (targetWidth - initialWidth) * progress + props.api.setSize({ width: currentWidth }) + + if (progress < 1) { + requestAnimationFrame(frame) + } else { + setIsAnimating(false) + } + } + + setIsAnimating(true) + requestAnimationFrame(frame) + } + + const open = () => { + if (!isAnimating) { + animateSize(0, targetWidth) + } + } + + const close = () => { + if (!isAnimating) { + setTargetWidth(currentWidth) + animateSize(currentWidth, 0) + } + } + + useEffect(() => { + const unsubscribe = subscribe(TOGGLE_FILE_DRAWER, () => { + if (currentWidth > 0) { + close() + } else { + open() + } + }) + + return () => { + unsubscribe() + } + }, [currentWidth, open, close, subscribe, TOGGLE_FILE_DRAWER]) + + // useEffect is now used only if you need an initial animation or similar effect + useEffect(() => { + // Example: animate the opening when the component mounts + const dispose = props.api.onDidDimensionsChange(event => { + setCurrentWidth(event.width) + }) + + props.api.setSize({ width: 200 }) + + return () => { + dispose.dispose() + } + }, [props.api]) + + return ( +
+ + + +
+ ) +} + +export default FileDrawer diff --git a/packages/editor/src/screens/MagickV2/panels/mainPanel.tsx b/packages/client/editor/src/screens/MagickV2/panels/mainPanel.tsx similarity index 67% rename from packages/editor/src/screens/MagickV2/panels/mainPanel.tsx rename to packages/client/editor/src/screens/MagickV2/panels/mainPanel.tsx index 6bfbb8b323..20e4212494 100644 --- a/packages/editor/src/screens/MagickV2/panels/mainPanel.tsx +++ b/packages/client/editor/src/screens/MagickV2/panels/mainPanel.tsx @@ -1,12 +1,17 @@ -import { DockviewApi, DockviewReact, DockviewReadyEvent, IDockviewPanelProps } from "dockview"; -import { useTabLayout } from "../../../contexts/TabProvider"; -import Events from "../../EventWindow" -import Requests from "../../RequestWindow" -import Settings from "../../settings/SettingsWindow" -import Documents from "../../DocumentWindow" -import Agents from "../../agents/AgentManagerWindow"; -import { ClientPluginManager, pluginManager } from "@magickml/core"; -import Composer from "../workspaces/composer"; +import { + DockviewApi, + DockviewReact, + DockviewReadyEvent, + IDockviewPanelProps, +} from 'dockview' +import { useTabLayout } from '../../../contexts/TabProvider' +import Events from '../../EventWindow' +import Requests from '../../RequestWindow' +import Settings from '../../settings/SettingsWindow' +import Documents from '../../DocumentWindow' +import Agents from '../../agents/AgentManagerWindow' +import { ClientPluginManager, pluginManager } from '@magickml/core' +import Composer from '../workspaces/composer' // we will move this out into the layouts package function loadDefaultLayout(api: DockviewApi) { @@ -17,24 +22,24 @@ function loadDefaultLayout(api: DockviewApi) { spellId: 'root', spellName: 'root', type: 'spell', - } - }); + }, + }) api.addPanel({ id: 'panel_2', component: 'default', - }); + }) api.addPanel({ id: 'panel_3', component: 'default', - }); + }) } const getComponents = () => { - const pluginComponents = []; + const pluginComponents = [] - (pluginManager as ClientPluginManager) + ;(pluginManager as ClientPluginManager) .getGroupedClientRoutes() .forEach(plugin => { plugin.routes.map(route => { @@ -67,7 +72,7 @@ const getComponents = () => { > {JSON.stringify(props.params)}
- ); + ) }, } } @@ -78,28 +83,27 @@ const MainPanel = () => { const onReady = (event: DockviewReadyEvent) => { const layout = getLayout() - let success = false; + let success = false if (layout) { - event.api.fromJSON(layout); - success = true; + event.api.fromJSON(layout) + success = true } if (!success) { - loadDefaultLayout(event.api); + loadDefaultLayout(event.api) } setApi(event.api) - }; + } return ( - ) -}; +} -export default MainPanel \ No newline at end of file +export default MainPanel diff --git a/packages/editor/src/screens/MagickV2/workspaces/composer.tsx b/packages/client/editor/src/screens/MagickV2/workspaces/composer.tsx similarity index 100% rename from packages/editor/src/screens/MagickV2/workspaces/composer.tsx rename to packages/client/editor/src/screens/MagickV2/workspaces/composer.tsx diff --git a/packages/editor/src/screens/RequestWindow/RequestTable.tsx b/packages/client/editor/src/screens/RequestWindow/RequestTable.tsx similarity index 89% rename from packages/editor/src/screens/RequestWindow/RequestTable.tsx rename to packages/client/editor/src/screens/RequestWindow/RequestTable.tsx index 19b722f398..aada4b69a8 100644 --- a/packages/editor/src/screens/RequestWindow/RequestTable.tsx +++ b/packages/client/editor/src/screens/RequestWindow/RequestTable.tsx @@ -1,4 +1,3 @@ - import { IconButton, Stack, @@ -27,13 +26,11 @@ import { TableComponent, useFeathers } from '@magickml/client-core' import { DocumentData, columns } from './requests' import { useSnackbar } from 'notistack' - /** * GlobalFilter component. * Filter the table data using a global search input. */ const GlobalFilter = ({ globalFilter, setGlobalFilter }) => { - const [value, setValue] = useState(globalFilter) const onChange = useAsyncDebounce(value => { setGlobalFilter(value || undefined) @@ -52,7 +49,6 @@ const GlobalFilter = ({ globalFilter, setGlobalFilter }) => { ) } - function ActionMenu({ anchorEl, handleClose, handleDelete }) { return ( { setAnchorEl(null) setSelectedRow(null) @@ -119,41 +113,38 @@ function RequestTable({ requests, updateCallback }) { // close the action menu handleActionClose() updateCallback() - setSelectedRows([]); + setSelectedRows([]) } // Handle events deletion - const handleDeleteMany = async (event) => { + const handleDeleteMany = async event => { const isDeleted = await client.service('request').remove(null, { query: { id: { $in: selectedRows, }, }, - }); + }) if (isDeleted) { - enqueueSnackbar('Requests deleted', { variant: 'success' }); + enqueueSnackbar('Requests deleted', { variant: 'success' }) // Update the table data with the updated data from the server - updateCallback(); + updateCallback() // Clear the selected rows - setSelectedRows([]); + setSelectedRows([]) - const updatedPageLength = page.length - selectedRows.length; + const updatedPageLength = page.length - selectedRows.length // Check if there are no more documents on the current page if (updatedPageLength === 0 && currentPage > 0) { - const pageIndex = currentPage - 1; - setCurrentPage(pageIndex); + const pageIndex = currentPage - 1 + setCurrentPage(pageIndex) // Go to the previous page - gotoPage(pageIndex); + gotoPage(pageIndex) } } else { - enqueueSnackbar('Error deleting Requests', { variant: 'error' }); + enqueueSnackbar('Error deleting Requests', { variant: 'error' }) } - }; - - - + } const defaultColumns = useMemo( () => [ @@ -217,22 +208,29 @@ function RequestTable({ requests, updateCallback }) { ) // @ts-ignore - const { page, flatRows, pageOptions, gotoPage, setGlobalFilter, state: { sortBy, globalFilter }, setSortBy } = - useTable( - { - columns: defaultColumns, - data: requests, - initialState: { - // todo need to pass generic into useTable to fix this type error - // @ts-ignore - pageIndex: currentPage - } + const { + page, + flatRows, + pageOptions, + gotoPage, + setGlobalFilter, + state: { sortBy, globalFilter }, + setSortBy, + } = useTable( + { + columns: defaultColumns, + data: requests, + initialState: { + // todo need to pass generic into useTable to fix this type error + // @ts-ignore + pageIndex: currentPage, }, - useFilters, - useGlobalFilter, - useSortBy, - usePagination - ) + }, + useFilters, + useGlobalFilter, + useSortBy, + usePagination + ) // Handle page change const handlePageChange = (page: number) => { @@ -241,8 +239,6 @@ function RequestTable({ requests, updateCallback }) { gotoPage(pageIndex) } - - // Generate original rows data for CSV export const originalRows = useMemo( () => flatRows.map(row => row.original), @@ -261,8 +257,7 @@ function RequestTable({ requests, updateCallback }) { requestData: string, responseData: string, parameters: string, - spell: string, - + spell: string ): DocumentData => { return { row, @@ -296,10 +291,11 @@ function RequestTable({ requests, updateCallback }) { } // Function to handle sorting when a column header is clicked - const handleSort = (column) => { - const isAsc = sortBy && sortBy[0] && sortBy[0].id === column && !sortBy[0].desc; - setSortBy([{ id: column, desc: isAsc ? isAsc : false }]); - }; + const handleSort = column => { + const isAsc = + sortBy && sortBy[0] && sortBy[0].id === column && !sortBy[0].desc + setSortBy([{ id: column, desc: isAsc ? isAsc : false }]) + } const rows = page.map(el => { return createData( @@ -315,25 +311,18 @@ function RequestTable({ requests, updateCallback }) { el.original.requestData, el.original.responseData, el.original.parameters, - el.original.spell, - + el.original.spell ) }) - - - - return ( -
Requests
-
@@ -370,23 +370,24 @@ const AgentDetails = ({ ) })}
- {selectedAgentData.publicVariables && selectedAgentData.publicVariables !== '{}' && ( - { - setSelectedAgentData({ - ...selectedAgentData, - publicVariables: JSON.stringify(data), - }) - }} - // todo we need to decide if we need to handle this. - setUpdateNeeded={() => { }} - publicVars={JSON.parse(selectedAgentData.publicVariables)} - /> - )} + {selectedAgentData.publicVariables && + selectedAgentData.publicVariables !== '{}' && ( + { + setSelectedAgentData({ + ...selectedAgentData, + publicVariables: JSON.stringify(data), + }) + }} + // todo we need to decide if we need to handle this. + setUpdateNeeded={() => { }} + publicVars={JSON.parse(selectedAgentData.publicVariables)} + /> + )}
{(pluginManager as ClientPluginManager).getAgentComponents().map((value, index, array) => { diff --git a/packages/editor/src/screens/agents/AgentWindow/AgentItem.tsx b/packages/client/editor/src/screens/agents/AgentWindow/AgentItem.tsx similarity index 62% rename from packages/editor/src/screens/agents/AgentWindow/AgentItem.tsx rename to packages/client/editor/src/screens/agents/AgentWindow/AgentItem.tsx index 03e9cc409c..ebd222fbc5 100644 --- a/packages/editor/src/screens/agents/AgentWindow/AgentItem.tsx +++ b/packages/client/editor/src/screens/agents/AgentWindow/AgentItem.tsx @@ -1,42 +1,42 @@ -import { Icon, IconBtn } from '@magickml/client-core'; -import { Avatar, Typography } from '@mui/material'; -import { Modal } from '@magickml/client-core'; -import styles from './index.module.scss'; -import { useState } from 'react'; +import { Icon, IconBtn } from '@magickml/client-core' +import { Avatar, Typography } from '@mui/material' +import { Modal } from '@magickml/client-core' +import styles from './index.module.scss' +import { useState } from 'react' const AgentItem = ({ keyId, agent, onDelete, onClick, style }) => { - const [openConfirm, setOpenConfirm] = useState(false); - const [agentId, setAgentID] = useState(''); + const [openConfirm, setOpenConfirm] = useState(false) + const [agentId, setAgentID] = useState('') const handleClose = () => { - setOpenConfirm(false); - setAgentID(''); - }; + setOpenConfirm(false) + setAgentID('') + } const onSubmit = () => { - onDelete(agentId); - setAgentID(''); - setOpenConfirm(false); - }; + onDelete(agentId) + setAgentID('') + setOpenConfirm(false) + } // Conditionally render the delete button only if the agent's name is not "Default Agent" const renderDeleteButton = () => { if (!agent.default) { - return ( + return ( } - onClick={(e) => { - e.stopPropagation(); - setAgentID(agent.id); - setOpenConfirm(true); + onClick={e => { + e.stopPropagation() + setAgentID(agent.id) + setOpenConfirm(true) }} /> - ); + ) } else { - return null; // Return null to effectively disable the delete button + return null // Return null to effectively disable the delete button } - }; + } return (
{ children="Do you want to delete this agent?" />
- ); -}; + ) +} -export default AgentItem; +export default AgentItem diff --git a/packages/editor/src/screens/agents/AgentWindow/AgentPubVariables.tsx b/packages/client/editor/src/screens/agents/AgentWindow/AgentPubVariables.tsx similarity index 90% rename from packages/editor/src/screens/agents/AgentWindow/AgentPubVariables.tsx rename to packages/client/editor/src/screens/agents/AgentWindow/AgentPubVariables.tsx index bdc015fa82..ed431ef4d6 100644 --- a/packages/editor/src/screens/agents/AgentWindow/AgentPubVariables.tsx +++ b/packages/client/editor/src/screens/agents/AgentWindow/AgentPubVariables.tsx @@ -37,7 +37,7 @@ const AgentPubVariables = ({ value: event.target.checked === undefined ? event.target.value - : event.target.checked + : event.target.checked, }, }) setUpdateNeeded(true) @@ -66,7 +66,13 @@ const AgentPubVariables = ({ }} > -

{`${variable.name}: `}

+

{`${variable.name}: `}

{variable?.type?.includes('Boolean') ? ( diff --git a/packages/editor/src/screens/agents/AgentWindow/index.module.scss b/packages/client/editor/src/screens/agents/AgentWindow/index.module.scss similarity index 100% rename from packages/editor/src/screens/agents/AgentWindow/index.module.scss rename to packages/client/editor/src/screens/agents/AgentWindow/index.module.scss diff --git a/packages/editor/src/screens/agents/AgentWindow/index.tsx b/packages/client/editor/src/screens/agents/AgentWindow/index.tsx similarity index 100% rename from packages/editor/src/screens/agents/AgentWindow/index.tsx rename to packages/client/editor/src/screens/agents/AgentWindow/index.tsx diff --git a/packages/editor/src/screens/agents/AgentWindow/spellValidator.ts b/packages/client/editor/src/screens/agents/AgentWindow/spellValidator.ts similarity index 100% rename from packages/editor/src/screens/agents/AgentWindow/spellValidator.ts rename to packages/client/editor/src/screens/agents/AgentWindow/spellValidator.ts diff --git a/packages/client/editor/src/screens/agents/AgentWindow/tooltip_texts.ts b/packages/client/editor/src/screens/agents/AgentWindow/tooltip_texts.ts new file mode 100644 index 0000000000..ac58d8a6b9 --- /dev/null +++ b/packages/client/editor/src/screens/agents/AgentWindow/tooltip_texts.ts @@ -0,0 +1,9 @@ +export const tooltip_text = { + rootSpell: 'The root spell of the agent', + 'GoogleAI API Key': 'The API key for the Google AI service', + 'OpenAI API Key': 'The API key for the OpenAI service', + 'ElevenLabs API Key': 'The API key for the ElevenLabs service', + 'Postgres Connection String': + 'The connection string for the Postgres database', + 'Anthropic API Key': 'The API key for the Anthropic', +} diff --git a/packages/editor/src/screens/agents/AgentWindowStyle.module.css b/packages/client/editor/src/screens/agents/AgentWindowStyle.module.css similarity index 100% rename from packages/editor/src/screens/agents/AgentWindowStyle.module.css rename to packages/client/editor/src/screens/agents/AgentWindowStyle.module.css diff --git a/packages/editor/src/screens/settings/SettingsWindow.tsx b/packages/client/editor/src/screens/settings/SettingsWindow.tsx similarity index 76% rename from packages/editor/src/screens/settings/SettingsWindow.tsx rename to packages/client/editor/src/screens/settings/SettingsWindow.tsx index 6349da6295..5ac24714a2 100644 --- a/packages/editor/src/screens/settings/SettingsWindow.tsx +++ b/packages/client/editor/src/screens/settings/SettingsWindow.tsx @@ -1,12 +1,10 @@ -import { Tooltip } from '@magickml/client-core'; -import { pluginManager } from '@magickml/core'; -import { Clear } from '@mui/icons-material/'; -import { IconButton, Input, Button } from '@mui/material'; -import { useState } from 'react'; -import { useSnackbar } from 'notistack'; -import styles from './styles.module.scss'; - - +import { Tooltip } from '@magickml/client-core' +import { pluginManager } from '@magickml/core' +import { Clear } from '@mui/icons-material/' +import { IconButton, Input, Button } from '@mui/material' +import { useState } from 'react' +import { useSnackbar } from 'notistack' +import styles from './styles.module.scss' /** * This function component renders an input form for entering an API key and buttons to copy and clear the key. @@ -41,8 +39,8 @@ const SettingsWindowChild = ({ id={keyName} name={keyName} value={getKey(keyName) || ''} - onChange={(e) => { - setKey(keyName, e.target.value); + onChange={e => { + setKey(keyName, e.target.value) }} /> {getKey(keyName) && getKey(keyName) !== '' && ( @@ -51,11 +49,11 @@ const SettingsWindowChild = ({ { - setKey(keyName, ''); - setClear('Cleared'); + setKey(keyName, '') + setClear('Cleared') setTimeout(() => { - setClear('Clear'); - }, 1000); + setClear('Clear') + }, 1000) }} > @@ -71,33 +69,33 @@ const SettingsWindowChild = ({
- ); -}; + ) +} const SettingsWindow = () => { - const { enqueueSnackbar } = useSnackbar(); + const { enqueueSnackbar } = useSnackbar() // State for keeping track of secret key values const [secretKeys, setSecretKeys] = useState(() => { - const info = window.localStorage.getItem('secrets'); - return info ? JSON.parse(info) : {}; - }); + const info = window.localStorage.getItem('secrets') + return info ? JSON.parse(info) : {} + }) // Function to get service key from local storage - const getKey = (key) => { - return secretKeys[key] || ''; - }; + const getKey = key => { + return secretKeys[key] || '' + } // Function to update secret key in state const setKey = (newKey, newValue) => { - setSecretKeys((prevSecretKeys) => ({ + setSecretKeys(prevSecretKeys => ({ ...prevSecretKeys, [newKey]: newValue, - })); - }; + })) + } const handleSaveKey = () => { - window.localStorage.setItem('secrets', JSON.stringify(secretKeys)); + window.localStorage.setItem('secrets', JSON.stringify(secretKeys)) pluginManager.getSecrets(true).forEach((value) => { const { name, displayName }: any = value; @@ -107,17 +105,17 @@ const SettingsWindow = () => { if (valueName) { enqueueSnackbar(`${secretName.toLowerCase()} set successfully`, { variant: 'success', - }); + }) } - }); - }; + }) + } - const globalSecrets = pluginManager.getSecrets(true); + const globalSecrets = pluginManager.getSecrets(true) return ( <>
- {globalSecrets.map((value) => { + {globalSecrets.map(value => { return ( { setKey={setKey} getKey={getKey} /> - ); + ) })}

@@ -147,7 +145,7 @@ const SettingsWindow = () => {

- ); -}; + ) +} -export default SettingsWindow; +export default SettingsWindow diff --git a/packages/editor/src/screens/settings/styles.module.scss b/packages/client/editor/src/screens/settings/styles.module.scss similarity index 97% rename from packages/editor/src/screens/settings/styles.module.scss rename to packages/client/editor/src/screens/settings/styles.module.scss index 8ca50cdf21..9da8a8fca1 100644 --- a/packages/editor/src/screens/settings/styles.module.scss +++ b/packages/client/editor/src/screens/settings/styles.module.scss @@ -51,7 +51,7 @@ padding: 2px 60px !important; } -.btn_container{ +.btn_container { display: flex; justify-content: space-around; -} \ No newline at end of file +} diff --git a/packages/editor/src/types/index.ts b/packages/client/editor/src/types/index.ts similarity index 100% rename from packages/editor/src/types/index.ts rename to packages/client/editor/src/types/index.ts diff --git a/packages/editor/src/types/openai.ts b/packages/client/editor/src/types/openai.ts similarity index 68% rename from packages/editor/src/types/openai.ts rename to packages/client/editor/src/types/openai.ts index 8193571107..d455f78fba 100644 --- a/packages/editor/src/types/openai.ts +++ b/packages/client/editor/src/types/openai.ts @@ -1,10 +1,9 @@ - export namespace OpenAI { export interface List { - data: T[]; + data: T[] } export interface FineTune { - fine_tuned_model: any; + fine_tuned_model: any } -} \ No newline at end of file +} diff --git a/packages/editor/src/types/styles/globals.css b/packages/client/editor/src/types/styles/globals.css similarity index 100% rename from packages/editor/src/types/styles/globals.css rename to packages/client/editor/src/types/styles/globals.css diff --git a/packages/editor/src/utils/AsyncStorage.ts b/packages/client/editor/src/utils/AsyncStorage.ts similarity index 98% rename from packages/editor/src/utils/AsyncStorage.ts rename to packages/client/editor/src/utils/AsyncStorage.ts index 93b2d6849a..66ad96d9df 100644 --- a/packages/editor/src/utils/AsyncStorage.ts +++ b/packages/client/editor/src/utils/AsyncStorage.ts @@ -1,4 +1,4 @@ -// DOCUMENTED +// DOCUMENTED /** * Gets the value stored in local storage for a given key, parsing it from JSON if needed * @@ -45,4 +45,4 @@ export const removeItem = (item: string): void => { */ export const clearStorage = (): void => { window.localStorage.clear() -} \ No newline at end of file +} diff --git a/packages/client/editor/src/utils/app/clean.ts b/packages/client/editor/src/utils/app/clean.ts new file mode 100644 index 0000000000..5f8eb8acc3 --- /dev/null +++ b/packages/client/editor/src/utils/app/clean.ts @@ -0,0 +1,43 @@ +import { Conversation } from '../../types' + +export const cleanSelectedConversation = (conversation: Conversation) => { + let updatedConversation = conversation + + // check for spell on each conversation + if (!updatedConversation.spell) { + updatedConversation = { + ...updatedConversation, + spell: null, + } + } + + // check for system prompt on each conversation + if (!updatedConversation.prompt) { + updatedConversation = { + ...updatedConversation, + } + } + + return updatedConversation +} + +export const cleanConversationHistory = (history: Conversation[]) => { + let updatedHistory = [...history] + + // check for spell on each conversation + if (!updatedHistory.every(conversation => conversation.spell)) { + updatedHistory = updatedHistory.map(conversation => ({ + ...conversation, + spell: null, + })) + } + + // check for system prompt on each conversation + if (!updatedHistory.every(conversation => conversation.prompt)) { + updatedHistory = updatedHistory.map(conversation => ({ + ...conversation, + })) + } + + return updatedHistory +} diff --git a/packages/client/editor/src/utils/app/conversation.ts b/packages/client/editor/src/utils/app/conversation.ts new file mode 100644 index 0000000000..251d2e8172 --- /dev/null +++ b/packages/client/editor/src/utils/app/conversation.ts @@ -0,0 +1,35 @@ +import { Conversation } from '../../types' + +export const updateConversation = ( + updatedConversation: Conversation, + allConversations: Conversation[] +) => { + const updatedConversations = allConversations.map(c => { + if (c.id === updatedConversation.id) { + return updatedConversation + } + + return c + }) + + saveConversation(updatedConversation) + saveConversations(updatedConversations) + + return { + single: updatedConversation, + all: updatedConversations, + } +} + +export const saveConversation = (conversation: Conversation) => { + localStorage.setItem('selectedConversation', JSON.stringify(conversation)) +} + +export const saveConversations = (conversations: Conversation[]) => { + console.log( + '🚀 ~ file: conversation.ts:26 ~ saveConversations ~ conversations:', + conversations + ) + // TODO: Create spell to save conversation history and "consume" it on chat window + localStorage.setItem('conversationHistory', JSON.stringify(conversations)) +} diff --git a/packages/client/editor/src/utils/app/data.ts b/packages/client/editor/src/utils/app/data.ts new file mode 100644 index 0000000000..6cd4a4d7d0 --- /dev/null +++ b/packages/client/editor/src/utils/app/data.ts @@ -0,0 +1,66 @@ +import { Conversation } from '../../types' + +export const exportConversations = () => { + const history = localStorage.getItem('conversationHistory') + + if (!history) return + + const blob = new Blob([history], { type: 'application/json' }) + const url = URL.createObjectURL(blob) + const link = document.createElement('a') + link.download = 'chatbot_ui_history.json' + link.href = url + link.style.display = 'none' + document.body.appendChild(link) + link.click() + document.body.removeChild(link) + URL.revokeObjectURL(url) +} + +export const importConversations = (conversations: Conversation[]) => { + localStorage.setItem('conversationHistory', JSON.stringify(conversations)) + localStorage.setItem( + 'selectedConversation', + JSON.stringify(conversations[conversations.length - 1]) + ) +} + +interface languageMap { + [key: string]: string | undefined +} + +export const programmingLanguages: languageMap = { + javascript: '.js', + python: '.py', + java: '.java', + c: '.c', + cpp: '.cpp', + 'c++': '.cpp', + 'c#': '.cs', + ruby: '.rb', + php: '.php', + swift: '.swift', + 'objective-c': '.m', + kotlin: '.kt', + typescript: '.ts', + go: '.go', + perl: '.pl', + rust: '.rs', + scala: '.scala', + haskell: '.hs', + lua: '.lua', + shell: '.sh', + sql: '.sql', + html: '.html', + css: '.css', + // add more file extensions here, make sure the key is same as language prop in CodeBlock.tsx component +} + +export const generateRandomString = (length: number, lowercase = false) => { + const chars = 'ABCDEFGHJKLMNPQRSTUVWXY3456789' // excluding similar looking characters like Z, 2, I, 1, O, 0 + let result = '' + for (let i = 0; i < length; i++) { + result += chars.charAt(Math.floor(Math.random() * chars.length)) + } + return lowercase ? result.toLowerCase() : result +} diff --git a/packages/editor/src/utils/debounce.js b/packages/client/editor/src/utils/debounce.js similarity index 100% rename from packages/editor/src/utils/debounce.js rename to packages/client/editor/src/utils/debounce.js diff --git a/packages/editor/src/utils/json0.ts b/packages/client/editor/src/utils/json0.ts similarity index 67% rename from packages/editor/src/utils/json0.ts rename to packages/client/editor/src/utils/json0.ts index 37cf0960dd..c211fb47c6 100644 --- a/packages/editor/src/utils/json0.ts +++ b/packages/client/editor/src/utils/json0.ts @@ -1,14 +1,14 @@ -// DOCUMENTED +// DOCUMENTED /** * Calculates the difference between two objects using an operational transformation approach. - * + * * @param obj1 - The first object that will be compared. * @param obj2 - The second object that will be compared. * @returns The difference between the two objects. */ -import jsonDiff from 'json0-ot-diff'; -import diffMatchPatch from 'diff-match-patch'; +import jsonDiff from 'json0-ot-diff' +import diffMatchPatch from 'diff-match-patch' export function diff(obj1: any, obj2: any): any { - return jsonDiff(obj1, obj2, diffMatchPatch); -} \ No newline at end of file + return jsonDiff(obj1, obj2, diffMatchPatch) +} diff --git a/packages/client/editor/src/utils/speechUtils.d.ts b/packages/client/editor/src/utils/speechUtils.d.ts new file mode 100644 index 0000000000..6fb721ef0c --- /dev/null +++ b/packages/client/editor/src/utils/speechUtils.d.ts @@ -0,0 +1,29 @@ +export declare class singleton { + static instance: speechUtils + static getInstance(): speechUtils +} +declare class speechUtils { + bufferSize: number + AudioContext: any + context: any + processor: any + input: any + globalStream: any + finalWord: boolean + removeLastSentence: boolean + streamStreaming: boolean + constraints: { + audio: boolean + video: boolean + } + socket: import('socket.io-client').Socket< + import('@socket.io/component-emitter').DefaultEventsMap, + import('@socket.io/component-emitter').DefaultEventsMap + > + constructor() + initRecording: (newMessageCallback: Function) => void + microphoneProcess: (e: any) => void + stopRecording: () => void + downsampleBuffer: (buffer: any, sampleRate: any, outSampleRate: any) => any +} +export default singleton diff --git a/packages/editor/src/utils/speechUtils.ts b/packages/client/editor/src/utils/speechUtils.ts similarity index 100% rename from packages/editor/src/utils/speechUtils.ts rename to packages/client/editor/src/utils/speechUtils.ts diff --git a/packages/editor/src/vite-env.d.ts b/packages/client/editor/src/vite-env.d.ts similarity index 100% rename from packages/editor/src/vite-env.d.ts rename to packages/client/editor/src/vite-env.d.ts diff --git a/packages/editor/src/wagmi.ts b/packages/client/editor/src/wagmi.ts similarity index 99% rename from packages/editor/src/wagmi.ts rename to packages/client/editor/src/wagmi.ts index 38bc54dd00..0b6b5d30e9 100644 --- a/packages/editor/src/wagmi.ts +++ b/packages/client/editor/src/wagmi.ts @@ -12,4 +12,4 @@ export const config = createConfig({ chain: mainnet, transport: http(), }), -}) \ No newline at end of file +}) diff --git a/packages/editor/src/wdyr.ts b/packages/client/editor/src/wdyr.ts similarity index 100% rename from packages/editor/src/wdyr.ts rename to packages/client/editor/src/wdyr.ts diff --git a/packages/editor/src/windows/AgentControlWindow.tsx b/packages/client/editor/src/windows/AgentControlWindow.tsx similarity index 100% rename from packages/editor/src/windows/AgentControlWindow.tsx rename to packages/client/editor/src/windows/AgentControlWindow.tsx diff --git a/packages/editor/src/windows/DebugConsole/index.tsx b/packages/client/editor/src/windows/DebugConsole/index.tsx similarity index 100% rename from packages/editor/src/windows/DebugConsole/index.tsx rename to packages/client/editor/src/windows/DebugConsole/index.tsx diff --git a/packages/editor/src/windows/EditorWindow/editorwindow.module.css b/packages/client/editor/src/windows/EditorWindow/editorwindow.module.css similarity index 100% rename from packages/editor/src/windows/EditorWindow/editorwindow.module.css rename to packages/client/editor/src/windows/EditorWindow/editorwindow.module.css diff --git a/packages/client/editor/src/windows/EditorWindow/editorwindow.module.css.d.ts b/packages/client/editor/src/windows/EditorWindow/editorwindow.module.css.d.ts new file mode 100644 index 0000000000..29b31f2026 --- /dev/null +++ b/packages/client/editor/src/windows/EditorWindow/editorwindow.module.css.d.ts @@ -0,0 +1,16 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'deploy-shield': string + 'deploy-window': string + 'editor-container': string + 'editor-deployments-wrapper': string + 'editor-toolbar': string + 'folder-arrow': string + inactive: string + 'list-item': string + 'load-button': string + message: string +} +export const cssExports: CssExports +export default cssExports diff --git a/packages/editor/src/windows/EditorWindow/index.tsx b/packages/client/editor/src/windows/EditorWindow/index.tsx similarity index 96% rename from packages/editor/src/windows/EditorWindow/index.tsx rename to packages/client/editor/src/windows/EditorWindow/index.tsx index f54b01eeaa..5833649e5b 100644 --- a/packages/editor/src/windows/EditorWindow/index.tsx +++ b/packages/client/editor/src/windows/EditorWindow/index.tsx @@ -1,7 +1,7 @@ -// DOCUMENTED +// DOCUMENTED // Import required components and hooks -import { Editor } from '../../contexts/EditorProvider'; -import css from './editorwindow.module.css'; +import { Editor } from '../../contexts/EditorProvider' +import css from './editorwindow.module.css' /** * EditorWindow functional component @@ -12,10 +12,10 @@ import css from './editorwindow.module.css'; const EditorWindow = ({ tab }) => { // Destructure required methods and properties from the useEditor hook // const { getNodes } = useEditor(); - + // State management for deployOpen status // const [setDeployOpen] = useState(false); - + // Extract the nodeList and nodeMap using the provided methods // const nodeList = getNodes(); // const nodeMap = getNodeMap(); @@ -133,8 +133,8 @@ const EditorWindow = ({ tab }) => {
- ); -}; + ) +} // Export the EditorWindow component -export default EditorWindow; \ No newline at end of file +export default EditorWindow diff --git a/packages/editor/src/windows/InspectorWindow.tsx b/packages/client/editor/src/windows/InspectorWindow.tsx similarity index 92% rename from packages/editor/src/windows/InspectorWindow.tsx rename to packages/client/editor/src/windows/InspectorWindow.tsx index 36f50d3652..1508ab2ecb 100644 --- a/packages/editor/src/windows/InspectorWindow.tsx +++ b/packages/client/editor/src/windows/InspectorWindow.tsx @@ -1,5 +1,10 @@ -// DOCUMENTED -import { componentCategories, Icon, Tooltip, Window } from '@magickml/client-core' +// DOCUMENTED +import { + componentCategories, + Icon, + Tooltip, + Window, +} from '@magickml/client-core' import { Help } from '@mui/icons-material' import { IconButton } from '@mui/material' import { useEffect, useState } from 'react' @@ -11,7 +16,7 @@ import DataControls from '../DataControls' /** * The Inspector component displays the selected component's data in a window with controls for modifying the data. */ -const Inspector = (props) => { +const Inspector = props => { const { inspectorData, saveInspector } = useInspector() const [width, setWidth] = useState() @@ -38,7 +43,7 @@ const Inspector = (props) => { * Update a control's properties. * @param {Object} control - The control object to update. */ - const updateControl = (control) => { + const updateControl = control => { if (!inspectorData) return const newData = { ...inspectorData, @@ -51,7 +56,7 @@ const Inspector = (props) => { * Update inspector data. * @param {Object} update - Object containing updated data. */ - const updateData = (update) => { + const updateData = update => { if (!inspectorData) return const newData = { ...inspectorData, @@ -113,4 +118,4 @@ const Inspector = (props) => { ) } -export default Inspector \ No newline at end of file +export default Inspector diff --git a/packages/editor/src/windows/PlaytestWindow.tsx b/packages/client/editor/src/windows/PlaytestWindow.tsx similarity index 100% rename from packages/editor/src/windows/PlaytestWindow.tsx rename to packages/client/editor/src/windows/PlaytestWindow.tsx diff --git a/packages/editor/src/windows/TextEditorWindow/index.tsx b/packages/client/editor/src/windows/TextEditorWindow/index.tsx similarity index 100% rename from packages/editor/src/windows/TextEditorWindow/index.tsx rename to packages/client/editor/src/windows/TextEditorWindow/index.tsx diff --git a/packages/editor/src/windows/TextEditorWindow/utils.tsx b/packages/client/editor/src/windows/TextEditorWindow/utils.tsx similarity index 100% rename from packages/editor/src/windows/TextEditorWindow/utils.tsx rename to packages/client/editor/src/windows/TextEditorWindow/utils.tsx diff --git a/packages/editor/tsconfig.json b/packages/client/editor/tsconfig.json similarity index 79% rename from packages/editor/tsconfig.json rename to packages/client/editor/tsconfig.json index 331e578b8f..31f6b0d29e 100644 --- a/packages/editor/tsconfig.json +++ b/packages/client/editor/tsconfig.json @@ -1,11 +1,11 @@ { - "extends": "../../tsconfig.base.json", + "extends": "../../../tsconfig.base.json", "compilerOptions": { "target": "ESNext", "useDefineForClassFields": true, "module": "ESNext", "lib": ["ESNext", "DOM", "DOM.Iterable"], - "rootDir": "../..", + "rootDir": "../../..", "outDir": "lib", "strict": false, "skipLibCheck": true, @@ -23,6 +23,7 @@ "src", "../core/client/src/providers/ConfigProvider.tsx", "../core/client/src/providers/PubSubProvider.tsx", - "../core/client/src/providers/FeathersProvider.tsx" -, "../core/shared/src/state" ] + "../core/client/src/providers/FeathersProvider.tsx", + "../core/shared/src/state" + ] } diff --git a/packages/editor/tsconfig.lib.json b/packages/client/editor/tsconfig.lib.json similarity index 91% rename from packages/editor/tsconfig.lib.json rename to packages/client/editor/tsconfig.lib.json index b767c3aba7..c1c97aa267 100644 --- a/packages/editor/tsconfig.lib.json +++ b/packages/client/editor/tsconfig.lib.json @@ -1,7 +1,7 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", + "outDir": "../../../dist/out-tsc", "types": [ "node", "@nx/react/typings/cssmodule.d.ts", diff --git a/packages/editor/tsconfig.spec.json b/packages/client/editor/tsconfig.spec.json similarity index 91% rename from packages/editor/tsconfig.spec.json rename to packages/client/editor/tsconfig.spec.json index ff5ccbdb76..234ebde7a3 100644 --- a/packages/editor/tsconfig.spec.json +++ b/packages/client/editor/tsconfig.spec.json @@ -1,7 +1,7 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", + "outDir": "../../../dist/out-tsc", "module": "commonjs", "types": [ "jest", diff --git a/packages/editor/vite.config.ts b/packages/client/editor/vite.config.ts similarity index 96% rename from packages/editor/vite.config.ts rename to packages/client/editor/vite.config.ts index df6fb9d026..e11dc32d28 100644 --- a/packages/editor/vite.config.ts +++ b/packages/client/editor/vite.config.ts @@ -10,7 +10,7 @@ import rollupNodePolyFill from 'rollup-plugin-node-polyfills' import mdPlugin, { Mode } from 'vite-plugin-markdown' export default defineConfig({ - cacheDir: '../../node_modules/.vite/editor', + cacheDir: '../../../node_modules/.vite/editor', assetsInclude: ['**/*.vrm', '**/*.svg'], resolve: { alias: { @@ -32,7 +32,7 @@ export default defineConfig({ // Uncomment this if you are using workers. // worker: { // viteTsConfigPaths({ - // root: '../../', + // root: '../../../', // }), // }, optimizeDeps: { diff --git a/packages/editor/src/App.tsx b/packages/editor/src/App.tsx deleted file mode 100644 index 4ed3fbffba..0000000000 --- a/packages/editor/src/App.tsx +++ /dev/null @@ -1,18 +0,0 @@ -// DOCUMENTED -/** - * A functional component that renders the 'Routes' component. - */ -import React from 'react'; -import Routes from './routes'; -import './App.css'; -import enableWhyDidYouRender from './wdyr'; - -enableWhyDidYouRender(React) - -function App(): JSX.Element { - return ( - - ); -} - -export default App; \ No newline at end of file diff --git a/packages/editor/src/components/MenuBar/menuBar.module.css.d.ts b/packages/editor/src/components/MenuBar/menuBar.module.css.d.ts deleted file mode 100644 index f76f479feb..0000000000 --- a/packages/editor/src/components/MenuBar/menuBar.module.css.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file is automatically generated. -// Please do not change this file! -interface CssExports { - 'folder-arrow': string; - 'list-item': string; - 'menu-bar': string; - 'menu-bar-item': string; - 'menu-panel': string; - 'preference-active': string; - 'preference-notActive': string; -} -export const cssExports: CssExports; -export default cssExports; diff --git a/packages/editor/src/components/Modal/modal.module.css.d.ts b/packages/editor/src/components/Modal/modal.module.css.d.ts deleted file mode 100644 index a4d3ba5cbc..0000000000 --- a/packages/editor/src/components/Modal/modal.module.css.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -// This file is automatically generated. -// Please do not change this file! -interface CssExports { - 'modal': string; - 'modal-action-strip': string; - 'modal-bg': string; - 'modal-main-div': string; - 'modal-panel': string; - 'modal-panel-content': string; - 'modal-title': string; - 'vertical': string; -} -export const cssExports: CssExports; -export default cssExports; diff --git a/packages/editor/src/components/Modals/loginModal.module.css.d.ts b/packages/editor/src/components/Modals/loginModal.module.css.d.ts deleted file mode 100644 index aa41286883..0000000000 --- a/packages/editor/src/components/Modals/loginModal.module.css.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -// This file is automatically generated. -// Please do not change this file! -interface CssExports { - 'error-message': string; - 'input': string; - 'input-container': string; - 'login-container': string; -} -export const cssExports: CssExports; -export default cssExports; diff --git a/packages/editor/src/components/Modals/modalForms.module.css.d.ts b/packages/editor/src/components/Modals/modalForms.module.css.d.ts deleted file mode 100644 index 6f4eb73159..0000000000 --- a/packages/editor/src/components/Modals/modalForms.module.css.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file is automatically generated. -// Please do not change this file! -interface CssExports { - 'delete-btn': string; - 'delete-modal': string; - 'error-message': string; - 'input': string; - 'input-container': string; - 'login-container': string; - 'select': string; -} -export const cssExports: CssExports; -export default cssExports; diff --git a/packages/editor/src/components/Node/Node.module.css.d.ts b/packages/editor/src/components/Node/Node.module.css.d.ts deleted file mode 100644 index 007b600828..0000000000 --- a/packages/editor/src/components/Node/Node.module.css.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -// This file is automatically generated. -// Please do not change this file! -interface CssExports { - 'bottom-container': string; - 'connection-container': string; - 'connections-container': string; - 'control': string; - 'error': string; - 'input': string; - 'node': string; - 'node-depricated': string; - 'node-id': string; - 'node-locked': string; - 'node-title': string; - 'nodeGenesis': string; - 'out': string; - 'output': string; - 'selected': string; - 'success': string; -} -export const cssExports: CssExports; -export default cssExports; diff --git a/packages/editor/src/components/TabBar/tabBar.module.css.d.ts b/packages/editor/src/components/TabBar/tabBar.module.css.d.ts deleted file mode 100644 index aac9f7fdbd..0000000000 --- a/packages/editor/src/components/TabBar/tabBar.module.css.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file is automatically generated. -// Please do not change this file! -interface CssExports { - 'active': string; - 'create-spell-tab': string; - 'inactive': string; - 'tabbar-section': string; - 'tabbar-tab': string; - 'tabbar-user': string; - 'th-tabbar': string; -} -export const cssExports: CssExports; -export default cssExports; diff --git a/packages/editor/src/layouts/MagickPageLayout/pagewrapper.module.css.d.ts b/packages/editor/src/layouts/MagickPageLayout/pagewrapper.module.css.d.ts deleted file mode 100644 index 00980db8ac..0000000000 --- a/packages/editor/src/layouts/MagickPageLayout/pagewrapper.module.css.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -// This file is automatically generated. -// Please do not change this file! -interface CssExports { - 'wrapper': string; -} -export const cssExports: CssExports; -export default cssExports; diff --git a/packages/editor/src/plugins/autoArrangePlugin/board.js b/packages/editor/src/plugins/autoArrangePlugin/board.js deleted file mode 100644 index ebc8c9392a..0000000000 --- a/packages/editor/src/plugins/autoArrangePlugin/board.js +++ /dev/null @@ -1,19 +0,0 @@ -export class Board { - constructor() { - this._cols = []; - } - - add(columnIndex, value) { - if (!this._cols[columnIndex]) this._cols[columnIndex] = []; - - this._cols[columnIndex].push(value); - } - - toArray() { - const normalized = Object.keys(this._cols) - .sort((i1, i2) => +i1 - +i2) - .map(key => this._cols[key]); - - return normalized; - } -} diff --git a/packages/editor/src/plugins/autoArrangePlugin/cache.js b/packages/editor/src/plugins/autoArrangePlugin/cache.js deleted file mode 100644 index 9070dcd5c9..0000000000 --- a/packages/editor/src/plugins/autoArrangePlugin/cache.js +++ /dev/null @@ -1,10 +0,0 @@ -export class Cache { - constructor() { - this._map = new WeakMap(); - } - - track(value) { - if (this._map.has(value)) return true; - this._map.set(value, true); - } -} diff --git a/packages/editor/src/screens/DocumentWindow/documentconvert.tsx b/packages/editor/src/screens/DocumentWindow/documentconvert.tsx deleted file mode 100644 index eac05ed361..0000000000 --- a/packages/editor/src/screens/DocumentWindow/documentconvert.tsx +++ /dev/null @@ -1,229 +0,0 @@ -import * as pdfjsLib from 'pdfjs-dist/build/pdf.min.js' -import * as Tesseract from 'tesseract.js'; -import * as mammoth from 'mammoth'; -import { PDFPageProxy } from 'pdfjs-dist/types/web/interfaces'; -import * as XLSX from 'xlsx/xlsx.mjs'; - -type SupportedFileTypes = 'pdf' | 'doc' | 'docx' | 'xls' | 'xlsx' | 'ppt' | 'pptx'; - -interface OCRConfig { - engine: 'tesseract' | 'other'; - other: any; -} - -export async function convertFileToText(file: File, ocrConfig?: OCRConfig): Promise { - const fileExt = file.name.split('.').pop()!.toLowerCase() as SupportedFileTypes; - - switch (fileExt) { - case 'pdf': - return await convertPdfToText(file, ocrConfig?.engine, ocrConfig?.other); - case 'doc': - case 'docx': - return await convertWordToText(file); - case 'xls': - case 'xlsx': - return await convertExcelToText(file); - /* case 'ppt': - case 'pptx': - return await convertPowerpointToText(file); */ - default: - throw new Error(`Unsupported file type: ${fileExt}`); - } -} - -export async function numberOfPages(file: File): Promise { - const fileExt = file.name.split('.').pop()!.toLowerCase() as SupportedFileTypes; - - switch (fileExt) { - case 'pdf': - return pdfNumberOfPages(file); - case 'doc': - case 'docx': - return 0;; - case 'xls': - case 'xlsx': - return 0; - /* case 'ppt': - case 'pptx': - return await convertPowerpointToText(file); */ - default: - throw new Error(`Unsupported file type: ${fileExt}`); - } -} - -async function pdfNumberOfPages(file: File) { - // Read the PDF file - const pdfBuffer = await readFileAsBuffer(file); - - // Define the PDF.js worker source path (needed for loading PDF.js) - pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.6.172/pdf.worker.min.js'; - //Load the PDF document - const pdfDocument = await pdfjsLib.getDocument({ data: pdfBuffer }).promise; - return pdfDocument.numPages -} - -async function convertPdfToText(file: File, ocrEngine = 'tesseract', ocrConfig?: any): Promise { - // Read the PDF file - const pdfBuffer = await readFileAsBuffer(file); - - // Define the PDF.js worker source path (needed for loading PDF.js) - pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.6.172/pdf.worker.min.js'; - - // Load the PDF document - const pdfDocument = await pdfjsLib.getDocument({ data: pdfBuffer }).promise; - - const text = []; - - if (ocrEngine === 'tesseract') { - // Initialize Tesseract.js with the English language - const worker = await Tesseract.createWorker({ - logger: m => console.log(m) - }); - - await worker.loadLanguage('eng'); - await worker.initialize('eng'); - - // Loop through each page of the PDF document - for (let i = 1; i <= pdfDocument.numPages; i++) { - // Get the page object - const page = await pdfDocument.getPage(i); - - // Get the text content of the page - const content = await page.getTextContent(); - const items = content.items; - - if (items.length === 1 && !items[0].str) { - // If the page has only one item and it's an image, use OCR to extract the text - const pngBuffer = await pdfPageToPngBuffer(page); - //@ts-ignore - const ocrResult = await worker.recognize(pngBuffer, { lang: 'eng' }); - //text += ocrResult.data.text; - text.push(ocrResult.data.text); - } else { - // If the page has multiple items, loop through each item - for (let j = 0; j < items.length; j++) { - const item = items[j]; - - if (item.str === '') { - //TODO: Only Extract the part of the table that is visible on the page - // If the item is an image, extract its text content - /* const imagePngBuffer = await pdfPageToPngBuffer(page); - //@ts-ignore - const imageOcrResult = await worker.recognize(imagePngBuffer, { lang: 'eng' }); - //text += imageOcrResult.data.text; - text.push(imageOcrResult.data.text); */ - } else { - // If the item is a text element or table, append its raw text content to the output file - //text += item.str; - text.push(item.str); - } - } - } - } - } else { - // TODO: Implement alternative OCR engine - throw new Error(`Unsupported OCR engine: ${ocrEngine}`); - } - - return text; -} - - - - - -async function convertWordToText(file: File): Promise { - const arrayBuffer = await readFileAsBuffer(file); - const result = await mammoth.convertToHtml({ arrayBuffer }); - return result.value.replace(/(<([^>]+)>)/gi, ''); -} -/* async function convertPowerpointToText(file: File): Promise { - console.log('convertPowerpointToText') - const arrayBuffer = await readFileAsBuffer(file); - console.log(arrayBuffer) - const result = await mammoth.extractRawText({ arrayBuffer }); - console.log(result) - return result.value.replace(/(<([^>]+)>)/gi, ''); -} */ -async function convertExcelToText(file: File): Promise { - const arrayBuffer = await readFileAsBuffer(file); - // Read the Excel file - const workbook = XLSX.read(arrayBuffer, { type: 'array' }); - - let text = ''; - let wordCount = 0; - - // Loop through each worksheet in the workbook - for (const sheetName of workbook.SheetNames) { - const worksheet = workbook.Sheets[sheetName]; - // Convert the worksheet to an array of rows - const rows = XLSX.utils.sheet_to_json(worksheet, { header: 1 }); - - // Get the table column headings - const columnHeadings = rows.shift() as []; - - // Append the column headings to the output text - text += columnHeadings.join('\t') + '\n'; - - // Append the rows to the output text - for (const row of rows) { - text += (row as []).join('\t') + '\n'; - - // Count the number of words added - const words = (row as []).join(' ').split(' '); - wordCount += words.length; - - // Check if 7000 words have been added - if (wordCount >= 7000) { - // Add "<>" marker - text += '<>\n'; - - // Reset the word count - wordCount = 0; - - // Append the column headings again - text += columnHeadings.join('\t') + '\n'; - } - } - } - - return text; -} - - - -async function pdfPageToPngBuffer(pdfPage: PDFPageProxy): Promise { - const canvas = document.createElement('canvas'); - const viewport = pdfPage.getViewport({ scale: 1.0 }); - canvas.width = viewport.width; - canvas.height = viewport.height; - const ctx = canvas.getContext('2d')!; - const renderContext: any = { - canvasContext: ctx, - viewport: viewport - }; - const renderTask: any = pdfPage.render(renderContext); - await renderTask.promise; - const blob = await (await fetch(canvas.toDataURL('image/png'))).blob(); - const arrayBuffer = await blob.arrayBuffer(); - return new Uint8Array(arrayBuffer); -} - -async function readFileAsBuffer(file: File): Promise { - return new Promise((resolve, reject) => { - const reader = new FileReader(); - reader.onload = () => { - if (reader.result instanceof ArrayBuffer) { - resolve(reader.result); - } else { - reject(new Error('Failed to read file as ArrayBuffer')); - } - }; - reader.onerror = () => { - reject(reader.error); - }; - reader.readAsArrayBuffer(file); - }); -} - - diff --git a/packages/editor/src/screens/Magick/magick.module.css.d.ts b/packages/editor/src/screens/Magick/magick.module.css.d.ts deleted file mode 100644 index 802475a19c..0000000000 --- a/packages/editor/src/screens/Magick/magick.module.css.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -// This file is automatically generated. -// Please do not change this file! -interface CssExports { - 'active': string; - 'bottom-container': string; - 'code-editor': string; - 'form-text-area': string; - 'node-bottom-container': string; - 'node-grid': string; - 'node-grid-item': string; - 'node-title': string; - 'playtest-input': string; - 'playtest-output': string; - 'tab': string; - 'tab-page': string; - 'tabs': string; - 'th-sidepanel': string; -} -export const cssExports: CssExports; -export default cssExports; diff --git a/packages/editor/src/screens/MagickV2/panels/fileDrawer.tsx b/packages/editor/src/screens/MagickV2/panels/fileDrawer.tsx deleted file mode 100644 index 709438f7bb..0000000000 --- a/packages/editor/src/screens/MagickV2/panels/fileDrawer.tsx +++ /dev/null @@ -1,100 +0,0 @@ -import { NewSidebar, TreeDataProvider, usePubSub } from "@magickml/client-core"; -import { IGridviewPanelProps } from "dockview"; -import { useEffect, useState } from "react"; -import { useHotkeys } from "react-hotkeys-hook"; - -const ANIMATION_DURATION = 50; - -const FileDrawer = (props: IGridviewPanelProps<{ title: string }>) => { - const [isAnimating, setIsAnimating] = useState(false); - const [currentWidth, setCurrentWidth] = useState(0); - const [targetWidth, setTargetWidth] = useState(0); - const { events, subscribe } = usePubSub() - - const { TOGGLE_FILE_DRAWER } = events - - useHotkeys( - 'ctrl+b', - () => { - if (currentWidth > 0) { - close(); - } else { - open(); - } - } - ); - - const animateSize = (initialWidth: number, targetWidth: number) => { - let startTimestamp: number | null = null; - - const frame = (timestamp: number) => { - if (!startTimestamp) startTimestamp = timestamp; - - const elapsed = timestamp - startTimestamp; - const progress = Math.min(elapsed / ANIMATION_DURATION, 1); - - const currentWidth = initialWidth + (targetWidth - initialWidth) * progress; - props.api.setSize({ width: currentWidth }); - - if (progress < 1) { - requestAnimationFrame(frame); - } else { - setIsAnimating(false); - } - }; - - setIsAnimating(true); - requestAnimationFrame(frame); - }; - - const open = () => { - if (!isAnimating) { - animateSize(0, targetWidth); - } - }; - - const close = () => { - if (!isAnimating) { - setTargetWidth(currentWidth); - animateSize(currentWidth, 0); - } - }; - - useEffect(() => { - const unsubscribe = subscribe(TOGGLE_FILE_DRAWER, () => { - if (currentWidth > 0) { - close(); - } else { - open(); - } - }) - - return () => { - unsubscribe() - } - }, [currentWidth, open, close, subscribe, TOGGLE_FILE_DRAWER]) - - // useEffect is now used only if you need an initial animation or similar effect - useEffect(() => { - // Example: animate the opening when the component mounts - const dispose = props.api.onDidDimensionsChange(event => { - setCurrentWidth(event.width); - }) - - props.api.setSize({ width: 200 }); - - return () => { - dispose.dispose() - } - }, [props.api]); - - return ( -
- - - -
- ); -} - -export default FileDrawer \ No newline at end of file diff --git a/packages/editor/src/screens/RequestWindow/requests.ts b/packages/editor/src/screens/RequestWindow/requests.ts deleted file mode 100644 index 2e1e40ed45..0000000000 --- a/packages/editor/src/screens/RequestWindow/requests.ts +++ /dev/null @@ -1,58 +0,0 @@ -export interface Column { - id: - | 'action' - | 'checkbox' - | 'collapse' - | 'provider' - | 'type' - | 'nodeId' - | 'cost' - | 'duration' - | 'status' - | 'statusCode' - | 'model' - | 'requestData' - | 'responseData' - | 'parameters' - | 'spell' - label: string - minWidth?: number - align?: 'right' -} - - export const columns: Column[] = [ - { id: 'action', label: 'Actions', minWidth: 10 }, - { id: 'checkbox', label: '', minWidth: 10 }, - { id: 'collapse', label: '', minWidth: 10 }, - { id: 'provider', label: 'Provider', minWidth: 65 }, - { id: 'type', label: 'Type', minWidth: 65 }, - { id: 'nodeId', label: 'Node ID', minWidth: 65 }, - { id: 'cost', label: 'Cost', minWidth: 65 }, - { id: 'duration', label: 'Request Time', minWidth: 65 }, - { id: 'status', label: 'Status', minWidth: 65 }, - { id: 'statusCode', label: 'Code', minWidth: 65 }, - { id: 'model', label: 'Model', minWidth: 65 }, - { id: 'requestData', label: 'Request Data', minWidth: 65 }, - { id: 'responseData', label: 'Response Data', minWidth: 65 }, - { id: 'parameters', label: 'Parameters', minWidth: 65 }, - { id: 'spell', label: 'Spell', minWidth: 65 }, - ] - - export interface DocumentData { - row: any - action: any - provider:string - type:string - nodeId:string - cost:string - duration:string - status:string - statusCode:string - model:string - requestData:string - responseData:string - parameters:string - spell:string - - } - \ No newline at end of file diff --git a/packages/editor/src/screens/agents/AgentWindow/tooltip_texts.ts b/packages/editor/src/screens/agents/AgentWindow/tooltip_texts.ts deleted file mode 100644 index 96f3102ead..0000000000 --- a/packages/editor/src/screens/agents/AgentWindow/tooltip_texts.ts +++ /dev/null @@ -1,8 +0,0 @@ -export const tooltip_text = { - rootSpell: 'The root spell of the agent', - "GoogleAI API Key": 'The API key for the Google AI service', - "OpenAI API Key": 'The API key for the OpenAI service', - "ElevenLabs API Key": 'The API key for the ElevenLabs service', - "Postgres Connection String": 'The connection string for the Postgres database', - "Anthropic API Key": "The API key for the Anthropic" -} \ No newline at end of file diff --git a/packages/editor/src/utils/app/clean.ts b/packages/editor/src/utils/app/clean.ts deleted file mode 100644 index f51cf0e004..0000000000 --- a/packages/editor/src/utils/app/clean.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { Conversation } from "../../types"; - -export const cleanSelectedConversation = (conversation: Conversation) => { - let updatedConversation = conversation; - - // check for spell on each conversation - if (!updatedConversation.spell) { - updatedConversation = { - ...updatedConversation, - spell: null - }; - } - - // check for system prompt on each conversation - if (!updatedConversation.prompt) { - updatedConversation = { - ...updatedConversation - }; - } - - return updatedConversation; -}; - -export const cleanConversationHistory = (history: Conversation[]) => { - let updatedHistory = [...history]; - - // check for spell on each conversation - if (!updatedHistory.every((conversation) => conversation.spell)) { - updatedHistory = updatedHistory.map((conversation) => ({ - ...conversation, - spell: null - })); - } - - // check for system prompt on each conversation - if (!updatedHistory.every((conversation) => conversation.prompt)) { - updatedHistory = updatedHistory.map((conversation) => ({ - ...conversation - })); - } - - return updatedHistory; -}; diff --git a/packages/editor/src/utils/app/conversation.ts b/packages/editor/src/utils/app/conversation.ts deleted file mode 100644 index cc80cd8e50..0000000000 --- a/packages/editor/src/utils/app/conversation.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { Conversation } from "../../types"; - -export const updateConversation = (updatedConversation: Conversation, allConversations: Conversation[]) => { - const updatedConversations = allConversations.map((c) => { - if (c.id === updatedConversation.id) { - return updatedConversation; - } - - return c; - }); - - saveConversation(updatedConversation); - saveConversations(updatedConversations); - - return { - single: updatedConversation, - all: updatedConversations - }; -}; - -export const saveConversation = (conversation: Conversation) => { - localStorage.setItem("selectedConversation", JSON.stringify(conversation)); -}; - -export const saveConversations = (conversations: Conversation[]) => { - console.log("🚀 ~ file: conversation.ts:26 ~ saveConversations ~ conversations:", conversations) - // TODO: Create spell to save conversation history and "consume" it on chat window - localStorage.setItem("conversationHistory", JSON.stringify(conversations)); -}; diff --git a/packages/editor/src/utils/app/data.ts b/packages/editor/src/utils/app/data.ts deleted file mode 100644 index 8ab07e69e5..0000000000 --- a/packages/editor/src/utils/app/data.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { Conversation } from "../../types"; - -export const exportConversations = () => { - const history = localStorage.getItem("conversationHistory"); - - if (!history) return; - - const blob = new Blob([history], { type: "application/json" }); - const url = URL.createObjectURL(blob); - const link = document.createElement("a"); - link.download = "chatbot_ui_history.json"; - link.href = url; - link.style.display = "none"; - document.body.appendChild(link); - link.click(); - document.body.removeChild(link); - URL.revokeObjectURL(url); -}; - -export const importConversations = (conversations: Conversation[]) => { - localStorage.setItem("conversationHistory", JSON.stringify(conversations)); - localStorage.setItem("selectedConversation", JSON.stringify(conversations[conversations.length - 1])); -}; - -interface languageMap { - [key: string]: string | undefined -} - -export const programmingLanguages: languageMap = { - 'javascript': '.js', - 'python': '.py', - 'java': '.java', - 'c': '.c', - 'cpp': '.cpp', - 'c++': '.cpp', - 'c#': '.cs', - 'ruby': '.rb', - 'php': '.php', - 'swift': '.swift', - 'objective-c': '.m', - 'kotlin': '.kt', - 'typescript': '.ts', - 'go': '.go', - 'perl': '.pl', - 'rust': '.rs', - 'scala': '.scala', - 'haskell': '.hs', - 'lua': '.lua', - 'shell': '.sh', - 'sql': '.sql', - 'html': '.html', - 'css': '.css' - // add more file extensions here, make sure the key is same as language prop in CodeBlock.tsx component -}; - - -export const generateRandomString = (length: number, lowercase = false) => { - const chars = "ABCDEFGHJKLMNPQRSTUVWXY3456789"; // excluding similar looking characters like Z, 2, I, 1, O, 0 - let result = ""; - for (let i = 0; i < length; i++) { - result += chars.charAt(Math.floor(Math.random() * chars.length)); - } - return lowercase ? result.toLowerCase() : result; -} diff --git a/packages/editor/src/utils/speechUtils.d.ts b/packages/editor/src/utils/speechUtils.d.ts deleted file mode 100644 index f111f80352..0000000000 --- a/packages/editor/src/utils/speechUtils.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -export declare class singleton { - static instance: speechUtils; - static getInstance(): speechUtils; -} -declare class speechUtils { - bufferSize: number; - AudioContext: any; - context: any; - processor: any; - input: any; - globalStream: any; - finalWord: boolean; - removeLastSentence: boolean; - streamStreaming: boolean; - constraints: { - audio: boolean; - video: boolean; - }; - socket: import("socket.io-client").Socket; - constructor(); - initRecording: (newMessageCallback: Function) => void; - microphoneProcess: (e: any) => void; - stopRecording: () => void; - downsampleBuffer: (buffer: any, sampleRate: any, outSampleRate: any) => any; -} -export default singleton; diff --git a/packages/editor/src/windows/EditorWindow/editorwindow.module.css.d.ts b/packages/editor/src/windows/EditorWindow/editorwindow.module.css.d.ts deleted file mode 100644 index 5dbb4b193d..0000000000 --- a/packages/editor/src/windows/EditorWindow/editorwindow.module.css.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file is automatically generated. -// Please do not change this file! -interface CssExports { - 'deploy-shield': string; - 'deploy-window': string; - 'editor-container': string; - 'editor-deployments-wrapper': string; - 'editor-toolbar': string; - 'folder-arrow': string; - 'inactive': string; - 'list-item': string; - 'load-button': string; - 'message': string; -} -export const cssExports: CssExports; -export default cssExports; diff --git a/tsconfig.base.json b/tsconfig.base.json index 02ba524ae4..4f28e56df2 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -39,7 +39,6 @@ "@magickml/config": ["packages/config/src/index.ts"], "@magickml/core": ["packages/core/shared/src/index.ts"], "@magickml/docs": ["apps/docs/src/index.ts"], - "@magickml/editor": ["packages/editor/src/index.ts"], "@magickml/plugin-anthropic-client": [ "packages/plugins/anthropic/client/src/index.ts" ], @@ -202,6 +201,7 @@ "@magickml/ui/components": ["packages/utils/components/src/index.ts"], "@magickml/ui/utils": ["packages/ui/src/utils.ts"], "server/event-tracker": ["packages/server/event-tracker/src/index.ts"], + "client/editor": ["packages/client/editor/src/index.ts"], "client/layouts": ["packages/client/layouts/src/index.ts"], "client/state": ["packages/client/state/src/index.ts"], "rete": ["packages/rete/src/index.ts"] From 01995a684789917880b19f564a33e2c022238113 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 27 Sep 2023 11:38:42 -0700 Subject: [PATCH 116/349] Move cloud agent manager --- apps/cloud-agent-manager/src/main.ts | 33 ++-- packages/cloud-agent-manager/project.json | 8 - .../src/lib/CloudAgentManager.ts | 138 ---------------- .../src/lib/Reporters/FeathersSyncReporter.ts | 26 --- .../src/lib/Reporters/PgNotifyReporter.ts | 39 ----- .../src/lib/Reporters/index.ts | 3 - .../cloud-agent-manager/README.md | 0 .../server/cloud-agent-manager/project.json | 8 + .../cloud-agent-manager/src/index.ts | 0 .../src/lib/CloudAgentManager.ts | 154 ++++++++++++++++++ .../src/lib/Reporters/FeathersSyncReporter.ts | 28 ++++ .../src/lib/Reporters/PgNotifyReporter.ts | 39 +++++ .../src/lib/Reporters/index.ts | 3 + .../cloud-agent-manager/tsconfig.json | 2 +- .../cloud-agent-manager/tsconfig.lib.json | 2 +- tsconfig.base.json | 8 +- 16 files changed, 255 insertions(+), 236 deletions(-) delete mode 100644 packages/cloud-agent-manager/project.json delete mode 100644 packages/cloud-agent-manager/src/lib/CloudAgentManager.ts delete mode 100644 packages/cloud-agent-manager/src/lib/Reporters/FeathersSyncReporter.ts delete mode 100644 packages/cloud-agent-manager/src/lib/Reporters/PgNotifyReporter.ts delete mode 100644 packages/cloud-agent-manager/src/lib/Reporters/index.ts rename packages/{ => server}/cloud-agent-manager/README.md (100%) create mode 100644 packages/server/cloud-agent-manager/project.json rename packages/{ => server}/cloud-agent-manager/src/index.ts (100%) create mode 100644 packages/server/cloud-agent-manager/src/lib/CloudAgentManager.ts create mode 100644 packages/server/cloud-agent-manager/src/lib/Reporters/FeathersSyncReporter.ts create mode 100644 packages/server/cloud-agent-manager/src/lib/Reporters/PgNotifyReporter.ts create mode 100644 packages/server/cloud-agent-manager/src/lib/Reporters/index.ts rename packages/{ => server}/cloud-agent-manager/tsconfig.json (89%) rename packages/{ => server}/cloud-agent-manager/tsconfig.lib.json (87%) diff --git a/apps/cloud-agent-manager/src/main.ts b/apps/cloud-agent-manager/src/main.ts index 4372014ee1..cb117a7f1d 100644 --- a/apps/cloud-agent-manager/src/main.ts +++ b/apps/cloud-agent-manager/src/main.ts @@ -1,23 +1,24 @@ -import { CloudAgentManager, FeathersSyncReporter } from "@magickml/cloud-agent-manager" -import { initLogger, getLogger } from "@magickml/core" -import { app, BullQueue, initApp } from "@magickml/server-core" -import { DONT_CRASH_ON_ERROR, PRODUCTION } from "@magickml/config" -import { initAgentCommander } from "@magickml/agents" +import { + CloudAgentManager, + FeathersSyncReporter, +} from 'server/cloud-agent-manager' +import { initLogger, getLogger } from '@magickml/core' +import { app, BullQueue, initApp } from '@magickml/server-core' +import { DONT_CRASH_ON_ERROR, PRODUCTION } from '@magickml/config' +import { initAgentCommander } from '@magickml/agents' import { getPinoTransport } from '@hyperdx/node-opentelemetry' if (PRODUCTION) { - initLogger({ - name: 'cloud-agent-manager', - transport: { - targets: [ - getPinoTransport('info') - ] - }, - level: 'info', - }) + initLogger({ + name: 'cloud-agent-manager', + transport: { + targets: [getPinoTransport('info')], + }, + level: 'info', + }) } else { - initLogger({ name: 'cloud-agent-manager' }) -} + initLogger({ name: 'cloud-agent-manager' }) +} const logger = getLogger() function start() { diff --git a/packages/cloud-agent-manager/project.json b/packages/cloud-agent-manager/project.json deleted file mode 100644 index 6e76f879a2..0000000000 --- a/packages/cloud-agent-manager/project.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "@magickml/cloud-agent-manager", - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "packages/cloud-agent-manager/src", - "projectType": "library", - "targets": {}, - "tags": [] -} diff --git a/packages/cloud-agent-manager/src/lib/CloudAgentManager.ts b/packages/cloud-agent-manager/src/lib/CloudAgentManager.ts deleted file mode 100644 index 1d8c398184..0000000000 --- a/packages/cloud-agent-manager/src/lib/CloudAgentManager.ts +++ /dev/null @@ -1,138 +0,0 @@ -import pino from 'pino' -import { diff, unique } from 'radash' -import { - AGENT_DELETE, - AGENT_DELETE_JOB, - AGENT_UPDATE_JOB, - getLogger, -} from '@magickml/core' -import type { Reporter } from './Reporters' -import { type PubSub, type MessageQueue, app } from '@magickml/server-core' -import { Agent } from 'packages/core/server/src/services/agents/agents.schema' -import { HEARTBEAT_MSEC, MANAGER_WARM_UP_MSEC } from '@magickml/config' - -interface CloudAgentManagerConstructor { - pubSub: PubSub - newQueue: MessageQueue - agentStateReporter: Reporter -} - -type AgentList = Record - -export class CloudAgentManager { - logger: pino.Logger = getLogger() - newQueue: MessageQueue - agentStateReporter: Reporter - pubSub: PubSub - workerToAgents: AgentList = {} - - constructor(args: CloudAgentManagerConstructor) { - this.logger.info('Cloud Agent Manager Startup') - this.newQueue = args.newQueue - this.newQueue.initialize('agent:new') - this.agentStateReporter = args.agentStateReporter - this.pubSub = app.get('pubsub') - - this.run = this.run.bind(this) - this.heartbeat = this.heartbeat.bind(this) - this.dedupeAgents = this.dedupeAgents.bind(this) - - this.heartbeat() - } - - async run() { - this.agentStateReporter.on('agent:updated', async (data: unknown) => { - const agent = data as Agent - - this.logger.info(`Agent Updated: ${agent.id}`) - - if (agent.enabled) { - this.logger.info( - `Agent ${agent.id} enabled, adding to cloud agent worker` - ) - await this.newQueue.addJob('agent:new', { agentId: agent.id }) - this.logger.debug(`Agent create job for ${agent.id} added`) - return - } - - this.pubSub.publish( - AGENT_UPDATE_JOB(agent.id), - JSON.stringify({ agentId: agent.id }) - ) - }) - - this.agentStateReporter.on(AGENT_DELETE, async (data: unknown) => { - const agent = data as Agent - this.pubSub.publish( - AGENT_DELETE_JOB(agent.id), - JSON.stringify({ agentId: agent.id }) - ) - }) - } - - async dedupeAgents(agents: string[]) { - const deduped = unique(agents) - const diffAgents = diff(agents, deduped) - - this.logger.trace('deduping agents %o', diffAgents) - diffAgents.forEach(async agentId => { - await this.pubSub.publish( - AGENT_DELETE_JOB(agentId), - JSON.stringify({ agentId: agentId }) - ) - await this.newQueue.addJob('agent:new', { agentId: agentId }) - }) - - return deduped - } - - // Eventually we'll need this heartbeat to keep track of running agents on workers - async heartbeat() { - this.logger.debug('Started heartbeat') - let agentsOfWorkers: string[] = [] - this.pubSub.subscribe('heartbeat-pong', async (agents: string[]) => { - this.logger.trace('Got heartbeat pong') - agents.forEach(a => agentsOfWorkers.push(a)) - agentsOfWorkers = await this.dedupeAgents(agentsOfWorkers) - }) - await this.pubSub.publish('heartbeat-ping', '{}') - - setTimeout( - () => - setInterval(async () => { - this.logger.trace(`Starting Heartbeat update`) - const enabledAgents = await app.service('agents').find({ - query: { - enabled: true, - }, - }) - - const agentDiff = diff( - enabledAgents.data.map(a => a.id), - Array.from(agentsOfWorkers) - ) - const agentsToUpdate = enabledAgents.data.filter(a => - agentDiff.includes(a.id) - ) - - if (agentDiff.length > 0) { - this.logger.info(`Found ${agentDiff.length} agents to Update`) - const agentPromises: Promise[] = [] - for (const agent of agentsToUpdate) { - this.logger.debug( - `Adding agent ${agent.id} to cloud agent worker` - ) - agentPromises.push( - this.newQueue.addJob('agent:new', { agentId: agent.id }) - ) - } - - await Promise.all(agentPromises) - } - agentsOfWorkers = [] - this.pubSub.publish('heartbeat-ping', '{}') - }, HEARTBEAT_MSEC), - MANAGER_WARM_UP_MSEC - ) - } -} diff --git a/packages/cloud-agent-manager/src/lib/Reporters/FeathersSyncReporter.ts b/packages/cloud-agent-manager/src/lib/Reporters/FeathersSyncReporter.ts deleted file mode 100644 index 0882e10e48..0000000000 --- a/packages/cloud-agent-manager/src/lib/Reporters/FeathersSyncReporter.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { AGENT_DELETE, getLogger } from '@magickml/core' -import { app } from '@magickml/server-core' -import { Reporter } from '.' -import { EventEmitter } from 'events' - -export class FeathersSyncReporter implements Reporter { - emitter: EventEmitter = new EventEmitter() - logger = getLogger() - - constructor() { - this.initReporter() - } - - async initReporter(): Promise { - this.logger.info('Initializing FeathersSyncReporter...') - app.service('agents').on('patched', (agent: any) => { - this.emitter.emit('agent:updated', agent) - }) - app.service('agents').on('deleted', (agent: any) => this.emitter.emit(AGENT_DELETE, agent)) - this.logger.info('FeathersSyncReporter initialized') - } - - on(event: string, callback: (...args: any) => any): void { - this.emitter.on(event, callback) - } -} diff --git a/packages/cloud-agent-manager/src/lib/Reporters/PgNotifyReporter.ts b/packages/cloud-agent-manager/src/lib/Reporters/PgNotifyReporter.ts deleted file mode 100644 index 6295537944..0000000000 --- a/packages/cloud-agent-manager/src/lib/Reporters/PgNotifyReporter.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { Reporter } from "." -import createSubscriber, { Subscriber } from "pg-listen" -import { getLogger } from "@magickml/core" - -export class PgNotifyReporter implements Reporter { - logger = getLogger() - subscriber: Subscriber - queueName: string - - constructor(queueName: string, dbUrl: string) { - this.subscriber = createSubscriber({ - connectionString: dbUrl, - }) - this.queueName = queueName - this.initReporter() - } - - async initReporter(): Promise { - this.logger.info("Initializing PgNotifyReporter...") - this.subscriber.events.on("error", (error: any) => { - console.error("Fatal database connection error:", error) - process.exit(1) - }) - - await this.subscriber.connect() - await this.subscriber.listenTo(this.queueName) - this.logger.info("PgNotifyReporter initialized") - } - - on(event: string, callback: (...args: any) => any): void { - this.subscriber.notifications.on(this.queueName, (payload) => { - this.logger.info(`Got postgres notification on ${this.queueName}`) - if (payload?.eventName === event) { - this.logger.info(`Postgres notification was type ${event}`) - return callback(payload) - } - }) - } -} diff --git a/packages/cloud-agent-manager/src/lib/Reporters/index.ts b/packages/cloud-agent-manager/src/lib/Reporters/index.ts deleted file mode 100644 index 24d008b517..0000000000 --- a/packages/cloud-agent-manager/src/lib/Reporters/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export interface Reporter { - on(event: string, callback: (data: unknown) => any): void -} diff --git a/packages/cloud-agent-manager/README.md b/packages/server/cloud-agent-manager/README.md similarity index 100% rename from packages/cloud-agent-manager/README.md rename to packages/server/cloud-agent-manager/README.md diff --git a/packages/server/cloud-agent-manager/project.json b/packages/server/cloud-agent-manager/project.json new file mode 100644 index 0000000000..0b9f9bed1f --- /dev/null +++ b/packages/server/cloud-agent-manager/project.json @@ -0,0 +1,8 @@ +{ + "name": "server-cloud-agent-manager", + "$schema": "../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "packages/server/cloud-agent-manager/src", + "projectType": "library", + "targets": {}, + "tags": [] +} diff --git a/packages/cloud-agent-manager/src/index.ts b/packages/server/cloud-agent-manager/src/index.ts similarity index 100% rename from packages/cloud-agent-manager/src/index.ts rename to packages/server/cloud-agent-manager/src/index.ts diff --git a/packages/server/cloud-agent-manager/src/lib/CloudAgentManager.ts b/packages/server/cloud-agent-manager/src/lib/CloudAgentManager.ts new file mode 100644 index 0000000000..a170cb07a6 --- /dev/null +++ b/packages/server/cloud-agent-manager/src/lib/CloudAgentManager.ts @@ -0,0 +1,154 @@ +import pino from 'pino' +import { diff } from 'radash' +import { + AGENT_DELETE, + AGENT_DELETE_JOB, + AGENT_UPDATE_JOB, + getLogger, +} from '@magickml/core' +import type { Reporter } from './Reporters' +import { type PubSub, type MessageQueue, app } from '@magickml/server-core' +import type { AgentListRecord } from '@magickml/cloud-agent-worker' +import { Agent } from 'packages/core/server/src/services/agents/agents.schema' + +interface CloudAgentManagerConstructor { + pubSub: PubSub + newQueue: MessageQueue + agentStateReporter: Reporter +} + +type AgentList = Record + +export class CloudAgentManager { + logger: pino.Logger = getLogger() + newQueue: MessageQueue + agentStateReporter: Reporter + pubSub: PubSub + workerToAgents: AgentList = {} + + constructor(args: CloudAgentManagerConstructor) { + this.newQueue = args.newQueue + this.newQueue.initialize('agent:new') + this.agentStateReporter = args.agentStateReporter + this.pubSub = app.get('pubsub') + + this.startup() + } + + async startup() { + this.logger.info('Cloud Agent Manager Startup') + + const enabledAgents = await app.service('agents').find({ + query: { + enabled: true, + }, + }) + + this.logger.info(`Found ${enabledAgents.data.length} enabled agents`) + const agentPromises: Promise[] = [] + for (const agent of enabledAgents.data) { + this.logger.debug(`Adding agent ${agent.id} to cloud agent worker`) + agentPromises.push( + this.newQueue.addJob( + 'agent:new', + { + agentId: agent.id, + }, + `agent-new-${agent.id}-${new Date().getTime()}}` + ) + ) + } + + await Promise.all(agentPromises) + } + + async run() { + this.agentStateReporter.on('agent:updated', async (data: unknown) => { + const agent = data as Agent + + this.logger.info(`Agent Updated: ${agent.id}`) + const agentUpdatedAt = agent.updatedAt + ? new Date(agent.updatedAt) + : new Date() + + if (agent.enabled) { + this.logger.info( + `Agent ${agent.id} enabled, adding to cloud agent worker` + ) + await this.newQueue.addJob( + 'agent:new', + { + agentId: agent.id, + }, + `agent-new-${agent.id}-${agentUpdatedAt.getTime()}` + ) + this.logger.debug(`Agent create job for ${agent.id} added`) + return + } + + this.pubSub.publish( + AGENT_UPDATE_JOB(agent.id), + JSON.stringify({ agentId: agent.id }) + ) + }) + + this.agentStateReporter.on(AGENT_DELETE, async (data: unknown) => { + const agent = data as Agent + this.pubSub.publish( + AGENT_DELETE_JOB(agent.id), + JSON.stringify({ agentId: agent.id }) + ) + }) + } + + // Eventually we'll need this heartbeat to keep track of running agents on workers + async heartbeat() { + this.pubSub.subscribe('cloud-agent-manager:pong', async list => { + const listData = JSON.parse(list) as AgentListRecord + + const lastAgentsOnWorker = this.workerToAgents[listData.id] || [] + const agentsOnWorker = listData.currentAgents + + const agentsDiff = diff(lastAgentsOnWorker, agentsOnWorker) + + const agentsRestarted: string[] = [] + + if (agentsDiff.length > 0) { + this.logger.info( + `Agents on worker ${listData.id} changed: ${agentsDiff}` + ) + const agents = await app.service('agents').find({ + query: { + id: { + $in: agentsDiff, + }, + }, + }) + + for (const agent of agents.data) { + if (agent.enabled) { + this.pubSub.publish( + 'agent:updated', + JSON.stringify({ + agentId: agent.id, + }) + ) + agentsRestarted.push(agent.id) + } + } + + this.workerToAgents[listData.id] = agentsOnWorker + } else { + this.workerToAgents[listData.id] = [ + ...agentsOnWorker, + ...agentsRestarted, + ] + } + }) + + setInterval(async () => { + this.logger.trace('Heartbeat') + this.pubSub.publish('cloud-agent-manager:ping', '') + }, 1000 * 60 * 5) + } +} diff --git a/packages/server/cloud-agent-manager/src/lib/Reporters/FeathersSyncReporter.ts b/packages/server/cloud-agent-manager/src/lib/Reporters/FeathersSyncReporter.ts new file mode 100644 index 0000000000..34bda9e6fd --- /dev/null +++ b/packages/server/cloud-agent-manager/src/lib/Reporters/FeathersSyncReporter.ts @@ -0,0 +1,28 @@ +import { AGENT_DELETE, getLogger } from '@magickml/core' +import { app } from '@magickml/server-core' +import { Reporter } from '.' +import { EventEmitter } from 'events' + +export class FeathersSyncReporter implements Reporter { + emitter: EventEmitter = new EventEmitter() + logger = getLogger() + + constructor() { + this.initReporter() + } + + async initReporter(): Promise { + this.logger.info('Initializing FeathersSyncReporter...') + app.service('agents').on('patched', (agent: any) => { + this.emitter.emit('agent:updated', agent) + }) + app + .service('agents') + .on('deleted', (agent: any) => this.emitter.emit(AGENT_DELETE, agent)) + this.logger.info('FeathersSyncReporter initialized') + } + + on(event: string, callback: (...args: any) => any): void { + this.emitter.on(event, callback) + } +} diff --git a/packages/server/cloud-agent-manager/src/lib/Reporters/PgNotifyReporter.ts b/packages/server/cloud-agent-manager/src/lib/Reporters/PgNotifyReporter.ts new file mode 100644 index 0000000000..26c7520632 --- /dev/null +++ b/packages/server/cloud-agent-manager/src/lib/Reporters/PgNotifyReporter.ts @@ -0,0 +1,39 @@ +import { Reporter } from '.' +import createSubscriber, { Subscriber } from 'pg-listen' +import { getLogger } from '@magickml/core' + +export class PgNotifyReporter implements Reporter { + logger = getLogger() + subscriber: Subscriber + queueName: string + + constructor(queueName: string, dbUrl: string) { + this.subscriber = createSubscriber({ + connectionString: dbUrl, + }) + this.queueName = queueName + this.initReporter() + } + + async initReporter(): Promise { + this.logger.info('Initializing PgNotifyReporter...') + this.subscriber.events.on('error', (error: any) => { + console.error('Fatal database connection error:', error) + process.exit(1) + }) + + await this.subscriber.connect() + await this.subscriber.listenTo(this.queueName) + this.logger.info('PgNotifyReporter initialized') + } + + on(event: string, callback: (...args: any) => any): void { + this.subscriber.notifications.on(this.queueName, payload => { + this.logger.info(`Got postgres notification on ${this.queueName}`) + if (payload?.eventName === event) { + this.logger.info(`Postgres notification was type ${event}`) + return callback(payload) + } + }) + } +} diff --git a/packages/server/cloud-agent-manager/src/lib/Reporters/index.ts b/packages/server/cloud-agent-manager/src/lib/Reporters/index.ts new file mode 100644 index 0000000000..1be223d6bd --- /dev/null +++ b/packages/server/cloud-agent-manager/src/lib/Reporters/index.ts @@ -0,0 +1,3 @@ +export interface Reporter { + on(event: string, callback: (data: unknown) => any): void +} diff --git a/packages/cloud-agent-manager/tsconfig.json b/packages/server/cloud-agent-manager/tsconfig.json similarity index 89% rename from packages/cloud-agent-manager/tsconfig.json rename to packages/server/cloud-agent-manager/tsconfig.json index db7b566661..f2400abede 100644 --- a/packages/cloud-agent-manager/tsconfig.json +++ b/packages/server/cloud-agent-manager/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig.base.json", + "extends": "../../../tsconfig.base.json", "compilerOptions": { "module": "commonjs", "forceConsistentCasingInFileNames": true, diff --git a/packages/cloud-agent-manager/tsconfig.lib.json b/packages/server/cloud-agent-manager/tsconfig.lib.json similarity index 87% rename from packages/cloud-agent-manager/tsconfig.lib.json rename to packages/server/cloud-agent-manager/tsconfig.lib.json index 302ba5cfab..0c6cfce84b 100644 --- a/packages/cloud-agent-manager/tsconfig.lib.json +++ b/packages/server/cloud-agent-manager/tsconfig.lib.json @@ -1,7 +1,7 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", + "outDir": "../../../dist/out-tsc", "declaration": true, "module": "esnext", "target": "es2017", diff --git a/tsconfig.base.json b/tsconfig.base.json index 4f28e56df2..4d4661b629 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -30,9 +30,6 @@ "@magickml/chatbox": ["packages/magickml-chatbox/src/index.ts"], "@magickml/client": ["apps/client/src/index.ts"], "@magickml/client-core": ["packages/core/client/src/index.ts"], - "@magickml/cloud-agent-manager": [ - "packages/cloud-agent-manager/src/index.ts" - ], "@magickml/cloud-agent-worker": [ "packages/cloud-agent-worker/src/index.ts" ], @@ -204,7 +201,10 @@ "client/editor": ["packages/client/editor/src/index.ts"], "client/layouts": ["packages/client/layouts/src/index.ts"], "client/state": ["packages/client/state/src/index.ts"], - "rete": ["packages/rete/src/index.ts"] + "rete": ["packages/rete/src/index.ts"], + "server/cloud-agent-manager": [ + "packages/server/cloud-agent-manager/src/index.ts" + ] } }, "exclude": ["node_modules", "tmp"] From ad5afa2c84b25822ed19f70d86dc8ca18a8ba539 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 27 Sep 2023 11:39:15 -0700 Subject: [PATCH 117/349] Move cloud agent worker to server folder --- apps/cloud-agent-worker/src/main.ts | 2 +- packages/cloud-agent-worker/project.json | 8 -------- .../cloud-agent-manager/src/lib/CloudAgentManager.ts | 2 +- packages/{ => server}/cloud-agent-worker/README.md | 0 packages/server/cloud-agent-worker/project.json | 8 ++++++++ packages/{ => server}/cloud-agent-worker/src/index.ts | 0 .../cloud-agent-worker/src/lib/cloud-agent-worker.ts | 0 packages/{ => server}/cloud-agent-worker/tsconfig.json | 2 +- .../{ => server}/cloud-agent-worker/tsconfig.lib.json | 2 +- tsconfig.base.json | 6 +++--- 10 files changed, 15 insertions(+), 15 deletions(-) delete mode 100644 packages/cloud-agent-worker/project.json rename packages/{ => server}/cloud-agent-worker/README.md (100%) create mode 100644 packages/server/cloud-agent-worker/project.json rename packages/{ => server}/cloud-agent-worker/src/index.ts (100%) rename packages/{ => server}/cloud-agent-worker/src/lib/cloud-agent-worker.ts (100%) rename packages/{ => server}/cloud-agent-worker/tsconfig.json (89%) rename packages/{ => server}/cloud-agent-worker/tsconfig.lib.json (84%) diff --git a/apps/cloud-agent-worker/src/main.ts b/apps/cloud-agent-worker/src/main.ts index e2243cc1f1..df09cc7509 100644 --- a/apps/cloud-agent-worker/src/main.ts +++ b/apps/cloud-agent-worker/src/main.ts @@ -1,4 +1,4 @@ -import { CloudAgentWorker } from '@magickml/cloud-agent-worker' +import { CloudAgentWorker } from 'server/cloud-agent-worker' import { initLogger, getLogger } from '@magickml/core' import { initApp } from '@magickml/server-core' import pluginExports from './plugins' diff --git a/packages/cloud-agent-worker/project.json b/packages/cloud-agent-worker/project.json deleted file mode 100644 index e4a70aeeed..0000000000 --- a/packages/cloud-agent-worker/project.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "@magickml/cloud-agent-worker", - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "packages/cloud-agent-worker/src", - "projectType": "library", - "targets": {}, - "tags": [] -} diff --git a/packages/server/cloud-agent-manager/src/lib/CloudAgentManager.ts b/packages/server/cloud-agent-manager/src/lib/CloudAgentManager.ts index a170cb07a6..14a262e091 100644 --- a/packages/server/cloud-agent-manager/src/lib/CloudAgentManager.ts +++ b/packages/server/cloud-agent-manager/src/lib/CloudAgentManager.ts @@ -8,7 +8,7 @@ import { } from '@magickml/core' import type { Reporter } from './Reporters' import { type PubSub, type MessageQueue, app } from '@magickml/server-core' -import type { AgentListRecord } from '@magickml/cloud-agent-worker' +import type { AgentListRecord } from 'server/cloud-agent-worker' import { Agent } from 'packages/core/server/src/services/agents/agents.schema' interface CloudAgentManagerConstructor { diff --git a/packages/cloud-agent-worker/README.md b/packages/server/cloud-agent-worker/README.md similarity index 100% rename from packages/cloud-agent-worker/README.md rename to packages/server/cloud-agent-worker/README.md diff --git a/packages/server/cloud-agent-worker/project.json b/packages/server/cloud-agent-worker/project.json new file mode 100644 index 0000000000..b128a49e59 --- /dev/null +++ b/packages/server/cloud-agent-worker/project.json @@ -0,0 +1,8 @@ +{ + "name": "server-cloud-agent-worker", + "$schema": "../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "packages/server/cloud-agent-worker/src", + "projectType": "library", + "targets": {}, + "tags": [] +} diff --git a/packages/cloud-agent-worker/src/index.ts b/packages/server/cloud-agent-worker/src/index.ts similarity index 100% rename from packages/cloud-agent-worker/src/index.ts rename to packages/server/cloud-agent-worker/src/index.ts diff --git a/packages/cloud-agent-worker/src/lib/cloud-agent-worker.ts b/packages/server/cloud-agent-worker/src/lib/cloud-agent-worker.ts similarity index 100% rename from packages/cloud-agent-worker/src/lib/cloud-agent-worker.ts rename to packages/server/cloud-agent-worker/src/lib/cloud-agent-worker.ts diff --git a/packages/cloud-agent-worker/tsconfig.json b/packages/server/cloud-agent-worker/tsconfig.json similarity index 89% rename from packages/cloud-agent-worker/tsconfig.json rename to packages/server/cloud-agent-worker/tsconfig.json index db7b566661..f2400abede 100644 --- a/packages/cloud-agent-worker/tsconfig.json +++ b/packages/server/cloud-agent-worker/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig.base.json", + "extends": "../../../tsconfig.base.json", "compilerOptions": { "module": "commonjs", "forceConsistentCasingInFileNames": true, diff --git a/packages/cloud-agent-worker/tsconfig.lib.json b/packages/server/cloud-agent-worker/tsconfig.lib.json similarity index 84% rename from packages/cloud-agent-worker/tsconfig.lib.json rename to packages/server/cloud-agent-worker/tsconfig.lib.json index 33eca2c2cd..4befa7f099 100644 --- a/packages/cloud-agent-worker/tsconfig.lib.json +++ b/packages/server/cloud-agent-worker/tsconfig.lib.json @@ -1,7 +1,7 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", + "outDir": "../../../dist/out-tsc", "declaration": true, "types": ["node"] }, diff --git a/tsconfig.base.json b/tsconfig.base.json index 4d4661b629..db0ae1af1a 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -30,9 +30,6 @@ "@magickml/chatbox": ["packages/magickml-chatbox/src/index.ts"], "@magickml/client": ["apps/client/src/index.ts"], "@magickml/client-core": ["packages/core/client/src/index.ts"], - "@magickml/cloud-agent-worker": [ - "packages/cloud-agent-worker/src/index.ts" - ], "@magickml/config": ["packages/config/src/index.ts"], "@magickml/core": ["packages/core/shared/src/index.ts"], "@magickml/docs": ["apps/docs/src/index.ts"], @@ -204,6 +201,9 @@ "rete": ["packages/rete/src/index.ts"], "server/cloud-agent-manager": [ "packages/server/cloud-agent-manager/src/index.ts" + ], + "server/cloud-agent-worker": [ + "packages/server/cloud-agent-worker/src/index.ts" ] } }, From 1435f03c92a59784509948d6dc901e233203cd2a Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 27 Sep 2023 11:39:53 -0700 Subject: [PATCH 118/349] Move agents into server folder --- apps/agent/project.json | 2 +- apps/agent/src/index.ts | 2 +- apps/cloud-agent-manager/src/main.ts | 2 +- apps/cloud-agent-worker/src/main.ts | 2 +- apps/server/src/index.ts | 2 +- packages/agents/src/index.ts | 14 -------------- packages/core/server/src/app.ts | 1 + .../src/communication/MessageQueues/BullMQ.ts | 2 +- .../communication/MessageQueues/MessageQueue.ts | 10 +++++----- .../server/src/services/agents/agents.class.ts | 2 +- packages/core/shared/src/plugin.ts | 2 +- packages/plugins/discord/shared/project.json | 2 +- packages/plugins/loop/server/src/index.ts | 2 +- .../src/services/agentHttp/agentHttp.class.ts | 2 +- packages/plugins/twitter/server/project.json | 2 +- packages/{ => server}/agents/.babelrc | 0 packages/{ => server}/agents/.eslintrc.json | 2 +- packages/{ => server}/agents/README.md | 0 packages/{ => server}/agents/jest.config.ts | 4 ++-- packages/{ => server}/agents/project.json | 10 +++++----- packages/server/agents/src/index.ts | 14 ++++++++++++++ packages/{ => server}/agents/src/lib/Agent.ts | 0 .../{ => server}/agents/src/lib/AgentCommander.ts | 2 +- .../{ => server}/agents/src/lib/AgentManager.ts | 0 packages/{ => server}/agents/src/lib/CommandHub.ts | 0 packages/{ => server}/agents/tsconfig.json | 2 +- packages/{ => server}/agents/tsconfig.lib.json | 2 +- packages/{ => server}/agents/tsconfig.spec.json | 2 +- .../src/lib/cloud-agent-worker.ts | 2 +- tsconfig.base.json | 2 +- 30 files changed, 46 insertions(+), 45 deletions(-) delete mode 100644 packages/agents/src/index.ts rename packages/{ => server}/agents/.babelrc (100%) rename packages/{ => server}/agents/.eslintrc.json (86%) rename packages/{ => server}/agents/README.md (100%) rename packages/{ => server}/agents/jest.config.ts (70%) rename packages/{ => server}/agents/project.json (65%) create mode 100644 packages/server/agents/src/index.ts rename packages/{ => server}/agents/src/lib/Agent.ts (100%) rename packages/{ => server}/agents/src/lib/AgentCommander.ts (99%) rename packages/{ => server}/agents/src/lib/AgentManager.ts (100%) rename packages/{ => server}/agents/src/lib/CommandHub.ts (100%) rename packages/{ => server}/agents/tsconfig.json (78%) rename packages/{ => server}/agents/tsconfig.lib.json (85%) rename packages/{ => server}/agents/tsconfig.spec.json (90%) diff --git a/apps/agent/project.json b/apps/agent/project.json index 5fc96d9896..d54d37f91b 100644 --- a/apps/agent/project.json +++ b/apps/agent/project.json @@ -6,7 +6,7 @@ "implicitDependencies": [ "@magickml/server-core", "@magickml/core", - "@magickml/agents", + "server-agents", "@magickml/plugin-*" ], "targets": { diff --git a/apps/agent/src/index.ts b/apps/agent/src/index.ts index da3777dd4a..a05e0d0e16 100644 --- a/apps/agent/src/index.ts +++ b/apps/agent/src/index.ts @@ -5,7 +5,7 @@ * @packageDocumentation */ -import { AgentManager } from '@magickml/agents' +import { AgentManager } from 'server/agents' import { app, initApp } from '@magickml/server-core' import { initLogger, getLogger } from '@magickml/core' import 'regenerator-runtime/runtime' diff --git a/apps/cloud-agent-manager/src/main.ts b/apps/cloud-agent-manager/src/main.ts index cb117a7f1d..9a28f14aa9 100644 --- a/apps/cloud-agent-manager/src/main.ts +++ b/apps/cloud-agent-manager/src/main.ts @@ -5,7 +5,7 @@ import { import { initLogger, getLogger } from '@magickml/core' import { app, BullQueue, initApp } from '@magickml/server-core' import { DONT_CRASH_ON_ERROR, PRODUCTION } from '@magickml/config' -import { initAgentCommander } from '@magickml/agents' +import { initAgentCommander } from 'server/agents' import { getPinoTransport } from '@hyperdx/node-opentelemetry' if (PRODUCTION) { diff --git a/apps/cloud-agent-worker/src/main.ts b/apps/cloud-agent-worker/src/main.ts index df09cc7509..07600ec6d9 100644 --- a/apps/cloud-agent-worker/src/main.ts +++ b/apps/cloud-agent-worker/src/main.ts @@ -2,7 +2,7 @@ import { CloudAgentWorker } from 'server/cloud-agent-worker' import { initLogger, getLogger } from '@magickml/core' import { initApp } from '@magickml/server-core' import pluginExports from './plugins' -import { initAgentCommander } from '@magickml/agents' +import { initAgentCommander } from 'server/agents' import { DONT_CRASH_ON_ERROR, PRODUCTION } from '@magickml/config' import { getPinoTransport } from '@hyperdx/node-opentelemetry' diff --git a/apps/server/src/index.ts b/apps/server/src/index.ts index 132c607863..09fc0b7757 100644 --- a/apps/server/src/index.ts +++ b/apps/server/src/index.ts @@ -23,7 +23,7 @@ import koaBody from 'koa-body' import compose from 'koa-compose' import 'regenerator-runtime/runtime' import plugins from './plugins' -import { initAgentCommander } from '@magickml/agents' +import { initAgentCommander } from 'server/agents' import { getPinoTransport } from '@hyperdx/node-opentelemetry' import { PRODUCTION } from '@magickml/config' diff --git a/packages/agents/src/index.ts b/packages/agents/src/index.ts deleted file mode 100644 index c4d2256246..0000000000 --- a/packages/agents/src/index.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { app } from '@magickml/server-core'; -import { AgentCommander } from './lib/AgentCommander'; - -export * from './lib/Agent' -export * from './lib/AgentManager' -export * from './lib/AgentCommander' - -export const initAgentCommander = async () => { - const agentCommander = new AgentCommander({ - pubSub: app.get('pubsub'), - }) - - app.set('agentCommander', agentCommander) -} diff --git a/packages/core/server/src/app.ts b/packages/core/server/src/app.ts index b278f6f8a9..c1ae40fa1f 100644 --- a/packages/core/server/src/app.ts +++ b/packages/core/server/src/app.ts @@ -31,6 +31,7 @@ import { createPosthogClient } from 'server/event-tracker' import { dbClient } from './dbClient' import type { Application } from './declarations' +import type { AgentCommander } from 'server/agents' import { logError } from './hooks' import channels from './sockets/channels' import { authentication } from './auth/authentication' diff --git a/packages/core/server/src/communication/MessageQueues/BullMQ.ts b/packages/core/server/src/communication/MessageQueues/BullMQ.ts index 6db57c5602..f3727091c6 100644 --- a/packages/core/server/src/communication/MessageQueues/BullMQ.ts +++ b/packages/core/server/src/communication/MessageQueues/BullMQ.ts @@ -4,7 +4,7 @@ import pino from 'pino' import { getLogger } from '@magickml/core' import { MessageQueue } from '../MessageQueues' -import { AgentJob } from '@magickml/agents' +import { AgentJob } from 'server/agents' export class BullQueue implements MessageQueue { logger: pino.Logger = getLogger() diff --git a/packages/core/server/src/communication/MessageQueues/MessageQueue.ts b/packages/core/server/src/communication/MessageQueues/MessageQueue.ts index f4240fbfe7..a23c4d2ffd 100644 --- a/packages/core/server/src/communication/MessageQueues/MessageQueue.ts +++ b/packages/core/server/src/communication/MessageQueues/MessageQueue.ts @@ -1,15 +1,15 @@ -import { AgentJob } from '@magickml/agents' +import { AgentJob } from 'server/agents' import EventEmitter from 'events' export interface MessageQueue { - addJob(jobType: string, job: AgentJob, jobId?: string): Promise + addJob(jobType: string, job: AgentJob, jobId?: string): Promise - initialize(queueName: string): void + initialize(queueName: string): void } export interface MessageWorker extends EventEmitter {} export interface Job { - id?: string - data: T + id?: string + data: T } diff --git a/packages/core/server/src/services/agents/agents.class.ts b/packages/core/server/src/services/agents/agents.class.ts index b303067566..45da75d250 100644 --- a/packages/core/server/src/services/agents/agents.class.ts +++ b/packages/core/server/src/services/agents/agents.class.ts @@ -7,7 +7,7 @@ import { app } from '@magickml/server-core' import md5 from 'md5' import type { Application } from '../../declarations' import type { Agent, AgentData, AgentPatch, AgentQuery } from './agents.schema' -import { AgentCommandData, RunRootSpellArgs } from '@magickml/agents' +import { AgentCommandData, RunRootSpellArgs } from 'server/agents' // Define AgentParams type based on KnexAdapterParams with AgentQuery export type AgentParams = KnexAdapterParams diff --git a/packages/core/shared/src/plugin.ts b/packages/core/shared/src/plugin.ts index dd697a212f..95b1d64428 100644 --- a/packages/core/shared/src/plugin.ts +++ b/packages/core/shared/src/plugin.ts @@ -1,7 +1,7 @@ import { FC, LazyExoticComponent } from 'react' import { MagickComponentArray } from './engine' import { CompletionProvider, Route, SpellInterface } from './types' -import { Agent } from '@magickml/agents' +import { Agent } from 'server/agents' export type PluginSecret = { name: string diff --git a/packages/plugins/discord/shared/project.json b/packages/plugins/discord/shared/project.json index 00a057761d..3963f184e0 100644 --- a/packages/plugins/discord/shared/project.json +++ b/packages/plugins/discord/shared/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/discord/shared/src", "projectType": "library", - "implicitDependencies": ["@magickml/core", "@magickml/agents"], + "implicitDependencies": ["@magickml/core", "server-agents"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/loop/server/src/index.ts b/packages/plugins/loop/server/src/index.ts index c5881e3472..fe997202fc 100644 --- a/packages/plugins/loop/server/src/index.ts +++ b/packages/plugins/loop/server/src/index.ts @@ -7,7 +7,7 @@ import { } from '@magickml/core' import { app } from '@magickml/server-core' import { LoopHandler } from './loopHandler' -import { Agent } from '@magickml/agents' +import { Agent } from 'server/agents' import pino from 'pino' type StartLoopArgs = { agent: any diff --git a/packages/plugins/rest/server/src/services/agentHttp/agentHttp.class.ts b/packages/plugins/rest/server/src/services/agentHttp/agentHttp.class.ts index 9bd683d719..edc50aa7c4 100644 --- a/packages/plugins/rest/server/src/services/agentHttp/agentHttp.class.ts +++ b/packages/plugins/rest/server/src/services/agentHttp/agentHttp.class.ts @@ -4,7 +4,7 @@ * https://dove.feathersjs.com/guides/cli/service.class.html#custom-services */ import { Application, app } from '@magickml/server-core' -import type { Agent } from '@magickml/agents' +import type { Agent } from 'server/agents' import type { Params, ServiceInterface } from '@feathersjs/feathers' import { GeneralError } from '@feathersjs/errors' import type { diff --git a/packages/plugins/twitter/server/project.json b/packages/plugins/twitter/server/project.json index f06774e2a3..d985faf2bb 100644 --- a/packages/plugins/twitter/server/project.json +++ b/packages/plugins/twitter/server/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "plugin-twitter/server/src", "projectType": "library", - "implicitDependencies": ["@magickml/core", "@magickml/agents"], + "implicitDependencies": ["@magickml/core", "server-agents"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/agents/.babelrc b/packages/server/agents/.babelrc similarity index 100% rename from packages/agents/.babelrc rename to packages/server/agents/.babelrc diff --git a/packages/agents/.eslintrc.json b/packages/server/agents/.eslintrc.json similarity index 86% rename from packages/agents/.eslintrc.json rename to packages/server/agents/.eslintrc.json index 9d9c0db55b..3456be9b90 100644 --- a/packages/agents/.eslintrc.json +++ b/packages/server/agents/.eslintrc.json @@ -1,5 +1,5 @@ { - "extends": ["../../.eslintrc.json"], + "extends": ["../../../.eslintrc.json"], "ignorePatterns": ["!**/*"], "overrides": [ { diff --git a/packages/agents/README.md b/packages/server/agents/README.md similarity index 100% rename from packages/agents/README.md rename to packages/server/agents/README.md diff --git a/packages/agents/jest.config.ts b/packages/server/agents/jest.config.ts similarity index 70% rename from packages/agents/jest.config.ts rename to packages/server/agents/jest.config.ts index b5b12ed377..79a1e786be 100644 --- a/packages/agents/jest.config.ts +++ b/packages/server/agents/jest.config.ts @@ -1,11 +1,11 @@ /* eslint-disable */ export default { displayName: 'agents', - preset: '../../jest.preset.js', + preset: '../../../jest.preset.js', testEnvironment: 'node', transform: { '^.+\\.[tj]sx?$': ['ts-jest', { tsconfig: '/tsconfig.spec.json' }], }, moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], - coverageDirectory: '../../coverage/packages/agents', + coverageDirectory: '../../../coverage/packages/server/agents', } diff --git a/packages/agents/project.json b/packages/server/agents/project.json similarity index 65% rename from packages/agents/project.json rename to packages/server/agents/project.json index b8d9207966..bfc784c89f 100644 --- a/packages/agents/project.json +++ b/packages/server/agents/project.json @@ -1,22 +1,22 @@ { - "name": "@magickml/agents", - "$schema": "../../node_modules/nx/schemas/project-schema.json", + "name": "server-agents", + "$schema": "../../../node_modules/nx/schemas/project-schema.json", "implicitDependencies": [], - "sourceRoot": "packages/agents/src", + "sourceRoot": "packages/server/agents/src", "projectType": "library", "targets": { "lint": { "executor": "@nx/linter:eslint", "outputs": ["{options.outputFile}"], "options": { - "lintFilePatterns": ["packages/agents/**/*.ts"] + "lintFilePatterns": ["packages/server/agents/**/*.ts"] } }, "test": { "executor": "@nx/jest:jest", "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], "options": { - "jestConfig": "packages/agents/jest.config.ts", + "jestConfig": "packages/server/agents/jest.config.ts", "passWithNoTests": true }, "configurations": { diff --git a/packages/server/agents/src/index.ts b/packages/server/agents/src/index.ts new file mode 100644 index 0000000000..5555f5a498 --- /dev/null +++ b/packages/server/agents/src/index.ts @@ -0,0 +1,14 @@ +import { app } from '@magickml/server-core' +import { AgentCommander } from './lib/AgentCommander' + +export * from './lib/Agent' +export * from './lib/AgentManager' +export * from './lib/AgentCommander' + +export const initAgentCommander = async () => { + const agentCommander = new AgentCommander({ + pubSub: app.get('pubsub'), + }) + + app.set('agentCommander', agentCommander) +} diff --git a/packages/agents/src/lib/Agent.ts b/packages/server/agents/src/lib/Agent.ts similarity index 100% rename from packages/agents/src/lib/Agent.ts rename to packages/server/agents/src/lib/Agent.ts diff --git a/packages/agents/src/lib/AgentCommander.ts b/packages/server/agents/src/lib/AgentCommander.ts similarity index 99% rename from packages/agents/src/lib/AgentCommander.ts rename to packages/server/agents/src/lib/AgentCommander.ts index cf7721b161..419a659b03 100644 --- a/packages/agents/src/lib/AgentCommander.ts +++ b/packages/server/agents/src/lib/AgentCommander.ts @@ -1,5 +1,5 @@ import EventEmitter from 'events' -import type { Agent } from '@magickml/agents' +import type { Agent } from 'server/agents' import { type PubSub, type Job } from '@magickml/server-core' import { AGENT_RUN_JOB, diff --git a/packages/agents/src/lib/AgentManager.ts b/packages/server/agents/src/lib/AgentManager.ts similarity index 100% rename from packages/agents/src/lib/AgentManager.ts rename to packages/server/agents/src/lib/AgentManager.ts diff --git a/packages/agents/src/lib/CommandHub.ts b/packages/server/agents/src/lib/CommandHub.ts similarity index 100% rename from packages/agents/src/lib/CommandHub.ts rename to packages/server/agents/src/lib/CommandHub.ts diff --git a/packages/agents/tsconfig.json b/packages/server/agents/tsconfig.json similarity index 78% rename from packages/agents/tsconfig.json rename to packages/server/agents/tsconfig.json index 62ebbd9464..667a3463d1 100644 --- a/packages/agents/tsconfig.json +++ b/packages/server/agents/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig.base.json", + "extends": "../../../tsconfig.base.json", "files": [], "include": [], "references": [ diff --git a/packages/agents/tsconfig.lib.json b/packages/server/agents/tsconfig.lib.json similarity index 85% rename from packages/agents/tsconfig.lib.json rename to packages/server/agents/tsconfig.lib.json index 3f06e80289..e583571eac 100644 --- a/packages/agents/tsconfig.lib.json +++ b/packages/server/agents/tsconfig.lib.json @@ -2,7 +2,7 @@ "extends": "./tsconfig.json", "compilerOptions": { "module": "commonjs", - "outDir": "../../dist/out-tsc", + "outDir": "../../../dist/out-tsc", "declaration": true, "types": ["node"] }, diff --git a/packages/agents/tsconfig.spec.json b/packages/server/agents/tsconfig.spec.json similarity index 90% rename from packages/agents/tsconfig.spec.json rename to packages/server/agents/tsconfig.spec.json index 26ef046ac5..25b7af8f6d 100644 --- a/packages/agents/tsconfig.spec.json +++ b/packages/server/agents/tsconfig.spec.json @@ -1,7 +1,7 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", + "outDir": "../../../dist/out-tsc", "module": "commonjs", "types": ["jest", "node"] }, diff --git a/packages/server/cloud-agent-worker/src/lib/cloud-agent-worker.ts b/packages/server/cloud-agent-worker/src/lib/cloud-agent-worker.ts index 58c386a20e..731c032c10 100644 --- a/packages/server/cloud-agent-worker/src/lib/cloud-agent-worker.ts +++ b/packages/server/cloud-agent-worker/src/lib/cloud-agent-worker.ts @@ -7,7 +7,7 @@ import { app, BullQueue, } from '@magickml/server-core' -import { Agent, AgentManager, type AgentRunJob } from '@magickml/agents' +import { Agent, AgentManager, type AgentRunJob } from 'server/agents' import { v4 as uuidv4 } from 'uuid' import { AGENT_DELETE, diff --git a/tsconfig.base.json b/tsconfig.base.json index db0ae1af1a..dadb0543a7 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -26,7 +26,6 @@ ], "paths": { "@magickml/agent": ["apps/agent/src/index.ts"], - "@magickml/agents": ["packages/agents/src/index.ts"], "@magickml/chatbox": ["packages/magickml-chatbox/src/index.ts"], "@magickml/client": ["apps/client/src/index.ts"], "@magickml/client-core": ["packages/core/client/src/index.ts"], @@ -199,6 +198,7 @@ "client/layouts": ["packages/client/layouts/src/index.ts"], "client/state": ["packages/client/state/src/index.ts"], "rete": ["packages/rete/src/index.ts"], + "server/agents": ["packages/server/agents/src/index.ts"], "server/cloud-agent-manager": [ "packages/server/cloud-agent-manager/src/index.ts" ], From ac6c4452c5a2f19260cc515a5f85b1224b526207 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 27 Sep 2023 11:40:46 -0700 Subject: [PATCH 119/349] move magick chatbox into client folder --- packages/client/editor/src/main.tsx | 2 +- .../{ => client}/magickml-chatbox/.babelrc | 0 .../magickml-chatbox/.eslintrc.json | 2 +- packages/client/magickml-chatbox/README.md | 7 +++++ .../magickml-chatbox/jest.config.ts | 6 ++-- packages/client/magickml-chatbox/package.json | 4 +++ .../magickml-chatbox/project.json | 22 +++++++------ .../magickml-chatbox/src/index.ts | 0 .../src/lib/magickml-chatbox.module.css | 0 .../src/lib/magickml-chatbox.spec.tsx | 0 .../src/lib/magickml-chatbox.tsx | 31 +++++++++---------- .../magickml-chatbox/tsconfig.json | 2 +- .../magickml-chatbox/tsconfig.lib.json | 6 ++-- .../magickml-chatbox/tsconfig.spec.json | 2 +- packages/magickml-chatbox/README.md | 7 ----- packages/magickml-chatbox/package.json | 4 --- tsconfig.base.json | 4 ++- 17 files changed, 51 insertions(+), 48 deletions(-) rename packages/{ => client}/magickml-chatbox/.babelrc (100%) rename packages/{ => client}/magickml-chatbox/.eslintrc.json (81%) create mode 100644 packages/client/magickml-chatbox/README.md rename packages/{ => client}/magickml-chatbox/jest.config.ts (62%) create mode 100644 packages/client/magickml-chatbox/package.json rename packages/{ => client}/magickml-chatbox/project.json (57%) rename packages/{ => client}/magickml-chatbox/src/index.ts (100%) rename packages/{ => client}/magickml-chatbox/src/lib/magickml-chatbox.module.css (100%) rename packages/{ => client}/magickml-chatbox/src/lib/magickml-chatbox.spec.tsx (100%) rename packages/{ => client}/magickml-chatbox/src/lib/magickml-chatbox.tsx (50%) rename packages/{ => client}/magickml-chatbox/tsconfig.json (88%) rename packages/{ => client}/magickml-chatbox/tsconfig.lib.json (72%) rename packages/{ => client}/magickml-chatbox/tsconfig.spec.json (90%) delete mode 100644 packages/magickml-chatbox/README.md delete mode 100644 packages/magickml-chatbox/package.json diff --git a/packages/client/editor/src/main.tsx b/packages/client/editor/src/main.tsx index d362190a1b..f345880570 100644 --- a/packages/client/editor/src/main.tsx +++ b/packages/client/editor/src/main.tsx @@ -19,7 +19,7 @@ import AppProviders from './contexts/AppProviders' import { LocalizationProvider } from '@mui/x-date-pickers' import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs' import { AppConfig } from '@magickml/client-core' -import { MagickmlChatbox } from '@magickml/chatbox' +import { MagickmlChatbox } from 'client/magickml-chatbox' import { createStore } from 'client/state' /** diff --git a/packages/magickml-chatbox/.babelrc b/packages/client/magickml-chatbox/.babelrc similarity index 100% rename from packages/magickml-chatbox/.babelrc rename to packages/client/magickml-chatbox/.babelrc diff --git a/packages/magickml-chatbox/.eslintrc.json b/packages/client/magickml-chatbox/.eslintrc.json similarity index 81% rename from packages/magickml-chatbox/.eslintrc.json rename to packages/client/magickml-chatbox/.eslintrc.json index a39ac5d057..75b85077de 100644 --- a/packages/magickml-chatbox/.eslintrc.json +++ b/packages/client/magickml-chatbox/.eslintrc.json @@ -1,5 +1,5 @@ { - "extends": ["plugin:@nx/react", "../../.eslintrc.json"], + "extends": ["plugin:@nx/react", "../../../.eslintrc.json"], "ignorePatterns": ["!**/*"], "overrides": [ { diff --git a/packages/client/magickml-chatbox/README.md b/packages/client/magickml-chatbox/README.md new file mode 100644 index 0000000000..6510acded9 --- /dev/null +++ b/packages/client/magickml-chatbox/README.md @@ -0,0 +1,7 @@ +# client-magickml-chatbox + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test client-magickml-chatbox` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/packages/magickml-chatbox/jest.config.ts b/packages/client/magickml-chatbox/jest.config.ts similarity index 62% rename from packages/magickml-chatbox/jest.config.ts rename to packages/client/magickml-chatbox/jest.config.ts index cb4396d35f..1faf7bd2c5 100644 --- a/packages/magickml-chatbox/jest.config.ts +++ b/packages/client/magickml-chatbox/jest.config.ts @@ -1,11 +1,11 @@ /* eslint-disable */ export default { - displayName: 'magickml-chatbox', - preset: '../../jest.preset.js', + displayName: 'client-magickml-chatbox', + preset: '../../../jest.preset.js', transform: { '^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest', '^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nx/react/babel'] }], }, moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], - coverageDirectory: '../../coverage/packages/magickml-chatbox', + coverageDirectory: '../../../coverage/packages/client/magickml-chatbox', } diff --git a/packages/client/magickml-chatbox/package.json b/packages/client/magickml-chatbox/package.json new file mode 100644 index 0000000000..ef69b8cd96 --- /dev/null +++ b/packages/client/magickml-chatbox/package.json @@ -0,0 +1,4 @@ +{ + "name": "client/magickml-chatbox", + "version": "0.0.1" +} diff --git a/packages/magickml-chatbox/project.json b/packages/client/magickml-chatbox/project.json similarity index 57% rename from packages/magickml-chatbox/project.json rename to packages/client/magickml-chatbox/project.json index a225d40405..830e48b465 100644 --- a/packages/magickml-chatbox/project.json +++ b/packages/client/magickml-chatbox/project.json @@ -1,7 +1,7 @@ { - "name": "magickml-chatbox", - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "packages/magickml-chatbox/src", + "name": "client-magickml-chatbox", + "$schema": "../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "packages/client/magickml-chatbox/src", "projectType": "library", "tags": [], "targets": { @@ -9,23 +9,25 @@ "executor": "@nx/linter:eslint", "outputs": ["{options.outputFile}"], "options": { - "lintFilePatterns": ["packages/magickml-chatbox/**/*.{ts,tsx,js,jsx}"] + "lintFilePatterns": [ + "packages/client/magickml-chatbox/**/*.{ts,tsx,js,jsx}" + ] } }, "build": { "executor": "@nx/rollup:rollup", "outputs": ["{options.outputPath}"], "options": { - "outputPath": "dist/packages/magickml-chatbox", - "tsConfig": "packages/magickml-chatbox/tsconfig.lib.json", - "project": "packages/magickml-chatbox/package.json", - "entryFile": "packages/magickml-chatbox/src/index.ts", + "outputPath": "dist/packages/client/magickml-chatbox", + "tsConfig": "packages/client/magickml-chatbox/tsconfig.lib.json", + "project": "packages/client/magickml-chatbox/package.json", + "entryFile": "packages/client/magickml-chatbox/src/index.ts", "external": ["react", "react-dom", "react/jsx-runtime"], "rollupConfig": "@nx/react/plugins/bundle-rollup", "compiler": "babel", "assets": [ { - "glob": "packages/magickml-chatbox/README.md", + "glob": "packages/client/magickml-chatbox/README.md", "input": ".", "output": "." } @@ -37,7 +39,7 @@ "executor": "@nx/jest:jest", "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], "options": { - "jestConfig": "packages/magickml-chatbox/jest.config.ts", + "jestConfig": "packages/client/magickml-chatbox/jest.config.ts", "passWithNoTests": true }, "configurations": { diff --git a/packages/magickml-chatbox/src/index.ts b/packages/client/magickml-chatbox/src/index.ts similarity index 100% rename from packages/magickml-chatbox/src/index.ts rename to packages/client/magickml-chatbox/src/index.ts diff --git a/packages/magickml-chatbox/src/lib/magickml-chatbox.module.css b/packages/client/magickml-chatbox/src/lib/magickml-chatbox.module.css similarity index 100% rename from packages/magickml-chatbox/src/lib/magickml-chatbox.module.css rename to packages/client/magickml-chatbox/src/lib/magickml-chatbox.module.css diff --git a/packages/magickml-chatbox/src/lib/magickml-chatbox.spec.tsx b/packages/client/magickml-chatbox/src/lib/magickml-chatbox.spec.tsx similarity index 100% rename from packages/magickml-chatbox/src/lib/magickml-chatbox.spec.tsx rename to packages/client/magickml-chatbox/src/lib/magickml-chatbox.spec.tsx diff --git a/packages/magickml-chatbox/src/lib/magickml-chatbox.tsx b/packages/client/magickml-chatbox/src/lib/magickml-chatbox.tsx similarity index 50% rename from packages/magickml-chatbox/src/lib/magickml-chatbox.tsx rename to packages/client/magickml-chatbox/src/lib/magickml-chatbox.tsx index 9f612baf4f..55e343e063 100644 --- a/packages/magickml-chatbox/src/lib/magickml-chatbox.tsx +++ b/packages/client/magickml-chatbox/src/lib/magickml-chatbox.tsx @@ -1,32 +1,31 @@ import { useFeatureFlagEnabled } from 'posthog-js/react' import styles from './magickml-chatbox.module.css' -import { Widget } from 'react-chat-widget'; -import 'react-chat-widget/lib/styles.css'; +import { Widget } from 'react-chat-widget' +import 'react-chat-widget/lib/styles.css' /* eslint-disable-next-line */ export interface MagickmlChatboxProps {} export function MagickmlChatbox(props: MagickmlChatboxProps) { - const showChatBoxFlag = useFeatureFlagEnabled('chat-exp-chatbox') - const handleNewUserMessage = (newMessage) => { + const handleNewUserMessage = newMessage => { // Now send the message throught the backend API - console.log(`New message incoming! ${newMessage}`); - }; + console.log(`New message incoming! ${newMessage}`) + } return (
- { - showChatBoxFlag ? ( - - ) : '' - } + {showChatBoxFlag ? ( + + ) : ( + '' + )}
) } diff --git a/packages/magickml-chatbox/tsconfig.json b/packages/client/magickml-chatbox/tsconfig.json similarity index 88% rename from packages/magickml-chatbox/tsconfig.json rename to packages/client/magickml-chatbox/tsconfig.json index 3c41f10fb2..4daaf45cd3 100644 --- a/packages/magickml-chatbox/tsconfig.json +++ b/packages/client/magickml-chatbox/tsconfig.json @@ -16,5 +16,5 @@ "path": "./tsconfig.spec.json" } ], - "extends": "../../tsconfig.base.json" + "extends": "../../../tsconfig.base.json" } diff --git a/packages/magickml-chatbox/tsconfig.lib.json b/packages/client/magickml-chatbox/tsconfig.lib.json similarity index 72% rename from packages/magickml-chatbox/tsconfig.lib.json rename to packages/client/magickml-chatbox/tsconfig.lib.json index 06e3087e41..7b862025e8 100644 --- a/packages/magickml-chatbox/tsconfig.lib.json +++ b/packages/client/magickml-chatbox/tsconfig.lib.json @@ -1,12 +1,12 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", + "outDir": "../../../dist/out-tsc", "types": ["node"] }, "files": [ - "../../node_modules/@nx/react/typings/cssmodule.d.ts", - "../../node_modules/@nx/react/typings/image.d.ts" + "../../../node_modules/@nx/react/typings/cssmodule.d.ts", + "../../../node_modules/@nx/react/typings/image.d.ts" ], "exclude": [ "jest.config.ts", diff --git a/packages/magickml-chatbox/tsconfig.spec.json b/packages/client/magickml-chatbox/tsconfig.spec.json similarity index 90% rename from packages/magickml-chatbox/tsconfig.spec.json rename to packages/client/magickml-chatbox/tsconfig.spec.json index 26ef046ac5..25b7af8f6d 100644 --- a/packages/magickml-chatbox/tsconfig.spec.json +++ b/packages/client/magickml-chatbox/tsconfig.spec.json @@ -1,7 +1,7 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", + "outDir": "../../../dist/out-tsc", "module": "commonjs", "types": ["jest", "node"] }, diff --git a/packages/magickml-chatbox/README.md b/packages/magickml-chatbox/README.md deleted file mode 100644 index 31018fd2c1..0000000000 --- a/packages/magickml-chatbox/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# magickml-chatbox - -This library was generated with [Nx](https://nx.dev). - -## Running unit tests - -Run `nx test magickml-chatbox` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/packages/magickml-chatbox/package.json b/packages/magickml-chatbox/package.json deleted file mode 100644 index 837bb20ba8..0000000000 --- a/packages/magickml-chatbox/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "@magickml/chatbox", - "version": "0.0.1" -} diff --git a/tsconfig.base.json b/tsconfig.base.json index dadb0543a7..ee5e7e075b 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -26,7 +26,6 @@ ], "paths": { "@magickml/agent": ["apps/agent/src/index.ts"], - "@magickml/chatbox": ["packages/magickml-chatbox/src/index.ts"], "@magickml/client": ["apps/client/src/index.ts"], "@magickml/client-core": ["packages/core/client/src/index.ts"], "@magickml/config": ["packages/config/src/index.ts"], @@ -196,6 +195,9 @@ "server/event-tracker": ["packages/server/event-tracker/src/index.ts"], "client/editor": ["packages/client/editor/src/index.ts"], "client/layouts": ["packages/client/layouts/src/index.ts"], + "client/magickml-chatbox": [ + "packages/client/magickml-chatbox/src/index.ts" + ], "client/state": ["packages/client/state/src/index.ts"], "rete": ["packages/rete/src/index.ts"], "server/agents": ["packages/server/agents/src/index.ts"], From 2f45d11820325d50228a6fe16aa88c0c28595a69 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 27 Sep 2023 11:46:11 -0700 Subject: [PATCH 120/349] Move redis pubsub package into server folder --- packages/core/server/src/app.ts | 2 +- .../server/src/communication/PubSub/Redis.ts | 30 +++++++++---------- packages/redis-pubsub/README.md | 11 ------- packages/{ => server}/redis-pubsub/.babelrc | 0 .../{ => server}/redis-pubsub/.eslintrc.json | 2 +- packages/server/redis-pubsub/README.md | 11 +++++++ .../{ => server}/redis-pubsub/jest.config.ts | 6 ++-- .../{ => server}/redis-pubsub/project.json | 10 +++---- .../{ => server}/redis-pubsub/src/index.ts | 0 .../redis-pubsub/src/lib/redis-pubsub-koa.ts | 0 .../redis-pubsub/src/lib/redis-pubsub.spec.ts | 0 .../redis-pubsub/src/lib/redis-pubsub.ts | 0 .../{ => server}/redis-pubsub/tsconfig.json | 2 +- .../redis-pubsub/tsconfig.lib.json | 2 +- .../redis-pubsub/tsconfig.spec.json | 2 +- tsconfig.base.json | 4 +-- 16 files changed, 41 insertions(+), 41 deletions(-) delete mode 100644 packages/redis-pubsub/README.md rename packages/{ => server}/redis-pubsub/.babelrc (100%) rename packages/{ => server}/redis-pubsub/.eslintrc.json (86%) create mode 100644 packages/server/redis-pubsub/README.md rename packages/{ => server}/redis-pubsub/jest.config.ts (60%) rename packages/{ => server}/redis-pubsub/project.json (62%) rename packages/{ => server}/redis-pubsub/src/index.ts (100%) rename packages/{ => server}/redis-pubsub/src/lib/redis-pubsub-koa.ts (100%) rename packages/{ => server}/redis-pubsub/src/lib/redis-pubsub.spec.ts (100%) rename packages/{ => server}/redis-pubsub/src/lib/redis-pubsub.ts (100%) rename packages/{ => server}/redis-pubsub/tsconfig.json (78%) rename packages/{ => server}/redis-pubsub/tsconfig.lib.json (85%) rename packages/{ => server}/redis-pubsub/tsconfig.spec.json (90%) diff --git a/packages/core/server/src/app.ts b/packages/core/server/src/app.ts index c1ae40fa1f..d34766e928 100644 --- a/packages/core/server/src/app.ts +++ b/packages/core/server/src/app.ts @@ -16,6 +16,7 @@ import { import socketio from '@feathersjs/socketio' import pino from 'pino' import Redis from 'ioredis' +import { RedisPubSub } from 'server/redis-pubsub' import sync from 'feathers-sync' import { @@ -23,7 +24,6 @@ import { API_ACCESS_KEY, bullMQConnection, } from '@magickml/config' -import { RedisPubSub } from '@magickml/redis-pubsub' import { getLogger } from '@magickml/core' import type { AgentCommander } from '@magickml/agents' import { configureManager, globalsManager } from '@magickml/core' diff --git a/packages/core/server/src/communication/PubSub/Redis.ts b/packages/core/server/src/communication/PubSub/Redis.ts index 1efd57d0ec..932a2faa0b 100644 --- a/packages/core/server/src/communication/PubSub/Redis.ts +++ b/packages/core/server/src/communication/PubSub/Redis.ts @@ -1,25 +1,25 @@ -import { RedisPubSub } from '@magickml/redis-pubsub' +import { RedisPubSub } from 'server/redis-pubsub' import { PubSub } from './PubSub' import { app } from '@magickml/server-core' export class RedisPubSubWrapper extends PubSub { - pubsub: RedisPubSub + pubsub: RedisPubSub - constructor() { - super() - this.pubsub = app.get('pubsub') - } + constructor() { + super() + this.pubsub = app.get('pubsub') + } - async publish(channel: string, message: string): Promise { - return await this.pubsub.publish(channel, message) - } + async publish(channel: string, message: string): Promise { + return await this.pubsub.publish(channel, message) + } - async subscribe(channel: string, callback: Function): Promise { - return await this.pubsub.subscribe(channel, callback) - } + async subscribe(channel: string, callback: Function): Promise { + return await this.pubsub.subscribe(channel, callback) + } - async patternSubscribe(pattern: string, callback: Function): Promise { - return await this.pubsub.patternSubscribe(pattern, callback) - } + async patternSubscribe(pattern: string, callback: Function): Promise { + return await this.pubsub.patternSubscribe(pattern, callback) + } } diff --git a/packages/redis-pubsub/README.md b/packages/redis-pubsub/README.md deleted file mode 100644 index 9c5eb9b7a2..0000000000 --- a/packages/redis-pubsub/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# redis-pubsub - -This library was generated with [Nx](https://nx.dev). - -## Running unit tests - -Run `nx test redis-pubsub` to execute the unit tests via [Jest](https://jestjs.io). - -## Running lint - -Run `nx lint redis-pubsub` to execute the lint via [ESLint](https://eslint.org/). diff --git a/packages/redis-pubsub/.babelrc b/packages/server/redis-pubsub/.babelrc similarity index 100% rename from packages/redis-pubsub/.babelrc rename to packages/server/redis-pubsub/.babelrc diff --git a/packages/redis-pubsub/.eslintrc.json b/packages/server/redis-pubsub/.eslintrc.json similarity index 86% rename from packages/redis-pubsub/.eslintrc.json rename to packages/server/redis-pubsub/.eslintrc.json index 9d9c0db55b..3456be9b90 100644 --- a/packages/redis-pubsub/.eslintrc.json +++ b/packages/server/redis-pubsub/.eslintrc.json @@ -1,5 +1,5 @@ { - "extends": ["../../.eslintrc.json"], + "extends": ["../../../.eslintrc.json"], "ignorePatterns": ["!**/*"], "overrides": [ { diff --git a/packages/server/redis-pubsub/README.md b/packages/server/redis-pubsub/README.md new file mode 100644 index 0000000000..d8bf8f1cc6 --- /dev/null +++ b/packages/server/redis-pubsub/README.md @@ -0,0 +1,11 @@ +# server-redis-pubsub + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test server-redis-pubsub` to execute the unit tests via [Jest](https://jestjs.io). + +## Running lint + +Run `nx lint server-redis-pubsub` to execute the lint via [ESLint](https://eslint.org/). diff --git a/packages/redis-pubsub/jest.config.ts b/packages/server/redis-pubsub/jest.config.ts similarity index 60% rename from packages/redis-pubsub/jest.config.ts rename to packages/server/redis-pubsub/jest.config.ts index a721be9c0f..c801da446d 100644 --- a/packages/redis-pubsub/jest.config.ts +++ b/packages/server/redis-pubsub/jest.config.ts @@ -1,11 +1,11 @@ /* eslint-disable */ export default { - displayName: 'redis-pubsub', - preset: '../../jest.preset.js', + displayName: 'server-redis-pubsub', + preset: '../../../jest.preset.js', testEnvironment: 'node', transform: { '^.+\\.[tj]sx?$': ['ts-jest', { tsconfig: '/tsconfig.spec.json' }], }, moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], - coverageDirectory: '../../coverage/packages/redis-pubsub', + coverageDirectory: '../../../coverage/packages/server/redis-pubsub', } diff --git a/packages/redis-pubsub/project.json b/packages/server/redis-pubsub/project.json similarity index 62% rename from packages/redis-pubsub/project.json rename to packages/server/redis-pubsub/project.json index 33b3fdaaa4..60143f8c3b 100644 --- a/packages/redis-pubsub/project.json +++ b/packages/server/redis-pubsub/project.json @@ -1,21 +1,21 @@ { - "name": "redis-pubsub", - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "packages/redis-pubsub/src", + "name": "server-redis-pubsub", + "$schema": "../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "packages/server/redis-pubsub/src", "projectType": "library", "targets": { "lint": { "executor": "@nx/linter:eslint", "outputs": ["{options.outputFile}"], "options": { - "lintFilePatterns": ["packages/redis-pubsub/**/*.ts"] + "lintFilePatterns": ["packages/server/redis-pubsub/**/*.ts"] } }, "test": { "executor": "@nx/jest:jest", "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], "options": { - "jestConfig": "packages/redis-pubsub/jest.config.ts", + "jestConfig": "packages/server/redis-pubsub/jest.config.ts", "passWithNoTests": true }, "configurations": { diff --git a/packages/redis-pubsub/src/index.ts b/packages/server/redis-pubsub/src/index.ts similarity index 100% rename from packages/redis-pubsub/src/index.ts rename to packages/server/redis-pubsub/src/index.ts diff --git a/packages/redis-pubsub/src/lib/redis-pubsub-koa.ts b/packages/server/redis-pubsub/src/lib/redis-pubsub-koa.ts similarity index 100% rename from packages/redis-pubsub/src/lib/redis-pubsub-koa.ts rename to packages/server/redis-pubsub/src/lib/redis-pubsub-koa.ts diff --git a/packages/redis-pubsub/src/lib/redis-pubsub.spec.ts b/packages/server/redis-pubsub/src/lib/redis-pubsub.spec.ts similarity index 100% rename from packages/redis-pubsub/src/lib/redis-pubsub.spec.ts rename to packages/server/redis-pubsub/src/lib/redis-pubsub.spec.ts diff --git a/packages/redis-pubsub/src/lib/redis-pubsub.ts b/packages/server/redis-pubsub/src/lib/redis-pubsub.ts similarity index 100% rename from packages/redis-pubsub/src/lib/redis-pubsub.ts rename to packages/server/redis-pubsub/src/lib/redis-pubsub.ts diff --git a/packages/redis-pubsub/tsconfig.json b/packages/server/redis-pubsub/tsconfig.json similarity index 78% rename from packages/redis-pubsub/tsconfig.json rename to packages/server/redis-pubsub/tsconfig.json index 62ebbd9464..667a3463d1 100644 --- a/packages/redis-pubsub/tsconfig.json +++ b/packages/server/redis-pubsub/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig.base.json", + "extends": "../../../tsconfig.base.json", "files": [], "include": [], "references": [ diff --git a/packages/redis-pubsub/tsconfig.lib.json b/packages/server/redis-pubsub/tsconfig.lib.json similarity index 85% rename from packages/redis-pubsub/tsconfig.lib.json rename to packages/server/redis-pubsub/tsconfig.lib.json index 3f06e80289..e583571eac 100644 --- a/packages/redis-pubsub/tsconfig.lib.json +++ b/packages/server/redis-pubsub/tsconfig.lib.json @@ -2,7 +2,7 @@ "extends": "./tsconfig.json", "compilerOptions": { "module": "commonjs", - "outDir": "../../dist/out-tsc", + "outDir": "../../../dist/out-tsc", "declaration": true, "types": ["node"] }, diff --git a/packages/redis-pubsub/tsconfig.spec.json b/packages/server/redis-pubsub/tsconfig.spec.json similarity index 90% rename from packages/redis-pubsub/tsconfig.spec.json rename to packages/server/redis-pubsub/tsconfig.spec.json index 26ef046ac5..25b7af8f6d 100644 --- a/packages/redis-pubsub/tsconfig.spec.json +++ b/packages/server/redis-pubsub/tsconfig.spec.json @@ -1,7 +1,7 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", + "outDir": "../../../dist/out-tsc", "module": "commonjs", "types": ["jest", "node"] }, diff --git a/tsconfig.base.json b/tsconfig.base.json index ee5e7e075b..8eefda6a35 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -184,7 +184,6 @@ "@magickml/plugin-twitter-server": [ "packages/plugins/twitter/server/src/index.ts" ], - "@magickml/redis-pubsub": ["packages/redis-pubsub/src/index.ts"], "@magickml/rete": ["packages/rete/src/index.ts"], "@magickml/server": ["apps/server/src/index.ts"], "@magickml/server-core": ["packages/core/server/src/index.ts"], @@ -206,7 +205,8 @@ ], "server/cloud-agent-worker": [ "packages/server/cloud-agent-worker/src/index.ts" - ] + ], + "server/redis-pubsub": ["packages/server/redis-pubsub/src/index.ts"] } }, "exclude": ["node_modules", "tmp"] From f10434151f67f3fed484a67b701bd1abd1f424ed Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 27 Sep 2023 11:47:37 -0700 Subject: [PATCH 121/349] Move rete into shared folder --- .../editor/src/contexts/EditorProvider.tsx | 2 +- .../src/plugins/connectionPlugin/events.ts | 2 +- .../src/plugins/connectionPlugin/flow.ts | 2 +- .../src/plugins/connectionPlugin/index.ts | 2 +- .../plugins/connectionPlugin/picker/index.ts | 2 +- .../plugins/connectionPlugin/picker/view.ts | 2 +- .../src/plugins/connectionPlugin/utils.ts | 2 +- .../src/plugins/highlightPlugin/index.ts | 2 +- .../src/plugins/highlightPlugin/utils.ts | 2 +- .../shared/src/dataControls/InputGenerator.ts | 3 +- .../src/dataControls/OutputGenerator.ts | 2 +- .../src/dataControls/TextInputControl.tsx | 70 +++++---- packages/core/shared/src/engine.ts | 2 +- .../shared/src/nodes/array/ArrayToJSON.ts | 2 +- .../shared/src/nodes/array/ArrayVariable.ts | 2 +- .../src/nodes/array/ExtractFromArray.ts | 2 +- .../src/nodes/array/GetValueFromArray.ts | 2 +- .../shared/src/nodes/array/JSONToArray.ts | 2 +- .../core/shared/src/nodes/array/JoinList.ts | 2 +- .../core/shared/src/nodes/array/RemapArray.ts | 2 +- .../shared/src/nodes/audio/TextToSpeech.ts | 2 +- .../src/nodes/boolean/BooleanVariable.ts | 2 +- .../src/nodes/boolean/IsVariableTrue.ts | 2 +- .../src/nodes/boolean/LogicalOperator.ts | 2 +- .../core/shared/src/nodes/code/Javascript.ts | 2 +- packages/core/shared/src/nodes/code/Python.ts | 2 +- .../core/shared/src/nodes/database/Delete.ts | 2 +- .../core/shared/src/nodes/database/Insert.ts | 2 +- .../core/shared/src/nodes/database/Select.ts | 2 +- .../core/shared/src/nodes/database/Update.ts | 2 +- .../core/shared/src/nodes/database/Upsert.ts | 2 +- .../src/nodes/document/DocumentToContent.ts | 2 +- .../shared/src/nodes/document/GetDocuments.ts | 2 +- .../src/nodes/document/StoreDocument.ts | 2 +- .../src/nodes/embedding/CosineSimilarity.ts | 2 +- .../nodes/embedding/CreateTextEmbedding.ts | 2 +- .../nodes/embedding/ExtractRelationship.ts | 2 +- .../src/nodes/embedding/FindTextEmbedding.ts | 2 +- .../shared/src/nodes/events/EventDelete.ts | 2 +- .../src/nodes/events/EventDestructure.ts | 2 +- .../shared/src/nodes/events/EventRecall.ts | 2 +- .../src/nodes/events/EventRestructure.ts | 2 +- .../shared/src/nodes/events/EventStore.ts | 2 +- .../src/nodes/events/EventsToConversation.ts | 2 +- .../core/shared/src/nodes/flow/BooleanGate.ts | 2 +- .../shared/src/nodes/flow/CommandParser.ts | 2 +- .../shared/src/nodes/flow/ExclusiveGate.ts | 2 +- .../src/nodes/flow/IsNullOrUndefined.ts | 2 +- packages/core/shared/src/nodes/flow/OrGate.ts | 2 +- .../core/shared/src/nodes/flow/RandomGate.ts | 2 +- .../core/shared/src/nodes/flow/SwitchGate.ts | 2 +- .../core/shared/src/nodes/flow/WaitForAll.ts | 2 +- packages/core/shared/src/nodes/io/Input.ts | 2 +- .../shared/src/nodes/io/JupyterNotebook.ts | 2 +- packages/core/shared/src/nodes/io/Output.ts | 2 +- packages/core/shared/src/nodes/io/Request.ts | 2 +- packages/core/shared/src/nodes/io/Respond.ts | 2 +- packages/core/shared/src/nodes/io/Skill.ts | 2 +- packages/core/shared/src/nodes/io/Spell.ts | 2 +- .../core/shared/src/nodes/io/SpellByName.ts | 2 +- .../core/shared/src/nodes/magick/runSpell.ts | 2 +- packages/core/shared/src/nodes/number/Add.ts | 2 +- .../core/shared/src/nodes/number/Divide.ts | 2 +- .../core/shared/src/nodes/number/Equal.ts | 2 +- .../shared/src/nodes/number/GreaterThan.ts | 2 +- .../src/nodes/number/GreaterThanOrEqual.ts | 2 +- .../core/shared/src/nodes/number/InRange.ts | 2 +- .../core/shared/src/nodes/number/IsANumber.ts | 2 +- .../core/shared/src/nodes/number/LessThan.ts | 2 +- .../src/nodes/number/LessThanOrEqual.ts | 2 +- .../core/shared/src/nodes/number/Multiply.ts | 2 +- .../shared/src/nodes/number/NumberVariable.ts | 2 +- .../core/shared/src/nodes/number/Subtract.ts | 2 +- .../shared/src/nodes/object/ComposeObject.ts | 2 +- .../src/nodes/object/GetValuesFromObject.ts | 2 +- .../shared/src/nodes/object/JSONToObject.ts | 2 +- .../shared/src/nodes/object/MergeObjects.ts | 2 +- .../shared/src/nodes/object/ObjectToJSON.ts | 2 +- .../core/shared/src/nodes/text/CombineText.ts | 2 +- .../src/nodes/text/ComplexStringMatcher.ts | 2 +- .../shared/src/nodes/text/EvaluateText.ts | 2 +- .../shared/src/nodes/text/GenerateText.ts | 2 +- .../shared/src/nodes/text/GenerateUUID.ts | 2 +- .../core/shared/src/nodes/text/GetLength.ts | 2 +- .../shared/src/nodes/text/ProfanityFilter.ts | 2 +- .../src/nodes/text/RegularExpression.ts | 2 +- .../core/shared/src/nodes/text/ReplaceText.ts | 2 +- .../shared/src/nodes/text/SplitBySentence.ts | 2 +- .../shared/src/nodes/text/StringVariable.ts | 2 +- .../shared/src/nodes/text/TextTemplate.ts | 2 +- .../shared/src/nodes/text/TextVariable.ts | 2 +- packages/core/shared/src/nodes/text/Trim.ts | 2 +- .../core/shared/src/nodes/text/TypeChat.ts | 2 +- .../shared/src/nodes/utility/AlertMessage.ts | 2 +- .../core/shared/src/nodes/utility/Cast.ts | 2 +- .../shared/src/nodes/utility/CurrentTime.ts | 2 +- .../core/shared/src/nodes/utility/Echo.ts | 2 +- .../core/shared/src/nodes/utility/Error.ts | 2 +- packages/core/shared/src/nodes/utility/Log.ts | 2 +- .../plugins/cachePlugin/RunLastArguments.tsx | 40 ++--- .../shared/src/plugins/cachePlugin/index.ts | 2 +- .../plugins/consolePlugin/MagickConsole.ts | 2 +- .../historyPlugin/actions/connection.ts | 2 +- .../src/plugins/historyPlugin/actions/node.ts | 2 +- .../plugins/inspectorPlugin/DataControl.ts | 2 +- .../src/plugins/inspectorPlugin/Inspector.ts | 2 +- .../src/plugins/lifecyclePlugin/index.ts | 2 +- .../src/plugins/lifecyclePlugin/interfaces.ts | 2 +- .../src/plugins/lifecyclePlugin/utils.ts | 2 +- .../plugins/modulePlugin/module-manager.ts | 5 +- .../shared/src/plugins/modulePlugin/utils.ts | 2 +- .../src/plugins/multiCopyPlugin/index.ts | 2 +- .../src/plugins/multiSocketGenerator/index.ts | 2 +- .../src/plugins/selectionPlugin/index.ts | 2 +- .../src/plugins/socketGenerator/index.ts | 2 +- .../shared/src/plugins/taskPlugin/index.ts | 4 +- packages/core/shared/src/sockets.ts | 2 +- packages/core/shared/src/types.ts | 2 +- .../src/nodes/DiscordCurrentChannelName.ts | 2 +- .../shared/src/nodes/DiscordJoinVoice.ts | 2 +- .../shared/src/nodes/DiscordLeaveVoice.ts | 2 +- .../DiscordLeaveVoiceChannelsInServer.ts | 2 +- .../src/nodes/DiscordListTextChannels.ts | 2 +- .../src/nodes/DiscordListVoiceChannels.ts | 2 +- .../src/nodes/DiscordVoiceChannelForSender.ts | 2 +- .../src/nodes/CallContractFunctionRead.ts | 2 +- .../src/nodes/CallContractFunctionWrite.ts | 2 +- .../src/nodes/CheckForRecentTxFromWallet.ts | 2 +- .../shared/src/nodes/CompileContract.ts | 2 +- .../shared/src/nodes/DeployContract.ts | 2 +- .../src/nodes/GetERC20BalanceFromWallet.ts | 2 +- .../src/nodes/GetNativeBalanceFromWallet.ts | 2 +- .../src/nodes/GetRecentTxsFromWallet.ts | 2 +- .../shared/src/nodes/GithubIssueSearch.ts | 2 +- .../intent/shared/src/nodes/IntentSearch.ts | 2 +- .../shared/src/nodes/QueryPinecone.ts | 2 +- .../search/shared/src/nodes/SearchGoogle.ts | 2 +- .../search/shared/src/nodes/SearchMetaphor.ts | 2 +- .../task/shared/src/nodes/CancelTask.ts | 2 +- .../task/shared/src/nodes/CompleteTask.ts | 2 +- .../task/shared/src/nodes/CreateTask.ts | 2 +- .../task/shared/src/nodes/DeleteTask.ts | 2 +- .../task/shared/src/nodes/FinishTaskStep.ts | 2 +- packages/rete/src/connection.ts | 22 --- packages/rete/src/control.ts | 39 ----- packages/rete/src/core/context.ts | 42 ------ packages/rete/src/core/data.ts | 41 ------ packages/rete/src/core/emitter.ts | 52 ------- packages/rete/src/core/events.ts | 23 --- packages/rete/src/core/plugin.ts | 6 - packages/rete/src/engine/component.ts | 15 -- packages/rete/src/engine/events.ts | 10 -- packages/rete/src/engine/recursion.ts | 55 ------- packages/rete/src/engine/state.ts | 1 - packages/rete/src/events.ts | 139 ------------------ packages/rete/src/input.ts | 47 ------ packages/rete/src/node.ts | 128 ---------------- packages/rete/src/output.ts | 50 ------- packages/rete/src/selected.ts | 29 ---- packages/rete/src/view/area.ts | 109 -------------- packages/rete/src/view/connection.ts | 50 ------- packages/rete/src/view/control.ts | 11 -- packages/rete/src/view/node.ts | 129 ---------------- packages/rete/src/view/socket.ts | 31 ---- packages/rete/src/view/utils.ts | 7 - packages/rete/src/view/zoom.ts | 98 ------------ packages/rete/test/data/add-numbers.js | 68 --------- packages/rete/test/data/components.ts | 31 ---- packages/rete/test/data/recursive.js | 122 --------------- packages/rete/test/utils/render-mock.js | 10 -- packages/rete/test/utils/throwsAsync.js | 13 -- packages/{ => shared}/rete/.eslintrc.json | 2 +- packages/{ => shared}/rete/README.md | 0 packages/{ => shared}/rete/jest.config.ts | 6 +- packages/{ => shared}/rete/package.json | 2 +- packages/{ => shared}/rete/project.json | 14 +- packages/{ => shared}/rete/src/component.ts | 0 packages/shared/rete/src/connection.ts | 21 +++ packages/shared/rete/src/control.ts | 37 +++++ packages/shared/rete/src/core/context.ts | 42 ++++++ packages/shared/rete/src/core/data.ts | 51 +++++++ packages/shared/rete/src/core/emitter.ts | 56 +++++++ packages/shared/rete/src/core/events.ts | 22 +++ packages/shared/rete/src/core/plugin.ts | 11 ++ .../{ => shared}/rete/src/core/validator.ts | 0 packages/{ => shared}/rete/src/editor.ts | 0 packages/shared/rete/src/engine/component.ts | 19 +++ packages/shared/rete/src/engine/events.ts | 8 + .../{ => shared}/rete/src/engine/index.ts | 0 packages/shared/rete/src/engine/recursion.ts | 54 +++++++ packages/shared/rete/src/engine/state.ts | 1 + packages/shared/rete/src/events.ts | 138 +++++++++++++++++ packages/{ => shared}/rete/src/index.ts | 0 packages/shared/rete/src/input.ts | 46 ++++++ packages/{ => shared}/rete/src/io.ts | 0 packages/shared/rete/src/node.ts | 133 +++++++++++++++++ packages/shared/rete/src/output.ts | 49 ++++++ packages/shared/rete/src/selected.ts | 26 ++++ packages/{ => shared}/rete/src/socket.ts | 1 - packages/shared/rete/src/view/area.ts | 120 +++++++++++++++ packages/shared/rete/src/view/connection.ts | 54 +++++++ packages/shared/rete/src/view/control.ts | 14 ++ packages/{ => shared}/rete/src/view/drag.ts | 0 packages/{ => shared}/rete/src/view/index.ts | 0 packages/shared/rete/src/view/node.ts | 137 +++++++++++++++++ packages/shared/rete/src/view/socket.ts | 36 +++++ packages/shared/rete/src/view/utils.ts | 10 ++ packages/shared/rete/src/view/zoom.ts | 114 ++++++++++++++ packages/{ => shared}/rete/test/control.ts | 0 packages/{ => shared}/rete/test/core.ts | 0 packages/shared/rete/test/data/add-numbers.js | 76 ++++++++++ packages/shared/rete/test/data/components.ts | 29 ++++ packages/shared/rete/test/data/recursive.js | 116 +++++++++++++++ packages/{ => shared}/rete/test/editor.ts | 0 packages/{ => shared}/rete/test/engine.ts | 0 packages/{ => shared}/rete/test/socket.ts | 0 .../shared/rete/test/utils/render-mock.js | 10 ++ .../shared/rete/test/utils/throwsAsync.js | 15 ++ packages/{ => shared}/rete/test/validator.ts | 0 packages/{ => shared}/rete/tsconfig.json | 2 +- packages/{ => shared}/rete/tsconfig.lib.json | 2 +- packages/{ => shared}/rete/tsconfig.spec.json | 2 +- packages/{ => shared}/rete/vite.config.ts | 2 +- tsconfig.base.json | 4 +- 224 files changed, 1669 insertions(+), 1589 deletions(-) delete mode 100644 packages/rete/src/connection.ts delete mode 100644 packages/rete/src/control.ts delete mode 100644 packages/rete/src/core/context.ts delete mode 100644 packages/rete/src/core/data.ts delete mode 100644 packages/rete/src/core/emitter.ts delete mode 100644 packages/rete/src/core/events.ts delete mode 100644 packages/rete/src/core/plugin.ts delete mode 100644 packages/rete/src/engine/component.ts delete mode 100644 packages/rete/src/engine/events.ts delete mode 100644 packages/rete/src/engine/recursion.ts delete mode 100644 packages/rete/src/engine/state.ts delete mode 100644 packages/rete/src/events.ts delete mode 100644 packages/rete/src/input.ts delete mode 100644 packages/rete/src/node.ts delete mode 100644 packages/rete/src/output.ts delete mode 100644 packages/rete/src/selected.ts delete mode 100644 packages/rete/src/view/area.ts delete mode 100644 packages/rete/src/view/connection.ts delete mode 100644 packages/rete/src/view/control.ts delete mode 100644 packages/rete/src/view/node.ts delete mode 100644 packages/rete/src/view/socket.ts delete mode 100644 packages/rete/src/view/utils.ts delete mode 100644 packages/rete/src/view/zoom.ts delete mode 100644 packages/rete/test/data/add-numbers.js delete mode 100644 packages/rete/test/data/components.ts delete mode 100644 packages/rete/test/data/recursive.js delete mode 100644 packages/rete/test/utils/render-mock.js delete mode 100644 packages/rete/test/utils/throwsAsync.js rename packages/{ => shared}/rete/.eslintrc.json (90%) rename packages/{ => shared}/rete/README.md (100%) rename packages/{ => shared}/rete/jest.config.ts (61%) rename packages/{ => shared}/rete/package.json (89%) rename packages/{ => shared}/rete/project.json (65%) rename packages/{ => shared}/rete/src/component.ts (100%) create mode 100644 packages/shared/rete/src/connection.ts create mode 100644 packages/shared/rete/src/control.ts create mode 100644 packages/shared/rete/src/core/context.ts create mode 100644 packages/shared/rete/src/core/data.ts create mode 100644 packages/shared/rete/src/core/emitter.ts create mode 100644 packages/shared/rete/src/core/events.ts create mode 100644 packages/shared/rete/src/core/plugin.ts rename packages/{ => shared}/rete/src/core/validator.ts (100%) rename packages/{ => shared}/rete/src/editor.ts (100%) create mode 100644 packages/shared/rete/src/engine/component.ts create mode 100644 packages/shared/rete/src/engine/events.ts rename packages/{ => shared}/rete/src/engine/index.ts (100%) create mode 100644 packages/shared/rete/src/engine/recursion.ts create mode 100644 packages/shared/rete/src/engine/state.ts create mode 100644 packages/shared/rete/src/events.ts rename packages/{ => shared}/rete/src/index.ts (100%) create mode 100644 packages/shared/rete/src/input.ts rename packages/{ => shared}/rete/src/io.ts (100%) create mode 100644 packages/shared/rete/src/node.ts create mode 100644 packages/shared/rete/src/output.ts create mode 100644 packages/shared/rete/src/selected.ts rename packages/{ => shared}/rete/src/socket.ts (96%) create mode 100644 packages/shared/rete/src/view/area.ts create mode 100644 packages/shared/rete/src/view/connection.ts create mode 100644 packages/shared/rete/src/view/control.ts rename packages/{ => shared}/rete/src/view/drag.ts (100%) rename packages/{ => shared}/rete/src/view/index.ts (100%) create mode 100644 packages/shared/rete/src/view/node.ts create mode 100644 packages/shared/rete/src/view/socket.ts create mode 100644 packages/shared/rete/src/view/utils.ts create mode 100644 packages/shared/rete/src/view/zoom.ts rename packages/{ => shared}/rete/test/control.ts (100%) rename packages/{ => shared}/rete/test/core.ts (100%) create mode 100644 packages/shared/rete/test/data/add-numbers.js create mode 100644 packages/shared/rete/test/data/components.ts create mode 100644 packages/shared/rete/test/data/recursive.js rename packages/{ => shared}/rete/test/editor.ts (100%) rename packages/{ => shared}/rete/test/engine.ts (100%) rename packages/{ => shared}/rete/test/socket.ts (100%) create mode 100644 packages/shared/rete/test/utils/render-mock.js create mode 100644 packages/shared/rete/test/utils/throwsAsync.js rename packages/{ => shared}/rete/test/validator.ts (100%) rename packages/{ => shared}/rete/tsconfig.json (90%) rename packages/{ => shared}/rete/tsconfig.lib.json (84%) rename packages/{ => shared}/rete/tsconfig.spec.json (85%) rename packages/{ => shared}/rete/vite.config.ts (94%) diff --git a/packages/client/editor/src/contexts/EditorProvider.tsx b/packages/client/editor/src/contexts/EditorProvider.tsx index e0f48dd14a..ad57e6e268 100644 --- a/packages/client/editor/src/contexts/EditorProvider.tsx +++ b/packages/client/editor/src/contexts/EditorProvider.tsx @@ -21,7 +21,7 @@ import { initEditor } from '../editor' import { zoomAt } from '../plugins/areaPlugin/zoom-at' import { useMagickInterface } from './MagickInterfaceProvider' import styles from './styles.module.scss' -import { EngineComponent } from '@magickml/rete' +import { EngineComponent } from 'shared/rete' import { spellApi } from 'client/state' /** diff --git a/packages/client/editor/src/plugins/connectionPlugin/events.ts b/packages/client/editor/src/plugins/connectionPlugin/events.ts index 339f662925..cdaf525076 100644 --- a/packages/client/editor/src/plugins/connectionPlugin/events.ts +++ b/packages/client/editor/src/plugins/connectionPlugin/events.ts @@ -1,4 +1,4 @@ -import { Connection, Input, Output } from '@magickml/rete' +import { Connection, Input, Output } from 'shared/rete' export interface EventsTypes { connectionpath: { diff --git a/packages/client/editor/src/plugins/connectionPlugin/flow.ts b/packages/client/editor/src/plugins/connectionPlugin/flow.ts index ad4f955005..4ad67a6ec3 100644 --- a/packages/client/editor/src/plugins/connectionPlugin/flow.ts +++ b/packages/client/editor/src/plugins/connectionPlugin/flow.ts @@ -1,4 +1,4 @@ -import { IO, Input, Output } from '@magickml/rete' +import { IO, Input, Output } from 'shared/rete' import { Picker } from './picker' export type FlowParams = { input?: Input; output?: Output } diff --git a/packages/client/editor/src/plugins/connectionPlugin/index.ts b/packages/client/editor/src/plugins/connectionPlugin/index.ts index fdf594ca2b..c150c49b84 100644 --- a/packages/client/editor/src/plugins/connectionPlugin/index.ts +++ b/packages/client/editor/src/plugins/connectionPlugin/index.ts @@ -1,4 +1,4 @@ -import { NodeEditor } from '@magickml/rete' +import { NodeEditor } from 'shared/rete' import { renderConnection, renderPathData, diff --git a/packages/client/editor/src/plugins/connectionPlugin/picker/index.ts b/packages/client/editor/src/plugins/connectionPlugin/picker/index.ts index bbd388aa13..da8b50b90a 100644 --- a/packages/client/editor/src/plugins/connectionPlugin/picker/index.ts +++ b/packages/client/editor/src/plugins/connectionPlugin/picker/index.ts @@ -1,4 +1,4 @@ -import { NodeEditor, Input, Output, Connection } from '@magickml/rete' +import { NodeEditor, Input, Output, Connection } from 'shared/rete' import { PickerView } from './view' export class Picker { diff --git a/packages/client/editor/src/plugins/connectionPlugin/picker/view.ts b/packages/client/editor/src/plugins/connectionPlugin/picker/view.ts index 893f0c5d40..f679b2e33c 100644 --- a/packages/client/editor/src/plugins/connectionPlugin/picker/view.ts +++ b/packages/client/editor/src/plugins/connectionPlugin/picker/view.ts @@ -1,4 +1,4 @@ -import { Output, Input, Emitter, EditorView } from '@magickml/rete' +import { Output, Input, Emitter, EditorView } from 'shared/rete' import { renderConnection, renderPathData, updateConnection } from '../utils' import { EventsTypes } from '../events' diff --git a/packages/client/editor/src/plugins/connectionPlugin/utils.ts b/packages/client/editor/src/plugins/connectionPlugin/utils.ts index 336ec327a8..9a107d644e 100644 --- a/packages/client/editor/src/plugins/connectionPlugin/utils.ts +++ b/packages/client/editor/src/plugins/connectionPlugin/utils.ts @@ -1,4 +1,4 @@ -import { Emitter, Connection } from '@magickml/rete' +import { Emitter, Connection } from 'shared/rete' import { EventsTypes } from './events' function toTrainCase(str: string) { diff --git a/packages/client/editor/src/plugins/highlightPlugin/index.ts b/packages/client/editor/src/plugins/highlightPlugin/index.ts index 879b1f96d1..bd5f47695c 100644 --- a/packages/client/editor/src/plugins/highlightPlugin/index.ts +++ b/packages/client/editor/src/plugins/highlightPlugin/index.ts @@ -1,4 +1,4 @@ -import { Connection } from '@magickml/rete' +import { Connection } from 'shared/rete' import { makeAllConnectionsOpaque, makeAllConnectionsTransparent, diff --git a/packages/client/editor/src/plugins/highlightPlugin/utils.ts b/packages/client/editor/src/plugins/highlightPlugin/utils.ts index 9d39202dff..d80e181329 100644 --- a/packages/client/editor/src/plugins/highlightPlugin/utils.ts +++ b/packages/client/editor/src/plugins/highlightPlugin/utils.ts @@ -1,5 +1,5 @@ import { MagickEditor } from '@magickml/core' -import { Connection } from '@magickml/rete' +import { Connection } from 'shared/rete' export const removeClassFromNodeConnections = ( editor: MagickEditor, diff --git a/packages/core/shared/src/dataControls/InputGenerator.ts b/packages/core/shared/src/dataControls/InputGenerator.ts index 8fb34e7319..3e152a76c2 100644 --- a/packages/core/shared/src/dataControls/InputGenerator.ts +++ b/packages/core/shared/src/dataControls/InputGenerator.ts @@ -1,5 +1,6 @@ // DOCUMENTED -import Rete, { InputsData } from '@magickml/rete' +import Rete from 'shared/rete' +import { InputsData } from 'rete/types/core/data' import { DataControl } from '../plugins/inspectorPlugin' import * as sockets from '../sockets' import { DataSocketType, InputComponentData } from '../types' diff --git a/packages/core/shared/src/dataControls/OutputGenerator.ts b/packages/core/shared/src/dataControls/OutputGenerator.ts index b64e02a3a4..fef9cbd8de 100644 --- a/packages/core/shared/src/dataControls/OutputGenerator.ts +++ b/packages/core/shared/src/dataControls/OutputGenerator.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete, { OutputsData } from '@magickml/rete' +import Rete, { OutputsData } from 'shared/rete' import { DataControl } from '../plugins/inspectorPlugin' import { SocketType } from '../sockets' diff --git a/packages/core/shared/src/dataControls/TextInputControl.tsx b/packages/core/shared/src/dataControls/TextInputControl.tsx index 0d3dfe778a..cfaa3ef3f3 100644 --- a/packages/core/shared/src/dataControls/TextInputControl.tsx +++ b/packages/core/shared/src/dataControls/TextInputControl.tsx @@ -1,38 +1,38 @@ -// DOCUMENTED -import React, { useState, useEffect } from 'react'; -import { Control } from '@magickml/rete'; -import { MagickEditor } from '../types'; +// DOCUMENTED +import React, { useState, useEffect } from 'react' +import { Control } from 'shared/rete' +import { MagickEditor } from '../types' /** * React text input props. */ type ReactTextInputProps = { - editor: MagickEditor | null; - value: string; - name: string; - putData: (name: string, value: string) => void; - label?: string; -}; + editor: MagickEditor | null + value: string + name: string + putData: (name: string, value: string) => void + label?: string +} /** * A functional React component used as a control in `TextInputControl`. * It handles rendering and managing state of the text input. */ -const ReactTextInputControl: React.FC = (props) => { +const ReactTextInputControl: React.FC = props => { // Set an initial value to be empty string - const [value, setValue] = useState(''); + const [value, setValue] = useState('') // Update state when properties change useEffect(() => { - setValue(props.value); - props.putData(props.name, props.value); - }, [props]); + setValue(props.value) + props.putData(props.name, props.value) + }, [props]) // Update redux state and local state when user changes input - const onChange = (e) => { - props.putData(props.name, e.target.value); - setValue(e.target.value); // update local state - }; + const onChange = e => { + props.putData(props.name, e.target.value) + setValue(e.target.value) // update local state + } return ( @@ -45,17 +45,17 @@ const ReactTextInputControl: React.FC = (props) => { onChange={onChange} /> - ); -}; + ) +} /** * A custom Rete control for a text input. It extends the Control class * from Rete and provides a renderer for a React component. */ export class TextInputControl extends Control { - render: string; - component: React.FC; - props: ReactTextInputProps; + render: string + component: React.FC + props: ReactTextInputProps /** * Constructor for the custom TextInputControl control. @@ -65,10 +65,20 @@ export class TextInputControl extends Control { * @property {string} param0.value - The initial input value * @property {string} [param0.label] - The label to display with the text input (optional) */ - constructor({ editor, key, value, label = undefined }: { editor: MagickEditor | null; key: string; value: string; label?: string }) { - super(key); - this.render = 'react'; - this.component = ReactTextInputControl; + constructor({ + editor, + key, + value, + label = undefined, + }: { + editor: MagickEditor | null + key: string + value: string + label?: string + }) { + super(key) + this.render = 'react' + this.component = ReactTextInputControl // Define the properties that are passed into the rendered React component this.props = { @@ -77,6 +87,6 @@ export class TextInputControl extends Control { label, value, putData: (key: string, data: unknown) => this.putData(key, data), - }; + } } -} \ No newline at end of file +} diff --git a/packages/core/shared/src/engine.ts b/packages/core/shared/src/engine.ts index 3392d87b30..0a4275986c 100644 --- a/packages/core/shared/src/engine.ts +++ b/packages/core/shared/src/engine.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete, { Node, Engine, NodeData, Plugin } from '@magickml/rete' +import Rete, { Node, Engine, NodeData, Plugin } from 'shared/rete' import io from 'socket.io' import { getLogger } from '@magickml/core' diff --git a/packages/core/shared/src/nodes/array/ArrayToJSON.ts b/packages/core/shared/src/nodes/array/ArrayToJSON.ts index 2bcb5d0162..2c9d5ac856 100644 --- a/packages/core/shared/src/nodes/array/ArrayToJSON.ts +++ b/packages/core/shared/src/nodes/array/ArrayToJSON.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { MagickComponent } from '../../engine' import { arraySocket, stringSocket, triggerSocket } from '../../sockets' diff --git a/packages/core/shared/src/nodes/array/ArrayVariable.ts b/packages/core/shared/src/nodes/array/ArrayVariable.ts index b11024aa3c..1841accdc9 100644 --- a/packages/core/shared/src/nodes/array/ArrayVariable.ts +++ b/packages/core/shared/src/nodes/array/ArrayVariable.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { BooleanControl } from '../../dataControls/BooleanControl' import { InputControl } from '../../dataControls/InputControl' import { MagickComponent } from '../../engine' diff --git a/packages/core/shared/src/nodes/array/ExtractFromArray.ts b/packages/core/shared/src/nodes/array/ExtractFromArray.ts index f3cc4c8108..1a0f1fade3 100644 --- a/packages/core/shared/src/nodes/array/ExtractFromArray.ts +++ b/packages/core/shared/src/nodes/array/ExtractFromArray.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { InputControl } from '../../dataControls/InputControl' import { MagickComponent } from '../../engine' import { arraySocket, triggerSocket } from '../../sockets' diff --git a/packages/core/shared/src/nodes/array/GetValueFromArray.ts b/packages/core/shared/src/nodes/array/GetValueFromArray.ts index 0afdbde616..e9b07d2857 100644 --- a/packages/core/shared/src/nodes/array/GetValueFromArray.ts +++ b/packages/core/shared/src/nodes/array/GetValueFromArray.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { InputControl } from '../../dataControls/InputControl' import { MagickComponent } from '../../engine' import { arraySocket, triggerSocket, anySocket } from '../../sockets' diff --git a/packages/core/shared/src/nodes/array/JSONToArray.ts b/packages/core/shared/src/nodes/array/JSONToArray.ts index 6d8b463bf4..6de2da05aa 100644 --- a/packages/core/shared/src/nodes/array/JSONToArray.ts +++ b/packages/core/shared/src/nodes/array/JSONToArray.ts @@ -2,7 +2,7 @@ /** * Class that represents a node that parses a JSON string into an array */ -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { MagickComponent } from '../../engine' import { arraySocket, stringSocket, triggerSocket } from '../../sockets' diff --git a/packages/core/shared/src/nodes/array/JoinList.ts b/packages/core/shared/src/nodes/array/JoinList.ts index d83880dbc9..93009c6586 100644 --- a/packages/core/shared/src/nodes/array/JoinList.ts +++ b/packages/core/shared/src/nodes/array/JoinList.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { InputControl } from '../../dataControls/InputControl' import { MagickComponent } from '../../engine' import { arraySocket, stringSocket } from '../../sockets' diff --git a/packages/core/shared/src/nodes/array/RemapArray.ts b/packages/core/shared/src/nodes/array/RemapArray.ts index 03a2460f55..72cd4259db 100644 --- a/packages/core/shared/src/nodes/array/RemapArray.ts +++ b/packages/core/shared/src/nodes/array/RemapArray.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { InputControl } from '../../dataControls/InputControl' import { MagickComponent } from '../../engine' import { arraySocket, triggerSocket } from '../../sockets' diff --git a/packages/core/shared/src/nodes/audio/TextToSpeech.ts b/packages/core/shared/src/nodes/audio/TextToSpeech.ts index d4baff2a1a..6e6fb9cec9 100644 --- a/packages/core/shared/src/nodes/audio/TextToSpeech.ts +++ b/packages/core/shared/src/nodes/audio/TextToSpeech.ts @@ -1,5 +1,5 @@ // UNDOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { DropdownControl } from '../../dataControls/DropdownControl' import { MagickComponent } from '../../engine' import { pluginManager } from '../../plugin' diff --git a/packages/core/shared/src/nodes/boolean/BooleanVariable.ts b/packages/core/shared/src/nodes/boolean/BooleanVariable.ts index ead013e11c..cd4dbe02f7 100644 --- a/packages/core/shared/src/nodes/boolean/BooleanVariable.ts +++ b/packages/core/shared/src/nodes/boolean/BooleanVariable.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { BooleanControl } from '../../dataControls/BooleanControl' import { InputControl } from '../../dataControls/InputControl' import { booleanSocket } from '../../sockets' diff --git a/packages/core/shared/src/nodes/boolean/IsVariableTrue.ts b/packages/core/shared/src/nodes/boolean/IsVariableTrue.ts index aa996294d8..53442b5597 100644 --- a/packages/core/shared/src/nodes/boolean/IsVariableTrue.ts +++ b/packages/core/shared/src/nodes/boolean/IsVariableTrue.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { MagickComponent } from '../../engine' import { anySocket, triggerSocket } from '../../sockets' diff --git a/packages/core/shared/src/nodes/boolean/LogicalOperator.ts b/packages/core/shared/src/nodes/boolean/LogicalOperator.ts index d13e32746d..e7233a14fd 100644 --- a/packages/core/shared/src/nodes/boolean/LogicalOperator.ts +++ b/packages/core/shared/src/nodes/boolean/LogicalOperator.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { NumberControl } from '../../dataControls/NumberControl' import { MagickComponent } from '../../engine' diff --git a/packages/core/shared/src/nodes/code/Javascript.ts b/packages/core/shared/src/nodes/code/Javascript.ts index f8b98d5ade..d1804630e4 100644 --- a/packages/core/shared/src/nodes/code/Javascript.ts +++ b/packages/core/shared/src/nodes/code/Javascript.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { CodeControl } from '../../dataControls/CodeControl' import { InputControl } from '../../dataControls/InputControl' diff --git a/packages/core/shared/src/nodes/code/Python.ts b/packages/core/shared/src/nodes/code/Python.ts index 8192c895f3..f6787112bd 100644 --- a/packages/core/shared/src/nodes/code/Python.ts +++ b/packages/core/shared/src/nodes/code/Python.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { CodeControl } from '../../dataControls/CodeControl' import { InputControl } from '../../dataControls/InputControl' diff --git a/packages/core/shared/src/nodes/database/Delete.ts b/packages/core/shared/src/nodes/database/Delete.ts index 7aba7d3cf9..43c14329b7 100644 --- a/packages/core/shared/src/nodes/database/Delete.ts +++ b/packages/core/shared/src/nodes/database/Delete.ts @@ -1,5 +1,5 @@ // UNDOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { DropdownControl } from '../../dataControls/DropdownControl' import { MagickComponent } from '../../engine' import { pluginManager } from '../../plugin' diff --git a/packages/core/shared/src/nodes/database/Insert.ts b/packages/core/shared/src/nodes/database/Insert.ts index 2a7b965646..843cec2982 100644 --- a/packages/core/shared/src/nodes/database/Insert.ts +++ b/packages/core/shared/src/nodes/database/Insert.ts @@ -1,5 +1,5 @@ // UNDOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { DropdownControl } from '../../dataControls/DropdownControl' import { MagickComponent } from '../../engine' import { pluginManager } from '../../plugin' diff --git a/packages/core/shared/src/nodes/database/Select.ts b/packages/core/shared/src/nodes/database/Select.ts index fc585aca75..e9b517528f 100644 --- a/packages/core/shared/src/nodes/database/Select.ts +++ b/packages/core/shared/src/nodes/database/Select.ts @@ -1,5 +1,5 @@ // UNDOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { DropdownControl } from '../../dataControls/DropdownControl' import { MagickComponent } from '../../engine' import { pluginManager } from '../../plugin' diff --git a/packages/core/shared/src/nodes/database/Update.ts b/packages/core/shared/src/nodes/database/Update.ts index f4e7a16192..0f531a2873 100644 --- a/packages/core/shared/src/nodes/database/Update.ts +++ b/packages/core/shared/src/nodes/database/Update.ts @@ -1,5 +1,5 @@ // UNDOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { DropdownControl } from '../../dataControls/DropdownControl' import { MagickComponent } from '../../engine' import { pluginManager } from '../../plugin' diff --git a/packages/core/shared/src/nodes/database/Upsert.ts b/packages/core/shared/src/nodes/database/Upsert.ts index 6903f60419..1bcd0bf7ba 100644 --- a/packages/core/shared/src/nodes/database/Upsert.ts +++ b/packages/core/shared/src/nodes/database/Upsert.ts @@ -1,5 +1,5 @@ // UNDOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { DropdownControl } from '../../dataControls/DropdownControl' import { MagickComponent } from '../../engine' import { pluginManager } from '../../plugin' diff --git a/packages/core/shared/src/nodes/document/DocumentToContent.ts b/packages/core/shared/src/nodes/document/DocumentToContent.ts index b3a44eaa8b..691c936483 100644 --- a/packages/core/shared/src/nodes/document/DocumentToContent.ts +++ b/packages/core/shared/src/nodes/document/DocumentToContent.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { MagickComponent } from '../../engine' import { documentSocket, stringSocket, triggerSocket } from '../../sockets' diff --git a/packages/core/shared/src/nodes/document/GetDocuments.ts b/packages/core/shared/src/nodes/document/GetDocuments.ts index 2a16270fb0..01f839c571 100644 --- a/packages/core/shared/src/nodes/document/GetDocuments.ts +++ b/packages/core/shared/src/nodes/document/GetDocuments.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { InputControl } from '../../dataControls/InputControl' import { MagickComponent } from '../../engine' import { diff --git a/packages/core/shared/src/nodes/document/StoreDocument.ts b/packages/core/shared/src/nodes/document/StoreDocument.ts index 02efa98dee..68b7e2ec7f 100644 --- a/packages/core/shared/src/nodes/document/StoreDocument.ts +++ b/packages/core/shared/src/nodes/document/StoreDocument.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { InputControl } from '../../dataControls/InputControl' import { MagickComponent } from '../../engine' diff --git a/packages/core/shared/src/nodes/embedding/CosineSimilarity.ts b/packages/core/shared/src/nodes/embedding/CosineSimilarity.ts index 8255fa1c67..8c772a93fa 100644 --- a/packages/core/shared/src/nodes/embedding/CosineSimilarity.ts +++ b/packages/core/shared/src/nodes/embedding/CosineSimilarity.ts @@ -3,7 +3,7 @@ * Computes the cosine similarity between two embeddings. */ import similarity from 'compute-cosine-similarity' -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { MagickComponent } from '../../engine' import { embeddingSocket, numberSocket, triggerSocket } from '../../sockets' import { diff --git a/packages/core/shared/src/nodes/embedding/CreateTextEmbedding.ts b/packages/core/shared/src/nodes/embedding/CreateTextEmbedding.ts index 2718b64bd9..e3b17f475f 100644 --- a/packages/core/shared/src/nodes/embedding/CreateTextEmbedding.ts +++ b/packages/core/shared/src/nodes/embedding/CreateTextEmbedding.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { DropdownControl } from '../../dataControls/DropdownControl' import { MagickComponent } from '../../engine' diff --git a/packages/core/shared/src/nodes/embedding/ExtractRelationship.ts b/packages/core/shared/src/nodes/embedding/ExtractRelationship.ts index 091565759b..bf23fa2cf9 100644 --- a/packages/core/shared/src/nodes/embedding/ExtractRelationship.ts +++ b/packages/core/shared/src/nodes/embedding/ExtractRelationship.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { MagickComponent } from '../../engine' import { embeddingSocket, triggerSocket } from '../../sockets' diff --git a/packages/core/shared/src/nodes/embedding/FindTextEmbedding.ts b/packages/core/shared/src/nodes/embedding/FindTextEmbedding.ts index 0ebded2575..d54563d743 100644 --- a/packages/core/shared/src/nodes/embedding/FindTextEmbedding.ts +++ b/packages/core/shared/src/nodes/embedding/FindTextEmbedding.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { MagickComponent } from '../../engine' import { embeddingSocket, stringSocket, triggerSocket } from '../../sockets' diff --git a/packages/core/shared/src/nodes/events/EventDelete.ts b/packages/core/shared/src/nodes/events/EventDelete.ts index dc699509b3..142db213d7 100644 --- a/packages/core/shared/src/nodes/events/EventDelete.ts +++ b/packages/core/shared/src/nodes/events/EventDelete.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { MagickComponent } from '../../engine' import { objectSocket, triggerSocket } from '../../sockets' import { MagickNode, MagickWorkerInputs, WorkerData } from '../../types' diff --git a/packages/core/shared/src/nodes/events/EventDestructure.ts b/packages/core/shared/src/nodes/events/EventDestructure.ts index ae830717b8..013ab4baee 100644 --- a/packages/core/shared/src/nodes/events/EventDestructure.ts +++ b/packages/core/shared/src/nodes/events/EventDestructure.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { v4 as uuidv4 } from 'uuid' import { MagickComponent } from '../../engine' diff --git a/packages/core/shared/src/nodes/events/EventRecall.ts b/packages/core/shared/src/nodes/events/EventRecall.ts index f7bc2acbf1..924e5686d8 100644 --- a/packages/core/shared/src/nodes/events/EventRecall.ts +++ b/packages/core/shared/src/nodes/events/EventRecall.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { InputControl } from '../../dataControls/InputControl' import { MagickComponent } from '../../engine' import { diff --git a/packages/core/shared/src/nodes/events/EventRestructure.ts b/packages/core/shared/src/nodes/events/EventRestructure.ts index 19d069aced..1eb962141e 100644 --- a/packages/core/shared/src/nodes/events/EventRestructure.ts +++ b/packages/core/shared/src/nodes/events/EventRestructure.ts @@ -5,7 +5,7 @@ * @version 1.0.0 */ -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { v4 as uuidv4 } from 'uuid' import { MagickComponent } from '../../engine' import { diff --git a/packages/core/shared/src/nodes/events/EventStore.ts b/packages/core/shared/src/nodes/events/EventStore.ts index 0229ad8101..4f4abf3a41 100644 --- a/packages/core/shared/src/nodes/events/EventStore.ts +++ b/packages/core/shared/src/nodes/events/EventStore.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { InputControl } from '../../dataControls/InputControl' import { MagickComponent } from '../../engine' import { diff --git a/packages/core/shared/src/nodes/events/EventsToConversation.ts b/packages/core/shared/src/nodes/events/EventsToConversation.ts index 1ec7656ac4..5e2ba59c28 100644 --- a/packages/core/shared/src/nodes/events/EventsToConversation.ts +++ b/packages/core/shared/src/nodes/events/EventsToConversation.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { MagickComponent } from '../../engine' import { arraySocket, stringSocket, triggerSocket } from '../../sockets' diff --git a/packages/core/shared/src/nodes/flow/BooleanGate.ts b/packages/core/shared/src/nodes/flow/BooleanGate.ts index b68411a5c6..0f032a44a7 100644 --- a/packages/core/shared/src/nodes/flow/BooleanGate.ts +++ b/packages/core/shared/src/nodes/flow/BooleanGate.ts @@ -2,7 +2,7 @@ /** * This component represents a boolean gate. It takes a boolean input, and depending on whether the value is true or false will only trigger one output or the other. */ -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { MagickComponent } from '../../engine' import { booleanSocket, triggerSocket } from '../../sockets' import { MagickNode, MagickWorkerInputs, WorkerData } from '../../types' diff --git a/packages/core/shared/src/nodes/flow/CommandParser.ts b/packages/core/shared/src/nodes/flow/CommandParser.ts index 64519185b2..5ec431d931 100644 --- a/packages/core/shared/src/nodes/flow/CommandParser.ts +++ b/packages/core/shared/src/nodes/flow/CommandParser.ts @@ -1,5 +1,5 @@ // UNDOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { MagickComponent } from '../../engine' import { arraySocket, diff --git a/packages/core/shared/src/nodes/flow/ExclusiveGate.ts b/packages/core/shared/src/nodes/flow/ExclusiveGate.ts index b9ab486ded..6978963b58 100644 --- a/packages/core/shared/src/nodes/flow/ExclusiveGate.ts +++ b/packages/core/shared/src/nodes/flow/ExclusiveGate.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { MultiSocketGeneratorControl } from '../../dataControls/MultiSocketGenerator' import { MagickComponent } from '../../engine' diff --git a/packages/core/shared/src/nodes/flow/IsNullOrUndefined.ts b/packages/core/shared/src/nodes/flow/IsNullOrUndefined.ts index 8ef104b97c..74ac4cc946 100644 --- a/packages/core/shared/src/nodes/flow/IsNullOrUndefined.ts +++ b/packages/core/shared/src/nodes/flow/IsNullOrUndefined.ts @@ -4,7 +4,7 @@ * @class * @extends {MagickComponent} */ -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { MagickComponent } from '../../engine' import { anySocket, triggerSocket } from '../../sockets' diff --git a/packages/core/shared/src/nodes/flow/OrGate.ts b/packages/core/shared/src/nodes/flow/OrGate.ts index 3889d2f220..dd7b7e5942 100644 --- a/packages/core/shared/src/nodes/flow/OrGate.ts +++ b/packages/core/shared/src/nodes/flow/OrGate.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { MagickComponent } from '../../engine' import { triggerSocket } from '../../sockets' diff --git a/packages/core/shared/src/nodes/flow/RandomGate.ts b/packages/core/shared/src/nodes/flow/RandomGate.ts index 656b1109a4..72783d288c 100644 --- a/packages/core/shared/src/nodes/flow/RandomGate.ts +++ b/packages/core/shared/src/nodes/flow/RandomGate.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { SocketGeneratorControl } from '../../dataControls/SocketGenerator' import { MagickComponent } from '../../engine' import { triggerSocket } from '../../sockets' diff --git a/packages/core/shared/src/nodes/flow/SwitchGate.ts b/packages/core/shared/src/nodes/flow/SwitchGate.ts index 7c9a1f364b..4625e94357 100644 --- a/packages/core/shared/src/nodes/flow/SwitchGate.ts +++ b/packages/core/shared/src/nodes/flow/SwitchGate.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { SocketGeneratorControl } from '../../dataControls/SocketGenerator' import { MagickComponent } from '../../engine' diff --git a/packages/core/shared/src/nodes/flow/WaitForAll.ts b/packages/core/shared/src/nodes/flow/WaitForAll.ts index 82307b9304..ff5708f744 100644 --- a/packages/core/shared/src/nodes/flow/WaitForAll.ts +++ b/packages/core/shared/src/nodes/flow/WaitForAll.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { SocketGeneratorControl } from '../../dataControls/SocketGenerator' import { MagickComponent } from '../../engine' diff --git a/packages/core/shared/src/nodes/io/Input.ts b/packages/core/shared/src/nodes/io/Input.ts index 851d343fc7..3c49a2d792 100644 --- a/packages/core/shared/src/nodes/io/Input.ts +++ b/packages/core/shared/src/nodes/io/Input.ts @@ -1,6 +1,6 @@ // DOCUMENTED import { isEmpty } from 'lodash' -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { v4 as uuidv4 } from 'uuid' import { DropdownControl } from '../../dataControls/DropdownControl' diff --git a/packages/core/shared/src/nodes/io/JupyterNotebook.ts b/packages/core/shared/src/nodes/io/JupyterNotebook.ts index b86fa39bb9..1c1c1648be 100644 --- a/packages/core/shared/src/nodes/io/JupyterNotebook.ts +++ b/packages/core/shared/src/nodes/io/JupyterNotebook.ts @@ -1,6 +1,6 @@ // DOCUMENTED import axios from 'axios' -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { InputControl } from '../../dataControls/InputControl' import { SocketGeneratorControl } from '../../dataControls/SocketGenerator' diff --git a/packages/core/shared/src/nodes/io/Output.ts b/packages/core/shared/src/nodes/io/Output.ts index f7f8d1c9a8..040c6f650a 100644 --- a/packages/core/shared/src/nodes/io/Output.ts +++ b/packages/core/shared/src/nodes/io/Output.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { v4 as uuidv4 } from 'uuid' import { DropdownControl } from '../../dataControls/DropdownControl' diff --git a/packages/core/shared/src/nodes/io/Request.ts b/packages/core/shared/src/nodes/io/Request.ts index 3896ca7813..054895d5a5 100644 --- a/packages/core/shared/src/nodes/io/Request.ts +++ b/packages/core/shared/src/nodes/io/Request.ts @@ -1,6 +1,6 @@ // DOCUMENTED import axios, { AxiosResponse } from 'axios' -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { API_ROOT_URL } from '@magickml/config' import { InputControl } from '../../dataControls/InputControl' diff --git a/packages/core/shared/src/nodes/io/Respond.ts b/packages/core/shared/src/nodes/io/Respond.ts index a01cbd3a28..04dd1cc5f9 100644 --- a/packages/core/shared/src/nodes/io/Respond.ts +++ b/packages/core/shared/src/nodes/io/Respond.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { v4 as uuidv4 } from 'uuid' import { MagickComponent } from '../../engine' diff --git a/packages/core/shared/src/nodes/io/Skill.ts b/packages/core/shared/src/nodes/io/Skill.ts index 82864475d0..53974d9146 100644 --- a/packages/core/shared/src/nodes/io/Skill.ts +++ b/packages/core/shared/src/nodes/io/Skill.ts @@ -1,4 +1,4 @@ -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { MagickComponent } from '../../engine' import { UpdateModuleSockets } from '../../plugins/modulePlugin' import { stringSocket, taskSocket, triggerSocket } from '../../sockets' diff --git a/packages/core/shared/src/nodes/io/Spell.ts b/packages/core/shared/src/nodes/io/Spell.ts index 8c578264cb..9b8c603e62 100644 --- a/packages/core/shared/src/nodes/io/Spell.ts +++ b/packages/core/shared/src/nodes/io/Spell.ts @@ -1,5 +1,5 @@ import isEqual from 'lodash/isEqual' -import Rete, { Data } from '@magickml/rete' +import Rete, { Data } from 'shared/rete' import { BooleanControl } from '../../dataControls/BooleanControl' import { FewshotControl } from '../../dataControls/FewshotControl' diff --git a/packages/core/shared/src/nodes/io/SpellByName.ts b/packages/core/shared/src/nodes/io/SpellByName.ts index 3cc9f3a189..39887f7ccb 100644 --- a/packages/core/shared/src/nodes/io/SpellByName.ts +++ b/packages/core/shared/src/nodes/io/SpellByName.ts @@ -1,4 +1,4 @@ -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { MagickComponent } from '../../engine' import { UpdateModuleSockets } from '../../plugins/modulePlugin' import { diff --git a/packages/core/shared/src/nodes/magick/runSpell.ts b/packages/core/shared/src/nodes/magick/runSpell.ts index 514896a954..1e04e07a95 100644 --- a/packages/core/shared/src/nodes/magick/runSpell.ts +++ b/packages/core/shared/src/nodes/magick/runSpell.ts @@ -3,7 +3,7 @@ * A simple rete component that returns the same output as the input. * @category Utility */ -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { MagickComponent } from '../../engine' import { objectSocket, stringSocket, triggerSocket } from '../../sockets' diff --git a/packages/core/shared/src/nodes/number/Add.ts b/packages/core/shared/src/nodes/number/Add.ts index 9848df2590..3e17a88b71 100644 --- a/packages/core/shared/src/nodes/number/Add.ts +++ b/packages/core/shared/src/nodes/number/Add.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { InputControl } from '../../dataControls/InputControl' import { MagickComponent } from '../../engine' diff --git a/packages/core/shared/src/nodes/number/Divide.ts b/packages/core/shared/src/nodes/number/Divide.ts index 98c0ff3b4b..351506ce8b 100644 --- a/packages/core/shared/src/nodes/number/Divide.ts +++ b/packages/core/shared/src/nodes/number/Divide.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { InputControl } from '../../dataControls/InputControl' import { MagickComponent } from '../../engine' diff --git a/packages/core/shared/src/nodes/number/Equal.ts b/packages/core/shared/src/nodes/number/Equal.ts index 863c6b0e6d..3eaa5dcd60 100644 --- a/packages/core/shared/src/nodes/number/Equal.ts +++ b/packages/core/shared/src/nodes/number/Equal.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { InputControl } from '../../dataControls/InputControl' import { MagickComponent } from '../../engine' diff --git a/packages/core/shared/src/nodes/number/GreaterThan.ts b/packages/core/shared/src/nodes/number/GreaterThan.ts index 10ab112fbe..269ee96beb 100644 --- a/packages/core/shared/src/nodes/number/GreaterThan.ts +++ b/packages/core/shared/src/nodes/number/GreaterThan.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { InputControl } from '../../dataControls/InputControl' import { MagickComponent } from '../../engine' diff --git a/packages/core/shared/src/nodes/number/GreaterThanOrEqual.ts b/packages/core/shared/src/nodes/number/GreaterThanOrEqual.ts index 377e56711b..18f20ed2ec 100644 --- a/packages/core/shared/src/nodes/number/GreaterThanOrEqual.ts +++ b/packages/core/shared/src/nodes/number/GreaterThanOrEqual.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { InputControl } from '../../dataControls/InputControl' import { MagickComponent } from '../../engine' diff --git a/packages/core/shared/src/nodes/number/InRange.ts b/packages/core/shared/src/nodes/number/InRange.ts index 11d948c843..511e5786db 100644 --- a/packages/core/shared/src/nodes/number/InRange.ts +++ b/packages/core/shared/src/nodes/number/InRange.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { InputControl } from '../../dataControls/InputControl' import { MagickComponent } from '../../engine' diff --git a/packages/core/shared/src/nodes/number/IsANumber.ts b/packages/core/shared/src/nodes/number/IsANumber.ts index f87ec9572a..aff7a13829 100644 --- a/packages/core/shared/src/nodes/number/IsANumber.ts +++ b/packages/core/shared/src/nodes/number/IsANumber.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { MagickComponent } from '../../engine' import { anySocket, triggerSocket } from '../../sockets' diff --git a/packages/core/shared/src/nodes/number/LessThan.ts b/packages/core/shared/src/nodes/number/LessThan.ts index c156f73552..e2c3c4bcca 100644 --- a/packages/core/shared/src/nodes/number/LessThan.ts +++ b/packages/core/shared/src/nodes/number/LessThan.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { InputControl } from '../../dataControls/InputControl' import { MagickComponent } from '../../engine' diff --git a/packages/core/shared/src/nodes/number/LessThanOrEqual.ts b/packages/core/shared/src/nodes/number/LessThanOrEqual.ts index 4f0597228d..b16294e0bb 100644 --- a/packages/core/shared/src/nodes/number/LessThanOrEqual.ts +++ b/packages/core/shared/src/nodes/number/LessThanOrEqual.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { InputControl } from '../../dataControls/InputControl' import { MagickComponent } from '../../engine' diff --git a/packages/core/shared/src/nodes/number/Multiply.ts b/packages/core/shared/src/nodes/number/Multiply.ts index 116770fc07..c72cfefab7 100644 --- a/packages/core/shared/src/nodes/number/Multiply.ts +++ b/packages/core/shared/src/nodes/number/Multiply.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { InputControl } from '../../dataControls/InputControl' import { MagickComponent } from '../../engine' diff --git a/packages/core/shared/src/nodes/number/NumberVariable.ts b/packages/core/shared/src/nodes/number/NumberVariable.ts index 3267327aa2..6958d4de99 100644 --- a/packages/core/shared/src/nodes/number/NumberVariable.ts +++ b/packages/core/shared/src/nodes/number/NumberVariable.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { BooleanControl } from '../../dataControls/BooleanControl' import { InputControl } from '../../dataControls/InputControl' diff --git a/packages/core/shared/src/nodes/number/Subtract.ts b/packages/core/shared/src/nodes/number/Subtract.ts index 66bcad95f8..74b7471054 100644 --- a/packages/core/shared/src/nodes/number/Subtract.ts +++ b/packages/core/shared/src/nodes/number/Subtract.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { InputControl } from '../../dataControls/InputControl' import { MagickComponent } from '../../engine' diff --git a/packages/core/shared/src/nodes/object/ComposeObject.ts b/packages/core/shared/src/nodes/object/ComposeObject.ts index 2e0c63aef7..02977376f5 100644 --- a/packages/core/shared/src/nodes/object/ComposeObject.ts +++ b/packages/core/shared/src/nodes/object/ComposeObject.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { SocketGeneratorControl } from '../../dataControls/SocketGenerator' import { MagickComponent } from '../../engine' import { objectSocket, triggerSocket } from '../../sockets' diff --git a/packages/core/shared/src/nodes/object/GetValuesFromObject.ts b/packages/core/shared/src/nodes/object/GetValuesFromObject.ts index c78bba3dbc..f94827489b 100644 --- a/packages/core/shared/src/nodes/object/GetValuesFromObject.ts +++ b/packages/core/shared/src/nodes/object/GetValuesFromObject.ts @@ -3,7 +3,7 @@ * @fileoverview The Destructure component allows you to destructure properties out of an object. */ -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { MagickComponent } from '../../engine' import { TaskOptions } from '../../plugins/taskPlugin/task' import { objectSocket, triggerSocket } from '../../sockets' diff --git a/packages/core/shared/src/nodes/object/JSONToObject.ts b/packages/core/shared/src/nodes/object/JSONToObject.ts index 771e986794..180958b295 100644 --- a/packages/core/shared/src/nodes/object/JSONToObject.ts +++ b/packages/core/shared/src/nodes/object/JSONToObject.ts @@ -2,7 +2,7 @@ /** * Class that represents a node that parses a JSON string into an Object */ -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { MagickComponent } from '../../engine' import { objectSocket, stringSocket, triggerSocket } from '../../sockets' diff --git a/packages/core/shared/src/nodes/object/MergeObjects.ts b/packages/core/shared/src/nodes/object/MergeObjects.ts index 124a7ac399..a8c523e9f2 100644 --- a/packages/core/shared/src/nodes/object/MergeObjects.ts +++ b/packages/core/shared/src/nodes/object/MergeObjects.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { InputControl } from '../../dataControls/InputControl' import { SocketGeneratorControl } from '../../dataControls/SocketGenerator' diff --git a/packages/core/shared/src/nodes/object/ObjectToJSON.ts b/packages/core/shared/src/nodes/object/ObjectToJSON.ts index 3ebef5cca1..d70860dcc6 100644 --- a/packages/core/shared/src/nodes/object/ObjectToJSON.ts +++ b/packages/core/shared/src/nodes/object/ObjectToJSON.ts @@ -2,7 +2,7 @@ /** * Represents a Rete object-to-JSON conversion component. */ -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { MagickComponent } from '../../engine' import { objectSocket, stringSocket, triggerSocket } from '../../sockets' diff --git a/packages/core/shared/src/nodes/text/CombineText.ts b/packages/core/shared/src/nodes/text/CombineText.ts index ed4f0e02fa..15b7b32fd3 100644 --- a/packages/core/shared/src/nodes/text/CombineText.ts +++ b/packages/core/shared/src/nodes/text/CombineText.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { InputControl } from '../../dataControls/InputControl' import { SocketGeneratorControl } from '../../dataControls/SocketGenerator' diff --git a/packages/core/shared/src/nodes/text/ComplexStringMatcher.ts b/packages/core/shared/src/nodes/text/ComplexStringMatcher.ts index 103f709c5a..6a8da8b06b 100644 --- a/packages/core/shared/src/nodes/text/ComplexStringMatcher.ts +++ b/packages/core/shared/src/nodes/text/ComplexStringMatcher.ts @@ -1,4 +1,4 @@ -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { InputControl } from '../../dataControls/InputControl' import { MagickComponent } from '../../engine' diff --git a/packages/core/shared/src/nodes/text/EvaluateText.ts b/packages/core/shared/src/nodes/text/EvaluateText.ts index 0bf008f282..5fdca92923 100644 --- a/packages/core/shared/src/nodes/text/EvaluateText.ts +++ b/packages/core/shared/src/nodes/text/EvaluateText.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { FewshotControl } from '../../dataControls/FewshotControl' import { MagickComponent } from '../../engine' import { stringSocket, triggerSocket } from '../../sockets' diff --git a/packages/core/shared/src/nodes/text/GenerateText.ts b/packages/core/shared/src/nodes/text/GenerateText.ts index 547052ebbc..dd2253f00c 100644 --- a/packages/core/shared/src/nodes/text/GenerateText.ts +++ b/packages/core/shared/src/nodes/text/GenerateText.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { DropdownControl } from '../../dataControls/DropdownControl' import { MagickComponent } from '../../engine' import { pluginManager } from '../../plugin' diff --git a/packages/core/shared/src/nodes/text/GenerateUUID.ts b/packages/core/shared/src/nodes/text/GenerateUUID.ts index 3a46dc995c..e5dbc21920 100644 --- a/packages/core/shared/src/nodes/text/GenerateUUID.ts +++ b/packages/core/shared/src/nodes/text/GenerateUUID.ts @@ -4,7 +4,7 @@ * This component generates a UUID v4. */ -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { v4 as uuidv4 } from 'uuid' import { MagickComponent } from '../../engine' import { stringSocket } from '../../sockets' diff --git a/packages/core/shared/src/nodes/text/GetLength.ts b/packages/core/shared/src/nodes/text/GetLength.ts index 2488199362..19df3fee79 100644 --- a/packages/core/shared/src/nodes/text/GetLength.ts +++ b/packages/core/shared/src/nodes/text/GetLength.ts @@ -3,7 +3,7 @@ * Get the length of the input string. * @category Text */ -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { MagickComponent } from '../../engine' import { numberSocket, stringSocket, triggerSocket } from '../../sockets' diff --git a/packages/core/shared/src/nodes/text/ProfanityFilter.ts b/packages/core/shared/src/nodes/text/ProfanityFilter.ts index 32aefa1500..87f9f14560 100644 --- a/packages/core/shared/src/nodes/text/ProfanityFilter.ts +++ b/packages/core/shared/src/nodes/text/ProfanityFilter.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { hasBadWords } from 'expletives' import { MagickComponent } from '../../engine' diff --git a/packages/core/shared/src/nodes/text/RegularExpression.ts b/packages/core/shared/src/nodes/text/RegularExpression.ts index f0c280d296..e1e7b65a1c 100644 --- a/packages/core/shared/src/nodes/text/RegularExpression.ts +++ b/packages/core/shared/src/nodes/text/RegularExpression.ts @@ -4,7 +4,7 @@ * This component replaces a string with another in the input. */ -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { InputControl } from '../../dataControls/InputControl' import { MagickComponent } from '../../engine' diff --git a/packages/core/shared/src/nodes/text/ReplaceText.ts b/packages/core/shared/src/nodes/text/ReplaceText.ts index e1c8d0410a..9ee4237ec9 100644 --- a/packages/core/shared/src/nodes/text/ReplaceText.ts +++ b/packages/core/shared/src/nodes/text/ReplaceText.ts @@ -4,7 +4,7 @@ * This component replaces a string with another in the input. */ -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { InputControl } from '../../dataControls/InputControl' import { MagickComponent } from '../../engine' diff --git a/packages/core/shared/src/nodes/text/SplitBySentence.ts b/packages/core/shared/src/nodes/text/SplitBySentence.ts index 2657356ac9..6fdee7fdf0 100644 --- a/packages/core/shared/src/nodes/text/SplitBySentence.ts +++ b/packages/core/shared/src/nodes/text/SplitBySentence.ts @@ -3,7 +3,7 @@ * Split a long body of text into multiple strings, each of which is no longer than the specified length. * @category Text */ -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { split } from 'sentence-splitter' import { MagickComponent } from '../../engine' diff --git a/packages/core/shared/src/nodes/text/StringVariable.ts b/packages/core/shared/src/nodes/text/StringVariable.ts index f8b486f9b5..f2cf611625 100644 --- a/packages/core/shared/src/nodes/text/StringVariable.ts +++ b/packages/core/shared/src/nodes/text/StringVariable.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { BooleanControl } from '../../dataControls/BooleanControl' import { InputControl } from '../../dataControls/InputControl' diff --git a/packages/core/shared/src/nodes/text/TextTemplate.ts b/packages/core/shared/src/nodes/text/TextTemplate.ts index 9c4c482028..7952ce307c 100644 --- a/packages/core/shared/src/nodes/text/TextTemplate.ts +++ b/packages/core/shared/src/nodes/text/TextTemplate.ts @@ -1,6 +1,6 @@ // DOCUMENTED import Handlebars from 'handlebars' -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { FewshotControl } from '../../dataControls/FewshotControl' import { SocketGeneratorControl } from '../../dataControls/SocketGenerator' import { MagickComponent } from '../../engine' diff --git a/packages/core/shared/src/nodes/text/TextVariable.ts b/packages/core/shared/src/nodes/text/TextVariable.ts index a19bb543cd..fdd599071b 100644 --- a/packages/core/shared/src/nodes/text/TextVariable.ts +++ b/packages/core/shared/src/nodes/text/TextVariable.ts @@ -5,7 +5,7 @@ */ /* eslint-disable @typescript-eslint/no-unused-vars */ -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { BooleanControl } from '../../dataControls/BooleanControl' import { FewshotControl } from '../../dataControls/FewshotControl' diff --git a/packages/core/shared/src/nodes/text/Trim.ts b/packages/core/shared/src/nodes/text/Trim.ts index 066fc2a541..ee069054c3 100644 --- a/packages/core/shared/src/nodes/text/Trim.ts +++ b/packages/core/shared/src/nodes/text/Trim.ts @@ -3,7 +3,7 @@ * A simple rete component that returns the same output as the input. * @category Utility */ -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { MagickComponent } from '../../engine' import { stringSocket, triggerSocket } from '../../sockets' diff --git a/packages/core/shared/src/nodes/text/TypeChat.ts b/packages/core/shared/src/nodes/text/TypeChat.ts index e971a639fc..a39b9f8993 100644 --- a/packages/core/shared/src/nodes/text/TypeChat.ts +++ b/packages/core/shared/src/nodes/text/TypeChat.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { DropdownControl } from '../../dataControls/DropdownControl' import { MagickComponent } from '../../engine' import { pluginManager } from '../../plugin' diff --git a/packages/core/shared/src/nodes/utility/AlertMessage.ts b/packages/core/shared/src/nodes/utility/AlertMessage.ts index 79fdde3ee6..1f614f3cc2 100644 --- a/packages/core/shared/src/nodes/utility/AlertMessage.ts +++ b/packages/core/shared/src/nodes/utility/AlertMessage.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import * as Rete from '@magickml/rete' // Use `* as` for consistent import style +import * as Rete from 'shared/rete' // Use `* as` for consistent import style import * as _ from 'lodash' // Use `* as` for consistent import style import { TextInputControl } from '../../dataControls/TextInputControl' import { MagickComponent } from '../../engine' diff --git a/packages/core/shared/src/nodes/utility/Cast.ts b/packages/core/shared/src/nodes/utility/Cast.ts index 4275c3ba56..b90d601de5 100644 --- a/packages/core/shared/src/nodes/utility/Cast.ts +++ b/packages/core/shared/src/nodes/utility/Cast.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { DropdownControl } from '../../dataControls/DropdownControl' import { MagickComponent } from '../../engine' import * as sockets from '../../sockets' diff --git a/packages/core/shared/src/nodes/utility/CurrentTime.ts b/packages/core/shared/src/nodes/utility/CurrentTime.ts index ebde3c6623..7d9ef772d5 100644 --- a/packages/core/shared/src/nodes/utility/CurrentTime.ts +++ b/packages/core/shared/src/nodes/utility/CurrentTime.ts @@ -3,7 +3,7 @@ * A simple rete component that returns the same output as the input. * @category Utility */ -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { MagickComponent } from '../../engine' import { numberSocket, stringSocket, triggerSocket } from '../../sockets' diff --git a/packages/core/shared/src/nodes/utility/Echo.ts b/packages/core/shared/src/nodes/utility/Echo.ts index 27b3acdf2b..3a27c35a9f 100644 --- a/packages/core/shared/src/nodes/utility/Echo.ts +++ b/packages/core/shared/src/nodes/utility/Echo.ts @@ -3,7 +3,7 @@ * A simple rete component that returns the same output as the input. * @category Utility */ -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { MagickComponent } from '../../engine' import { anySocket, triggerSocket } from '../../sockets' diff --git a/packages/core/shared/src/nodes/utility/Error.ts b/packages/core/shared/src/nodes/utility/Error.ts index 14a9609693..28b276d8c2 100644 --- a/packages/core/shared/src/nodes/utility/Error.ts +++ b/packages/core/shared/src/nodes/utility/Error.ts @@ -3,7 +3,7 @@ * A simple rete component that returns the same output as the input. * @category Utility */ -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { MagickComponent } from '../../engine' import { stringSocket, triggerSocket } from '../../sockets' diff --git a/packages/core/shared/src/nodes/utility/Log.ts b/packages/core/shared/src/nodes/utility/Log.ts index 642d84ce82..363d7314dd 100644 --- a/packages/core/shared/src/nodes/utility/Log.ts +++ b/packages/core/shared/src/nodes/utility/Log.ts @@ -2,7 +2,7 @@ /** * Logs a value to the console. */ -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { InputControl } from '../../dataControls/InputControl' import { MagickComponent } from '../../engine' diff --git a/packages/core/shared/src/plugins/cachePlugin/RunLastArguments.tsx b/packages/core/shared/src/plugins/cachePlugin/RunLastArguments.tsx index 2c000687df..87d80c1adc 100644 --- a/packages/core/shared/src/plugins/cachePlugin/RunLastArguments.tsx +++ b/packages/core/shared/src/plugins/cachePlugin/RunLastArguments.tsx @@ -1,21 +1,21 @@ -// DOCUMENTED -import React from 'react'; -import { Control } from '@magickml/rete'; +// DOCUMENTED +import React from 'react' +import { Control } from 'shared/rete' /** * React component for the run button. * @param {Object} props - The properties passed to the component. * @returns {JSX.Element} - The rendered react component. */ -const ReactRunButton = (props) => { +const ReactRunButton = props => { /** * Button click handler for running the function. */ const onButtonClick = async () => { - const nodeData = props.getNode().toJSON(); - const value = await props.run(nodeData); - console.log('Run with last arguments', value); - }; + const nodeData = props.getNode().toJSON() + const value = await props.run(nodeData) + console.log('Run with last arguments', value) + } return ( - ); -}; + ) +} /** * Class representing the RunButtonControl component. * @extends Control */ export class RunButtonControl extends Control { - render: string; - component: (props: any) => JSX.Element; - props: any; + render: string + component: (props: any) => JSX.Element + props: any /** * Creates a new RunButtonControl instance. * @param {Object} param0 - The options for the control. @@ -43,16 +43,16 @@ export class RunButtonControl extends Control { * @param {Function} param0.run - The function to be run by the control. */ constructor({ key, run }) { - super(key); - this.render = 'react'; - this.key = key; - this.component = ReactRunButton; + super(key) + this.render = 'react' + this.key = key + this.component = ReactRunButton // Define the props that are passed into the rendered react component. this.props = { run, getNode: this.getNode.bind(this), - }; + } } /** @@ -60,6 +60,6 @@ export class RunButtonControl extends Control { * @returns {Node} - The parent node instance. */ getNode() { - return this.parent as any; + return this.parent as any } -} \ No newline at end of file +} diff --git a/packages/core/shared/src/plugins/cachePlugin/index.ts b/packages/core/shared/src/plugins/cachePlugin/index.ts index 6bc7beec7f..a916770cad 100644 --- a/packages/core/shared/src/plugins/cachePlugin/index.ts +++ b/packages/core/shared/src/plugins/cachePlugin/index.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import { Component, Control } from '@magickml/rete' +import { Component, Control } from 'shared/rete' import { MagickComponent } from '../../engine' import { MagickEditor, MagickNode, WorkerData } from '../../types' diff --git a/packages/core/shared/src/plugins/consolePlugin/MagickConsole.ts b/packages/core/shared/src/plugins/consolePlugin/MagickConsole.ts index 38931897c0..bbd22bfb01 100644 --- a/packages/core/shared/src/plugins/consolePlugin/MagickConsole.ts +++ b/packages/core/shared/src/plugins/consolePlugin/MagickConsole.ts @@ -1,4 +1,4 @@ -import { NodeView } from '@magickml/rete' +import { NodeView } from 'shared/rete' import { MagickComponent } from '../../engine' import { IRunContextEditor, diff --git a/packages/core/shared/src/plugins/historyPlugin/actions/connection.ts b/packages/core/shared/src/plugins/historyPlugin/actions/connection.ts index 3ae9a85012..b034d111f4 100644 --- a/packages/core/shared/src/plugins/historyPlugin/actions/connection.ts +++ b/packages/core/shared/src/plugins/historyPlugin/actions/connection.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import { Connection, NodeEditor } from '@magickml/rete' +import { Connection, NodeEditor } from 'shared/rete' import Action from '../action' /** diff --git a/packages/core/shared/src/plugins/historyPlugin/actions/node.ts b/packages/core/shared/src/plugins/historyPlugin/actions/node.ts index 79d11f421b..1a14a96521 100644 --- a/packages/core/shared/src/plugins/historyPlugin/actions/node.ts +++ b/packages/core/shared/src/plugins/historyPlugin/actions/node.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import { Node, NodeEditor } from '@magickml/rete' +import { Node, NodeEditor } from 'shared/rete' import Action from '../action' /** diff --git a/packages/core/shared/src/plugins/inspectorPlugin/DataControl.ts b/packages/core/shared/src/plugins/inspectorPlugin/DataControl.ts index 614b102466..8ea746c694 100644 --- a/packages/core/shared/src/plugins/inspectorPlugin/DataControl.ts +++ b/packages/core/shared/src/plugins/inspectorPlugin/DataControl.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import { NodeEditor } from '@magickml/rete' +import { NodeEditor } from 'shared/rete' import { MagickComponent } from '../../engine' import { ComponentData, ControlData, MagickNode } from '../../types' diff --git a/packages/core/shared/src/plugins/inspectorPlugin/Inspector.ts b/packages/core/shared/src/plugins/inspectorPlugin/Inspector.ts index 668075b969..ab5e97d974 100644 --- a/packages/core/shared/src/plugins/inspectorPlugin/Inspector.ts +++ b/packages/core/shared/src/plugins/inspectorPlugin/Inspector.ts @@ -1,5 +1,5 @@ import deepEqual from 'deep-equal' -import Rete, { Input, Output } from '@magickml/rete' +import Rete, { Input, Output } from 'shared/rete' import { v4 as uuidv4 } from 'uuid' import { MagickComponent } from '../../engine' diff --git a/packages/core/shared/src/plugins/lifecyclePlugin/index.ts b/packages/core/shared/src/plugins/lifecyclePlugin/index.ts index 1f7e9ff704..94f98812c1 100644 --- a/packages/core/shared/src/plugins/lifecyclePlugin/index.ts +++ b/packages/core/shared/src/plugins/lifecyclePlugin/index.ts @@ -2,7 +2,7 @@ /** * Imports Required for the Plugin */ -import { NodeEditor } from '@magickml/rete' +import { NodeEditor } from 'shared/rete' import { OnCreated, diff --git a/packages/core/shared/src/plugins/lifecyclePlugin/interfaces.ts b/packages/core/shared/src/plugins/lifecyclePlugin/interfaces.ts index 8bc9a377b1..4b52f9b3e4 100644 --- a/packages/core/shared/src/plugins/lifecyclePlugin/interfaces.ts +++ b/packages/core/shared/src/plugins/lifecyclePlugin/interfaces.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import { Connection, Input, Node, Output } from '@magickml/rete' +import { Connection, Input, Node, Output } from 'shared/rete' /** * Namespace for interfaces related to Rete Editor events. diff --git a/packages/core/shared/src/plugins/lifecyclePlugin/utils.ts b/packages/core/shared/src/plugins/lifecyclePlugin/utils.ts index dce80033b9..25b75bdb1b 100644 --- a/packages/core/shared/src/plugins/lifecyclePlugin/utils.ts +++ b/packages/core/shared/src/plugins/lifecyclePlugin/utils.ts @@ -1,4 +1,4 @@ -import { NodeEditor } from '@magickml/rete' +import { NodeEditor } from 'shared/rete' import { OnCreated, diff --git a/packages/core/shared/src/plugins/modulePlugin/module-manager.ts b/packages/core/shared/src/plugins/modulePlugin/module-manager.ts index 00bc39ec84..8b6f4eda10 100644 --- a/packages/core/shared/src/plugins/modulePlugin/module-manager.ts +++ b/packages/core/shared/src/plugins/modulePlugin/module-manager.ts @@ -1,5 +1,6 @@ -import { Engine, Socket, NodeData } from '@magickml/rete' -import { type Socket as SocketType } from '@magickml/rete' +import { Engine, Socket } from 'shared/rete' +import { Socket as SocketType } from 'rete/types' +import { NodeData } from 'rete/types/core/data' import { extractNodes } from '../../engine' import { SocketNameType } from '../../sockets' diff --git a/packages/core/shared/src/plugins/modulePlugin/utils.ts b/packages/core/shared/src/plugins/modulePlugin/utils.ts index 73ca6a5ede..0becedc70f 100644 --- a/packages/core/shared/src/plugins/modulePlugin/utils.ts +++ b/packages/core/shared/src/plugins/modulePlugin/utils.ts @@ -1,4 +1,4 @@ -import { Input, NodeEditor, Output } from '@magickml/rete' +import { Input, NodeEditor, Output } from 'shared/rete' import { DataSocketType, diff --git a/packages/core/shared/src/plugins/multiCopyPlugin/index.ts b/packages/core/shared/src/plugins/multiCopyPlugin/index.ts index 701824ac45..57fd061ffc 100644 --- a/packages/core/shared/src/plugins/multiCopyPlugin/index.ts +++ b/packages/core/shared/src/plugins/multiCopyPlugin/index.ts @@ -1,4 +1,4 @@ -import { Input, Output, Connection } from '@magickml/rete' +import { Input, Output, Connection } from 'shared/rete' import { IRunContextEditor, MagickNode } from '../../types' function install(editor: IRunContextEditor) { diff --git a/packages/core/shared/src/plugins/multiSocketGenerator/index.ts b/packages/core/shared/src/plugins/multiSocketGenerator/index.ts index 653a9afe76..a85bc857c5 100644 --- a/packages/core/shared/src/plugins/multiSocketGenerator/index.ts +++ b/packages/core/shared/src/plugins/multiSocketGenerator/index.ts @@ -1,4 +1,4 @@ -import Rete, { Input, Output } from '@magickml/rete' +import Rete, { Input, Output } from 'shared/rete' import { AsDataSocket, IRunContextEditor, MagickNode } from '../../types' import * as sockets from '../../sockets' diff --git a/packages/core/shared/src/plugins/selectionPlugin/index.ts b/packages/core/shared/src/plugins/selectionPlugin/index.ts index 80cce0a4a4..11a5fe208f 100644 --- a/packages/core/shared/src/plugins/selectionPlugin/index.ts +++ b/packages/core/shared/src/plugins/selectionPlugin/index.ts @@ -1,4 +1,4 @@ -import { NodeEditor } from '@magickml/rete' +import { NodeEditor } from 'shared/rete' declare module '@magickml/rete' { interface EventsTypes { diff --git a/packages/core/shared/src/plugins/socketGenerator/index.ts b/packages/core/shared/src/plugins/socketGenerator/index.ts index f22bca0975..77b58bc87b 100644 --- a/packages/core/shared/src/plugins/socketGenerator/index.ts +++ b/packages/core/shared/src/plugins/socketGenerator/index.ts @@ -1,4 +1,4 @@ -import Rete, { Input, Output } from '@magickml/rete' +import Rete, { Input, Output } from 'shared/rete' import { AsDataSocket, IRunContextEditor, MagickNode } from '../../types' import * as sockets from '../../sockets' diff --git a/packages/core/shared/src/plugins/taskPlugin/index.ts b/packages/core/shared/src/plugins/taskPlugin/index.ts index b1c79ed8a8..ff09ced66f 100644 --- a/packages/core/shared/src/plugins/taskPlugin/index.ts +++ b/packages/core/shared/src/plugins/taskPlugin/index.ts @@ -1,4 +1,6 @@ -import { Component, NodeData, WorkerOutputs } from '@magickml/rete' +import { Component } from 'shared/rete' +import { NodeData, WorkerOutputs } from 'rete/types/core/data' + import { MagickEditor, MagickWorkerInputs, diff --git a/packages/core/shared/src/sockets.ts b/packages/core/shared/src/sockets.ts index d32d627bf2..92fa3e9093 100644 --- a/packages/core/shared/src/sockets.ts +++ b/packages/core/shared/src/sockets.ts @@ -1,4 +1,4 @@ -import Rete from '@magickml/rete' +import Rete from 'shared/rete' // TODO: fix this very unmaintainable mapping // this is a hack and only temporary until we have a rete schema migration system set up diff --git a/packages/core/shared/src/types.ts b/packages/core/shared/src/types.ts index 2c8ac18ffd..5eb61b61da 100644 --- a/packages/core/shared/src/types.ts +++ b/packages/core/shared/src/types.ts @@ -16,7 +16,7 @@ import { NodeData, OutputsData, WorkerOutputs, -} from '@magickml/rete' +} from 'shared/rete' import { MagickComponent } from './engine' import { MagickConsole } from './plugins/consolePlugin/MagickConsole' import { Inspector } from './plugins/inspectorPlugin/Inspector' diff --git a/packages/plugins/discord/shared/src/nodes/DiscordCurrentChannelName.ts b/packages/plugins/discord/shared/src/nodes/DiscordCurrentChannelName.ts index 8339f21249..1552f9a07f 100644 --- a/packages/plugins/discord/shared/src/nodes/DiscordCurrentChannelName.ts +++ b/packages/plugins/discord/shared/src/nodes/DiscordCurrentChannelName.ts @@ -4,7 +4,7 @@ * @category Discord */ -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { Event, MagickComponent, diff --git a/packages/plugins/discord/shared/src/nodes/DiscordJoinVoice.ts b/packages/plugins/discord/shared/src/nodes/DiscordJoinVoice.ts index c6c83fcb12..cd0d3757ee 100644 --- a/packages/plugins/discord/shared/src/nodes/DiscordJoinVoice.ts +++ b/packages/plugins/discord/shared/src/nodes/DiscordJoinVoice.ts @@ -3,7 +3,7 @@ * A simple rete component that is paired with AgentExectuor to Join the voice channel when triggered * @category Discord */ -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { MagickComponent, stringSocket, diff --git a/packages/plugins/discord/shared/src/nodes/DiscordLeaveVoice.ts b/packages/plugins/discord/shared/src/nodes/DiscordLeaveVoice.ts index 294c4c7fb0..ed685e742a 100644 --- a/packages/plugins/discord/shared/src/nodes/DiscordLeaveVoice.ts +++ b/packages/plugins/discord/shared/src/nodes/DiscordLeaveVoice.ts @@ -3,7 +3,7 @@ * A simple rete component that is paired with AgentExectuor to Leave the voice channel when triggered * @category Discord */ -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { MagickComponent, stringSocket, diff --git a/packages/plugins/discord/shared/src/nodes/DiscordLeaveVoiceChannelsInServer.ts b/packages/plugins/discord/shared/src/nodes/DiscordLeaveVoiceChannelsInServer.ts index 97c965e14e..d8fc09e129 100644 --- a/packages/plugins/discord/shared/src/nodes/DiscordLeaveVoiceChannelsInServer.ts +++ b/packages/plugins/discord/shared/src/nodes/DiscordLeaveVoiceChannelsInServer.ts @@ -4,7 +4,7 @@ * @category Discord */ -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { Event, MagickComponent, diff --git a/packages/plugins/discord/shared/src/nodes/DiscordListTextChannels.ts b/packages/plugins/discord/shared/src/nodes/DiscordListTextChannels.ts index 2ea8948124..d37604fc59 100644 --- a/packages/plugins/discord/shared/src/nodes/DiscordListTextChannels.ts +++ b/packages/plugins/discord/shared/src/nodes/DiscordListTextChannels.ts @@ -4,7 +4,7 @@ * @category Discord */ -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { Event, MagickComponent, diff --git a/packages/plugins/discord/shared/src/nodes/DiscordListVoiceChannels.ts b/packages/plugins/discord/shared/src/nodes/DiscordListVoiceChannels.ts index 20da58bde8..bcfc92f44a 100644 --- a/packages/plugins/discord/shared/src/nodes/DiscordListVoiceChannels.ts +++ b/packages/plugins/discord/shared/src/nodes/DiscordListVoiceChannels.ts @@ -4,7 +4,7 @@ * @category Discord */ -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { Event, MagickComponent, diff --git a/packages/plugins/discord/shared/src/nodes/DiscordVoiceChannelForSender.ts b/packages/plugins/discord/shared/src/nodes/DiscordVoiceChannelForSender.ts index e74492accb..31820a4ba0 100644 --- a/packages/plugins/discord/shared/src/nodes/DiscordVoiceChannelForSender.ts +++ b/packages/plugins/discord/shared/src/nodes/DiscordVoiceChannelForSender.ts @@ -4,7 +4,7 @@ * @category Discord */ -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { Event, MagickComponent, diff --git a/packages/plugins/ethereum/shared/src/nodes/CallContractFunctionRead.ts b/packages/plugins/ethereum/shared/src/nodes/CallContractFunctionRead.ts index 46fd1993e0..9f213779ef 100644 --- a/packages/plugins/ethereum/shared/src/nodes/CallContractFunctionRead.ts +++ b/packages/plugins/ethereum/shared/src/nodes/CallContractFunctionRead.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { v4 as uuidv4 } from 'uuid' import { anySocket, diff --git a/packages/plugins/ethereum/shared/src/nodes/CallContractFunctionWrite.ts b/packages/plugins/ethereum/shared/src/nodes/CallContractFunctionWrite.ts index 2ccd58d2cb..0cf653fa14 100644 --- a/packages/plugins/ethereum/shared/src/nodes/CallContractFunctionWrite.ts +++ b/packages/plugins/ethereum/shared/src/nodes/CallContractFunctionWrite.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { v4 as uuidv4 } from 'uuid' import { diff --git a/packages/plugins/ethereum/shared/src/nodes/CheckForRecentTxFromWallet.ts b/packages/plugins/ethereum/shared/src/nodes/CheckForRecentTxFromWallet.ts index 6d1086e661..984452618f 100644 --- a/packages/plugins/ethereum/shared/src/nodes/CheckForRecentTxFromWallet.ts +++ b/packages/plugins/ethereum/shared/src/nodes/CheckForRecentTxFromWallet.ts @@ -1,6 +1,6 @@ // DOCUMENTED import { isEmpty } from 'lodash' -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { v4 as uuidv4 } from 'uuid' import { diff --git a/packages/plugins/ethereum/shared/src/nodes/CompileContract.ts b/packages/plugins/ethereum/shared/src/nodes/CompileContract.ts index cd5d4e19fb..27f73a1aa9 100644 --- a/packages/plugins/ethereum/shared/src/nodes/CompileContract.ts +++ b/packages/plugins/ethereum/shared/src/nodes/CompileContract.ts @@ -1,6 +1,6 @@ // DOCUMENTED import { isEmpty } from 'lodash' -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { v4 as uuidv4 } from 'uuid' import { API_ROOT_URL } from '@magickml/config' diff --git a/packages/plugins/ethereum/shared/src/nodes/DeployContract.ts b/packages/plugins/ethereum/shared/src/nodes/DeployContract.ts index 6c4bf369db..36ed860a0c 100644 --- a/packages/plugins/ethereum/shared/src/nodes/DeployContract.ts +++ b/packages/plugins/ethereum/shared/src/nodes/DeployContract.ts @@ -1,6 +1,6 @@ // DOCUMENTED import { isEmpty } from 'lodash' -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { v4 as uuidv4 } from 'uuid' import * as ethers from 'ethers' diff --git a/packages/plugins/ethereum/shared/src/nodes/GetERC20BalanceFromWallet.ts b/packages/plugins/ethereum/shared/src/nodes/GetERC20BalanceFromWallet.ts index 056a9fe441..c3b24d8167 100644 --- a/packages/plugins/ethereum/shared/src/nodes/GetERC20BalanceFromWallet.ts +++ b/packages/plugins/ethereum/shared/src/nodes/GetERC20BalanceFromWallet.ts @@ -1,6 +1,6 @@ // DOCUMENTED import { isEmpty } from 'lodash' -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { v4 as uuidv4 } from 'uuid' import { diff --git a/packages/plugins/ethereum/shared/src/nodes/GetNativeBalanceFromWallet.ts b/packages/plugins/ethereum/shared/src/nodes/GetNativeBalanceFromWallet.ts index 8d8d859220..7cd9057840 100644 --- a/packages/plugins/ethereum/shared/src/nodes/GetNativeBalanceFromWallet.ts +++ b/packages/plugins/ethereum/shared/src/nodes/GetNativeBalanceFromWallet.ts @@ -1,6 +1,6 @@ // DOCUMENTED import { isEmpty } from 'lodash' -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { v4 as uuidv4 } from 'uuid' import { diff --git a/packages/plugins/ethereum/shared/src/nodes/GetRecentTxsFromWallet.ts b/packages/plugins/ethereum/shared/src/nodes/GetRecentTxsFromWallet.ts index 721737432c..a3bab571e6 100644 --- a/packages/plugins/ethereum/shared/src/nodes/GetRecentTxsFromWallet.ts +++ b/packages/plugins/ethereum/shared/src/nodes/GetRecentTxsFromWallet.ts @@ -4,7 +4,7 @@ * More information: https://lodash.com/docs/4.17.15#isEmpty */ import { isEmpty } from 'lodash' -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { v4 as uuidv4 } from 'uuid' import { diff --git a/packages/plugins/github/shared/src/nodes/GithubIssueSearch.ts b/packages/plugins/github/shared/src/nodes/GithubIssueSearch.ts index 8ceed63fa7..de026e38a3 100644 --- a/packages/plugins/github/shared/src/nodes/GithubIssueSearch.ts +++ b/packages/plugins/github/shared/src/nodes/GithubIssueSearch.ts @@ -3,7 +3,7 @@ * A component to process Github Issue. * @category Github */ -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { MagickComponent, stringSocket, diff --git a/packages/plugins/intent/shared/src/nodes/IntentSearch.ts b/packages/plugins/intent/shared/src/nodes/IntentSearch.ts index bb12ecad0a..7a4cd5688b 100644 --- a/packages/plugins/intent/shared/src/nodes/IntentSearch.ts +++ b/packages/plugins/intent/shared/src/nodes/IntentSearch.ts @@ -3,7 +3,7 @@ * A component to process Intent Search. * @category Intent */ -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { InputControl } from '@magickml/core' import { MagickComponent, diff --git a/packages/plugins/pinecone/shared/src/nodes/QueryPinecone.ts b/packages/plugins/pinecone/shared/src/nodes/QueryPinecone.ts index 33129a75bb..051bb17c61 100644 --- a/packages/plugins/pinecone/shared/src/nodes/QueryPinecone.ts +++ b/packages/plugins/pinecone/shared/src/nodes/QueryPinecone.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { arraySocket, diff --git a/packages/plugins/search/shared/src/nodes/SearchGoogle.ts b/packages/plugins/search/shared/src/nodes/SearchGoogle.ts index 7d85fa638a..5f71fae6bb 100644 --- a/packages/plugins/search/shared/src/nodes/SearchGoogle.ts +++ b/packages/plugins/search/shared/src/nodes/SearchGoogle.ts @@ -4,7 +4,7 @@ * @module SearchGoogle */ -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { MagickNode, MagickWorkerInputs, diff --git a/packages/plugins/search/shared/src/nodes/SearchMetaphor.ts b/packages/plugins/search/shared/src/nodes/SearchMetaphor.ts index 2f1c63009d..a196ee8035 100644 --- a/packages/plugins/search/shared/src/nodes/SearchMetaphor.ts +++ b/packages/plugins/search/shared/src/nodes/SearchMetaphor.ts @@ -1,4 +1,4 @@ -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { MagickNode, MagickWorkerInputs, diff --git a/packages/plugins/task/shared/src/nodes/CancelTask.ts b/packages/plugins/task/shared/src/nodes/CancelTask.ts index 2a7fad6c51..f106473719 100644 --- a/packages/plugins/task/shared/src/nodes/CancelTask.ts +++ b/packages/plugins/task/shared/src/nodes/CancelTask.ts @@ -8,7 +8,7 @@ import { taskSocket, triggerSocket, } from '@magickml/core' -import Rete from '@magickml/rete' +import Rete from 'shared/rete' const info = 'Cancel a task.' diff --git a/packages/plugins/task/shared/src/nodes/CompleteTask.ts b/packages/plugins/task/shared/src/nodes/CompleteTask.ts index 3e1b8c2ff9..6d4f5c29a1 100644 --- a/packages/plugins/task/shared/src/nodes/CompleteTask.ts +++ b/packages/plugins/task/shared/src/nodes/CompleteTask.ts @@ -8,7 +8,7 @@ import { taskSocket, triggerSocket, } from '@magickml/core' -import Rete from '@magickml/rete' +import Rete from 'shared/rete' const info = 'Complete a task.' diff --git a/packages/plugins/task/shared/src/nodes/CreateTask.ts b/packages/plugins/task/shared/src/nodes/CreateTask.ts index c115208270..344029fae2 100644 --- a/packages/plugins/task/shared/src/nodes/CreateTask.ts +++ b/packages/plugins/task/shared/src/nodes/CreateTask.ts @@ -15,7 +15,7 @@ import { WorkerData, Event, } from '@magickml/core' -import Rete from '@magickml/rete' +import Rete from 'shared/rete' /** * Information about the CreateTask class diff --git a/packages/plugins/task/shared/src/nodes/DeleteTask.ts b/packages/plugins/task/shared/src/nodes/DeleteTask.ts index 3a47ed614e..eebd6d147f 100644 --- a/packages/plugins/task/shared/src/nodes/DeleteTask.ts +++ b/packages/plugins/task/shared/src/nodes/DeleteTask.ts @@ -7,7 +7,7 @@ import { taskSocket, triggerSocket, } from '@magickml/core' -import Rete from '@magickml/rete' +import Rete from 'shared/rete' const info = 'Delete a task.' diff --git a/packages/plugins/task/shared/src/nodes/FinishTaskStep.ts b/packages/plugins/task/shared/src/nodes/FinishTaskStep.ts index 9ef666b99d..a8ed54bc86 100644 --- a/packages/plugins/task/shared/src/nodes/FinishTaskStep.ts +++ b/packages/plugins/task/shared/src/nodes/FinishTaskStep.ts @@ -11,7 +11,7 @@ import { taskSocket, triggerSocket, } from '@magickml/core' -import Rete from '@magickml/rete' +import Rete from 'shared/rete' /** * Information about the CreateTask class diff --git a/packages/rete/src/connection.ts b/packages/rete/src/connection.ts deleted file mode 100644 index 93f7f0cc23..0000000000 --- a/packages/rete/src/connection.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Input } from './input'; -import { Output } from './output'; - -export class Connection { - - output: Output; - input: Input; - data: unknown = {}; - - constructor(output: Output, input: Input) { - this.output = output; - this.input = input; - this.data = {}; - - this.input.addConnection(this); - } - - remove() { - this.input.removeConnection(this); - this.output.removeConnection(this); - } -} \ No newline at end of file diff --git a/packages/rete/src/control.ts b/packages/rete/src/control.ts deleted file mode 100644 index 13225f2d66..0000000000 --- a/packages/rete/src/control.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { Input } from './input'; -import { Node } from './node'; - -export class Control { - - key: string; - data: unknown = {}; - parent: Node | Input | null = null; - - constructor(key: string) { - if (this.constructor === Control) - throw new TypeError('Can not construct abstract class'); - if (!key) - throw new Error('The key parameter is missing in super() of Control '); - - this.key = key; - } - - getNode() { - if (this.parent === null) - throw new Error('Control isn\'t added to Node/Input'); - - if (this.parent instanceof Node) - return this.parent; - - if (!this.parent.node) - throw new Error('Control hasn\'t be added to Input or Node'); - - return this.parent.node; - } - - getData(key: string) { - return this.getNode().data[key]; - } - - putData(key: string, data: unknown) { - this.getNode().data[key] = data; - } -} \ No newline at end of file diff --git a/packages/rete/src/core/context.ts b/packages/rete/src/core/context.ts deleted file mode 100644 index 459dbe31cf..0000000000 --- a/packages/rete/src/core/context.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { Component } from '../engine/component'; -import { Emitter } from './emitter' -import { Validator } from './validator' -import { EventsTypes as DefaultEvents, Events } from './events'; -import { Plugin, PluginParams } from './plugin'; - -export class Context extends Emitter { - - id: string; - plugins: Map; - components: Map; - - constructor(id: string, events: Events) { - super(events); - - if (!Validator.isValidId(id)) - throw new Error('ID should be valid to name@0.1.0 format'); - - this.id = id; - this.plugins = new Map(); - this.components = new Map(); - } - - use>(plugin: T, options?: O) { - if (plugin.name && this.plugins.has(plugin.name)) throw new Error(`Plugin ${plugin.name} already in use`) - - plugin.install(this, options || {}); - this.plugins.set(plugin.name, options) - } - - register(component: Component) { - if (this.components.has(component.name)) - throw new Error(`Component ${component.name} already registered`); - - this.components.set(component.name, component); - this.trigger('componentregister', component); - } - - destroy() { - this.trigger('destroy'); - } -} \ No newline at end of file diff --git a/packages/rete/src/core/data.ts b/packages/rete/src/core/data.ts deleted file mode 100644 index a7c8355b3c..0000000000 --- a/packages/rete/src/core/data.ts +++ /dev/null @@ -1,41 +0,0 @@ -export interface ConnectionData { - node: number; - data: unknown; -} - -export type InputConnectionData = ConnectionData & { - output: string; -} -export type OutputConnectionData = ConnectionData & { - input: string; -} - -export interface InputData { - connections: InputConnectionData[]; -} -export interface OutputData { - connections: OutputConnectionData[]; -} - -export interface InputsData { [key: string]: InputData } -export interface OutputsData { [key: string]: OutputData } - -export interface NodeData { - id: number; - name: string; - inputs: InputsData; - outputs: OutputsData; - data: {[key: string]: unknown}; - position: [number, number]; -} - -export interface NodesData { [id: string]: NodeData } - -export interface Data { - id: string; - nodes: NodesData; -} - -export interface WorkerInputs { [key: string]: unknown[] } - -export interface WorkerOutputs { [key: string]: unknown } \ No newline at end of file diff --git a/packages/rete/src/core/emitter.ts b/packages/rete/src/core/emitter.ts deleted file mode 100644 index 772abe701c..0000000000 --- a/packages/rete/src/core/emitter.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { Events } from './events'; - -export class Emitter { - - events: {[key: string]: Function[]} = {}; - silent = false; - - constructor(events: Events | Emitter) { - this.events = events instanceof Emitter ? events.events : events.handlers; - } - - on(names: K | K[], handler: (args: EventTypes[K]) => void | unknown): Function { - const events = names instanceof Array ? names : (names as string).split(' '); - - const unsubscribeMap: any= {}; - - (events as string[]).forEach(name => { - if (!this.events[name]) - throw new Error(`The event ${name} does not exist`); - this.events[name].push(handler); - unsubscribeMap[name] = () =>{ - const index: number = this.events[name].length - 1; - - this.events[name].splice(index, 1); - } - }); - - return () => { - Object.values(unsubscribeMap).forEach((f: any) => f()) - } - } - - trigger(name: K, params: EventTypes[K] | {} = {}) { - if (!(name in this.events)) - throw new Error(`The event ${String(name)} cannot be triggered`); - - return this.events[name as string].reduce((r: boolean, e: Function) => { - return (e(params) !== false) && r - }, true); // return false if at least one event is false - } - - bind(name: string) { - if (this.events[name]) - throw new Error(`The event ${name} is already bound`); - - this.events[name] = []; - } - - exist(name: string) { - return Array.isArray(this.events[name]); - } -} diff --git a/packages/rete/src/core/events.ts b/packages/rete/src/core/events.ts deleted file mode 100644 index c972a42c98..0000000000 --- a/packages/rete/src/core/events.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { Component } from '../engine/component'; - -export class Events { - - handlers: {}; - - constructor(handlers: {}) { - this.handlers = { - warn: [console.warn], - error: [console.error], - componentregister: [], - destroy: [], - ...handlers - } - } -} - -export interface EventsTypes { - warn: string | Error; - error: string | Error; - componentregister: Component; - destroy: void; -} \ No newline at end of file diff --git a/packages/rete/src/core/plugin.ts b/packages/rete/src/core/plugin.ts deleted file mode 100644 index 53437ad28c..0000000000 --- a/packages/rete/src/core/plugin.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface Plugin { - name: string; - install: (context: any, options?: any) => void; -} - -export type PluginParams = T['install'] extends (arg1: unknown, arg2: infer U) => void ? U : void; diff --git a/packages/rete/src/engine/component.ts b/packages/rete/src/engine/component.ts deleted file mode 100644 index e3576ac8ea..0000000000 --- a/packages/rete/src/engine/component.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Engine } from './index'; -import { NodeData, WorkerInputs, WorkerOutputs } from '../core/data'; - -export abstract class Component { - - name: string; - data: unknown = {}; - engine: Engine | null = null; - - constructor(name: string) { - this.name = name; - } - - abstract worker(node: NodeData, inputs: WorkerInputs, outputs: WorkerOutputs, ...args: unknown[]): void; -} \ No newline at end of file diff --git a/packages/rete/src/engine/events.ts b/packages/rete/src/engine/events.ts deleted file mode 100644 index 3fbaee6da7..0000000000 --- a/packages/rete/src/engine/events.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Events } from '../core/events'; - -export class EngineEvents extends Events { - - constructor() { - super({}); - } -} -export interface EventsTypes { -} \ No newline at end of file diff --git a/packages/rete/src/engine/recursion.ts b/packages/rete/src/engine/recursion.ts deleted file mode 100644 index 5b446efbaf..0000000000 --- a/packages/rete/src/engine/recursion.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { InputConnectionData, NodeData, NodesData } from '../core/data'; - -function intersect(array1: T[], array2: T[]) { - return array1.filter(value => -1 !== array2.indexOf(value)); -} - -export class Recursion { - - nodes: NodesData; - - constructor(nodes: NodesData) { - this.nodes = nodes; - } - - extractInputNodes(node: NodeData): NodeData[] { - return Object.keys(node.inputs).reduce((acc: NodeData[], key: string) => { - const { connections } = node.inputs[key]; - const nodesData = (connections || []).reduce((b: NodeData[], c: InputConnectionData) => { - return [...b, this.nodes[c.node]]; - }, []); - - return [...acc, ...nodesData] - }, []); - } - - findSelf(list: NodeData[], inputNodes: NodeData[]): NodeData | null { - const inters = intersect(list, inputNodes); - - if (inters.length) - return inters[0]; - - for (const node of inputNodes) { - const l = [node, ...list]; - const inter = this.findSelf(l, this.extractInputNodes(node)); - - if (inter) - return inter; - } - - return null; - } - - detect(): NodeData | null { - const nodesArr = Object.keys(this.nodes).map(id => this.nodes[id]); - - for (const node of nodesArr) { - const inters = this.findSelf([node], this.extractInputNodes(node)); - - if (inters) - return inters; - } - - return null; - } -} diff --git a/packages/rete/src/engine/state.ts b/packages/rete/src/engine/state.ts deleted file mode 100644 index 48a39c6a07..0000000000 --- a/packages/rete/src/engine/state.ts +++ /dev/null @@ -1 +0,0 @@ -export const State = { AVAILABLE: 0, PROCESSED: 1, ABORT: 2 } \ No newline at end of file diff --git a/packages/rete/src/events.ts b/packages/rete/src/events.ts deleted file mode 100644 index 85bc68dbfe..0000000000 --- a/packages/rete/src/events.ts +++ /dev/null @@ -1,139 +0,0 @@ -import { Component } from './component'; -import { Connection } from './connection'; -import { Control } from './control'; -import { Data } from './core/data'; -import { EditorView } from './view/index'; -import { Input } from './input'; -import { Node } from './node'; -import { Output } from './output'; -import { Socket } from './socket'; -import { EventsTypes as DefaultEventsTypes, Events } from './core/events'; -import { Mouse, Transform, ZoomSource } from './view/area'; - -export class EditorEvents extends Events { - - constructor() { - super({ - nodecreate: [], - nodecreated: [], - noderemove: [], - noderemoved: [], - connectioncreate: [], - connectioncreated: [], - connectionremove: [], - connectionremoved: [], - translatenode: [], - nodetranslate: [], - nodetranslated: [], - nodedraged: [], - nodedragged: [], - selectnode: [], - multiselectnode: [], - nodeselect: [], - nodeselected: [], - rendernode: [], - rendersocket: [], - rendercontrol: [], - renderconnection: [], - updateconnection: [], - keydown: [], - keyup: [], - translate: [], - translated: [], - zoom: [], - zoomed: [], - click: [], - mousemove: [], - contextmenu: [], - import: [], - export: [], - process: [], - clear: [] - }); - } -} - -export interface EventsTypes extends DefaultEventsTypes { - componentregister: Component; - nodecreate: Node; - nodecreated: Node; - noderemove: Node; - noderemoved: Node; - connectioncreate: { input: Input; output: Output }; - connectioncreated: Connection; - connectionremove: Connection; - connectionremoved: Connection; - translatenode: { node: Node; dx: number; dy: number }; - nodetranslate: { node: Node; x: number; y: number }; - nodetranslated: { node: Node; prev: [number, number] }; - nodedraged: Node; - nodedragged: Node; - selectnode: { - node: Node; - accumulate: boolean; - }; - multiselectnode: { - node: Node; - accumulate: boolean; - e: MouseEvent; - }; - nodeselect: Node; - nodeselected: Node; - rendernode: { - el: HTMLElement; - node: Node; - component: object; - bindSocket: Function; - bindControl: Function; - }; - rendersocket: { - el: HTMLElement; - input?: Input; - output?: Output; - socket: Socket; - }; - rendercontrol: { - el: HTMLElement; - control: Control; - }; - renderconnection: { - el: HTMLElement; - connection: Connection; - points: number[]; - }; - updateconnection: { - el: HTMLElement; - connection: Connection; - points: number[]; - }; - keydown: KeyboardEvent; - keyup: KeyboardEvent; - translate: { - transform: Transform; - x: number; - y: number; - }; - translated: void; - zoom: { - transform: Transform; - zoom: number; - source: ZoomSource; - }; - zoomed: { - source: ZoomSource; - }; - click: { - e: Event; - container: HTMLElement; - }; - mousemove: Mouse; - contextmenu: { - e: MouseEvent; - view?: EditorView; - node?: Node; - }; - import: Data; - export: Data; - process: void; - clear: void; -} diff --git a/packages/rete/src/input.ts b/packages/rete/src/input.ts deleted file mode 100644 index 0ec104f3da..0000000000 --- a/packages/rete/src/input.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { Connection } from './connection'; -import { Control } from './control'; -import { IO } from './io'; -import { InputData } from './core/data'; -import { Socket } from './socket'; - -export class Input extends IO { - - control: Control | null = null; - - constructor(key: string, title: string, socket: Socket, multiConns = false) { - super(key, title, socket, multiConns); - } - - hasConnection() { - return this.connections.length > 0; - } - - addConnection(connection: Connection) { - if (!this.multipleConnections && this.hasConnection()) - throw new Error('Multiple connections not allowed'); - this.connections.push(connection); - } - - addControl(control: Control) { - this.control = control; - control.parent = this; - } - - showControl() { - return !this.hasConnection() && this.control !== null; - } - - toJSON(): InputData { - return { - 'connections': this.connections.map(c => { - if (!c.output.node) throw new Error('Node not added to Output'); - - return { - node: c.output.node.id, - output: c.output.key, - data: c.data - }; - }) - }; - } -} diff --git a/packages/rete/src/node.ts b/packages/rete/src/node.ts deleted file mode 100644 index fa3ef06f63..0000000000 --- a/packages/rete/src/node.ts +++ /dev/null @@ -1,128 +0,0 @@ -import { Connection } from './connection'; -import { Control } from './control'; -import { Input } from './input'; -import { Output } from './output'; -import { InputsData, NodeData, OutputsData } from './core/data'; - -export class Node { - - name: string; - id: number; - position: [number, number] = [0.0, 0.0]; - inputs = new Map(); - outputs = new Map(); - controls = new Map(); - data: {[key: string]: unknown} = {}; - meta: {[key: string]: unknown} = {}; - - static latestId = 0; - - constructor(name: string) { - this.name = name; - this.id = Node.incrementId(); - } - - _add>(list: Map, item: T, prop: string) { - if (list.has(item.key)) - throw new Error(`Item with key '${item.key}' already been added to the node`); - if (item[prop] !== null) - throw new Error('Item has already been added to some node'); - - (item as Record)[prop] = this; - list.set(item.key, item); - } - - addControl(control: Control) { - this._add(this.controls, control, 'parent'); - return this; - } - - removeControl(control: Control) { - control.parent = null; - - this.controls.delete(control.key); - } - - addInput(input: Input) { - this._add(this.inputs, input, 'node'); - return this; - } - - removeInput(input: Input) { - input.removeConnections(); - input.node = null; - - this.inputs.delete(input.key); - } - - addOutput(output: Output) { - this._add(this.outputs, output, 'node'); - return this; - } - - removeOutput(output: Output) { - output.removeConnections(); - output.node = null; - - this.outputs.delete(output.key); - } - - setMeta (meta: {[key: string]: unknown}) { - this.meta = meta; - return this; - } - - getConnections() { - const ios = [...this.inputs.values(), ...this.outputs.values()]; - const connections = ios.reduce((arr, io) => { - return [...arr, ...io.connections]; - }, [] as Connection[]); - - return connections; - } - - update() {} - - static incrementId() { - if (!this.latestId) - this.latestId = 1 - else - this.latestId++ - return this.latestId - } - - static resetId() { - this.latestId = 0; - } - - toJSON(): NodeData { - const reduceIO = >(list: Map) => { - return Array.from(list).reduce((obj, [key, io]) => { - (obj as Record)[key] = io.toJSON(); - return obj; - }, {} as any) - } - - return { - 'id': this.id, - 'data': this.data, - 'inputs': reduceIO(this.inputs), - 'outputs': reduceIO(this.outputs), - 'position': this.position, - 'name': this.name - } - } - - static fromJSON(json: NodeData) { - const node = new Node(json.name); - const [x, y] = json.position; - - node.id = json.id; - node.data = json.data; - node.position = [x, y]; - node.name = json.name; - Node.latestId = Math.max(node.id, Node.latestId); - - return node; - } -} diff --git a/packages/rete/src/output.ts b/packages/rete/src/output.ts deleted file mode 100644 index 003b2b7e3c..0000000000 --- a/packages/rete/src/output.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { Connection } from './connection'; -import { IO } from './io'; -import { Input } from './input'; -import { OutputData } from './core/data'; -import { Socket } from './socket'; - -export class Output extends IO { - - constructor(key: string, title: string, socket: Socket, multiConns = true) { - super(key, title, socket, multiConns); - } - - hasConnection() { - return this.connections.length > 0; - } - - connectTo(input: Input) { - if (!this.socket.compatibleWith(input.socket)) - throw new Error('Sockets not compatible'); - if (!input.multipleConnections && input.hasConnection()) - throw new Error('Input already has one connection'); - if (!this.multipleConnections && this.hasConnection()) - throw new Error('Output already has one connection'); - - const connection = new Connection(this, input); - - this.connections.push(connection); - return connection; - } - - connectedTo(input: Input) { - return this.connections.some((item) => { - return item.input === input; - }); - } - - toJSON(): OutputData { - return { - 'connections': this.connections.map(c => { - if (!c.input.node) throw new Error('Node not added to Input'); - - return { - node: c.input.node.id, - input: c.input.key, - data: c.data - } - }) - }; - } -} diff --git a/packages/rete/src/selected.ts b/packages/rete/src/selected.ts deleted file mode 100644 index e0d5f9c7cf..0000000000 --- a/packages/rete/src/selected.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { Node } from './node'; - -export class Selected { - - list: Node[] = []; - - add(item: Node, accumulate = false) { - if (!accumulate) - this.list = [item]; - else if (!this.contains(item)) - this.list.push(item); - } - - clear() { - this.list = []; - } - - remove(item: Node) { - this.list.splice(this.list.indexOf(item), 1); - } - - contains(item: Node) { - return this.list.indexOf(item) !== -1; - } - - each(callback: (n: Node, index: number) => void) { - this.list.forEach(callback); - } -} \ No newline at end of file diff --git a/packages/rete/src/view/area.ts b/packages/rete/src/view/area.ts deleted file mode 100644 index aa6321df43..0000000000 --- a/packages/rete/src/view/area.ts +++ /dev/null @@ -1,109 +0,0 @@ -import { Drag } from './drag'; -import { Emitter } from '../core/emitter'; -import { EventsTypes } from '../events'; -import { Zoom } from './zoom'; - -export interface Transform { k: number; x: number; y: number } -export interface Mouse { x: number; y: number } -export type ZoomSource = 'wheel' | 'touch' | 'dblclick'; - -export class Area extends Emitter { - - el: HTMLElement; - container: HTMLElement; - transform: Transform = { k: 1, x: 0, y: 0 }; - mouse: Mouse = { x: 0, y: 0 } - - private _startPosition: Transform | null = null - private _zoom: Zoom; - private _drag: Drag; - - constructor(container: HTMLElement, emitter: Emitter) { - super(emitter); - - const el = this.el = document.createElement('div'); - - this.container = container; - el.style.transformOrigin = '0 0'; - - this._zoom = new Zoom(container, el, 0.1, this.onZoom.bind(this)); - this._drag = new Drag(container, this.onTranslate.bind(this), this.onStart.bind(this)); - - emitter.on('destroy', () => { - this._zoom.destroy(); - this._drag.destroy(); - }); - - this.container.addEventListener('pointermove', this.pointermove.bind(this)); - - this.update(); - } - - update() { - const t = this.transform; - - this.el.style.transform = `translate(${t.x}px, ${t.y}px) scale(${t.k})`; - } - - pointermove(e: PointerEvent) { - const { clientX, clientY } = e; - const rect = this.el.getBoundingClientRect(); - const x = clientX - rect.left; - const y = clientY - rect.top; - const k = this.transform.k; - - this.mouse = { x: x / k, y: y / k }; - this.trigger('mousemove', { ...this.mouse }); // TODO rename on `pointermove` - } - - onStart() { - this._startPosition = { ...this.transform }; - } - - onTranslate(dx: number, dy: number) { - if (this._zoom.translating) return; // lock translation while zoom on multitouch - if (this._startPosition) this.translate(this._startPosition.x + dx, this._startPosition.y + dy); - } - - onZoom(delta: number, ox: number, oy: number, source: ZoomSource) { - this.zoom(this.transform.k * (1 + delta), ox, oy, source); - - this.update(); - } - - translate(x: number, y: number) { - const params = { transform: this.transform, x, y }; - - if (!this.trigger('translate', params)) return; - - this.transform.x = params.x; - this.transform.y = params.y; - - this.update(); - this.trigger('translated'); - } - - zoom(zoom: number, ox = 0, oy = 0, source: ZoomSource) { - const k = this.transform.k; - const params = { transform: this.transform, zoom, source }; - - if (!this.trigger('zoom', params)) return; - - const d = (k - params.zoom) / ((k - zoom) || 1); - - this.transform.k = params.zoom || 1; - this.transform.x += ox * d; - this.transform.y += oy * d; - - this.update(); - this.trigger('zoomed', { source }); - } - - appendChild(el: HTMLElement) { - this.el.appendChild(el) - } - - removeChild(el: HTMLElement) { - this.el.removeChild(el) - } -} \ No newline at end of file diff --git a/packages/rete/src/view/connection.ts b/packages/rete/src/view/connection.ts deleted file mode 100644 index a7be5ff3f4..0000000000 --- a/packages/rete/src/view/connection.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { Connection } from '../connection'; -import { Emitter } from '../core/emitter'; -import { EventsTypes } from '../events'; -import { NodeView } from './node'; - -export class ConnectionView extends Emitter { - - connection: Connection; - inputNode: NodeView; - outputNode: NodeView; - el: HTMLElement; - - constructor(connection: Connection, inputNode: NodeView, outputNode: NodeView, emitter: Emitter) { - super(emitter); - this.connection = connection; - this.inputNode = inputNode; - this.outputNode = outputNode; - - this.el = document.createElement('div'); - this.el.style.position = 'absolute'; - this.el.style.zIndex = '-1'; - - this.trigger('renderconnection', { - el: this.el, - connection: this.connection, - points: this.getPoints() - }); - } - - getPoints() { - const { input, output } = this.connection - - if (this.inputNode.hasSocket(input) && this.outputNode.hasSocket(output)) { - const [x1, y1] = this.outputNode.getSocketPosition(output); - const [x2, y2] = this.inputNode.getSocketPosition(input); - - return [x1, y1, x2, y2]; - } - - return [0, 0, 0, 0] - } - - update() { - this.trigger('updateconnection', { - el: this.el, - connection: this.connection, - points: this.getPoints() - }); - } -} diff --git a/packages/rete/src/view/control.ts b/packages/rete/src/view/control.ts deleted file mode 100644 index 69109466b8..0000000000 --- a/packages/rete/src/view/control.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Control } from '../control'; -import { Emitter } from '../core/emitter'; -import { EventsTypes } from '../events'; - -export class ControlView extends Emitter { - - constructor(el: HTMLElement, control: Control, emitter: Emitter) { - super(emitter); - this.trigger('rendercontrol', { el, control }); - } -} \ No newline at end of file diff --git a/packages/rete/src/view/node.ts b/packages/rete/src/view/node.ts deleted file mode 100644 index e3815d9044..0000000000 --- a/packages/rete/src/view/node.ts +++ /dev/null @@ -1,129 +0,0 @@ -import { Component } from '../engine/component'; -import { Control } from '../control'; -import { ControlView } from './control'; -import { Drag } from './drag'; -import { Emitter } from '../core/emitter'; -import { EventsTypes } from '../events'; -import { IO } from '../io'; -import { Node } from '../node'; -import { SocketView } from './socket'; - -export class NodeView extends Emitter { - - node: Node; - component: Component; - sockets = new Map(); - controls = new Map(); - - el: HTMLElement; - private _startPosition: number[] = []; - private _drag: Drag; - - constructor(node: Node, component: Component, emitter: Emitter) { - super(emitter); - - this.node = node; - this.component = component; - this.el = document.createElement('div'); - this.el.style.position = 'absolute'; - - this.el.addEventListener('contextmenu', e => this.trigger('contextmenu', { e, node: this.node })); - - this._drag = new Drag(this.el, this.onTranslate.bind(this), this.onSelect.bind(this), () => { - this.trigger('nodedraged', node); - this.trigger('nodedragged', node); - }); - - this.trigger('rendernode', { - el: this.el, - node, - component: component.data, - bindSocket: this.bindSocket.bind(this), - bindControl: this.bindControl.bind(this) - }); - - this.update(); - } - - clearSockets() { - const ios: IO[] = [ ...this.node.inputs.values(), ...this.node.outputs.values()]; - - this.sockets.forEach(s => { - if (!ios.includes(s.io)) this.sockets.delete(s.io); - }); - } - - bindSocket(el: HTMLElement, type: string, io: IO) { - this.clearSockets(); - this.sockets.set(io, new SocketView(el, type, io, this.node, this)); - } - - bindControl(el: HTMLElement, control: Control) { - this.controls.set(control, new ControlView(el, control, this)); - } - - hasSocket(io: IO) { - return this.sockets.has(io) - } - - getSocketPosition(io: IO) { - const socket = this.sockets.get(io); - - if (!socket) throw new Error(`Socket not found for ${io.name} with key ${io.key}`); - - return socket.getPosition(this.node); - } - - onSelect(e: MouseEvent) { - const payload = { node: this.node, accumulate: e.ctrlKey, e }; - - this.onStart(); - this.trigger('multiselectnode', payload); - this.trigger('selectnode', payload); - } - - onStart() { - this._startPosition = [...this.node.position]; - } - - onTranslate(dx: number, dy: number) { - this.trigger('translatenode', { node: this.node, dx, dy }); - } - - onDrag(dx: number, dy: number) { - const x = this._startPosition[0] + dx; - const y = this._startPosition[1] + dy; - - this.translate(x, y); - } - - translate(x: number, y: number) { - const node = this.node; - const params = { node, x, y }; - - if (!this.trigger('nodetranslate', params)) return; - - const [px, py] = node.position; - const prev: [number, number] = [px, py]; - - node.position[0] = params.x; - node.position[1] = params.y; - - this.update(); - this.trigger('nodetranslated', { node, prev }); - } - - update() { - const [x, y] = this.node.position; - - this.el.style.transform = `translate(${x}px, ${y}px)`; - } - - remove() { - - } - - destroy() { - this._drag.destroy(); - } -} diff --git a/packages/rete/src/view/socket.ts b/packages/rete/src/view/socket.ts deleted file mode 100644 index aff6addb17..0000000000 --- a/packages/rete/src/view/socket.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { Emitter } from '../core/emitter'; -import { EventsTypes } from '../events'; -import { IO } from '../io'; -import { Node } from '../node'; - -export class SocketView extends Emitter { - - el: HTMLElement; - type: string; - io: IO; - node: Node; - - constructor(el: HTMLElement, type: string, io: IO, node: Node, emitter: Emitter) { - super(emitter); - this.el = el; - this.type = type; - this.io = io; - this.node = node; - - this.trigger('rendersocket', { el, [type]: this.io, socket: io.socket }); - } - - getPosition({ position }: { position: number[] }): [number, number] { - const el = this.el; - - return [ - position[0] + el.offsetLeft + el.offsetWidth / 2, - position[1] + el.offsetTop + el.offsetHeight / 2 - ] - } -} \ No newline at end of file diff --git a/packages/rete/src/view/utils.ts b/packages/rete/src/view/utils.ts deleted file mode 100644 index 84f99c3f77..0000000000 --- a/packages/rete/src/view/utils.ts +++ /dev/null @@ -1,7 +0,0 @@ -export function listenWindow(event: K, handler: (e: WindowEventMap[K]) => void) { - window.addEventListener(event, handler); - - return () => { - window.removeEventListener(event, handler); - } -} diff --git a/packages/rete/src/view/zoom.ts b/packages/rete/src/view/zoom.ts deleted file mode 100644 index 05564d5f2f..0000000000 --- a/packages/rete/src/view/zoom.ts +++ /dev/null @@ -1,98 +0,0 @@ -import { listenWindow } from './utils'; - -export class Zoom { - - el: HTMLElement; - intensity: number; - onzoom: Function; - previous: { cx: number; cy: number; distance: number } | null = null; - - pointers: PointerEvent[] = []; - destroy: () => void; - - constructor(container: HTMLElement, el: HTMLElement, intensity: number, onzoom: Function) { - this.el = el; - this.intensity = intensity; - this.onzoom = onzoom; - - container.addEventListener('wheel', this.wheel.bind(this)); - container.addEventListener('pointerdown', this.down.bind(this)); - container.addEventListener('dblclick', this.dblclick.bind(this)); - - const destroyMove = listenWindow('pointermove', this.move.bind(this)); - const destroyUp = listenWindow('pointerup', this.end.bind(this)); - const destroyCancel = listenWindow('pointercancel', this.end.bind(this)); - - this.destroy = () => { destroyMove(); destroyUp(); destroyCancel(); } - } - - get translating() { // is translating while zoom (works on multitouch) - return this.pointers.length >= 2; - } - - wheel(e: WheelEvent) { - e.preventDefault(); - - const rect = this.el.getBoundingClientRect(); - const isNegative = e.deltaY < 0; - const delta = isNegative ? this.intensity : - this.intensity; - const ox = (rect.left - e.clientX) * delta; - const oy = (rect.top - e.clientY) * delta; - - this.onzoom(delta, ox, oy, 'wheel'); - } - - touches() { - const e = { touches: this.pointers } - const [x1, y1] = [e.touches[0].clientX, e.touches[0].clientY]; - const [x2, y2] = [e.touches[1].clientX, e.touches[1].clientY]; - - const distance = Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2)); - - return { - cx: (x1 + x2)/2, - cy: (y1 + y2)/2, - distance - }; - } - - down(e: PointerEvent) { - this.pointers.push(e); - } - - move(e: PointerEvent) { - this.pointers = this.pointers.map(p => p.pointerId === e.pointerId ? e : p) - if (!this.translating) return; - - const rect = this.el.getBoundingClientRect(); - - const { cx, cy, distance } = this.touches(); - - if (this.previous !== null) { - const delta = distance / this.previous.distance - 1; - - const ox = (rect.left - cx) * delta; - const oy = (rect.top - cy) * delta; - - this.onzoom(delta, ox - (this.previous.cx - cx), oy - (this.previous.cy - cy), 'touch'); - } - this.previous = { cx, cy, distance }; - } - - end(e: PointerEvent) { - this.previous = null; - this.pointers = this.pointers.filter(p => p.pointerId !== e.pointerId) - } - - dblclick(e: MouseEvent) { - e.preventDefault(); - - const rect = this.el.getBoundingClientRect(); - const delta = 4 * this.intensity; - - const ox = (rect.left - e.clientX) * delta; - const oy = (rect.top - e.clientY) * delta; - - this.onzoom(delta, ox, oy, 'dblclick'); - } -} diff --git a/packages/rete/test/data/add-numbers.js b/packages/rete/test/data/add-numbers.js deleted file mode 100644 index 785c67540f..0000000000 --- a/packages/rete/test/data/add-numbers.js +++ /dev/null @@ -1,68 +0,0 @@ -export default { - 'id': 'test@0.0.1', - 'nodes': { - '1': { - 'id': 1, - 'data': { - 'num': 2 - }, - 'inputs': {}, - 'outputs': { - 'num': { - 'connections': [{ - 'node': 3, - 'input': 'num1', - 'data': {} - }] - } - }, - 'position': [80, 200], - 'name': 'Number' - }, - '2': { - 'id': 2, - 'data': { - 'num': 0 - }, - 'inputs': {}, - 'outputs': { - 'num': { - 'connections': [{ - 'node': 3, - 'input': 'num2', - 'data': {} - }] - } - }, - 'position': [80, 400], - 'name': 'Number' - }, - '3': { - 'id': 3, - 'data': {}, - 'inputs': { - 'num1': { - 'connections': [{ - 'node': 1, - 'output': 'num', - 'data': {} - }] - }, - 'num2': { - 'connections': [{ - 'node': 2, - 'output': 'num', - 'data': {} - }] - } - }, - 'outputs': { - 'num': { - 'connections': [] - } - }, - 'position': [500, 240], - 'name': 'Add' - } - } -} \ No newline at end of file diff --git a/packages/rete/test/data/components.ts b/packages/rete/test/data/components.ts deleted file mode 100644 index f6d9eb7333..0000000000 --- a/packages/rete/test/data/components.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { Component, Input, Node, Output, Socket } from '../../src'; - -const socketNum = new Socket('Number'); - -export class Comp1 extends Component { - - constructor() { - super('Number'); - } - - async builder(node: Node) { - node.addOutput(new Output('num', 'Name', socketNum)) - } - - worker() { } -} - -export class Comp2 extends Component { - - constructor() { - super('Add'); - } - - async builder(node: Node) { - node.addInput(new Input('num1', 'Name', socketNum)); - node.addInput(new Input('num2', 'Name', socketNum)); - node.addOutput(new Output('num', 'Name', socketNum)) - } - - worker() { } -} \ No newline at end of file diff --git a/packages/rete/test/data/recursive.js b/packages/rete/test/data/recursive.js deleted file mode 100644 index 1716024686..0000000000 --- a/packages/rete/test/data/recursive.js +++ /dev/null @@ -1,122 +0,0 @@ -export default { - 'id' : 'test@0.0.1', - 'nodes' : { - '1': { - 'id': 1, - 'data': { - 'num': 2 - }, - 'group': null, - 'inputs': [], - 'outputs': [ - { - 'connections': [ - { - 'node': 3, - 'input': 0 - } - ] - } - ], - 'position': [ - 80, 200 - ], - 'name': 'name' - }, - '2': { - 'id': 2, - 'data': { - 'num': 1 - }, - 'group': null, - 'inputs': [], - 'outputs': [ - { - 'connections': [ - { - 'node': 4, - 'input': 1 - } - ] - } - ], - 'position': [ - 105.55555555555556, 516.6666666666666 - ], - 'name': 'name' - }, - '3': { - 'id': 3, - 'data': {}, - 'group': null, - 'inputs': [ - { - 'connections': [ - { - 'node': 1, - 'output': 0 - } - ] - }, { - 'connections': [ - { - 'node': 4, - 'output': 0 - } - ] - } - ], - 'outputs': [ - { - 'connections': [ - { - 'node': 4, - 'input': 0 - } - ] - } - ], - 'position': [ - 454.44444444444446, 108.88888888888889 - ], - 'name': 'Add' - }, - '4': { - 'id': 4, - 'data': {}, - 'group': null, - 'inputs': [ - { - 'connections': [ - { - 'node': 3, - 'output': 0 - } - ] - }, { - 'connections': [ - { - 'node': 2, - 'output': 0 - } - ] - } - ], - 'outputs': [ - { - 'connections': [ - { - 'node': 3, - 'input': 1 - } - ] - } - ], - 'position': [ - 781.6666666666663, 260.0000000000001 - ], - 'name': 'Add' - } - }, - 'groups' : {} -} \ No newline at end of file diff --git a/packages/rete/test/utils/render-mock.js b/packages/rete/test/utils/render-mock.js deleted file mode 100644 index 7a5dcb37a8..0000000000 --- a/packages/rete/test/utils/render-mock.js +++ /dev/null @@ -1,10 +0,0 @@ -export function renderMock(editor) { - editor.on('rendernode', ({ node, bindSocket, bindControl }) => { - Array.from(node.inputs.values()).forEach(i => { - bindSocket(document.createElement('div'), 'input', i); - }); - Array.from(node.outputs.values()).forEach(o => { - bindSocket(document.createElement('div'), 'output', o); - }); - }); -} \ No newline at end of file diff --git a/packages/rete/test/utils/throwsAsync.js b/packages/rete/test/utils/throwsAsync.js deleted file mode 100644 index aad5eccc2b..0000000000 --- a/packages/rete/test/utils/throwsAsync.js +++ /dev/null @@ -1,13 +0,0 @@ -import assert from 'assert'; - -export default async function(fn, msg) { - let f = () => {}; - - try { - await fn(); - } catch (e) { - f = () => { throw new Error(e) }; - } finally { - assert.throws(f, Error, msg); - } -} \ No newline at end of file diff --git a/packages/rete/.eslintrc.json b/packages/shared/rete/.eslintrc.json similarity index 90% rename from packages/rete/.eslintrc.json rename to packages/shared/rete/.eslintrc.json index adbe7ae2df..3230caf3d2 100644 --- a/packages/rete/.eslintrc.json +++ b/packages/shared/rete/.eslintrc.json @@ -1,5 +1,5 @@ { - "extends": ["../../.eslintrc.json"], + "extends": ["../../../.eslintrc.json"], "ignorePatterns": ["!**/*"], "overrides": [ { diff --git a/packages/rete/README.md b/packages/shared/rete/README.md similarity index 100% rename from packages/rete/README.md rename to packages/shared/rete/README.md diff --git a/packages/rete/jest.config.ts b/packages/shared/rete/jest.config.ts similarity index 61% rename from packages/rete/jest.config.ts rename to packages/shared/rete/jest.config.ts index 4aa93090bc..7471bb16ad 100644 --- a/packages/rete/jest.config.ts +++ b/packages/shared/rete/jest.config.ts @@ -1,11 +1,11 @@ /* eslint-disable */ export default { - displayName: '@magickml/rete', - preset: '../../jest.preset.js', + displayName: 'shared-rete', + preset: '../../../jest.preset.js', testEnvironment: 'node', transform: { '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '/tsconfig.spec.json' }], }, moduleFileExtensions: ['ts', 'js', 'html'], - coverageDirectory: '../../coverage/packages/rete', + coverageDirectory: '../../../coverage/packages/shared/rete', } diff --git a/packages/rete/package.json b/packages/shared/rete/package.json similarity index 89% rename from packages/rete/package.json rename to packages/shared/rete/package.json index 775d1526cd..172d1fb58a 100644 --- a/packages/rete/package.json +++ b/packages/shared/rete/package.json @@ -1,5 +1,5 @@ { - "name": "@magickml/rete", + "name": "shared/rete", "version": "0.0.1", "main": "./index.js", "module": "./index.mjs", diff --git a/packages/rete/project.json b/packages/shared/rete/project.json similarity index 65% rename from packages/rete/project.json rename to packages/shared/rete/project.json index 20b2ae7ed7..1b7093d995 100644 --- a/packages/rete/project.json +++ b/packages/shared/rete/project.json @@ -1,14 +1,14 @@ { - "name": "@magickml/rete", - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "packages/rete/src", + "name": "shared-rete", + "$schema": "../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "packages/shared/rete/src", "projectType": "library", "targets": { "build": { "executor": "@nx/vite:build", "outputs": ["{options.outputPath}"], "options": { - "outputPath": "dist/packages/rete" + "outputPath": "dist/packages/shared/rete" } }, "lint": { @@ -16,8 +16,8 @@ "outputs": ["{options.outputFile}"], "options": { "lintFilePatterns": [ - "packages/rete/**/*.ts", - "packages/rete/package.json" + "packages/shared/rete/**/*.ts", + "packages/shared/rete/package.json" ] } }, @@ -25,7 +25,7 @@ "executor": "@nx/jest:jest", "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], "options": { - "jestConfig": "packages/rete/jest.config.ts", + "jestConfig": "packages/shared/rete/jest.config.ts", "passWithNoTests": true }, "configurations": { diff --git a/packages/rete/src/component.ts b/packages/shared/rete/src/component.ts similarity index 100% rename from packages/rete/src/component.ts rename to packages/shared/rete/src/component.ts diff --git a/packages/shared/rete/src/connection.ts b/packages/shared/rete/src/connection.ts new file mode 100644 index 0000000000..c7dc758d79 --- /dev/null +++ b/packages/shared/rete/src/connection.ts @@ -0,0 +1,21 @@ +import { Input } from './input' +import { Output } from './output' + +export class Connection { + output: Output + input: Input + data: unknown = {} + + constructor(output: Output, input: Input) { + this.output = output + this.input = input + this.data = {} + + this.input.addConnection(this) + } + + remove() { + this.input.removeConnection(this) + this.output.removeConnection(this) + } +} diff --git a/packages/shared/rete/src/control.ts b/packages/shared/rete/src/control.ts new file mode 100644 index 0000000000..09250c391d --- /dev/null +++ b/packages/shared/rete/src/control.ts @@ -0,0 +1,37 @@ +import { Input } from './input' +import { Node } from './node' + +export class Control { + key: string + data: unknown = {} + parent: Node | Input | null = null + + constructor(key: string) { + if (this.constructor === Control) + throw new TypeError('Can not construct abstract class') + if (!key) + throw new Error('The key parameter is missing in super() of Control ') + + this.key = key + } + + getNode() { + if (this.parent === null) + throw new Error("Control isn't added to Node/Input") + + if (this.parent instanceof Node) return this.parent + + if (!this.parent.node) + throw new Error("Control hasn't be added to Input or Node") + + return this.parent.node + } + + getData(key: string) { + return this.getNode().data[key] + } + + putData(key: string, data: unknown) { + this.getNode().data[key] = data + } +} diff --git a/packages/shared/rete/src/core/context.ts b/packages/shared/rete/src/core/context.ts new file mode 100644 index 0000000000..b53f3ce482 --- /dev/null +++ b/packages/shared/rete/src/core/context.ts @@ -0,0 +1,42 @@ +import { Component } from '../engine/component' +import { Emitter } from './emitter' +import { Validator } from './validator' +import { EventsTypes as DefaultEvents, Events } from './events' +import { Plugin, PluginParams } from './plugin' + +export class Context extends Emitter { + id: string + plugins: Map + components: Map + + constructor(id: string, events: Events) { + super(events) + + if (!Validator.isValidId(id)) + throw new Error('ID should be valid to name@0.1.0 format') + + this.id = id + this.plugins = new Map() + this.components = new Map() + } + + use>(plugin: T, options?: O) { + if (plugin.name && this.plugins.has(plugin.name)) + throw new Error(`Plugin ${plugin.name} already in use`) + + plugin.install(this, options || {}) + this.plugins.set(plugin.name, options) + } + + register(component: Component) { + if (this.components.has(component.name)) + throw new Error(`Component ${component.name} already registered`) + + this.components.set(component.name, component) + this.trigger('componentregister', component) + } + + destroy() { + this.trigger('destroy') + } +} diff --git a/packages/shared/rete/src/core/data.ts b/packages/shared/rete/src/core/data.ts new file mode 100644 index 0000000000..f9a6b4c437 --- /dev/null +++ b/packages/shared/rete/src/core/data.ts @@ -0,0 +1,51 @@ +export interface ConnectionData { + node: number + data: unknown +} + +export type InputConnectionData = ConnectionData & { + output: string +} +export type OutputConnectionData = ConnectionData & { + input: string +} + +export interface InputData { + connections: InputConnectionData[] +} +export interface OutputData { + connections: OutputConnectionData[] +} + +export interface InputsData { + [key: string]: InputData +} +export interface OutputsData { + [key: string]: OutputData +} + +export interface NodeData { + id: number + name: string + inputs: InputsData + outputs: OutputsData + data: { [key: string]: unknown } + position: [number, number] +} + +export interface NodesData { + [id: string]: NodeData +} + +export interface Data { + id: string + nodes: NodesData +} + +export interface WorkerInputs { + [key: string]: unknown[] +} + +export interface WorkerOutputs { + [key: string]: unknown +} diff --git a/packages/shared/rete/src/core/emitter.ts b/packages/shared/rete/src/core/emitter.ts new file mode 100644 index 0000000000..55285edb09 --- /dev/null +++ b/packages/shared/rete/src/core/emitter.ts @@ -0,0 +1,56 @@ +import { Events } from './events' + +export class Emitter { + events: { [key: string]: Function[] } = {} + silent = false + + constructor(events: Events | Emitter) { + this.events = events instanceof Emitter ? events.events : events.handlers + } + + on( + names: K | K[], + handler: (args: EventTypes[K]) => void | unknown + ): Function { + const events = names instanceof Array ? names : (names as string).split(' ') + + const unsubscribeMap: any = {} + + ;(events as string[]).forEach(name => { + if (!this.events[name]) + throw new Error(`The event ${name} does not exist`) + this.events[name].push(handler) + unsubscribeMap[name] = () => { + const index: number = this.events[name].length - 1 + + this.events[name].splice(index, 1) + } + }) + + return () => { + Object.values(unsubscribeMap).forEach((f: any) => f()) + } + } + + trigger( + name: K, + params: EventTypes[K] | {} = {} + ) { + if (!(name in this.events)) + throw new Error(`The event ${String(name)} cannot be triggered`) + + return this.events[name as string].reduce((r: boolean, e: Function) => { + return e(params) !== false && r + }, true) // return false if at least one event is false + } + + bind(name: string) { + if (this.events[name]) throw new Error(`The event ${name} is already bound`) + + this.events[name] = [] + } + + exist(name: string) { + return Array.isArray(this.events[name]) + } +} diff --git a/packages/shared/rete/src/core/events.ts b/packages/shared/rete/src/core/events.ts new file mode 100644 index 0000000000..8c99f86b5a --- /dev/null +++ b/packages/shared/rete/src/core/events.ts @@ -0,0 +1,22 @@ +import { Component } from '../engine/component' + +export class Events { + handlers: {} + + constructor(handlers: {}) { + this.handlers = { + warn: [console.warn], + error: [console.error], + componentregister: [], + destroy: [], + ...handlers, + } + } +} + +export interface EventsTypes { + warn: string | Error + error: string | Error + componentregister: Component + destroy: void +} diff --git a/packages/shared/rete/src/core/plugin.ts b/packages/shared/rete/src/core/plugin.ts new file mode 100644 index 0000000000..3ba244a1c4 --- /dev/null +++ b/packages/shared/rete/src/core/plugin.ts @@ -0,0 +1,11 @@ +export interface Plugin { + name: string + install: (context: any, options?: any) => void +} + +export type PluginParams = T['install'] extends ( + arg1: unknown, + arg2: infer U +) => void + ? U + : void diff --git a/packages/rete/src/core/validator.ts b/packages/shared/rete/src/core/validator.ts similarity index 100% rename from packages/rete/src/core/validator.ts rename to packages/shared/rete/src/core/validator.ts diff --git a/packages/rete/src/editor.ts b/packages/shared/rete/src/editor.ts similarity index 100% rename from packages/rete/src/editor.ts rename to packages/shared/rete/src/editor.ts diff --git a/packages/shared/rete/src/engine/component.ts b/packages/shared/rete/src/engine/component.ts new file mode 100644 index 0000000000..f6f357e0db --- /dev/null +++ b/packages/shared/rete/src/engine/component.ts @@ -0,0 +1,19 @@ +import { Engine } from './index' +import { NodeData, WorkerInputs, WorkerOutputs } from '../core/data' + +export abstract class Component { + name: string + data: unknown = {} + engine: Engine | null = null + + constructor(name: string) { + this.name = name + } + + abstract worker( + node: NodeData, + inputs: WorkerInputs, + outputs: WorkerOutputs, + ...args: unknown[] + ): void +} diff --git a/packages/shared/rete/src/engine/events.ts b/packages/shared/rete/src/engine/events.ts new file mode 100644 index 0000000000..1858367b40 --- /dev/null +++ b/packages/shared/rete/src/engine/events.ts @@ -0,0 +1,8 @@ +import { Events } from '../core/events' + +export class EngineEvents extends Events { + constructor() { + super({}) + } +} +export interface EventsTypes {} diff --git a/packages/rete/src/engine/index.ts b/packages/shared/rete/src/engine/index.ts similarity index 100% rename from packages/rete/src/engine/index.ts rename to packages/shared/rete/src/engine/index.ts diff --git a/packages/shared/rete/src/engine/recursion.ts b/packages/shared/rete/src/engine/recursion.ts new file mode 100644 index 0000000000..e65b9edf61 --- /dev/null +++ b/packages/shared/rete/src/engine/recursion.ts @@ -0,0 +1,54 @@ +import { InputConnectionData, NodeData, NodesData } from '../core/data' + +function intersect(array1: T[], array2: T[]) { + return array1.filter(value => -1 !== array2.indexOf(value)) +} + +export class Recursion { + nodes: NodesData + + constructor(nodes: NodesData) { + this.nodes = nodes + } + + extractInputNodes(node: NodeData): NodeData[] { + return Object.keys(node.inputs).reduce((acc: NodeData[], key: string) => { + const { connections } = node.inputs[key] + const nodesData = (connections || []).reduce( + (b: NodeData[], c: InputConnectionData) => { + return [...b, this.nodes[c.node]] + }, + [] + ) + + return [...acc, ...nodesData] + }, []) + } + + findSelf(list: NodeData[], inputNodes: NodeData[]): NodeData | null { + const inters = intersect(list, inputNodes) + + if (inters.length) return inters[0] + + for (const node of inputNodes) { + const l = [node, ...list] + const inter = this.findSelf(l, this.extractInputNodes(node)) + + if (inter) return inter + } + + return null + } + + detect(): NodeData | null { + const nodesArr = Object.keys(this.nodes).map(id => this.nodes[id]) + + for (const node of nodesArr) { + const inters = this.findSelf([node], this.extractInputNodes(node)) + + if (inters) return inters + } + + return null + } +} diff --git a/packages/shared/rete/src/engine/state.ts b/packages/shared/rete/src/engine/state.ts new file mode 100644 index 0000000000..a6e24305ee --- /dev/null +++ b/packages/shared/rete/src/engine/state.ts @@ -0,0 +1 @@ +export const State = { AVAILABLE: 0, PROCESSED: 1, ABORT: 2 } diff --git a/packages/shared/rete/src/events.ts b/packages/shared/rete/src/events.ts new file mode 100644 index 0000000000..461e7c6c86 --- /dev/null +++ b/packages/shared/rete/src/events.ts @@ -0,0 +1,138 @@ +import { Component } from './component' +import { Connection } from './connection' +import { Control } from './control' +import { Data } from './core/data' +import { EditorView } from './view/index' +import { Input } from './input' +import { Node } from './node' +import { Output } from './output' +import { Socket } from './socket' +import { EventsTypes as DefaultEventsTypes, Events } from './core/events' +import { Mouse, Transform, ZoomSource } from './view/area' + +export class EditorEvents extends Events { + constructor() { + super({ + nodecreate: [], + nodecreated: [], + noderemove: [], + noderemoved: [], + connectioncreate: [], + connectioncreated: [], + connectionremove: [], + connectionremoved: [], + translatenode: [], + nodetranslate: [], + nodetranslated: [], + nodedraged: [], + nodedragged: [], + selectnode: [], + multiselectnode: [], + nodeselect: [], + nodeselected: [], + rendernode: [], + rendersocket: [], + rendercontrol: [], + renderconnection: [], + updateconnection: [], + keydown: [], + keyup: [], + translate: [], + translated: [], + zoom: [], + zoomed: [], + click: [], + mousemove: [], + contextmenu: [], + import: [], + export: [], + process: [], + clear: [], + }) + } +} + +export interface EventsTypes extends DefaultEventsTypes { + componentregister: Component + nodecreate: Node + nodecreated: Node + noderemove: Node + noderemoved: Node + connectioncreate: { input: Input; output: Output } + connectioncreated: Connection + connectionremove: Connection + connectionremoved: Connection + translatenode: { node: Node; dx: number; dy: number } + nodetranslate: { node: Node; x: number; y: number } + nodetranslated: { node: Node; prev: [number, number] } + nodedraged: Node + nodedragged: Node + selectnode: { + node: Node + accumulate: boolean + } + multiselectnode: { + node: Node + accumulate: boolean + e: MouseEvent + } + nodeselect: Node + nodeselected: Node + rendernode: { + el: HTMLElement + node: Node + component: object + bindSocket: Function + bindControl: Function + } + rendersocket: { + el: HTMLElement + input?: Input + output?: Output + socket: Socket + } + rendercontrol: { + el: HTMLElement + control: Control + } + renderconnection: { + el: HTMLElement + connection: Connection + points: number[] + } + updateconnection: { + el: HTMLElement + connection: Connection + points: number[] + } + keydown: KeyboardEvent + keyup: KeyboardEvent + translate: { + transform: Transform + x: number + y: number + } + translated: void + zoom: { + transform: Transform + zoom: number + source: ZoomSource + } + zoomed: { + source: ZoomSource + } + click: { + e: Event + container: HTMLElement + } + mousemove: Mouse + contextmenu: { + e: MouseEvent + view?: EditorView + node?: Node + } + import: Data + export: Data + process: void + clear: void +} diff --git a/packages/rete/src/index.ts b/packages/shared/rete/src/index.ts similarity index 100% rename from packages/rete/src/index.ts rename to packages/shared/rete/src/index.ts diff --git a/packages/shared/rete/src/input.ts b/packages/shared/rete/src/input.ts new file mode 100644 index 0000000000..b5f86c9474 --- /dev/null +++ b/packages/shared/rete/src/input.ts @@ -0,0 +1,46 @@ +import { Connection } from './connection' +import { Control } from './control' +import { IO } from './io' +import { InputData } from './core/data' +import { Socket } from './socket' + +export class Input extends IO { + control: Control | null = null + + constructor(key: string, title: string, socket: Socket, multiConns = false) { + super(key, title, socket, multiConns) + } + + hasConnection() { + return this.connections.length > 0 + } + + addConnection(connection: Connection) { + if (!this.multipleConnections && this.hasConnection()) + throw new Error('Multiple connections not allowed') + this.connections.push(connection) + } + + addControl(control: Control) { + this.control = control + control.parent = this + } + + showControl() { + return !this.hasConnection() && this.control !== null + } + + toJSON(): InputData { + return { + connections: this.connections.map(c => { + if (!c.output.node) throw new Error('Node not added to Output') + + return { + node: c.output.node.id, + output: c.output.key, + data: c.data, + } + }), + } + } +} diff --git a/packages/rete/src/io.ts b/packages/shared/rete/src/io.ts similarity index 100% rename from packages/rete/src/io.ts rename to packages/shared/rete/src/io.ts diff --git a/packages/shared/rete/src/node.ts b/packages/shared/rete/src/node.ts new file mode 100644 index 0000000000..6de7f1ede9 --- /dev/null +++ b/packages/shared/rete/src/node.ts @@ -0,0 +1,133 @@ +import { Connection } from './connection' +import { Control } from './control' +import { Input } from './input' +import { Output } from './output' +import { InputsData, NodeData, OutputsData } from './core/data' + +export class Node { + name: string + id: number + position: [number, number] = [0.0, 0.0] + inputs = new Map() + outputs = new Map() + controls = new Map() + data: { [key: string]: unknown } = {} + meta: { [key: string]: unknown } = {} + + static latestId = 0 + + constructor(name: string) { + this.name = name + this.id = Node.incrementId() + } + + _add>( + list: Map, + item: T, + prop: string + ) { + if (list.has(item.key)) + throw new Error( + `Item with key '${item.key}' already been added to the node` + ) + if (item[prop] !== null) + throw new Error('Item has already been added to some node') + + ;(item as Record)[prop] = this + list.set(item.key, item) + } + + addControl(control: Control) { + this._add(this.controls, control, 'parent') + return this + } + + removeControl(control: Control) { + control.parent = null + + this.controls.delete(control.key) + } + + addInput(input: Input) { + this._add(this.inputs, input, 'node') + return this + } + + removeInput(input: Input) { + input.removeConnections() + input.node = null + + this.inputs.delete(input.key) + } + + addOutput(output: Output) { + this._add(this.outputs, output, 'node') + return this + } + + removeOutput(output: Output) { + output.removeConnections() + output.node = null + + this.outputs.delete(output.key) + } + + setMeta(meta: { [key: string]: unknown }) { + this.meta = meta + return this + } + + getConnections() { + const ios = [...this.inputs.values(), ...this.outputs.values()] + const connections = ios.reduce((arr, io) => { + return [...arr, ...io.connections] + }, [] as Connection[]) + + return connections + } + + update() {} + + static incrementId() { + if (!this.latestId) this.latestId = 1 + else this.latestId++ + return this.latestId + } + + static resetId() { + this.latestId = 0 + } + + toJSON(): NodeData { + const reduceIO = >( + list: Map + ) => { + return Array.from(list).reduce((obj, [key, io]) => { + ;(obj as Record)[key] = io.toJSON() + return obj + }, {} as any) + } + + return { + id: this.id, + data: this.data, + inputs: reduceIO(this.inputs), + outputs: reduceIO(this.outputs), + position: this.position, + name: this.name, + } + } + + static fromJSON(json: NodeData) { + const node = new Node(json.name) + const [x, y] = json.position + + node.id = json.id + node.data = json.data + node.position = [x, y] + node.name = json.name + Node.latestId = Math.max(node.id, Node.latestId) + + return node + } +} diff --git a/packages/shared/rete/src/output.ts b/packages/shared/rete/src/output.ts new file mode 100644 index 0000000000..9a46206c37 --- /dev/null +++ b/packages/shared/rete/src/output.ts @@ -0,0 +1,49 @@ +import { Connection } from './connection' +import { IO } from './io' +import { Input } from './input' +import { OutputData } from './core/data' +import { Socket } from './socket' + +export class Output extends IO { + constructor(key: string, title: string, socket: Socket, multiConns = true) { + super(key, title, socket, multiConns) + } + + hasConnection() { + return this.connections.length > 0 + } + + connectTo(input: Input) { + if (!this.socket.compatibleWith(input.socket)) + throw new Error('Sockets not compatible') + if (!input.multipleConnections && input.hasConnection()) + throw new Error('Input already has one connection') + if (!this.multipleConnections && this.hasConnection()) + throw new Error('Output already has one connection') + + const connection = new Connection(this, input) + + this.connections.push(connection) + return connection + } + + connectedTo(input: Input) { + return this.connections.some(item => { + return item.input === input + }) + } + + toJSON(): OutputData { + return { + connections: this.connections.map(c => { + if (!c.input.node) throw new Error('Node not added to Input') + + return { + node: c.input.node.id, + input: c.input.key, + data: c.data, + } + }), + } + } +} diff --git a/packages/shared/rete/src/selected.ts b/packages/shared/rete/src/selected.ts new file mode 100644 index 0000000000..d28fd09fe0 --- /dev/null +++ b/packages/shared/rete/src/selected.ts @@ -0,0 +1,26 @@ +import { Node } from './node' + +export class Selected { + list: Node[] = [] + + add(item: Node, accumulate = false) { + if (!accumulate) this.list = [item] + else if (!this.contains(item)) this.list.push(item) + } + + clear() { + this.list = [] + } + + remove(item: Node) { + this.list.splice(this.list.indexOf(item), 1) + } + + contains(item: Node) { + return this.list.indexOf(item) !== -1 + } + + each(callback: (n: Node, index: number) => void) { + this.list.forEach(callback) + } +} diff --git a/packages/rete/src/socket.ts b/packages/shared/rete/src/socket.ts similarity index 96% rename from packages/rete/src/socket.ts rename to packages/shared/rete/src/socket.ts index 46c2acc677..65c5aa6364 100644 --- a/packages/rete/src/socket.ts +++ b/packages/shared/rete/src/socket.ts @@ -1,7 +1,6 @@ export class Socket { name: string data: unknown - hide = false compatible: Socket[] = [] constructor(name: string, data = {}) { diff --git a/packages/shared/rete/src/view/area.ts b/packages/shared/rete/src/view/area.ts new file mode 100644 index 0000000000..56e642ae5c --- /dev/null +++ b/packages/shared/rete/src/view/area.ts @@ -0,0 +1,120 @@ +import { Drag } from './drag' +import { Emitter } from '../core/emitter' +import { EventsTypes } from '../events' +import { Zoom } from './zoom' + +export interface Transform { + k: number + x: number + y: number +} +export interface Mouse { + x: number + y: number +} +export type ZoomSource = 'wheel' | 'touch' | 'dblclick' + +export class Area extends Emitter { + el: HTMLElement + container: HTMLElement + transform: Transform = { k: 1, x: 0, y: 0 } + mouse: Mouse = { x: 0, y: 0 } + + private _startPosition: Transform | null = null + private _zoom: Zoom + private _drag: Drag + + constructor(container: HTMLElement, emitter: Emitter) { + super(emitter) + + const el = (this.el = document.createElement('div')) + + this.container = container + el.style.transformOrigin = '0 0' + + this._zoom = new Zoom(container, el, 0.1, this.onZoom.bind(this)) + this._drag = new Drag( + container, + this.onTranslate.bind(this), + this.onStart.bind(this) + ) + + emitter.on('destroy', () => { + this._zoom.destroy() + this._drag.destroy() + }) + + this.container.addEventListener('pointermove', this.pointermove.bind(this)) + + this.update() + } + + update() { + const t = this.transform + + this.el.style.transform = `translate(${t.x}px, ${t.y}px) scale(${t.k})` + } + + pointermove(e: PointerEvent) { + const { clientX, clientY } = e + const rect = this.el.getBoundingClientRect() + const x = clientX - rect.left + const y = clientY - rect.top + const k = this.transform.k + + this.mouse = { x: x / k, y: y / k } + this.trigger('mousemove', { ...this.mouse }) // TODO rename on `pointermove` + } + + onStart() { + this._startPosition = { ...this.transform } + } + + onTranslate(dx: number, dy: number) { + if (this._zoom.translating) return // lock translation while zoom on multitouch + if (this._startPosition) + this.translate(this._startPosition.x + dx, this._startPosition.y + dy) + } + + onZoom(delta: number, ox: number, oy: number, source: ZoomSource) { + this.zoom(this.transform.k * (1 + delta), ox, oy, source) + + this.update() + } + + translate(x: number, y: number) { + const params = { transform: this.transform, x, y } + + if (!this.trigger('translate', params)) return + + this.transform.x = params.x + this.transform.y = params.y + + this.update() + this.trigger('translated') + } + + zoom(zoom: number, ox = 0, oy = 0, source: ZoomSource) { + const k = this.transform.k + const params = { transform: this.transform, zoom, source } + + if (!this.trigger('zoom', params)) return + + const d = (k - params.zoom) / (k - zoom || 1) + + this.transform.k = params.zoom || 1 + this.transform.x += ox * d + this.transform.y += oy * d + + this.update() + this.trigger('zoomed', { source }) + } + + appendChild(el: HTMLElement) { + this.el.appendChild(el) + } + + removeChild(el: HTMLElement) { + this.el.removeChild(el) + } +} diff --git a/packages/shared/rete/src/view/connection.ts b/packages/shared/rete/src/view/connection.ts new file mode 100644 index 0000000000..6076def650 --- /dev/null +++ b/packages/shared/rete/src/view/connection.ts @@ -0,0 +1,54 @@ +import { Connection } from '../connection' +import { Emitter } from '../core/emitter' +import { EventsTypes } from '../events' +import { NodeView } from './node' + +export class ConnectionView extends Emitter { + connection: Connection + inputNode: NodeView + outputNode: NodeView + el: HTMLElement + + constructor( + connection: Connection, + inputNode: NodeView, + outputNode: NodeView, + emitter: Emitter + ) { + super(emitter) + this.connection = connection + this.inputNode = inputNode + this.outputNode = outputNode + + this.el = document.createElement('div') + this.el.style.position = 'absolute' + this.el.style.zIndex = '-1' + + this.trigger('renderconnection', { + el: this.el, + connection: this.connection, + points: this.getPoints(), + }) + } + + getPoints() { + const { input, output } = this.connection + + if (this.inputNode.hasSocket(input) && this.outputNode.hasSocket(output)) { + const [x1, y1] = this.outputNode.getSocketPosition(output) + const [x2, y2] = this.inputNode.getSocketPosition(input) + + return [x1, y1, x2, y2] + } + + return [0, 0, 0, 0] + } + + update() { + this.trigger('updateconnection', { + el: this.el, + connection: this.connection, + points: this.getPoints(), + }) + } +} diff --git a/packages/shared/rete/src/view/control.ts b/packages/shared/rete/src/view/control.ts new file mode 100644 index 0000000000..bc812dee2f --- /dev/null +++ b/packages/shared/rete/src/view/control.ts @@ -0,0 +1,14 @@ +import { Control } from '../control' +import { Emitter } from '../core/emitter' +import { EventsTypes } from '../events' + +export class ControlView extends Emitter { + constructor( + el: HTMLElement, + control: Control, + emitter: Emitter + ) { + super(emitter) + this.trigger('rendercontrol', { el, control }) + } +} diff --git a/packages/rete/src/view/drag.ts b/packages/shared/rete/src/view/drag.ts similarity index 100% rename from packages/rete/src/view/drag.ts rename to packages/shared/rete/src/view/drag.ts diff --git a/packages/rete/src/view/index.ts b/packages/shared/rete/src/view/index.ts similarity index 100% rename from packages/rete/src/view/index.ts rename to packages/shared/rete/src/view/index.ts diff --git a/packages/shared/rete/src/view/node.ts b/packages/shared/rete/src/view/node.ts new file mode 100644 index 0000000000..46ab0d4c59 --- /dev/null +++ b/packages/shared/rete/src/view/node.ts @@ -0,0 +1,137 @@ +import { Component } from '../engine/component' +import { Control } from '../control' +import { ControlView } from './control' +import { Drag } from './drag' +import { Emitter } from '../core/emitter' +import { EventsTypes } from '../events' +import { IO } from '../io' +import { Node } from '../node' +import { SocketView } from './socket' + +export class NodeView extends Emitter { + node: Node + component: Component + sockets = new Map() + controls = new Map() + + el: HTMLElement + private _startPosition: number[] = [] + private _drag: Drag + + constructor(node: Node, component: Component, emitter: Emitter) { + super(emitter) + + this.node = node + this.component = component + this.el = document.createElement('div') + this.el.style.position = 'absolute' + + this.el.addEventListener('contextmenu', e => + this.trigger('contextmenu', { e, node: this.node }) + ) + + this._drag = new Drag( + this.el, + this.onTranslate.bind(this), + this.onSelect.bind(this), + () => { + this.trigger('nodedraged', node) + this.trigger('nodedragged', node) + } + ) + + this.trigger('rendernode', { + el: this.el, + node, + component: component.data, + bindSocket: this.bindSocket.bind(this), + bindControl: this.bindControl.bind(this), + }) + + this.update() + } + + clearSockets() { + const ios: IO[] = [ + ...this.node.inputs.values(), + ...this.node.outputs.values(), + ] + + this.sockets.forEach(s => { + if (!ios.includes(s.io)) this.sockets.delete(s.io) + }) + } + + bindSocket(el: HTMLElement, type: string, io: IO) { + this.clearSockets() + this.sockets.set(io, new SocketView(el, type, io, this.node, this)) + } + + bindControl(el: HTMLElement, control: Control) { + this.controls.set(control, new ControlView(el, control, this)) + } + + hasSocket(io: IO) { + return this.sockets.has(io) + } + + getSocketPosition(io: IO) { + const socket = this.sockets.get(io) + + if (!socket) + throw new Error(`Socket not found for ${io.name} with key ${io.key}`) + + return socket.getPosition(this.node) + } + + onSelect(e: MouseEvent) { + const payload = { node: this.node, accumulate: e.ctrlKey, e } + + this.onStart() + this.trigger('multiselectnode', payload) + this.trigger('selectnode', payload) + } + + onStart() { + this._startPosition = [...this.node.position] + } + + onTranslate(dx: number, dy: number) { + this.trigger('translatenode', { node: this.node, dx, dy }) + } + + onDrag(dx: number, dy: number) { + const x = this._startPosition[0] + dx + const y = this._startPosition[1] + dy + + this.translate(x, y) + } + + translate(x: number, y: number) { + const node = this.node + const params = { node, x, y } + + if (!this.trigger('nodetranslate', params)) return + + const [px, py] = node.position + const prev: [number, number] = [px, py] + + node.position[0] = params.x + node.position[1] = params.y + + this.update() + this.trigger('nodetranslated', { node, prev }) + } + + update() { + const [x, y] = this.node.position + + this.el.style.transform = `translate(${x}px, ${y}px)` + } + + remove() {} + + destroy() { + this._drag.destroy() + } +} diff --git a/packages/shared/rete/src/view/socket.ts b/packages/shared/rete/src/view/socket.ts new file mode 100644 index 0000000000..8af3de50a0 --- /dev/null +++ b/packages/shared/rete/src/view/socket.ts @@ -0,0 +1,36 @@ +import { Emitter } from '../core/emitter' +import { EventsTypes } from '../events' +import { IO } from '../io' +import { Node } from '../node' + +export class SocketView extends Emitter { + el: HTMLElement + type: string + io: IO + node: Node + + constructor( + el: HTMLElement, + type: string, + io: IO, + node: Node, + emitter: Emitter + ) { + super(emitter) + this.el = el + this.type = type + this.io = io + this.node = node + + this.trigger('rendersocket', { el, [type]: this.io, socket: io.socket }) + } + + getPosition({ position }: { position: number[] }): [number, number] { + const el = this.el + + return [ + position[0] + el.offsetLeft + el.offsetWidth / 2, + position[1] + el.offsetTop + el.offsetHeight / 2, + ] + } +} diff --git a/packages/shared/rete/src/view/utils.ts b/packages/shared/rete/src/view/utils.ts new file mode 100644 index 0000000000..6f9e2fbf4e --- /dev/null +++ b/packages/shared/rete/src/view/utils.ts @@ -0,0 +1,10 @@ +export function listenWindow( + event: K, + handler: (e: WindowEventMap[K]) => void +) { + window.addEventListener(event, handler) + + return () => { + window.removeEventListener(event, handler) + } +} diff --git a/packages/shared/rete/src/view/zoom.ts b/packages/shared/rete/src/view/zoom.ts new file mode 100644 index 0000000000..370c59f057 --- /dev/null +++ b/packages/shared/rete/src/view/zoom.ts @@ -0,0 +1,114 @@ +import { listenWindow } from './utils' + +export class Zoom { + el: HTMLElement + intensity: number + onzoom: Function + previous: { cx: number; cy: number; distance: number } | null = null + + pointers: PointerEvent[] = [] + destroy: () => void + + constructor( + container: HTMLElement, + el: HTMLElement, + intensity: number, + onzoom: Function + ) { + this.el = el + this.intensity = intensity + this.onzoom = onzoom + + container.addEventListener('wheel', this.wheel.bind(this)) + container.addEventListener('pointerdown', this.down.bind(this)) + container.addEventListener('dblclick', this.dblclick.bind(this)) + + const destroyMove = listenWindow('pointermove', this.move.bind(this)) + const destroyUp = listenWindow('pointerup', this.end.bind(this)) + const destroyCancel = listenWindow('pointercancel', this.end.bind(this)) + + this.destroy = () => { + destroyMove() + destroyUp() + destroyCancel() + } + } + + get translating() { + // is translating while zoom (works on multitouch) + return this.pointers.length >= 2 + } + + wheel(e: WheelEvent) { + e.preventDefault() + + const rect = this.el.getBoundingClientRect() + const isNegative = e.deltaY < 0 + const delta = isNegative ? this.intensity : -this.intensity + const ox = (rect.left - e.clientX) * delta + const oy = (rect.top - e.clientY) * delta + + this.onzoom(delta, ox, oy, 'wheel') + } + + touches() { + const e = { touches: this.pointers } + const [x1, y1] = [e.touches[0].clientX, e.touches[0].clientY] + const [x2, y2] = [e.touches[1].clientX, e.touches[1].clientY] + + const distance = Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2)) + + return { + cx: (x1 + x2) / 2, + cy: (y1 + y2) / 2, + distance, + } + } + + down(e: PointerEvent) { + this.pointers.push(e) + } + + move(e: PointerEvent) { + this.pointers = this.pointers.map(p => + p.pointerId === e.pointerId ? e : p + ) + if (!this.translating) return + + const rect = this.el.getBoundingClientRect() + + const { cx, cy, distance } = this.touches() + + if (this.previous !== null) { + const delta = distance / this.previous.distance - 1 + + const ox = (rect.left - cx) * delta + const oy = (rect.top - cy) * delta + + this.onzoom( + delta, + ox - (this.previous.cx - cx), + oy - (this.previous.cy - cy), + 'touch' + ) + } + this.previous = { cx, cy, distance } + } + + end(e: PointerEvent) { + this.previous = null + this.pointers = this.pointers.filter(p => p.pointerId !== e.pointerId) + } + + dblclick(e: MouseEvent) { + e.preventDefault() + + const rect = this.el.getBoundingClientRect() + const delta = 4 * this.intensity + + const ox = (rect.left - e.clientX) * delta + const oy = (rect.top - e.clientY) * delta + + this.onzoom(delta, ox, oy, 'dblclick') + } +} diff --git a/packages/rete/test/control.ts b/packages/shared/rete/test/control.ts similarity index 100% rename from packages/rete/test/control.ts rename to packages/shared/rete/test/control.ts diff --git a/packages/rete/test/core.ts b/packages/shared/rete/test/core.ts similarity index 100% rename from packages/rete/test/core.ts rename to packages/shared/rete/test/core.ts diff --git a/packages/shared/rete/test/data/add-numbers.js b/packages/shared/rete/test/data/add-numbers.js new file mode 100644 index 0000000000..ca85122e69 --- /dev/null +++ b/packages/shared/rete/test/data/add-numbers.js @@ -0,0 +1,76 @@ +export default { + id: 'test@0.0.1', + nodes: { + 1: { + id: 1, + data: { + num: 2, + }, + inputs: {}, + outputs: { + num: { + connections: [ + { + node: 3, + input: 'num1', + data: {}, + }, + ], + }, + }, + position: [80, 200], + name: 'Number', + }, + 2: { + id: 2, + data: { + num: 0, + }, + inputs: {}, + outputs: { + num: { + connections: [ + { + node: 3, + input: 'num2', + data: {}, + }, + ], + }, + }, + position: [80, 400], + name: 'Number', + }, + 3: { + id: 3, + data: {}, + inputs: { + num1: { + connections: [ + { + node: 1, + output: 'num', + data: {}, + }, + ], + }, + num2: { + connections: [ + { + node: 2, + output: 'num', + data: {}, + }, + ], + }, + }, + outputs: { + num: { + connections: [], + }, + }, + position: [500, 240], + name: 'Add', + }, + }, +} diff --git a/packages/shared/rete/test/data/components.ts b/packages/shared/rete/test/data/components.ts new file mode 100644 index 0000000000..c3e61b680c --- /dev/null +++ b/packages/shared/rete/test/data/components.ts @@ -0,0 +1,29 @@ +import { Component, Input, Node, Output, Socket } from '../../src' + +const socketNum = new Socket('Number') + +export class Comp1 extends Component { + constructor() { + super('Number') + } + + async builder(node: Node) { + node.addOutput(new Output('num', 'Name', socketNum)) + } + + worker() {} +} + +export class Comp2 extends Component { + constructor() { + super('Add') + } + + async builder(node: Node) { + node.addInput(new Input('num1', 'Name', socketNum)) + node.addInput(new Input('num2', 'Name', socketNum)) + node.addOutput(new Output('num', 'Name', socketNum)) + } + + worker() {} +} diff --git a/packages/shared/rete/test/data/recursive.js b/packages/shared/rete/test/data/recursive.js new file mode 100644 index 0000000000..db4d4acaf6 --- /dev/null +++ b/packages/shared/rete/test/data/recursive.js @@ -0,0 +1,116 @@ +export default { + id: 'test@0.0.1', + nodes: { + 1: { + id: 1, + data: { + num: 2, + }, + group: null, + inputs: [], + outputs: [ + { + connections: [ + { + node: 3, + input: 0, + }, + ], + }, + ], + position: [80, 200], + name: 'name', + }, + 2: { + id: 2, + data: { + num: 1, + }, + group: null, + inputs: [], + outputs: [ + { + connections: [ + { + node: 4, + input: 1, + }, + ], + }, + ], + position: [105.55555555555556, 516.6666666666666], + name: 'name', + }, + 3: { + id: 3, + data: {}, + group: null, + inputs: [ + { + connections: [ + { + node: 1, + output: 0, + }, + ], + }, + { + connections: [ + { + node: 4, + output: 0, + }, + ], + }, + ], + outputs: [ + { + connections: [ + { + node: 4, + input: 0, + }, + ], + }, + ], + position: [454.44444444444446, 108.88888888888889], + name: 'Add', + }, + 4: { + id: 4, + data: {}, + group: null, + inputs: [ + { + connections: [ + { + node: 3, + output: 0, + }, + ], + }, + { + connections: [ + { + node: 2, + output: 0, + }, + ], + }, + ], + outputs: [ + { + connections: [ + { + node: 3, + input: 1, + }, + ], + }, + ], + position: [781.6666666666663, 260.0000000000001], + name: 'Add', + }, + }, + groups: {}, +} diff --git a/packages/rete/test/editor.ts b/packages/shared/rete/test/editor.ts similarity index 100% rename from packages/rete/test/editor.ts rename to packages/shared/rete/test/editor.ts diff --git a/packages/rete/test/engine.ts b/packages/shared/rete/test/engine.ts similarity index 100% rename from packages/rete/test/engine.ts rename to packages/shared/rete/test/engine.ts diff --git a/packages/rete/test/socket.ts b/packages/shared/rete/test/socket.ts similarity index 100% rename from packages/rete/test/socket.ts rename to packages/shared/rete/test/socket.ts diff --git a/packages/shared/rete/test/utils/render-mock.js b/packages/shared/rete/test/utils/render-mock.js new file mode 100644 index 0000000000..576f175796 --- /dev/null +++ b/packages/shared/rete/test/utils/render-mock.js @@ -0,0 +1,10 @@ +export function renderMock(editor) { + editor.on('rendernode', ({ node, bindSocket, bindControl }) => { + Array.from(node.inputs.values()).forEach(i => { + bindSocket(document.createElement('div'), 'input', i) + }) + Array.from(node.outputs.values()).forEach(o => { + bindSocket(document.createElement('div'), 'output', o) + }) + }) +} diff --git a/packages/shared/rete/test/utils/throwsAsync.js b/packages/shared/rete/test/utils/throwsAsync.js new file mode 100644 index 0000000000..197b9959d9 --- /dev/null +++ b/packages/shared/rete/test/utils/throwsAsync.js @@ -0,0 +1,15 @@ +import assert from 'assert' + +export default async function (fn, msg) { + let f = () => {} + + try { + await fn() + } catch (e) { + f = () => { + throw new Error(e) + } + } finally { + assert.throws(f, Error, msg) + } +} diff --git a/packages/rete/test/validator.ts b/packages/shared/rete/test/validator.ts similarity index 100% rename from packages/rete/test/validator.ts rename to packages/shared/rete/test/validator.ts diff --git a/packages/rete/tsconfig.json b/packages/shared/rete/tsconfig.json similarity index 90% rename from packages/rete/tsconfig.json rename to packages/shared/rete/tsconfig.json index f5b85657a8..8122543a9a 100644 --- a/packages/rete/tsconfig.json +++ b/packages/shared/rete/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig.base.json", + "extends": "../../../tsconfig.base.json", "compilerOptions": { "module": "commonjs", "forceConsistentCasingInFileNames": true, diff --git a/packages/rete/tsconfig.lib.json b/packages/shared/rete/tsconfig.lib.json similarity index 84% rename from packages/rete/tsconfig.lib.json rename to packages/shared/rete/tsconfig.lib.json index 33eca2c2cd..4befa7f099 100644 --- a/packages/rete/tsconfig.lib.json +++ b/packages/shared/rete/tsconfig.lib.json @@ -1,7 +1,7 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", + "outDir": "../../../dist/out-tsc", "declaration": true, "types": ["node"] }, diff --git a/packages/rete/tsconfig.spec.json b/packages/shared/rete/tsconfig.spec.json similarity index 85% rename from packages/rete/tsconfig.spec.json rename to packages/shared/rete/tsconfig.spec.json index 9b2a121d11..69a251f328 100644 --- a/packages/rete/tsconfig.spec.json +++ b/packages/shared/rete/tsconfig.spec.json @@ -1,7 +1,7 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", + "outDir": "../../../dist/out-tsc", "module": "commonjs", "types": ["jest", "node"] }, diff --git a/packages/rete/vite.config.ts b/packages/shared/rete/vite.config.ts similarity index 94% rename from packages/rete/vite.config.ts rename to packages/shared/rete/vite.config.ts index ffd87e14a9..ac495d9ac5 100644 --- a/packages/rete/vite.config.ts +++ b/packages/shared/rete/vite.config.ts @@ -6,7 +6,7 @@ import dts from 'vite-plugin-dts' import * as path from 'path' export default defineConfig({ - cacheDir: '../../node_modules/.vite/@magickml/rete', + cacheDir: '../../../node_modules/.vite/@magickml/rete', plugins: [ dts({ diff --git a/tsconfig.base.json b/tsconfig.base.json index 8eefda6a35..26b17bd891 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -184,7 +184,6 @@ "@magickml/plugin-twitter-server": [ "packages/plugins/twitter/server/src/index.ts" ], - "@magickml/rete": ["packages/rete/src/index.ts"], "@magickml/server": ["apps/server/src/index.ts"], "@magickml/server-core": ["packages/core/server/src/index.ts"], "@magickml/types": ["packages/@types/src/index.ts"], @@ -206,7 +205,8 @@ "server/cloud-agent-worker": [ "packages/server/cloud-agent-worker/src/index.ts" ], - "server/redis-pubsub": ["packages/server/redis-pubsub/src/index.ts"] + "server/redis-pubsub": ["packages/server/redis-pubsub/src/index.ts"], + "shared/rete": ["packages/shared/rete/src/index.ts"] } }, "exclude": ["node_modules", "tmp"] From 06a45990e9a96b571de3f111e5af9792891b142a Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 27 Sep 2023 11:48:33 -0700 Subject: [PATCH 122/349] Move config into shared folder --- apps/agent/knexfile.ts | 2 +- apps/agent/src/index.ts | 2 +- apps/client/src/main.tsx | 2 +- apps/cloud-agent-manager/src/main.ts | 2 +- apps/cloud-agent-worker/src/main.ts | 2 +- apps/server/src/index.ts | 2 +- .../editor/src/components/MenuBar/MenuBar.tsx | 2 +- .../src/plugins/reactRenderPlugin/Upload.tsx | 2 +- .../screens/DocumentWindow/DocumentTable.tsx | 2 +- .../src/screens/DocumentWindow/index.tsx | 2 +- .../src/screens/EventWindow/EventTable.tsx | 2 +- .../editor/src/screens/EventWindow/index.tsx | 2 +- .../screens/RequestWindow/RequestTable.tsx | 2 +- .../src/screens/RequestWindow/index.tsx | 2 +- .../src/screens/agents/AgentManagerWindow.tsx | 2 +- .../client/editor/src/utils/speechUtils.ts | 2 +- packages/client/editor/src/wdyr.ts | 2 +- packages/config/README.md | 11 - .../src/components/Drawer/AgentMenu.tsx | 2 +- .../components/Drawer/Newsidebar/index.tsx | 130 ++-- .../components/Drawer/OldSidebar/index.tsx | 2 +- .../components/Drawer/ProjectWindow/index.tsx | 14 +- .../client/src/components/Drawer/index.tsx | 2 +- .../client/src/contexts/TreeDataProvider.tsx | 30 +- .../client/src/providers/ConfigProvider.tsx | 48 +- packages/core/server/src/app.ts | 6 +- packages/core/server/src/dbClient.ts | 2 +- .../server/src/metering/meteringClient.ts | 2 +- .../core/server/src/servers/fileServer.ts | 2 +- .../server/src/servers/googleSpeechToText.ts | 2 +- .../services/agentImage/agentImage.class.ts | 3 +- .../core/shared/src/functions/speechUtils.ts | 2 +- packages/core/shared/src/logger/index.ts | 2 +- packages/core/shared/src/nodes/io/Request.ts | 2 +- packages/core/shared/src/utils/getSpell.ts | 2 +- .../avatar/client/src/hooks/useAgentList.ts | 2 +- .../avatar/client/src/hooks/useSpellList.ts | 2 +- .../client/src/components/agent.component.tsx | 4 +- .../shared/src/nodes/CompileContract.ts | 2 +- .../src/windows/IntentWindow/IntentTable.tsx | 115 +-- .../client/src/windows/IntentWindow/index.tsx | 11 +- .../src/functions/makeChatCompletion.ts | 2 +- .../src/functions/makeTextCompletion.ts | 2 +- .../server/src/functions/makeTextEmbedding.ts | 2 +- .../client/src/components/rest.component.tsx | 707 +++++++++--------- .../src/services/agentHttp/agentHttp.class.ts | 2 +- .../src/windows/TaskWindow/TaskTable.tsx | 2 +- .../client/src/windows/TaskWindow/index.tsx | 2 +- .../server/agents/src/lib/AgentCommander.ts | 2 +- .../server/agents/src/lib/AgentManager.ts | 2 +- .../redis-pubsub/src/lib/redis-pubsub.ts | 2 +- packages/{ => shared}/config/.eslintrc.json | 2 +- packages/shared/config/README.md | 11 + packages/{ => shared}/config/package.json | 2 +- packages/{ => shared}/config/project.json | 14 +- packages/{ => shared}/config/src/config.ts | 0 .../config/src/import-meta-env.ts | 0 packages/{ => shared}/config/src/index.ts | 0 packages/{ => shared}/config/tsconfig.json | 2 +- .../{ => shared}/config/tsconfig.lib.json | 2 +- .../{ => shared}/config/tsconfig.spec.json | 2 +- packages/{ => shared}/config/vite.config.ts | 8 +- tsconfig.base.json | 2 +- 63 files changed, 605 insertions(+), 599 deletions(-) delete mode 100644 packages/config/README.md rename packages/{ => shared}/config/.eslintrc.json (86%) create mode 100644 packages/shared/config/README.md rename packages/{ => shared}/config/package.json (61%) rename packages/{ => shared}/config/project.json (52%) rename packages/{ => shared}/config/src/config.ts (100%) rename packages/{ => shared}/config/src/import-meta-env.ts (100%) rename packages/{ => shared}/config/src/index.ts (100%) rename packages/{ => shared}/config/tsconfig.json (91%) rename packages/{ => shared}/config/tsconfig.lib.json (88%) rename packages/{ => shared}/config/tsconfig.spec.json (92%) rename packages/{ => shared}/config/vite.config.ts (90%) diff --git a/apps/agent/knexfile.ts b/apps/agent/knexfile.ts index 86ff32c483..e422b05cd4 100644 --- a/apps/agent/knexfile.ts +++ b/apps/agent/knexfile.ts @@ -1,4 +1,4 @@ -import { DATABASE_URL } from '@magickml/config' +import { DATABASE_URL } from 'shared/config' const config = { client: 'pg', diff --git a/apps/agent/src/index.ts b/apps/agent/src/index.ts index a05e0d0e16..fdb846da19 100644 --- a/apps/agent/src/index.ts +++ b/apps/agent/src/index.ts @@ -10,7 +10,7 @@ import { app, initApp } from '@magickml/server-core' import { initLogger, getLogger } from '@magickml/core' import 'regenerator-runtime/runtime' import pluginExports from './plugins' -import { PRODUCTION, DONT_CRASH_ON_ERROR } from '@magickml/config' +import { PRODUCTION, DONT_CRASH_ON_ERROR } from 'shared/config' /** * Asynchronously loads the application's plugins and logs their names. diff --git a/apps/client/src/main.tsx b/apps/client/src/main.tsx index e8413169ed..895cd7c7a1 100644 --- a/apps/client/src/main.tsx +++ b/apps/client/src/main.tsx @@ -10,7 +10,7 @@ import { POSTHOG_ENABLED, DEFAULT_USER_TOKEN, STANDALONE, -} from '@magickml/config' +} from 'shared/config' import { PostHogProvider } from 'posthog-js/react' import { initLogger, getLogger } from '@magickml/core' diff --git a/apps/cloud-agent-manager/src/main.ts b/apps/cloud-agent-manager/src/main.ts index 9a28f14aa9..990dde3d14 100644 --- a/apps/cloud-agent-manager/src/main.ts +++ b/apps/cloud-agent-manager/src/main.ts @@ -4,7 +4,7 @@ import { } from 'server/cloud-agent-manager' import { initLogger, getLogger } from '@magickml/core' import { app, BullQueue, initApp } from '@magickml/server-core' -import { DONT_CRASH_ON_ERROR, PRODUCTION } from '@magickml/config' +import { DONT_CRASH_ON_ERROR, PRODUCTION } from 'shared/config' import { initAgentCommander } from 'server/agents' import { getPinoTransport } from '@hyperdx/node-opentelemetry' diff --git a/apps/cloud-agent-worker/src/main.ts b/apps/cloud-agent-worker/src/main.ts index 07600ec6d9..8e26e99c22 100644 --- a/apps/cloud-agent-worker/src/main.ts +++ b/apps/cloud-agent-worker/src/main.ts @@ -3,7 +3,7 @@ import { initLogger, getLogger } from '@magickml/core' import { initApp } from '@magickml/server-core' import pluginExports from './plugins' import { initAgentCommander } from 'server/agents' -import { DONT_CRASH_ON_ERROR, PRODUCTION } from '@magickml/config' +import { DONT_CRASH_ON_ERROR, PRODUCTION } from 'shared/config' import { getPinoTransport } from '@hyperdx/node-opentelemetry' if (PRODUCTION) { diff --git a/apps/server/src/index.ts b/apps/server/src/index.ts index 09fc0b7757..bbabe4d4f0 100644 --- a/apps/server/src/index.ts +++ b/apps/server/src/index.ts @@ -25,7 +25,7 @@ import 'regenerator-runtime/runtime' import plugins from './plugins' import { initAgentCommander } from 'server/agents' import { getPinoTransport } from '@hyperdx/node-opentelemetry' -import { PRODUCTION } from '@magickml/config' +import { PRODUCTION } from 'shared/config' if (PRODUCTION) { initLogger({ diff --git a/packages/client/editor/src/components/MenuBar/MenuBar.tsx b/packages/client/editor/src/components/MenuBar/MenuBar.tsx index 4b067f5f99..9522610658 100644 --- a/packages/client/editor/src/components/MenuBar/MenuBar.tsx +++ b/packages/client/editor/src/components/MenuBar/MenuBar.tsx @@ -2,7 +2,7 @@ import { useFeatureFlagEnabled } from 'posthog-js/react' import OldMenuBar from './OldMenuBar' import NewMenuBar from './newMenuBar' -import { FEATURE_FLAGS } from '@magickml/config' +import { FEATURE_FLAGS } from 'shared/config' /** * MenuBar component diff --git a/packages/client/editor/src/plugins/reactRenderPlugin/Upload.tsx b/packages/client/editor/src/plugins/reactRenderPlugin/Upload.tsx index 2c722854a1..3c792dde67 100644 --- a/packages/client/editor/src/plugins/reactRenderPlugin/Upload.tsx +++ b/packages/client/editor/src/plugins/reactRenderPlugin/Upload.tsx @@ -1,6 +1,6 @@ // DOCUMENTED -import { API_ROOT_URL } from '@magickml/config' +import { API_ROOT_URL } from 'shared/config' import { useState } from 'react' import { useSelector } from 'react-redux' diff --git a/packages/client/editor/src/screens/DocumentWindow/DocumentTable.tsx b/packages/client/editor/src/screens/DocumentWindow/DocumentTable.tsx index 75f49f31ea..34f60fecbf 100644 --- a/packages/client/editor/src/screens/DocumentWindow/DocumentTable.tsx +++ b/packages/client/editor/src/screens/DocumentWindow/DocumentTable.tsx @@ -2,7 +2,7 @@ // Import statements kept as-is import { TableComponent } from '@magickml/client-core' import { CompletionProvider, pluginManager } from '@magickml/core' -import { API_ROOT_URL } from '@magickml/config' +import { API_ROOT_URL } from 'shared/config' import { MoreHoriz, NewReleases, Refresh } from '@mui/icons-material' import { Button, diff --git a/packages/client/editor/src/screens/DocumentWindow/index.tsx b/packages/client/editor/src/screens/DocumentWindow/index.tsx index a37134518d..b7d9e36884 100644 --- a/packages/client/editor/src/screens/DocumentWindow/index.tsx +++ b/packages/client/editor/src/screens/DocumentWindow/index.tsx @@ -1,5 +1,5 @@ // DOCUMENTED -import { API_ROOT_URL } from '@magickml/config' +import { API_ROOT_URL } from 'shared/config' import { useEffect, useState } from 'react' import { useSelector } from 'react-redux' import { LoadingScreen, useConfig } from '@magickml/client-core' diff --git a/packages/client/editor/src/screens/EventWindow/EventTable.tsx b/packages/client/editor/src/screens/EventWindow/EventTable.tsx index e6a659467d..3c9bf77639 100644 --- a/packages/client/editor/src/screens/EventWindow/EventTable.tsx +++ b/packages/client/editor/src/screens/EventWindow/EventTable.tsx @@ -1,7 +1,7 @@ // DOCUMENTED // Import statements kept as-is import { TableComponent } from '@magickml/client-core' -import { API_ROOT_URL } from '@magickml/config' +import { API_ROOT_URL } from 'shared/config' import { useFeathers } from '@magickml/client-core' import { Delete, MoreHoriz, Refresh } from '@mui/icons-material' import { diff --git a/packages/client/editor/src/screens/EventWindow/index.tsx b/packages/client/editor/src/screens/EventWindow/index.tsx index 47000991d1..a0c871753b 100644 --- a/packages/client/editor/src/screens/EventWindow/index.tsx +++ b/packages/client/editor/src/screens/EventWindow/index.tsx @@ -1,5 +1,5 @@ // DOCUMENTED -import { API_ROOT_URL } from '@magickml/config' +import { API_ROOT_URL } from 'shared/config' import { useEffect, useState } from 'react' import { useSelector } from 'react-redux' import { LoadingScreen, useConfig } from '@magickml/client-core' diff --git a/packages/client/editor/src/screens/RequestWindow/RequestTable.tsx b/packages/client/editor/src/screens/RequestWindow/RequestTable.tsx index aada4b69a8..0218674f36 100644 --- a/packages/client/editor/src/screens/RequestWindow/RequestTable.tsx +++ b/packages/client/editor/src/screens/RequestWindow/RequestTable.tsx @@ -7,7 +7,7 @@ import { Menu, MenuItem, } from '@mui/material' -import { API_ROOT_URL } from '@magickml/config' +import { API_ROOT_URL } from 'shared/config' import { useMemo, useState } from 'react' import { CSVLink } from 'react-csv' import { FaFileCsv } from 'react-icons/fa' diff --git a/packages/client/editor/src/screens/RequestWindow/index.tsx b/packages/client/editor/src/screens/RequestWindow/index.tsx index e2605e6128..0959051940 100644 --- a/packages/client/editor/src/screens/RequestWindow/index.tsx +++ b/packages/client/editor/src/screens/RequestWindow/index.tsx @@ -8,7 +8,7 @@ import { useEffect, useState } from 'react' import RequestTable from './RequestTable' -import { API_ROOT_URL } from '@magickml/config' +import { API_ROOT_URL } from 'shared/config' import { LoadingScreen, useConfig } from '@magickml/client-core' import { useSelector } from 'react-redux' diff --git a/packages/client/editor/src/screens/agents/AgentManagerWindow.tsx b/packages/client/editor/src/screens/agents/AgentManagerWindow.tsx index 93cc110c07..3955929344 100644 --- a/packages/client/editor/src/screens/agents/AgentManagerWindow.tsx +++ b/packages/client/editor/src/screens/agents/AgentManagerWindow.tsx @@ -1,7 +1,7 @@ // DOCUMENTED import { LoadingScreen } from '@magickml/client-core' import { type ClientPluginManager, pluginManager } from '@magickml/core' -import { DEFAULT_USER_TOKEN, PRODUCTION, STANDALONE } from '@magickml/config' +import { DEFAULT_USER_TOKEN, PRODUCTION, STANDALONE } from 'shared/config' import { useSnackbar } from 'notistack' import { useEffect, useState } from 'react' import { useSelector } from 'react-redux' diff --git a/packages/client/editor/src/utils/speechUtils.ts b/packages/client/editor/src/utils/speechUtils.ts index 8d1682fe55..f7eb8a85d7 100644 --- a/packages/client/editor/src/utils/speechUtils.ts +++ b/packages/client/editor/src/utils/speechUtils.ts @@ -1,6 +1,6 @@ // DOCUMENTED -import { SPEECH_SERVER_URL } from '@magickml/config' +import { SPEECH_SERVER_URL } from 'shared/config' import socketIOClient from 'socket.io-client' /** diff --git a/packages/client/editor/src/wdyr.ts b/packages/client/editor/src/wdyr.ts index fe1ab09da5..d3cd6b14de 100644 --- a/packages/client/editor/src/wdyr.ts +++ b/packages/client/editor/src/wdyr.ts @@ -1,6 +1,6 @@ // DOCUMENTED -import { NODE_ENV } from '@magickml/config' +import { NODE_ENV } from 'shared/config' import whyDidYouRender from '@welldone-software/why-did-you-render' /** diff --git a/packages/config/README.md b/packages/config/README.md deleted file mode 100644 index fb0e33f51e..0000000000 --- a/packages/config/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# config - -This library was generated with [Nx](https://nx.dev). - -## Building - -Run `nx build config` to build the library. - -## Running unit tests - -Run `nx test config` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/packages/core/client/src/components/Drawer/AgentMenu.tsx b/packages/core/client/src/components/Drawer/AgentMenu.tsx index 85a3471c05..15cd172c20 100644 --- a/packages/core/client/src/components/Drawer/AgentMenu.tsx +++ b/packages/core/client/src/components/Drawer/AgentMenu.tsx @@ -20,7 +20,7 @@ import { useConfig } from '@magickml/client-core' import { enqueueSnackbar } from 'notistack' import { useDispatch, useSelector } from 'react-redux' import { Modal } from '@magickml/client-core' -import { DEFAULT_USER_TOKEN, STANDALONE, API_ROOT_URL } from '@magickml/config' +import { DEFAULT_USER_TOKEN, STANDALONE, API_ROOT_URL } from 'shared/config' import { useFeathers } from '../../providers/FeathersProvider' diff --git a/packages/core/client/src/components/Drawer/Newsidebar/index.tsx b/packages/core/client/src/components/Drawer/Newsidebar/index.tsx index 975986f4a6..0c7b0aadbf 100644 --- a/packages/core/client/src/components/Drawer/Newsidebar/index.tsx +++ b/packages/core/client/src/components/Drawer/Newsidebar/index.tsx @@ -39,7 +39,7 @@ import DescriptionOutlinedIcon from '@mui/icons-material/DescriptionOutlined' import StarBorderPurple500OutlinedIcon from '@mui/icons-material/StarBorderPurple500Outlined' import HistoryEduOutlinedIcon from '@mui/icons-material/HistoryEduOutlined' import { useConfig } from '@magickml/client-core' -import { DEFAULT_USER_TOKEN, STANDALONE, PRODUCTION } from '@magickml/config' +import { DEFAULT_USER_TOKEN, STANDALONE, PRODUCTION } from 'shared/config' import { useDispatch, useSelector } from 'react-redux' // todo FIX THIS IMPORT @@ -63,7 +63,7 @@ const closedMixin = (theme: Theme): CSSObject => ({ duration: theme.transitions.duration.leavingScreen, }), overflowX: 'hidden', - width: '0px' + width: '0px', }) // DrawerHeader component properties @@ -110,7 +110,6 @@ const StyledDrawer = styled(MuiDrawer, { }), })) - // DrawerItem component properties type DrawerItemProps = { Icon: React.ElementType @@ -177,38 +176,36 @@ const PluginDrawerItems: React.FC = ({ const drawerItems = (pluginManager as ClientPluginManager).getDrawerItems() let lastPlugin: string | null = null let divider = false - return ( - drawerItems.map(item => { - if (item.plugin !== lastPlugin) { - divider = false - lastPlugin = item.plugin - } else { - divider = false - } - return ( -
- {divider && } - { - openTab({ - name: item.text, - type: item.text, - switchActive: true, - id: item.text, - }) - }} - text={item.text} - tooltip="Avatar and Tasks Tooltip" - tooltipText={item.tooltip} - /> -
- ) - }) - ) + return drawerItems.map(item => { + if (item.plugin !== lastPlugin) { + divider = false + lastPlugin = item.plugin + } else { + divider = false + } + return ( +
+ {divider && } + { + openTab({ + name: item.text, + type: item.text, + switchActive: true, + id: item.text, + }) + }} + text={item.text} + tooltip="Avatar and Tasks Tooltip" + tooltipText={item.tooltip} + /> +
+ ) + }) } type DrawerProps = { @@ -231,11 +228,10 @@ export function NewSidebar(DrawerProps): JSX.Element { const [data, setData] = useState([]) const globalConfig = useSelector((state: any) => state.globalConfig) const token = globalConfig?.token - const { treeData, setTreeData, - setAgentUpdate } = useTreeData() + const { treeData, setTreeData, setAgentUpdate } = useTreeData() useEffect(() => { - console.log("!!!!!!!!!TREE DATA", treeData) + console.log('!!!!!!!!!TREE DATA', treeData) }, [treeData]) const handleDrop = (newTree: NodeModel[]) => { @@ -321,33 +317,33 @@ export function NewSidebar(DrawerProps): JSX.Element { useEffect(() => { if (!config.apiUrl) return - ; (async () => { - const res = await fetch( - `${config.apiUrl}/agents?projectId=${config.projectId}`, - { - headers: STANDALONE - ? { Authorization: `Bearer ${DEFAULT_USER_TOKEN}` } - : { Authorization: `Bearer ${token}` }, - } - ) - const json = await res.json() - // if data.length === 0 create new agent - if (json.data.length === 0) { - await createNew({ - name: "Default Agent", - projectId: config.projectId, - enabled: false, - publicVariables: '{}', - secrets: '{}', - default: true, - }) - setData(json.data) - } else { - setData(json.data) + ;(async () => { + const res = await fetch( + `${config.apiUrl}/agents?projectId=${config.projectId}`, + { + headers: STANDALONE + ? { Authorization: `Bearer ${DEFAULT_USER_TOKEN}` } + : { Authorization: `Bearer ${token}` }, } + ) + const json = await res.json() + // if data.length === 0 create new agent + if (json.data.length === 0) { + await createNew({ + name: 'Default Agent', + projectId: config.projectId, + enabled: false, + publicVariables: '{}', + secrets: '{}', + default: true, + }) + setData(json.data) + } else { + setData(json.data) + } - // setIsLoading(false) - })() + // setIsLoading(false) + })() }, [config?.apiUrl]) // Function to handle the click event on the hideMenu div @@ -472,7 +468,9 @@ export function NewSidebar(DrawerProps): JSX.Element {
- Notion (coming soon) + + Notion (coming soon) +
@@ -553,7 +551,5 @@ export function NewSidebar(DrawerProps): JSX.Element { } export const DrawerProvider = ({ children }: DrawerProps) => { - return ( - {children} - ) + return {children} } diff --git a/packages/core/client/src/components/Drawer/OldSidebar/index.tsx b/packages/core/client/src/components/Drawer/OldSidebar/index.tsx index 375ed6eba1..adda6cb640 100644 --- a/packages/core/client/src/components/Drawer/OldSidebar/index.tsx +++ b/packages/core/client/src/components/Drawer/OldSidebar/index.tsx @@ -26,7 +26,7 @@ import MagickLogo from '../logo-full.png' import MagickLogoSmall from '../logo-small.png' import { Tooltip } from '@mui/material' import { drawerTooltipText } from '../tooltiptext' -import { STANDALONE } from '@magickml/config' +import { STANDALONE } from 'shared/config' // Constants const drawerWidth = 150 diff --git a/packages/core/client/src/components/Drawer/ProjectWindow/index.tsx b/packages/core/client/src/components/Drawer/ProjectWindow/index.tsx index 6ea105dc95..20690bfa75 100644 --- a/packages/core/client/src/components/Drawer/ProjectWindow/index.tsx +++ b/packages/core/client/src/components/Drawer/ProjectWindow/index.tsx @@ -2,7 +2,7 @@ /** @module ProjectWindow */ import { SpellInterface } from '@magickml/core' -import { API_ROOT_URL, PRODUCTION } from '@magickml/config' +import { API_ROOT_URL, PRODUCTION } from 'shared/config' import { Apps, ChevronRight, @@ -55,7 +55,11 @@ const ProjectWindow = ({ openDrawer }) => { const [anchorEl, setAnchorEl] = useState(null) const open = Boolean(anchorEl) - const [data, setData] = useState({ agents: [], spells: [], documents: [] }) + const [data, setData] = useState({ + agents: [], + spells: [], + documents: [], + }) const [loaded, setLoaded] = useState(false) const token = globalConfig?.token @@ -364,7 +368,11 @@ const ProjectWindow = ({ openDrawer }) => { key={index} style={{ width: '100%' }} nodeId={30 + index.toString()} - label={document?.content ? document.content.slice(0, 12) : "document"} + label={ + document?.content + ? document.content.slice(0, 12) + : 'document' + } icon={} /> ))} diff --git a/packages/core/client/src/components/Drawer/index.tsx b/packages/core/client/src/components/Drawer/index.tsx index 7200ccb7e4..a375fb9d67 100644 --- a/packages/core/client/src/components/Drawer/index.tsx +++ b/packages/core/client/src/components/Drawer/index.tsx @@ -1,6 +1,6 @@ // DOCUMENTED import { useFeatureFlagEnabled } from 'posthog-js/react' -import { FEATURE_FLAGS } from '@magickml/config' +import { FEATURE_FLAGS } from 'shared/config' import { ProjectWindowProvider } from '../../contexts/ProjectWindowContext' import { OldSidebar } from './OldSidebar' import { NewSidebar } from './Newsidebar' diff --git a/packages/core/client/src/contexts/TreeDataProvider.tsx b/packages/core/client/src/contexts/TreeDataProvider.tsx index 710e9e73f0..acb895b32e 100644 --- a/packages/core/client/src/contexts/TreeDataProvider.tsx +++ b/packages/core/client/src/contexts/TreeDataProvider.tsx @@ -2,7 +2,7 @@ import React, { createContext, useContext, useState, useEffect } from 'react' import { NodeModel } from '@minoru/react-dnd-treeview' import { useSnackbar } from 'notistack' import { useConfig, useFeathers } from '@magickml/client-core' -import { API_ROOT_URL } from '@magickml/config' +import { API_ROOT_URL } from 'shared/config' import { useSelector } from 'react-redux' import SampleData from './data/sampleData.json' @@ -19,29 +19,28 @@ interface TreeDataContextType { setOpenDoc: React.Dispatch> agentUpdate: boolean setAgentUpdate: React.Dispatch> - } interface Document { - id: string; - content: string; + id: string + content: string } interface Spell { - id: string; - name: string; + id: string + name: string } const TreeDataContext = createContext({ treeData: [], - setTreeData: () => { }, + setTreeData: () => {}, isAdded: false, - setIsAdded: () => { }, + setIsAdded: () => {}, docState: false, - setDocState: () => { }, + setDocState: () => {}, toDelete: null, - setToDelete: () => { }, + setToDelete: () => {}, openDoc: '', - setOpenDoc: () => { }, + setOpenDoc: () => {}, agentUpdate: false, setAgentUpdate: () => { }, }) @@ -199,13 +198,8 @@ export const TreeDataProvider = ({ children }: Props): JSX.Element => { agentUpdate, setAgentUpdate, }} - >{children} + > + {children} ) } - - - - - - diff --git a/packages/core/client/src/providers/ConfigProvider.tsx b/packages/core/client/src/providers/ConfigProvider.tsx index 725310eb08..910a2f5557 100644 --- a/packages/core/client/src/providers/ConfigProvider.tsx +++ b/packages/core/client/src/providers/ConfigProvider.tsx @@ -1,31 +1,31 @@ -// DOCUMENTED +// DOCUMENTED // Import required dependencies -import { DEFAULT_PROJECT_ID } from '@magickml/config'; -import { createContext, useContext, useState } from 'react'; +import { DEFAULT_PROJECT_ID } from 'shared/config' +import { createContext, useContext, useState } from 'react' // Define AppConfig type export type AppConfig = { - apiUrl: string; - projectId: string; - token: string; - posthogEnabled?: boolean; -}; + apiUrl: string + projectId: string + token: string + posthogEnabled?: boolean +} // Define ConfigContext interface export interface ConfigContext { - apiUrl: string; - setApiUrl: (url: string) => void; - projectId: string; - setProjectId: (id: string) => void; + apiUrl: string + setApiUrl: (url: string) => void + projectId: string + setProjectId: (id: string) => void } // Create context for ConfigContext -const Context = createContext(undefined!); +const Context = createContext(undefined!) /** * Custom hook to use the config context */ -export const useConfig = () => useContext(Context); +export const useConfig = () => useContext(Context) /** * Default AppConfig @@ -34,27 +34,23 @@ export const defaultConfig: AppConfig = { apiUrl: 'http://localhost:3030', projectId: DEFAULT_PROJECT_ID, token: '', -}; +} /** * ConfigProvider component that handles global configuration */ export const ConfigProvider = ({ config = defaultConfig, children }) => { - const [apiUrl, setApiUrl] = useState(config.apiUrl); + const [apiUrl, setApiUrl] = useState(config.apiUrl) const [projectId, setProjectId] = useState( - config.projectId, - ); + config.projectId + ) const publicInterface: ConfigContext = { apiUrl, setApiUrl, projectId, setProjectId, - }; - - return ( - - {children} - - ); -}; \ No newline at end of file + } + + return {children} +} diff --git a/packages/core/server/src/app.ts b/packages/core/server/src/app.ts index d34766e928..5a7561d5ef 100644 --- a/packages/core/server/src/app.ts +++ b/packages/core/server/src/app.ts @@ -19,11 +19,7 @@ import Redis from 'ioredis' import { RedisPubSub } from 'server/redis-pubsub' import sync from 'feathers-sync' -import { - REDISCLOUD_URL, - API_ACCESS_KEY, - bullMQConnection, -} from '@magickml/config' +import { REDISCLOUD_URL, API_ACCESS_KEY, bullMQConnection } from 'shared/config' import { getLogger } from '@magickml/core' import type { AgentCommander } from '@magickml/agents' import { configureManager, globalsManager } from '@magickml/core' diff --git a/packages/core/server/src/dbClient.ts b/packages/core/server/src/dbClient.ts index 14b4a13150..028c60a879 100644 --- a/packages/core/server/src/dbClient.ts +++ b/packages/core/server/src/dbClient.ts @@ -3,7 +3,7 @@ import type { Knex } from 'knex' import knex from 'knex' import type { Application } from './declarations' -import { DATABASE_URL } from '@magickml/config' +import { DATABASE_URL } from 'shared/config' // Extend Configuration interface to include dbClient diff --git a/packages/core/server/src/metering/meteringClient.ts b/packages/core/server/src/metering/meteringClient.ts index 77aaa0ea7f..5ce44cf717 100644 --- a/packages/core/server/src/metering/meteringClient.ts +++ b/packages/core/server/src/metering/meteringClient.ts @@ -4,7 +4,7 @@ import { OPENMETER_ENABLED, OPENMETER_TOKEN, OPENMETER_SOURCE, -} from '@magickml/config' +} from 'shared/config' import { getLogger } from '@magickml/core' import { v4 as uuidv4 } from 'uuid' diff --git a/packages/core/server/src/servers/fileServer.ts b/packages/core/server/src/servers/fileServer.ts index fdd69ccbb8..08fcaa1d7e 100644 --- a/packages/core/server/src/servers/fileServer.ts +++ b/packages/core/server/src/servers/fileServer.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import { FILE_SERVER_PORT, USESSL } from '@magickml/config' +import { FILE_SERVER_PORT, USESSL } from 'shared/config' import * as fs from 'fs' import http from 'http' import https from 'https' diff --git a/packages/core/server/src/servers/googleSpeechToText.ts b/packages/core/server/src/servers/googleSpeechToText.ts index 793688fbd5..50a363a7d5 100644 --- a/packages/core/server/src/servers/googleSpeechToText.ts +++ b/packages/core/server/src/servers/googleSpeechToText.ts @@ -5,7 +5,7 @@ import https from 'https' import * as fs from 'fs' import path from 'path' -import { SPEECH_SERVER_PORT, USSSL_SPEECH } from '@magickml/config' +import { SPEECH_SERVER_PORT, USSSL_SPEECH } from 'shared/config' let speechClient: SpeechClient const encoding = 'LINEAR16' diff --git a/packages/core/server/src/services/agentImage/agentImage.class.ts b/packages/core/server/src/services/agentImage/agentImage.class.ts index f1b7cbf593..22aa7470bc 100644 --- a/packages/core/server/src/services/agentImage/agentImage.class.ts +++ b/packages/core/server/src/services/agentImage/agentImage.class.ts @@ -5,7 +5,8 @@ import { AWS_REGION, AWS_SECRET_KEY, AWS_BUCKET_ENDPOINT, -} from '@magickml/config' +} from 'shared/config' + import { getLogger } from '@magickml/core' type AgentImageData = { diff --git a/packages/core/shared/src/functions/speechUtils.ts b/packages/core/shared/src/functions/speechUtils.ts index 82a8bd4ceb..7ccfbd2ade 100644 --- a/packages/core/shared/src/functions/speechUtils.ts +++ b/packages/core/shared/src/functions/speechUtils.ts @@ -1,7 +1,7 @@ // DOCUMENTED import io, { Socket } from 'socket.io-client' import { DefaultEventsMap } from 'socket.io/dist/typed-events' -import { API_ROOT_URL, SPEECH_SERVER_PORT } from '@magickml/config' +import { API_ROOT_URL, SPEECH_SERVER_PORT } from 'shared/config' const SPEECH_SERVER_URL = `${API_ROOT_URL}:${SPEECH_SERVER_PORT}` /** diff --git a/packages/core/shared/src/logger/index.ts b/packages/core/shared/src/logger/index.ts index 02bfff5835..2f253f41e2 100644 --- a/packages/core/shared/src/logger/index.ts +++ b/packages/core/shared/src/logger/index.ts @@ -1,5 +1,5 @@ import pino from 'pino' -import { NODE_ENV, PINO_LOG_LEVEL } from '@magickml/config' +import { NODE_ENV, PINO_LOG_LEVEL } from 'shared/config' let logger: pino.Logger | null = null diff --git a/packages/core/shared/src/nodes/io/Request.ts b/packages/core/shared/src/nodes/io/Request.ts index 054895d5a5..e1cd932897 100644 --- a/packages/core/shared/src/nodes/io/Request.ts +++ b/packages/core/shared/src/nodes/io/Request.ts @@ -1,7 +1,7 @@ // DOCUMENTED import axios, { AxiosResponse } from 'axios' import Rete from 'shared/rete' -import { API_ROOT_URL } from '@magickml/config' +import { API_ROOT_URL } from 'shared/config' import { InputControl } from '../../dataControls/InputControl' import { SocketGeneratorControl } from '../../dataControls/SocketGenerator' diff --git a/packages/core/shared/src/utils/getSpell.ts b/packages/core/shared/src/utils/getSpell.ts index d93d608bce..63f9f7d035 100644 --- a/packages/core/shared/src/utils/getSpell.ts +++ b/packages/core/shared/src/utils/getSpell.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import { API_ROOT_URL } from '@magickml/config' +import { API_ROOT_URL } from 'shared/config' /** * The type for the function's input parameter which contains the * app object, the projectId, and the id of a specific spell. diff --git a/packages/plugins/avatar/client/src/hooks/useAgentList.ts b/packages/plugins/avatar/client/src/hooks/useAgentList.ts index 9030c278cc..0b50e1b036 100644 --- a/packages/plugins/avatar/client/src/hooks/useAgentList.ts +++ b/packages/plugins/avatar/client/src/hooks/useAgentList.ts @@ -1,5 +1,5 @@ import { useEffect, useState } from 'react' -import { IGNORE_AUTH } from '@magickml/config' +import { IGNORE_AUTH } from 'shared/config' import { useConfig } from '@magickml/client-core' import { useSelector } from 'react-redux' diff --git a/packages/plugins/avatar/client/src/hooks/useSpellList.ts b/packages/plugins/avatar/client/src/hooks/useSpellList.ts index 10bf8e834b..490dfd4bd7 100644 --- a/packages/plugins/avatar/client/src/hooks/useSpellList.ts +++ b/packages/plugins/avatar/client/src/hooks/useSpellList.ts @@ -1,5 +1,5 @@ import { useEffect, useState } from 'react' -import { DEFAULT_USER_TOKEN, STANDALONE } from '@magickml/config' +import { DEFAULT_USER_TOKEN, STANDALONE } from 'shared/config' import { useConfig } from '@magickml/client-core' import { useSelector } from 'react-redux' diff --git a/packages/plugins/discord/client/src/components/agent.component.tsx b/packages/plugins/discord/client/src/components/agent.component.tsx index e1665793f9..552c10a439 100644 --- a/packages/plugins/discord/client/src/components/agent.component.tsx +++ b/packages/plugins/discord/client/src/components/agent.component.tsx @@ -2,13 +2,13 @@ import axios from 'axios' import { useSnackbar } from 'notistack' import React, { FC, useEffect, useRef, useState } from 'react' import { debounce } from 'lodash' -import { Tooltip } from "@mui/material" +import { Tooltip } from '@mui/material' type PluginProps = { selectedAgentData: any props } -import { API_ROOT_URL, FILE_SERVER_URL } from '@magickml/config' +import { API_ROOT_URL, FILE_SERVER_URL } from 'shared/config' import { Switch } from '@magickml/client-core' import VariableModal from './VariableModal' import { useSelector } from 'react-redux' diff --git a/packages/plugins/ethereum/shared/src/nodes/CompileContract.ts b/packages/plugins/ethereum/shared/src/nodes/CompileContract.ts index 27f73a1aa9..290b5425c6 100644 --- a/packages/plugins/ethereum/shared/src/nodes/CompileContract.ts +++ b/packages/plugins/ethereum/shared/src/nodes/CompileContract.ts @@ -2,7 +2,7 @@ import { isEmpty } from 'lodash' import Rete from 'shared/rete' import { v4 as uuidv4 } from 'uuid' -import { API_ROOT_URL } from '@magickml/config' +import { API_ROOT_URL } from 'shared/config' import { anySocket, diff --git a/packages/plugins/intent/client/src/windows/IntentWindow/IntentTable.tsx b/packages/plugins/intent/client/src/windows/IntentWindow/IntentTable.tsx index e4b5e34239..7b3fd8efef 100644 --- a/packages/plugins/intent/client/src/windows/IntentWindow/IntentTable.tsx +++ b/packages/plugins/intent/client/src/windows/IntentWindow/IntentTable.tsx @@ -2,7 +2,7 @@ // Import statements kept as-is import { TableComponent } from '@magickml/client-core' import { CompletionProvider, pluginManager } from '@magickml/core' -import { API_ROOT_URL } from '@magickml/config' +import { API_ROOT_URL } from 'shared/config' import { MoreHoriz, NewReleases, Refresh } from '@mui/icons-material' import { Button, @@ -148,29 +148,35 @@ function IntentTable({ intents, updateCallback }) { ) // Initialize the table with hooks - const { page, pageOptions, gotoPage, setGlobalFilter, state: { sortBy, globalFilter }, - setSortBy } = - useTable( - { - columns: defaultColumns, - data: intents, - initialState: { - // todo needto add proper generic to useTable to fix this - // @ts-ignore - pageIndex: currentPage - } + const { + page, + pageOptions, + gotoPage, + setGlobalFilter, + state: { sortBy, globalFilter }, + setSortBy, + } = useTable( + { + columns: defaultColumns, + data: intents, + initialState: { + // todo needto add proper generic to useTable to fix this + // @ts-ignore + pageIndex: currentPage, }, - useFilters, - useGlobalFilter, - useSortBy, - usePagination - ) as TableInstance & any //TODO: FIX Type + }, + useFilters, + useGlobalFilter, + useSortBy, + usePagination + ) as TableInstance & any //TODO: FIX Type // Function to handle sorting when a column header is clicked - const handleSort = (column) => { - const isAsc = sortBy && sortBy[0] && sortBy[0].id === column && !sortBy[0].desc; - setSortBy([{ id: column, desc: isAsc ? isAsc : false }]); - }; + const handleSort = column => { + const isAsc = + sortBy && sortBy[0] && sortBy[0].id === column && !sortBy[0].desc + setSortBy([{ id: column, desc: isAsc ? isAsc : false }]) + } const rows = page.map(el => { return createData( @@ -197,12 +203,15 @@ function IntentTable({ intents, updateCallback }) { // Handle intent deletion const handleIntentDelete = async (intent: any) => { if (!selectedRow) return - const isDeleted = await fetch(`${API_ROOT_URL}/documents/${selectedRow.id}`, { - method: 'DELETE', - headers: { - Authorization: `Bearer ${token}`, - }, - }) + const isDeleted = await fetch( + `${API_ROOT_URL}/documents/${selectedRow.id}`, + { + method: 'DELETE', + headers: { + Authorization: `Bearer ${token}`, + }, + } + ) if (isDeleted) enqueueSnackbar('intent deleted', { variant: 'success' }) else enqueueSnackbar('Error deleting intent', { variant: 'error' }) @@ -226,10 +235,10 @@ function IntentTable({ intents, updateCallback }) { intent: '', date: new Date().toISOString(), embedding: '', - variations: 0 + variations: 0, }) // Handle save action - const handleSave = async (selectedModel) => { + const handleSave = async selectedModel => { // call documents endpoint const result = await fetch(`${API_ROOT_URL}/intents`, { method: 'POST', @@ -246,10 +255,10 @@ function IntentTable({ intents, updateCallback }) { projectId: config.projectId, modelName: selectedModel.model, variations: newIntent.variations > 20 ? 20 : newIntent.variations, - chatModelName: "gpt-3.5-turbo", + chatModelName: 'gpt-3.5-turbo', secrets: localStorage.getItem('secrets'), }), - }); + }) // Check if the save operation was successful if (result.ok) { // Reset newIntent @@ -259,24 +268,22 @@ function IntentTable({ intents, updateCallback }) { intent: '', date: '', embedding: '', - variations: 0 - }); - enqueueSnackbar('Intent saved successfully', { variant: 'success' }); - + variations: 0, + }) + enqueueSnackbar('Intent saved successfully', { variant: 'success' }) // Close the modal by setting createMode to false after a delay setTimeout(() => { - setCreateMode(false); - }, 2000); + setCreateMode(false) + }, 2000) // Trigger the updateCallback function to update the table after a delay - updateCallback(); - + updateCallback() } else { - enqueueSnackbar('Error saving intent', { variant: 'error' }); + enqueueSnackbar('Error saving intent', { variant: 'error' }) } - }; + } // Show create modal const showCreateModal = () => { @@ -286,20 +293,21 @@ function IntentTable({ intents, updateCallback }) { // trigger updateCallback when createMode changes useEffect(() => { if (!createMode) { - updateCallback(); + updateCallback() } - }, [createMode]); + }, [createMode]) return ( - <>{createMode && ( - - )} + <> + {createMode && ( + + )}
@@ -366,7 +374,6 @@ function IntentTable({ intents, updateCallback }) { - ) } diff --git a/packages/plugins/intent/client/src/windows/IntentWindow/index.tsx b/packages/plugins/intent/client/src/windows/IntentWindow/index.tsx index ab9a6843bb..d9ee4fa248 100644 --- a/packages/plugins/intent/client/src/windows/IntentWindow/index.tsx +++ b/packages/plugins/intent/client/src/windows/IntentWindow/index.tsx @@ -1,11 +1,10 @@ // DOCUMENTED -import { API_ROOT_URL } from '@magickml/config' +import { API_ROOT_URL } from 'shared/config' import { useEffect, useState } from 'react' import { useSelector } from 'react-redux' import { LoadingScreen, useConfig } from '@magickml/client-core' import IntentTable from './IntentTable' - /** * IntentWindow component displays the intents of a project. * @returns JSX Element @@ -35,7 +34,9 @@ const IntentWindow = (): JSX.Element => { const fetchIntents = async (): Promise => { try { const response = await fetch( - `${API_ROOT_URL}/documents?projectId=${config.projectId}&metadata=${encodeURI('{"intent": { "type": "story" }}')}`, + `${API_ROOT_URL}/documents?projectId=${ + config.projectId + }&metadata=${encodeURI('{"intent": { "type": "story" }}')}`, { headers: { Authorization: `Bearer ${token}`, @@ -67,7 +68,9 @@ const IntentWindow = (): JSX.Element => { }} > {loading && } - {intents && } + {intents && ( + + )}
) } diff --git a/packages/plugins/openai/server/src/functions/makeChatCompletion.ts b/packages/plugins/openai/server/src/functions/makeChatCompletion.ts index 8e4fc5c22b..2d2ce3805c 100644 --- a/packages/plugins/openai/server/src/functions/makeChatCompletion.ts +++ b/packages/plugins/openai/server/src/functions/makeChatCompletion.ts @@ -10,7 +10,7 @@ import { DEFAULT_OPENAI_KEY, PRODUCTION, BACKOFF_RETRY_LIMIT, -} from '@magickml/config' +} from 'shared/config' import { GPT4_MODELS } from '@magickml/plugin-openai-shared' import { trackOpenAIUsage } from '@magickml/server-core' import axiosRetry from 'axios-retry' diff --git a/packages/plugins/openai/server/src/functions/makeTextCompletion.ts b/packages/plugins/openai/server/src/functions/makeTextCompletion.ts index 453be6adef..f1a58617b8 100644 --- a/packages/plugins/openai/server/src/functions/makeTextCompletion.ts +++ b/packages/plugins/openai/server/src/functions/makeTextCompletion.ts @@ -6,7 +6,7 @@ import { DEFAULT_OPENAI_KEY, PRODUCTION, BACKOFF_RETRY_LIMIT, -} from '@magickml/config' +} from 'shared/config' import { GPT4_MODELS } from '@magickml/plugin-openai-shared' import { trackOpenAIUsage } from '@magickml/server-core' import axiosRetry from 'axios-retry' diff --git a/packages/plugins/openai/server/src/functions/makeTextEmbedding.ts b/packages/plugins/openai/server/src/functions/makeTextEmbedding.ts index 8cf4357c1e..b32e6722ab 100644 --- a/packages/plugins/openai/server/src/functions/makeTextEmbedding.ts +++ b/packages/plugins/openai/server/src/functions/makeTextEmbedding.ts @@ -6,7 +6,7 @@ import { } from '@magickml/core' import axios from 'axios' import { OPENAI_ENDPOINT } from '../constants' -import { DEFAULT_OPENAI_KEY } from '@magickml/config' +import { DEFAULT_OPENAI_KEY } from 'shared/config' import { trackOpenAIUsage } from '@magickml/server-core' /** diff --git a/packages/plugins/rest/client/src/components/rest.component.tsx b/packages/plugins/rest/client/src/components/rest.component.tsx index 7b1b1f033b..58c447464e 100644 --- a/packages/plugins/rest/client/src/components/rest.component.tsx +++ b/packages/plugins/rest/client/src/components/rest.component.tsx @@ -6,12 +6,12 @@ import md5 from 'md5' import { Button, Input } from '@mui/material' import { enqueueSnackbar } from 'notistack' import { debounce } from 'lodash' -import { API_ROOT_URL } from '@magickml/config' -import { Tooltip } from "@mui/material" - +import { API_ROOT_URL } from 'shared/config' +import { Tooltip } from '@mui/material' const fetchGetExample = (selectedAgentData, content) => ` - fetch("${API_ROOT_URL}/api/${selectedAgentData.id}?content=${encodeURIComponent(content)}", { + fetch("${API_ROOT_URL}/api/${selectedAgentData.id + }?content=${encodeURIComponent(content)}", { method: 'GET', headers: { 'Authorization': ${selectedAgentData.data?.rest_api_key} @@ -22,10 +22,11 @@ const fetchGetExample = (selectedAgentData, content) => ` .catch((error) => { console.error('Error:', error); }); -`; +` const fetchDeleteExample = (selectedAgentData, content) => ` - fetch("${API_ROOT_URL}/api/${selectedAgentData.id}?content=${encodeURIComponent(content)}", { + fetch("${API_ROOT_URL}/api/${selectedAgentData.id + }?content=${encodeURIComponent(content)}", { method: 'GET', headers: { 'Authorization': ${selectedAgentData.data?.rest_api_key} @@ -36,7 +37,7 @@ const fetchDeleteExample = (selectedAgentData, content) => ` .catch((error) => { console.error('Error:', error); }); -`; +` const fetchPutExample = (selectedAgentData, content) => ` fetch("${API_ROOT_URL}/api/${selectedAgentData.id}", { @@ -52,7 +53,7 @@ const fetchPutExample = (selectedAgentData, content) => ` .catch((error) => { console.error('Error:', error); }); -`; +` const fetchPostExample = (selectedAgentData, content) => ` fetch("${API_ROOT_URL}/api", { @@ -68,7 +69,7 @@ const fetchPostExample = (selectedAgentData, content) => ` .catch((error) => { console.error('Error:', error); }); -`; +` /** * RestAgentWindow component enables users to control the REST API settings. @@ -76,356 +77,360 @@ const fetchPostExample = (selectedAgentData, content) => ` * @returns {JSX.Element} - RestAgentWindow component. */ export const RestAgentWindow: FC = props => { - props = props.props - const { selectedAgentData, setSelectedAgentData, update } = props - const debouncedFunction = debounce((id, data) => update(id, data), 500) - const [showGetExample, setShowGetExample] = useState(false) - const [showPostExample, setShowPostExample] = useState(false) - const [showPutExample, setShowPutExample] = useState(false) - const [showDeleteExample, setShowDeleteExample] = useState(false) - const [viewMode, setViewMode] = useState(false) - const [checked, setChecked] = useState(selectedAgentData.data?.rest_enabled) - const [disable, setDisable] = useState(false) + props = props.props + const { selectedAgentData, setSelectedAgentData, update } = props + const debouncedFunction = debounce((id, data) => update(id, data), 500) + const [showGetExample, setShowGetExample] = useState(false) + const [showPostExample, setShowPostExample] = useState(false) + const [showPutExample, setShowPutExample] = useState(false) + const [showDeleteExample, setShowDeleteExample] = useState(false) + const [viewMode, setViewMode] = useState(false) + const [checked, setChecked] = useState(selectedAgentData.data?.rest_enabled) + const [disable, setDisable] = useState(false) - const handleClose = () => { - setViewMode(false) - } + const handleClose = () => { + setViewMode(false) + } - useEffect(() => { - if (props.enable['RestPlugin'] === false) { - setChecked(false) - setDisable(true) - } + useEffect(() => { + if (props.enable['RestPlugin'] === false) { + setChecked(false) + setDisable(true) + } - if (props.enable['RestPlugin'] === true) { - setChecked(selectedAgentData.data?.rest_enabled) - setDisable(false) - } - }, [props.enable, selectedAgentData]) + if (props.enable['RestPlugin'] === true) { + setChecked(selectedAgentData.data?.rest_enabled) + setDisable(false) + } + }, [props.enable, selectedAgentData]) - return ( - <> -
- -

REST API

+ return ( + <> +
+ +

REST API

+
+
+ + { + setChecked(!checked) + debouncedFunction(selectedAgentData.id, { + ...selectedAgentData, + data: { + ...selectedAgentData.data, + rest_enabled: e.target.checked, + }, + }) + setSelectedAgentData({ + ...selectedAgentData, + data: { + ...selectedAgentData.data, + rest_enabled: e.target.checked, + }, + }) + }} + label={''} + /> +
+
+ {viewMode && ( + +
+ + + + + Agent ID + -
{ + navigator.clipboard.writeText(selectedAgentData.id) + enqueueSnackbar('Copied to clipboard', { + variant: 'success', + }) + }} + /> + + + + + API Key + + + { + navigator.clipboard.writeText( + selectedAgentData.data?.rest_api_key + ) + enqueueSnackbar('Copied to clipboard', { + variant: 'success', + }) + }} + /> + + + + + URL + + + { + navigator.clipboard.writeText( + selectedAgentData.data?.rest_api_key + ) + enqueueSnackbar('Copied to clipboard', { + variant: 'success', + }) + }} + /> + + + + + +

GET Example

+
+
+ {showGetExample && ( +
+ + Fetch + + + { + navigator.clipboard.writeText( + fetchGetExample(selectedAgentData, 'Hello, World') + ) + }} + /> +
+ )} +
+ + - + +

POST Example

+
+
+ {showPostExample && ( +
+ - View - - { - setChecked(!checked) - debouncedFunction(selectedAgentData.id, { - ...selectedAgentData, - data: { - ...selectedAgentData.data, - rest_enabled: e.target.checked, - }, - }) - setSelectedAgentData({ - ...selectedAgentData, - data: { - ...selectedAgentData.data, - rest_enabled: e.target.checked, - }, - }) - }} - label={''} + Fetch + + { + // copy the value of the input + navigator.clipboard.writeText( + fetchPostExample(selectedAgentData, 'Hello, World') + ) + }} + className="modal-element" + style={{ + textDecoration: 'none', + border: 'none', + }} /> -
-
- {viewMode && ( - -
- - - - Agent ID - - { - navigator.clipboard.writeText(selectedAgentData.id) - enqueueSnackbar('Copied to clipboard', { - variant: 'success', - }) - }} - /> - - - - - API Key - - - { - navigator.clipboard.writeText( - selectedAgentData.data?.rest_api_key - ) - enqueueSnackbar('Copied to clipboard', { - variant: 'success', - }) - }} - /> - - - - - URL - - - { - navigator.clipboard.writeText( - selectedAgentData.data?.rest_api_key - ) - enqueueSnackbar('Copied to clipboard', { - variant: 'success', - }) - }} - /> - - - - - - -

GET Example

-
-
- {showGetExample && ( -
- - - Fetch - - - { - navigator.clipboard.writeText( - fetchGetExample(selectedAgentData, "Hello, World") - ) - }} - /> -
- )} -
- - - - -

POST Example

-
-
- {showPostExample && ( -
- - Fetch - - { - // copy the value of the input - navigator.clipboard.writeText( - fetchPostExample(selectedAgentData, "Hello, World") - ) - }} - className="modal-element" - style={{ - textDecoration: 'none', - border: 'none', - }} - /> -
- )} -
- - - - -

PUT Example

-
-
- {showPutExample && ( -
- - Fetch - - { - // copy the value of the input - navigator.clipboard.writeText( - fetchPutExample(selectedAgentData, "Hello, World") - ) - }} - className="modal-element" - style={{ - textDecoration: 'none', - border: 'none', - }} - /> -
- )} -
- - - - -

DELETE Example

-
-
- {showDeleteExample && ( -
- - Fetch - - { - // copy the value of the input - navigator.clipboard.writeText( - fetchDeleteExample(selectedAgentData, "Hello, World") - ) - }} - className="modal-element" - style={{ - textDecoration: 'none', - border: 'none', - }} - /> -
- )} -
-
-
-
- )} - - ) +
+ )} + + + + + +

PUT Example

+
+
+ {showPutExample && ( +
+ + Fetch + + { + // copy the value of the input + navigator.clipboard.writeText( + fetchPutExample(selectedAgentData, 'Hello, World') + ) + }} + className="modal-element" + style={{ + textDecoration: 'none', + border: 'none', + }} + /> +
+ )} +
+ + + + +

DELETE Example

+
+
+ {showDeleteExample && ( +
+ + Fetch + + { + // copy the value of the input + navigator.clipboard.writeText( + fetchDeleteExample(selectedAgentData, 'Hello, World') + ) + }} + className="modal-element" + style={{ + textDecoration: 'none', + border: 'none', + }} + /> +
+ )} +
+ +
+ + )} + + ) } diff --git a/packages/plugins/rest/server/src/services/agentHttp/agentHttp.class.ts b/packages/plugins/rest/server/src/services/agentHttp/agentHttp.class.ts index edc50aa7c4..ee4dc538b5 100644 --- a/packages/plugins/rest/server/src/services/agentHttp/agentHttp.class.ts +++ b/packages/plugins/rest/server/src/services/agentHttp/agentHttp.class.ts @@ -16,7 +16,7 @@ import type { import { BadRequest, NotFound } from '@feathersjs/errors/lib' import { pino } from 'pino' import { getLogger } from '@magickml/core' -import { CLOUD_AGENT_KEY, STANDALONE } from '@magickml/config' +import { CLOUD_AGENT_KEY, STANDALONE } from 'shared/config' export type { AgentHttp, AgentHttpData, AgentHttpPatch, AgentHttpQuery } diff --git a/packages/plugins/task/client/src/windows/TaskWindow/TaskTable.tsx b/packages/plugins/task/client/src/windows/TaskWindow/TaskTable.tsx index 3c97ff16ab..94ce29b24b 100644 --- a/packages/plugins/task/client/src/windows/TaskWindow/TaskTable.tsx +++ b/packages/plugins/task/client/src/windows/TaskWindow/TaskTable.tsx @@ -3,7 +3,7 @@ // TODO this whole file is a mess of typescript errors. Fix. //@ts-nocheck import { Button } from '@magickml/client-core' -import { API_ROOT_URL } from '@magickml/config' +import { API_ROOT_URL } from 'shared/config' import { Grid, IconButton, diff --git a/packages/plugins/task/client/src/windows/TaskWindow/index.tsx b/packages/plugins/task/client/src/windows/TaskWindow/index.tsx index dd6676e062..a98ab3a496 100644 --- a/packages/plugins/task/client/src/windows/TaskWindow/index.tsx +++ b/packages/plugins/task/client/src/windows/TaskWindow/index.tsx @@ -1,5 +1,5 @@ // DOCUMENTED -import { API_ROOT_URL } from '@magickml/config' +import { API_ROOT_URL } from 'shared/config' import { useEffect, useState } from 'react' import { useSelector } from 'react-redux' import { useConfig } from '@magickml/client-core' diff --git a/packages/server/agents/src/lib/AgentCommander.ts b/packages/server/agents/src/lib/AgentCommander.ts index 419a659b03..e0cacf408a 100644 --- a/packages/server/agents/src/lib/AgentCommander.ts +++ b/packages/server/agents/src/lib/AgentCommander.ts @@ -14,7 +14,7 @@ import type { MagickSpellInput } from '@magickml/core' import { v4 as uuidv4 } from 'uuid' import type pino from 'pino' import { AgentResult, AgentRunJob } from './Agent' -import { AGENT_RESPONSE_TIMEOUT_MSEC } from '@magickml/config' +import { AGENT_RESPONSE_TIMEOUT_MSEC } from 'shared/config' export type RunRootSpellArgs = { agent?: Agent diff --git a/packages/server/agents/src/lib/AgentManager.ts b/packages/server/agents/src/lib/AgentManager.ts index c946592919..640ab22dcf 100644 --- a/packages/server/agents/src/lib/AgentManager.ts +++ b/packages/server/agents/src/lib/AgentManager.ts @@ -3,7 +3,7 @@ import Agent from './Agent' import _ from 'lodash' import pino from 'pino' import { getLogger } from '@magickml/core' -import { AGENT_UPDATE_TIME_MSEC, PING_AGENT_TIME_MSEC } from '@magickml/config' +import { AGENT_UPDATE_TIME_MSEC, PING_AGENT_TIME_MSEC } from 'shared/config' import { BullMQWorker, RedisPubSubWrapper } from '@magickml/server-core' /** diff --git a/packages/server/redis-pubsub/src/lib/redis-pubsub.ts b/packages/server/redis-pubsub/src/lib/redis-pubsub.ts index 582c4a6df1..1e1304a113 100644 --- a/packages/server/redis-pubsub/src/lib/redis-pubsub.ts +++ b/packages/server/redis-pubsub/src/lib/redis-pubsub.ts @@ -1,6 +1,6 @@ import { createClient, RedisClientOptions } from 'redis' import { EventEmitter } from 'events' -import { REDISCLOUD_URL } from '@magickml/config' +import { REDISCLOUD_URL } from 'shared/config' export class RedisPubSub extends EventEmitter { private client!: ReturnType diff --git a/packages/config/.eslintrc.json b/packages/shared/config/.eslintrc.json similarity index 86% rename from packages/config/.eslintrc.json rename to packages/shared/config/.eslintrc.json index 9d9c0db55b..3456be9b90 100644 --- a/packages/config/.eslintrc.json +++ b/packages/shared/config/.eslintrc.json @@ -1,5 +1,5 @@ { - "extends": ["../../.eslintrc.json"], + "extends": ["../../../.eslintrc.json"], "ignorePatterns": ["!**/*"], "overrides": [ { diff --git a/packages/shared/config/README.md b/packages/shared/config/README.md new file mode 100644 index 0000000000..0c85f811e2 --- /dev/null +++ b/packages/shared/config/README.md @@ -0,0 +1,11 @@ +# shared-config + +This library was generated with [Nx](https://nx.dev). + +## Building + +Run `nx build shared-config` to build the library. + +## Running unit tests + +Run `nx test shared-config` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/packages/config/package.json b/packages/shared/config/package.json similarity index 61% rename from packages/config/package.json rename to packages/shared/config/package.json index 3ad7f1d149..2c60107e5a 100644 --- a/packages/config/package.json +++ b/packages/shared/config/package.json @@ -1,5 +1,5 @@ { - "name": "@magickml/config", + "name": "shared/config", "version": "0.0.1", "type": "commonjs" } diff --git a/packages/config/project.json b/packages/shared/config/project.json similarity index 52% rename from packages/config/project.json rename to packages/shared/config/project.json index a432cea737..95aef6f750 100644 --- a/packages/config/project.json +++ b/packages/shared/config/project.json @@ -1,29 +1,29 @@ { - "name": "config", - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "packages/config/src", + "name": "shared-config", + "$schema": "../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "packages/shared/config/src", "projectType": "library", "targets": { "build": { "executor": "@nx/vite:build", "outputs": ["{options.outputPath}"], "options": { - "outputPath": "dist/packages/config" + "outputPath": "dist/packages/shared/config" } }, "test": { "executor": "@nx/vite:test", - "outputs": ["{workspaceRoot}/coverage/packages/config"], + "outputs": ["{workspaceRoot}/coverage/packages/shared/config"], "options": { "passWithNoTests": true, - "reportsDirectory": "../../coverage/packages/config" + "reportsDirectory": "../../../coverage/packages/shared/config" } }, "lint": { "executor": "@nx/linter:eslint", "outputs": ["{options.outputFile}"], "options": { - "lintFilePatterns": ["packages/config/**/*.ts"] + "lintFilePatterns": ["packages/shared/config/**/*.ts"] } } }, diff --git a/packages/config/src/config.ts b/packages/shared/config/src/config.ts similarity index 100% rename from packages/config/src/config.ts rename to packages/shared/config/src/config.ts diff --git a/packages/config/src/import-meta-env.ts b/packages/shared/config/src/import-meta-env.ts similarity index 100% rename from packages/config/src/import-meta-env.ts rename to packages/shared/config/src/import-meta-env.ts diff --git a/packages/config/src/index.ts b/packages/shared/config/src/index.ts similarity index 100% rename from packages/config/src/index.ts rename to packages/shared/config/src/index.ts diff --git a/packages/config/tsconfig.json b/packages/shared/config/tsconfig.json similarity index 91% rename from packages/config/tsconfig.json rename to packages/shared/config/tsconfig.json index 7d886e8b85..1607e6b496 100644 --- a/packages/config/tsconfig.json +++ b/packages/shared/config/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig.base.json", + "extends": "../../../tsconfig.base.json", "compilerOptions": { "target": "ESNext", "module": "ESNext", diff --git a/packages/config/tsconfig.lib.json b/packages/shared/config/tsconfig.lib.json similarity index 88% rename from packages/config/tsconfig.lib.json rename to packages/shared/config/tsconfig.lib.json index cd1503157b..3014cdf55c 100644 --- a/packages/config/tsconfig.lib.json +++ b/packages/shared/config/tsconfig.lib.json @@ -1,7 +1,7 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", + "outDir": "../../../dist/out-tsc", "declaration": true, "types": [ "node", diff --git a/packages/config/tsconfig.spec.json b/packages/shared/config/tsconfig.spec.json similarity index 92% rename from packages/config/tsconfig.spec.json rename to packages/shared/config/tsconfig.spec.json index b0ad5c163a..d6c98a3463 100644 --- a/packages/config/tsconfig.spec.json +++ b/packages/shared/config/tsconfig.spec.json @@ -1,7 +1,7 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "outDir": "../../dist/out-tsc", + "outDir": "../../../dist/out-tsc", "types": [ "vitest/globals", "vitest/importMeta", diff --git a/packages/config/vite.config.ts b/packages/shared/config/vite.config.ts similarity index 90% rename from packages/config/vite.config.ts rename to packages/shared/config/vite.config.ts index a71541c097..8ba8de7be4 100644 --- a/packages/config/vite.config.ts +++ b/packages/shared/config/vite.config.ts @@ -1,12 +1,12 @@ /// import { defineConfig } from 'vite' -import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; +import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin' import dts from 'vite-plugin-dts' import { joinPathFragments } from '@nx/devkit' export default defineConfig({ - cacheDir: '../../node_modules/.vite/config', + cacheDir: '../../../node_modules/.vite/config', plugins: [ dts({ @@ -22,7 +22,7 @@ export default defineConfig({ // worker: { // plugins: [ // viteTsConfigPaths({ - // root: '../../', + // root: '../../../', // }), // ], // }, @@ -48,7 +48,7 @@ export default defineConfig({ test: { globals: true, cache: { - dir: '../../node_modules/.vitest', + dir: '../../../node_modules/.vitest', }, environment: 'jsdom', include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], diff --git a/tsconfig.base.json b/tsconfig.base.json index 26b17bd891..aa0ac9fdf1 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -28,7 +28,6 @@ "@magickml/agent": ["apps/agent/src/index.ts"], "@magickml/client": ["apps/client/src/index.ts"], "@magickml/client-core": ["packages/core/client/src/index.ts"], - "@magickml/config": ["packages/config/src/index.ts"], "@magickml/core": ["packages/core/shared/src/index.ts"], "@magickml/docs": ["apps/docs/src/index.ts"], "@magickml/plugin-anthropic-client": [ @@ -206,6 +205,7 @@ "packages/server/cloud-agent-worker/src/index.ts" ], "server/redis-pubsub": ["packages/server/redis-pubsub/src/index.ts"], + "shared/config": ["packages/shared/config/src/index.ts"], "shared/rete": ["packages/shared/rete/src/index.ts"] } }, From 6b1461cb88f89810b2002fab8c88bb72192dfbf3 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 27 Sep 2023 11:49:42 -0700 Subject: [PATCH 123/349] Move core client into client core folder --- apps/client/src/main.tsx | 2 +- .../client => client/core}/.eslintrc.json | 0 .../{core/client => client/core}/.gitignore | 0 .../{core/client => client/core}/.gitkeep | 0 .../client => client/core}/jest.config.ts | 2 +- packages/client/core/package.json | 4 + .../{core/client => client/core}/project.json | 12 +- .../components/Accordion/index.module.scss | 0 .../core}/src/components/Accordion/index.tsx | 40 +-- .../src/components/Button/button.module.css | 0 .../core}/src/components/Button/index.tsx | 20 +- .../core}/src/components/Chip/chip.module.css | 4 +- .../src/components/Chip/chip.module.css.d.ts | 8 + .../core}/src/components/Chip/index.tsx | 25 +- .../src/components/CustomizedSwitch/index.tsx | 0 .../core}/src/components/Drawer/AgentMenu.tsx | 6 +- .../src/components/Drawer/CustomNode.tsx | 37 +-- .../components/Drawer/Newsidebar/index.tsx | 2 +- .../components/Drawer/OldSidebar/index.tsx | 0 .../Drawer/ProjectWindow/index.module.scss | 0 .../components/Drawer/ProjectWindow/index.tsx | 0 .../src/components/Drawer/SetAPIKeys.tsx | 24 +- .../core/src/components/Drawer/TypeIcon.tsx | 27 ++ .../core}/src/components/Drawer/index.tsx | 0 .../core}/src/components/Drawer/logo-full.png | Bin .../src/components/Drawer/logo-small.png | Bin .../src/components/Drawer/menu.module.css | 0 .../src/components/Drawer/tooltiptext.ts | 0 .../src/components/FileInput/FileInput.tsx | 30 +- .../core}/src/components/Icon/icon.module.css | 2 +- .../src/components/Icon/icon.module.css.d.ts | 48 ++++ .../core}/src/components/Icon/icons/Lock.svg | 0 .../src/components/Icon/icons/account.svg | 0 .../core}/src/components/Icon/icons/add.svg | 0 .../core}/src/components/Icon/icons/ankh.svg | 0 .../core}/src/components/Icon/icons/bird.svg | 0 .../core}/src/components/Icon/icons/close.svg | 0 .../core}/src/components/Icon/icons/cloth.svg | 0 .../core}/src/components/Icon/icons/cup.svg | 0 .../components/Icon/icons/danger-trash.svg | 0 .../src/components/Icon/icons/delete.svg | 0 .../src/components/Icon/icons/feathers.svg | 0 .../src/components/Icon/icons/fewshot.svg | 0 .../src/components/Icon/icons/folder.svg | 0 .../core}/src/components/Icon/icons/hand.svg | 0 .../core}/src/components/Icon/icons/info.svg | 0 .../core}/src/components/Icon/icons/merge.svg | 0 .../core}/src/components/Icon/icons/minus.svg | 0 .../core}/src/components/Icon/icons/moon.svg | 0 .../src/components/Icon/icons/newnode.svg | 0 .../src/components/Icon/icons/node-lock.svg | 0 .../core}/src/components/Icon/icons/pause.svg | 0 .../src/components/Icon/icons/person.svg | 0 .../src/components/Icon/icons/play-print.svg | 0 .../core}/src/components/Icon/icons/play.svg | 0 .../src/components/Icon/icons/properties.svg | 0 .../src/components/Icon/icons/refresh.svg | 0 .../src/components/Icon/icons/search.svg | 0 .../core}/src/components/Icon/icons/seive.svg | 0 .../core}/src/components/Icon/icons/snake.svg | 0 .../src/components/Icon/icons/state-read.svg | 0 .../src/components/Icon/icons/state-write.svg | 0 .../core}/src/components/Icon/icons/state.svg | 0 .../src/components/Icon/icons/stop-sign.svg | 0 .../core}/src/components/Icon/icons/stop.svg | 0 .../src/components/Icon/icons/switch.svg | 0 .../src/components/Icon/icons/temperature.svg | 0 .../core}/src/components/Icon/icons/text.svg | 0 .../core}/src/components/Icon/icons/tiles.svg | 0 .../core}/src/components/Icon/icons/time.svg | 0 .../core}/src/components/Icon/icons/trash.svg | 0 .../core}/src/components/Icon/icons/warn.svg | 0 .../src/components/Icon/icons/water-play.svg | 0 .../src/components/Icon/icons/water-run.svg | 0 .../core}/src/components/Icon/icons/water.svg | 0 .../core}/src/components/Icon/index.tsx | 2 +- .../core/src/components/IconButton/index.tsx | 37 +++ .../components/InfoDialog/index.module.scss | 0 .../core}/src/components/InfoDialog/index.tsx | 50 ++-- .../core}/src/components/Input/index.tsx | 0 .../src/components/Input/input.module.css | 0 .../src/components/LoadingScreen/index.tsx | 0 .../LoadingScreen/magick-loading.svg | 0 .../src/components/Modal/index.module.scss | 0 .../core}/src/components/Modal/index.tsx | 1 - .../core}/src/components/Panel/index.tsx | 0 .../src/components/Panel/panel.module.css | 0 .../components/Panel/panel.module.css.d.ts | 13 + .../core}/src/components/Select/index.tsx | 42 +-- .../src/components/Select/select.module.css | 28 +- .../components/Select/select.module.css.d.ts | 9 + .../core}/src/components/Switch/index.tsx | 18 +- .../components/TabLayout/TabLayout.module.css | 0 .../TabLayout/TabLayout.module.css.d.ts | 6 +- .../core}/src/components/TabLayout/index.tsx | 14 +- .../src/components/Table/TablePagination.tsx | 0 .../src/components/Table/TableSortLabel.tsx | 0 .../src/components/Table/index.module.scss | 0 .../core}/src/components/Table/index.tsx | 56 ++-- .../core}/src/components/Toolbar/index.tsx | 18 +- .../src/components/Toolbar/toolbar.module.css | 0 .../core}/src/components/Tooltip/index.tsx | 16 +- .../core}/src/components/Window/grid.png | Bin .../core}/src/components/Window/index.tsx | 15 +- .../src/components/Window/window.module.css | 0 .../components/Window/window.module.css.d.ts | 15 + .../core}/src/components/index.ts | 0 .../src/contexts/ProjectWindowContext.tsx | 0 .../core}/src/contexts/TreeDataProvider.tsx | 2 +- .../core/src/contexts/data/sampleData.json | 21 ++ .../core}/src/contexts/index.ts | 2 +- .../{core/client => client/core}/src/index.ts | 2 +- .../core}/src/providers/ConfigProvider.tsx | 0 .../core}/src/providers/FeathersProvider.tsx | 16 +- .../core}/src/providers/PubSubProvider.tsx | 5 +- .../core}/src/providers/index.tsx | 2 +- .../core}/src/templates/index.ts | 20 +- .../src/templates/spells/Blank.spell.json | 66 +++++ .../src/templates/spells/Starter.spell.json | 244 +++++++++++++++++ .../client => client/core}/tsconfig.json | 0 .../client => client/core}/tsconfig.lib.json | 0 .../client => client/core}/tsconfig.spec.json | 0 .../client => client/core}/vite.config.ts | 0 .../editor/src/DataControls/CodeControl.tsx | 2 +- .../src/DataControls/DropdownSelect.tsx | 2 +- .../client/editor/src/DataControls/Form.tsx | 2 +- .../client/editor/src/DataControls/Input.tsx | 2 +- .../src/DataControls/LongTextControl.tsx | 2 +- .../src/DataControls/PlaytestControl.tsx | 2 +- .../editor/src/DataControls/SingleElement.tsx | 2 +- .../editor/src/DataControls/SpellSelect.tsx | 6 +- .../editor/src/DataControls/SwitchControl.tsx | 2 +- .../editor/src/components/EventHandler.tsx | 2 +- .../editor/src/components/FileInput.tsx | 2 +- .../components/MenuBar/OldMenuBar/index.tsx | 2 +- .../components/MenuBar/newMenuBar/index.tsx | 2 +- .../editor/src/components/Modal/Modal.tsx | 4 +- .../src/components/Modals/SaveAsModal.tsx | 4 +- .../editor/src/components/Node/Node.tsx | 2 +- .../editor/src/components/ProjectRow.tsx | 2 +- .../editor/src/components/TabBar/TabBar.tsx | 2 +- .../editor/src/components/TemplatePanel.tsx | 2 +- .../editor/src/components/VideoInput.tsx | 2 +- .../editor/src/components/Workspace.tsx | 2 +- .../editor/src/contexts/AppProviders.tsx | 6 +- .../editor/src/contexts/EditorProvider.tsx | 4 +- .../editor/src/contexts/InspectorProvider.tsx | 2 +- .../editor/src/contexts/LayoutProvider.tsx | 2 +- .../src/contexts/MagickInterfaceProvider.tsx | 2 +- .../editor/src/contexts/TabProvider.tsx | 2 +- .../src/layouts/MainLayout/MainLayout.tsx | 2 +- packages/client/editor/src/main.tsx | 2 +- .../editor/src/plugins/areaPlugin/snap.ts | 2 +- .../editor/src/screens/Composer/index.tsx | 2 +- .../DocumentWindow/DocContentModal.tsx | 2 +- .../screens/DocumentWindow/DocumentModal.tsx | 2 +- .../screens/DocumentWindow/DocumentTable.tsx | 4 +- .../src/screens/DocumentWindow/index.tsx | 2 +- .../src/screens/EventWindow/EventTable.tsx | 4 +- .../editor/src/screens/EventWindow/index.tsx | 2 +- .../src/screens/HomeScreen/AllProjects.tsx | 2 +- .../src/screens/HomeScreen/CreateNew.tsx | 6 +- .../src/screens/HomeScreen/HomeScreen.tsx | 4 +- .../src/screens/HomeScreen/OpenProject.tsx | 2 +- .../editor/src/screens/Magick/Magick.tsx | 2 +- .../screens/MagickV2/panels/fileDrawer.tsx | 2 +- .../screens/MagickV2/workspaces/composer.tsx | 2 +- .../screens/RequestWindow/RequestTable.tsx | 2 +- .../src/screens/RequestWindow/index.tsx | 2 +- .../src/screens/agents/AgentManagerWindow.tsx | 4 +- .../agents/AgentWindow/AgentDetails.tsx | 4 +- .../screens/agents/AgentWindow/AgentItem.tsx | 4 +- .../agents/AgentWindow/AgentPubVariables.tsx | 2 +- .../src/screens/agents/AgentWindow/index.tsx | 2 +- .../src/screens/settings/SettingsWindow.tsx | 2 +- .../editor/src/windows/AgentControlWindow.tsx | 2 +- .../editor/src/windows/DebugConsole/index.tsx | 2 +- .../editor/src/windows/InspectorWindow.tsx | 7 +- .../editor/src/windows/PlaytestWindow.tsx | 4 +- .../src/windows/TextEditorWindow/index.tsx | 2 +- packages/core/client/package.json | 4 - .../src/components/Chip/chip.module.css.d.ts | 8 - .../client/src/components/Drawer/TypeIcon.tsx | 27 -- .../src/components/Icon/icon.module.css.d.ts | 48 ---- .../src/components/IconButton/index.tsx | 35 --- .../components/Panel/panel.module.css.d.ts | 13 - .../components/Select/select.module.css.d.ts | 9 - .../components/Window/window.module.css.d.ts | 15 - .../client/src/contexts/data/sampleData.json | 24 -- .../src/templates/spells/Blank.spell.json | 72 ----- .../src/templates/spells/Starter.spell.json | 256 ------------------ packages/plugins/avatar/client/project.json | 2 +- .../client/src/components/Chat/ChatBox.tsx | 27 +- .../avatar/client/src/hooks/useAgentList.ts | 2 +- .../avatar/client/src/hooks/useSpellList.ts | 2 +- .../client/src/components/VariableModal.tsx | 2 +- .../client/src/components/agent.component.tsx | 2 +- .../client/src/components/VariableModal.tsx | 9 +- .../client/src/components/agent.component.tsx | 2 +- .../client/src/components/agent.component.tsx | 73 ++--- .../client/src/components/VariableModal.tsx | 16 +- .../client/src/components/agent.component.tsx | 4 +- .../src/windows/IntentWindow/IntentModal.tsx | 152 ++++++++--- .../src/windows/IntentWindow/IntentTable.tsx | 4 +- .../client/src/windows/IntentWindow/index.tsx | 2 +- .../client/src/components/loop.component.tsx | 2 +- .../client/src/components/rest.component.tsx | 2 +- .../client/src/components/task.component.tsx | 2 +- .../src/windows/TaskWindow/TaskTable.tsx | 4 +- .../client/src/windows/TaskWindow/index.tsx | 2 +- .../client/src/components/VariableModal.tsx | 2 +- .../client/src/components/agent.component.tsx | 3 +- tsconfig.base.json | 2 +- 213 files changed, 1036 insertions(+), 957 deletions(-) rename packages/{core/client => client/core}/.eslintrc.json (100%) rename packages/{core/client => client/core}/.gitignore (100%) rename packages/{core/client => client/core}/.gitkeep (100%) rename packages/{core/client => client/core}/jest.config.ts (83%) create mode 100644 packages/client/core/package.json rename packages/{core/client => client/core}/project.json (74%) rename packages/{core/client => client/core}/src/components/Accordion/index.module.scss (100%) rename packages/{core/client => client/core}/src/components/Accordion/index.tsx (83%) rename packages/{core/client => client/core}/src/components/Button/button.module.css (100%) rename packages/{core/client => client/core}/src/components/Button/index.tsx (66%) rename packages/{core/client => client/core}/src/components/Chip/chip.module.css (94%) create mode 100644 packages/client/core/src/components/Chip/chip.module.css.d.ts rename packages/{core/client => client/core}/src/components/Chip/index.tsx (67%) rename packages/{core/client => client/core}/src/components/CustomizedSwitch/index.tsx (100%) rename packages/{core/client => client/core}/src/components/Drawer/AgentMenu.tsx (99%) rename packages/{core/client => client/core}/src/components/Drawer/CustomNode.tsx (92%) rename packages/{core/client => client/core}/src/components/Drawer/Newsidebar/index.tsx (99%) rename packages/{core/client => client/core}/src/components/Drawer/OldSidebar/index.tsx (100%) rename packages/{core/client => client/core}/src/components/Drawer/ProjectWindow/index.module.scss (100%) rename packages/{core/client => client/core}/src/components/Drawer/ProjectWindow/index.tsx (100%) rename packages/{core/client => client/core}/src/components/Drawer/SetAPIKeys.tsx (76%) create mode 100644 packages/client/core/src/components/Drawer/TypeIcon.tsx rename packages/{core/client => client/core}/src/components/Drawer/index.tsx (100%) rename packages/{core/client => client/core}/src/components/Drawer/logo-full.png (100%) rename packages/{core/client => client/core}/src/components/Drawer/logo-small.png (100%) rename packages/{core/client => client/core}/src/components/Drawer/menu.module.css (100%) rename packages/{core/client => client/core}/src/components/Drawer/tooltiptext.ts (100%) rename packages/{core/client => client/core}/src/components/FileInput/FileInput.tsx (72%) rename packages/{core/client => client/core}/src/components/Icon/icon.module.css (98%) create mode 100644 packages/client/core/src/components/Icon/icon.module.css.d.ts rename packages/{core/client => client/core}/src/components/Icon/icons/Lock.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/account.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/add.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/ankh.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/bird.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/close.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/cloth.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/cup.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/danger-trash.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/delete.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/feathers.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/fewshot.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/folder.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/hand.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/info.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/merge.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/minus.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/moon.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/newnode.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/node-lock.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/pause.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/person.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/play-print.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/play.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/properties.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/refresh.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/search.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/seive.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/snake.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/state-read.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/state-write.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/state.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/stop-sign.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/stop.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/switch.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/temperature.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/text.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/tiles.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/time.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/trash.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/warn.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/water-play.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/water-run.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/icons/water.svg (100%) rename packages/{core/client => client/core}/src/components/Icon/index.tsx (99%) create mode 100644 packages/client/core/src/components/IconButton/index.tsx rename packages/{core/client => client/core}/src/components/InfoDialog/index.module.scss (100%) rename packages/{core/client => client/core}/src/components/InfoDialog/index.tsx (75%) rename packages/{core/client => client/core}/src/components/Input/index.tsx (100%) rename packages/{core/client => client/core}/src/components/Input/input.module.css (100%) rename packages/{core/client => client/core}/src/components/LoadingScreen/index.tsx (100%) rename packages/{core/client => client/core}/src/components/LoadingScreen/magick-loading.svg (100%) rename packages/{core/client => client/core}/src/components/Modal/index.module.scss (100%) rename packages/{core/client => client/core}/src/components/Modal/index.tsx (99%) rename packages/{core/client => client/core}/src/components/Panel/index.tsx (100%) rename packages/{core/client => client/core}/src/components/Panel/panel.module.css (100%) create mode 100644 packages/client/core/src/components/Panel/panel.module.css.d.ts rename packages/{core/client => client/core}/src/components/Select/index.tsx (89%) rename packages/{core/client => client/core}/src/components/Select/select.module.css (56%) create mode 100644 packages/client/core/src/components/Select/select.module.css.d.ts rename packages/{core/client => client/core}/src/components/Switch/index.tsx (83%) rename packages/{core/client => client/core}/src/components/TabLayout/TabLayout.module.css (100%) rename packages/{core/client => client/core}/src/components/TabLayout/TabLayout.module.css.d.ts (52%) rename packages/{core/client => client/core}/src/components/TabLayout/index.tsx (83%) rename packages/{core/client => client/core}/src/components/Table/TablePagination.tsx (100%) rename packages/{core/client => client/core}/src/components/Table/TableSortLabel.tsx (100%) rename packages/{core/client => client/core}/src/components/Table/index.module.scss (100%) rename packages/{core/client => client/core}/src/components/Table/index.tsx (91%) rename packages/{core/client => client/core}/src/components/Toolbar/index.tsx (74%) rename packages/{core/client => client/core}/src/components/Toolbar/toolbar.module.css (100%) rename packages/{core/client => client/core}/src/components/Tooltip/index.tsx (75%) rename packages/{core/client => client/core}/src/components/Window/grid.png (100%) rename packages/{core/client => client/core}/src/components/Window/index.tsx (93%) rename packages/{core/client => client/core}/src/components/Window/window.module.css (100%) create mode 100644 packages/client/core/src/components/Window/window.module.css.d.ts rename packages/{core/client => client/core}/src/components/index.ts (100%) rename packages/{core/client => client/core}/src/contexts/ProjectWindowContext.tsx (100%) rename packages/{core/client => client/core}/src/contexts/TreeDataProvider.tsx (98%) create mode 100644 packages/client/core/src/contexts/data/sampleData.json rename packages/{core/client => client/core}/src/contexts/index.ts (97%) rename packages/{core/client => client/core}/src/index.ts (99%) rename packages/{core/client => client/core}/src/providers/ConfigProvider.tsx (100%) rename packages/{core/client => client/core}/src/providers/FeathersProvider.tsx (94%) rename packages/{core/client => client/core}/src/providers/PubSubProvider.tsx (97%) rename packages/{core/client => client/core}/src/providers/index.tsx (65%) rename packages/{core/client => client/core}/src/templates/index.ts (63%) create mode 100644 packages/client/core/src/templates/spells/Blank.spell.json create mode 100644 packages/client/core/src/templates/spells/Starter.spell.json rename packages/{core/client => client/core}/tsconfig.json (100%) rename packages/{core/client => client/core}/tsconfig.lib.json (100%) rename packages/{core/client => client/core}/tsconfig.spec.json (100%) rename packages/{core/client => client/core}/vite.config.ts (100%) delete mode 100644 packages/core/client/package.json delete mode 100644 packages/core/client/src/components/Chip/chip.module.css.d.ts delete mode 100644 packages/core/client/src/components/Drawer/TypeIcon.tsx delete mode 100644 packages/core/client/src/components/Icon/icon.module.css.d.ts delete mode 100644 packages/core/client/src/components/IconButton/index.tsx delete mode 100644 packages/core/client/src/components/Panel/panel.module.css.d.ts delete mode 100644 packages/core/client/src/components/Select/select.module.css.d.ts delete mode 100644 packages/core/client/src/components/Window/window.module.css.d.ts delete mode 100644 packages/core/client/src/contexts/data/sampleData.json delete mode 100644 packages/core/client/src/templates/spells/Blank.spell.json delete mode 100644 packages/core/client/src/templates/spells/Starter.spell.json diff --git a/apps/client/src/main.tsx b/apps/client/src/main.tsx index 895cd7c7a1..27d8c7297a 100644 --- a/apps/client/src/main.tsx +++ b/apps/client/src/main.tsx @@ -1,7 +1,7 @@ // DOCUMENTED import { createRoot } from 'react-dom/client' import { MagickIDE } from 'client/editor' -import { AppConfig } from '@magickml/client-core' +import { AppConfig } from 'client/core' import { DEFAULT_PROJECT_ID, API_ROOT_URL, diff --git a/packages/core/client/.eslintrc.json b/packages/client/core/.eslintrc.json similarity index 100% rename from packages/core/client/.eslintrc.json rename to packages/client/core/.eslintrc.json diff --git a/packages/core/client/.gitignore b/packages/client/core/.gitignore similarity index 100% rename from packages/core/client/.gitignore rename to packages/client/core/.gitignore diff --git a/packages/core/client/.gitkeep b/packages/client/core/.gitkeep similarity index 100% rename from packages/core/client/.gitkeep rename to packages/client/core/.gitkeep diff --git a/packages/core/client/jest.config.ts b/packages/client/core/jest.config.ts similarity index 83% rename from packages/core/client/jest.config.ts rename to packages/client/core/jest.config.ts index 1babdce191..fc9ee95bff 100644 --- a/packages/core/client/jest.config.ts +++ b/packages/client/core/jest.config.ts @@ -7,5 +7,5 @@ export default { '^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nx/react/babel'] }], }, moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], - coverageDirectory: '../../coverage/packages/core/client', + coverageDirectory: '../../coverage/packages/client/core', } diff --git a/packages/client/core/package.json b/packages/client/core/package.json new file mode 100644 index 0000000000..ff0a8f1fc5 --- /dev/null +++ b/packages/client/core/package.json @@ -0,0 +1,4 @@ +{ + "name": "client/core", + "version": "0.1.0" +} diff --git a/packages/core/client/project.json b/packages/client/core/project.json similarity index 74% rename from packages/core/client/project.json rename to packages/client/core/project.json index 1625ecabdb..23fe60e378 100644 --- a/packages/core/client/project.json +++ b/packages/client/core/project.json @@ -1,7 +1,7 @@ { - "name": "@magickml/client-core", + "name": "client-core", "$schema": "../../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "packages/core/client/src", + "sourceRoot": "packages/client/core/src", "projectType": "library", "implicitDependencies": [], "tags": [], @@ -10,16 +10,16 @@ "executor": "@nx/linter:eslint", "outputs": ["{options.outputFile}"], "options": { - "lintFilePatterns": ["packages/core/client/**/*.{ts,tsx,js,jsx}"] + "lintFilePatterns": ["packages/client/core/**/*.{ts,tsx,js,jsx}"] } }, "build": { "executor": "@nx/vite:build", "outputs": ["{options.outputPath}"], - "configFile": "packages/core/client/vite.config.ts", + "configFile": "packages/client/core/vite.config.ts", "defaultConfiguration": "production", "options": { - "outputPath": "dist/packages/core/client" + "outputPath": "dist/packages/client/core" }, "configurations": { "development": { @@ -34,7 +34,7 @@ "executor": "@nx/jest:jest", "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], "options": { - "jestConfig": "packages/core/client/jest.config.ts", + "jestConfig": "packages/client/core/jest.config.ts", "passWithNoTests": true }, "configurations": { diff --git a/packages/core/client/src/components/Accordion/index.module.scss b/packages/client/core/src/components/Accordion/index.module.scss similarity index 100% rename from packages/core/client/src/components/Accordion/index.module.scss rename to packages/client/core/src/components/Accordion/index.module.scss diff --git a/packages/core/client/src/components/Accordion/index.tsx b/packages/client/core/src/components/Accordion/index.tsx similarity index 83% rename from packages/core/client/src/components/Accordion/index.tsx rename to packages/client/core/src/components/Accordion/index.tsx index de699733ff..4bd0c94e45 100644 --- a/packages/core/client/src/components/Accordion/index.tsx +++ b/packages/client/core/src/components/Accordion/index.tsx @@ -1,13 +1,15 @@ -// DOCUMENTED +// DOCUMENTED // Import required packages and components -import * as React from 'react'; -import { styled } from '@mui/material/styles'; -import ArrowForwardIosSharpIcon from '@mui/icons-material/ArrowForwardIosSharp'; -import MuiAccordion, { AccordionProps } from '@mui/material/Accordion'; -import MuiAccordionSummary, { AccordionSummaryProps } from '@mui/material/AccordionSummary'; -import MuiAccordionDetails from '@mui/material/AccordionDetails'; -import Typography from '@mui/material/Typography'; -import styles from './index.module.scss'; +import * as React from 'react' +import { styled } from '@mui/material/styles' +import ArrowForwardIosSharpIcon from '@mui/icons-material/ArrowForwardIosSharp' +import MuiAccordion, { AccordionProps } from '@mui/material/Accordion' +import MuiAccordionSummary, { + AccordionSummaryProps, +} from '@mui/material/AccordionSummary' +import MuiAccordionDetails from '@mui/material/AccordionDetails' +import Typography from '@mui/material/Typography' +import styles from './index.module.scss' // Create a styled accordion component const StyledAccordion = styled((props: AccordionProps) => ( @@ -25,7 +27,7 @@ const StyledAccordion = styled((props: AccordionProps) => ( '&:before': { display: 'none', }, -})); +})) // Create a styled accordion summary component const AccordionSummary = styled((props: AccordionSummaryProps) => ( @@ -45,18 +47,18 @@ const AccordionSummary = styled((props: AccordionSummaryProps) => ( '& .MuiAccordionSummary-content': { marginLeft: theme.spacing(1), }, -})); +})) // Create a styled accordion details component const AccordionDetails = styled(MuiAccordionDetails)(({ theme }) => ({ padding: theme.spacing(2), borderTop: '1px solid rgba(0, 0, 0, .125)', -})); +})) // Define accordion properties interface interface Props { - title: string; - children: React.ReactNode; + title: string + children: React.ReactNode } /** @@ -66,12 +68,12 @@ interface Props { * @param children - Accordion content */ export function Accordion({ title, children }: Props) { - const [expanded, setExpanded] = React.useState('panel1'); + const [expanded, setExpanded] = React.useState('panel1') const handleChange = (panel: string) => (event: React.SyntheticEvent, newExpanded: boolean) => { - setExpanded(newExpanded ? panel : false); - }; + setExpanded(newExpanded ? panel : false) + } return (
@@ -87,5 +89,5 @@ export function Accordion({ title, children }: Props) {
- ); -} \ No newline at end of file + ) +} diff --git a/packages/core/client/src/components/Button/button.module.css b/packages/client/core/src/components/Button/button.module.css similarity index 100% rename from packages/core/client/src/components/Button/button.module.css rename to packages/client/core/src/components/Button/button.module.css diff --git a/packages/core/client/src/components/Button/index.tsx b/packages/client/core/src/components/Button/index.tsx similarity index 66% rename from packages/core/client/src/components/Button/index.tsx rename to packages/client/core/src/components/Button/index.tsx index 7288af79e0..05678c94fb 100644 --- a/packages/core/client/src/components/Button/index.tsx +++ b/packages/client/core/src/components/Button/index.tsx @@ -1,6 +1,6 @@ -// DOCUMENTED -import React, { MouseEventHandler, ButtonHTMLAttributes } from 'react'; -import styles from './button.module.css'; +// DOCUMENTED +import React, { MouseEventHandler, ButtonHTMLAttributes } from 'react' +import styles from './button.module.css' /** * Button component. Provides onClick functionality and allows for props to be passed in. @@ -9,14 +9,20 @@ import styles from './button.module.css'; * @param {function} [onClick] - The click event handler function. Optional. */ export const Button: React.FC> = ({ - onClick = (e?: React.MouseEvent) => { /* null */}, + onClick = (e?: React.MouseEvent) => { + /* null */ + }, ...props }) => { return ( // Render a button with the provided onClick handler and spread props - - ); -}; \ No newline at end of file + ) +} diff --git a/packages/core/client/src/components/Chip/chip.module.css b/packages/client/core/src/components/Chip/chip.module.css similarity index 94% rename from packages/core/client/src/components/Chip/chip.module.css rename to packages/client/core/src/components/Chip/chip.module.css index 44a019840b..e78ec82b26 100644 --- a/packages/core/client/src/components/Chip/chip.module.css +++ b/packages/client/core/src/components/Chip/chip.module.css @@ -24,6 +24,6 @@ box-shadow: none; border-color: var(--dark-3); color: var(--dark-4); - font-family: "IBM Plex Mono"; + font-family: 'IBM Plex Mono'; text-transform: uppercase; -} \ No newline at end of file +} diff --git a/packages/client/core/src/components/Chip/chip.module.css.d.ts b/packages/client/core/src/components/Chip/chip.module.css.d.ts new file mode 100644 index 0000000000..ac4892af37 --- /dev/null +++ b/packages/client/core/src/components/Chip/chip.module.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + chip: string + 'no-events': string +} +export const cssExports: CssExports +export default cssExports diff --git a/packages/core/client/src/components/Chip/index.tsx b/packages/client/core/src/components/Chip/index.tsx similarity index 67% rename from packages/core/client/src/components/Chip/index.tsx rename to packages/client/core/src/components/Chip/index.tsx index f54bfdfb49..1472fba54b 100644 --- a/packages/core/client/src/components/Chip/index.tsx +++ b/packages/client/core/src/components/Chip/index.tsx @@ -1,15 +1,15 @@ -// DOCUMENTED -import * as React from 'react'; -import { Icon } from '../Icon'; -import css from './chip.module.css'; +// DOCUMENTED +import * as React from 'react' +import { Icon } from '../Icon' +import css from './chip.module.css' /** * Chip component properties. */ interface ChipProps { - label: string; - onClick?: () => void; - noEvents?: boolean; + label: string + onClick?: () => void + noEvents?: boolean } /** @@ -23,15 +23,12 @@ export const Chip: React.FC = ({ noEvents, }: ChipProps): React.ReactElement => { // Set the classNames for the chip component - const classNames = `${css.chip} ${noEvents ? css['no-events'] : ''}`; + const classNames = `${css.chip} ${noEvents ? css['no-events'] : ''}` return ( -
+
{label} {!noEvents && }
- ); -}; \ No newline at end of file + ) +} diff --git a/packages/core/client/src/components/CustomizedSwitch/index.tsx b/packages/client/core/src/components/CustomizedSwitch/index.tsx similarity index 100% rename from packages/core/client/src/components/CustomizedSwitch/index.tsx rename to packages/client/core/src/components/CustomizedSwitch/index.tsx diff --git a/packages/core/client/src/components/Drawer/AgentMenu.tsx b/packages/client/core/src/components/Drawer/AgentMenu.tsx similarity index 99% rename from packages/core/client/src/components/Drawer/AgentMenu.tsx rename to packages/client/core/src/components/Drawer/AgentMenu.tsx index 15cd172c20..e86bf31c64 100644 --- a/packages/core/client/src/components/Drawer/AgentMenu.tsx +++ b/packages/client/core/src/components/Drawer/AgentMenu.tsx @@ -13,13 +13,13 @@ import MenuItem from '@mui/material/MenuItem' import ListItemIcon from '@mui/material/ListItemIcon' import Divider from '@mui/material/Divider' import AddCircleIcon from '@mui/icons-material/AddCircle' -import { IconBtn } from '@magickml/client-core' +import { IconBtn } from 'client/core' import { Close, Done } from '@mui/icons-material' import styles from './menu.module.css' -import { useConfig } from '@magickml/client-core' +import { useConfig } from 'client/core' import { enqueueSnackbar } from 'notistack' import { useDispatch, useSelector } from 'react-redux' -import { Modal } from '@magickml/client-core' +import { Modal } from 'client/core' import { DEFAULT_USER_TOKEN, STANDALONE, API_ROOT_URL } from 'shared/config' import { useFeathers } from '../../providers/FeathersProvider' diff --git a/packages/core/client/src/components/Drawer/CustomNode.tsx b/packages/client/core/src/components/Drawer/CustomNode.tsx similarity index 92% rename from packages/core/client/src/components/Drawer/CustomNode.tsx rename to packages/client/core/src/components/Drawer/CustomNode.tsx index 8fd92d2e3c..59bd380687 100644 --- a/packages/core/client/src/components/Drawer/CustomNode.tsx +++ b/packages/client/core/src/components/Drawer/CustomNode.tsx @@ -11,8 +11,8 @@ import Menu from '@mui/material/Menu' import MenuItem from '@mui/material/MenuItem' import DriveFileRenameOutlineTwoToneIcon from '@mui/icons-material/DriveFileRenameOutlineTwoTone' import DeleteOutlineTwoToneIcon from '@mui/icons-material/DeleteOutlineTwoTone' -import { useFeathers } from '@magickml/client-core' -import { Modal } from '@magickml/client-core'; +import { useFeathers } from 'client/core' +import { Modal } from 'client/core' import { RootState, closeTab, @@ -53,7 +53,7 @@ export const CustomNode: React.FC = props => { const [isRenaming, setIsRenaming] = useState(false) const [newName, setNewName] = useState(props.node.text) const [patchSpell] = spellApi.usePatchSpellMutation() - const [openConfirm, setOpenConfirm] = useState(false); + const [openConfirm, setOpenConfirm] = useState(false) const activeTab = useSelector(activeTabSelector) const handleToggle = (e: React.MouseEvent) => { @@ -62,18 +62,18 @@ export const CustomNode: React.FC = props => { } const handleClose = () => { - setOpenConfirm(false); - }; + setOpenConfirm(false) + } const handleClick = () => { if (!props.node) return if (props.node.fileType === 'txt') { setOpenDoc(props.node.id) props.openTab({ - id: "Documents", + id: 'Documents', name: 'Documents', type: 'Documents', - switchActive: true + switchActive: true, }) } else if (props.node.fileType === 'spell') { console.log('Open spell', props.node) @@ -188,7 +188,9 @@ export const CustomNode: React.FC = props => { useEffect(() => { if (isRenaming) { - const renameInput = document?.querySelector('.rename-input') as HTMLElement + const renameInput = document?.querySelector( + '.rename-input' + ) as HTMLElement if (renameInput) renameInput.focus() } }, [isRenaming]) @@ -203,8 +205,9 @@ export const CustomNode: React.FC = props => { style={{ paddingInlineStart: indent }} >
{props.node.droppable && (
@@ -222,7 +225,7 @@ export const CustomNode: React.FC = props => { {isRenaming ? ( setNewName(e.target.value)} onBlur={handleRename} @@ -234,7 +237,7 @@ export const CustomNode: React.FC = props => { sx={{ cursor: 'pointer', marginLeft: '8px', - whiteSpace: 'nowrap' + whiteSpace: 'nowrap', }} onClick={handleClick} onContextMenu={handleContextMenu} @@ -276,8 +279,8 @@ export const CustomNode: React.FC = props => { { - e.stopPropagation(); - setOpenConfirm(true); + e.stopPropagation() + setOpenConfirm(true) }} > @@ -288,12 +291,14 @@ export const CustomNode: React.FC = props => { Rename - + children="Do you want to delete this spell?" + />
) } diff --git a/packages/core/client/src/components/Drawer/Newsidebar/index.tsx b/packages/client/core/src/components/Drawer/Newsidebar/index.tsx similarity index 99% rename from packages/core/client/src/components/Drawer/Newsidebar/index.tsx rename to packages/client/core/src/components/Drawer/Newsidebar/index.tsx index 0c7b0aadbf..497993556c 100644 --- a/packages/core/client/src/components/Drawer/Newsidebar/index.tsx +++ b/packages/client/core/src/components/Drawer/Newsidebar/index.tsx @@ -38,7 +38,7 @@ import FolderOpenOutlinedIcon from '@mui/icons-material/FolderOpenOutlined' import DescriptionOutlinedIcon from '@mui/icons-material/DescriptionOutlined' import StarBorderPurple500OutlinedIcon from '@mui/icons-material/StarBorderPurple500Outlined' import HistoryEduOutlinedIcon from '@mui/icons-material/HistoryEduOutlined' -import { useConfig } from '@magickml/client-core' +import { useConfig } from 'client/core' import { DEFAULT_USER_TOKEN, STANDALONE, PRODUCTION } from 'shared/config' import { useDispatch, useSelector } from 'react-redux' diff --git a/packages/core/client/src/components/Drawer/OldSidebar/index.tsx b/packages/client/core/src/components/Drawer/OldSidebar/index.tsx similarity index 100% rename from packages/core/client/src/components/Drawer/OldSidebar/index.tsx rename to packages/client/core/src/components/Drawer/OldSidebar/index.tsx diff --git a/packages/core/client/src/components/Drawer/ProjectWindow/index.module.scss b/packages/client/core/src/components/Drawer/ProjectWindow/index.module.scss similarity index 100% rename from packages/core/client/src/components/Drawer/ProjectWindow/index.module.scss rename to packages/client/core/src/components/Drawer/ProjectWindow/index.module.scss diff --git a/packages/core/client/src/components/Drawer/ProjectWindow/index.tsx b/packages/client/core/src/components/Drawer/ProjectWindow/index.tsx similarity index 100% rename from packages/core/client/src/components/Drawer/ProjectWindow/index.tsx rename to packages/client/core/src/components/Drawer/ProjectWindow/index.tsx diff --git a/packages/core/client/src/components/Drawer/SetAPIKeys.tsx b/packages/client/core/src/components/Drawer/SetAPIKeys.tsx similarity index 76% rename from packages/core/client/src/components/Drawer/SetAPIKeys.tsx rename to packages/client/core/src/components/Drawer/SetAPIKeys.tsx index 29cccc22e3..5454e227c0 100644 --- a/packages/core/client/src/components/Drawer/SetAPIKeys.tsx +++ b/packages/client/core/src/components/Drawer/SetAPIKeys.tsx @@ -1,12 +1,12 @@ -// DOCUMENTED +// DOCUMENTED // Import hooks and libraries -import { useEffect, useState } from 'react'; -import InfoDialog from '../InfoDialog'; +import { useEffect, useState } from 'react' +import InfoDialog from '../InfoDialog' // Constants for title and body of the InfoDialog -const title = 'Set Your API Keys'; +const title = 'Set Your API Keys' const body = - 'Please set your API keys in the editor settings to use external APIs. You will need to do this before you can use any AI features'; + 'Please set your API keys in the editor settings to use external APIs. You will need to do this before you can use any AI features' /** * SetAPIKeys component to show a warning about setting API keys. @@ -14,7 +14,7 @@ const body = */ export const SetAPIKeys = (): JSX.Element => { // Declare state variables - const [showWarning, setShowWarning] = useState(false); + const [showWarning, setShowWarning] = useState(false) // Use useEffect to check and set first-time user local storage useEffect(() => { @@ -22,12 +22,12 @@ export const SetAPIKeys = (): JSX.Element => { // Set the local storage item for first-time user window.localStorage.setItem( 'first_time_user', - JSON.stringify({ has_seen_api_key_warning: true }), - ); + JSON.stringify({ has_seen_api_key_warning: true }) + ) // Show the warning for API keys - setShowWarning(true); + setShowWarning(true) } - }, []); + }, []) // Render the component return ( @@ -45,5 +45,5 @@ export const SetAPIKeys = (): JSX.Element => { /> )} - ); -}; \ No newline at end of file + ) +} diff --git a/packages/client/core/src/components/Drawer/TypeIcon.tsx b/packages/client/core/src/components/Drawer/TypeIcon.tsx new file mode 100644 index 0000000000..e93cd5f98d --- /dev/null +++ b/packages/client/core/src/components/Drawer/TypeIcon.tsx @@ -0,0 +1,27 @@ +import React from 'react' +import FolderOpenOutlinedIcon from '@mui/icons-material/FolderOpenOutlined' +import DescriptionOutlinedIcon from '@mui/icons-material/DescriptionOutlined' +import StarBorderPurple500OutlinedIcon from '@mui/icons-material/StarBorderPurple500Outlined' +import HistoryEduOutlinedIcon from '@mui/icons-material/HistoryEduOutlined' + +type Props = { + droppable: boolean + fileType?: string +} + +export const TypeIcon: React.FC = props => { + if (props.droppable) { + return + } + + switch (props.fileType) { + case 'txt': + return + case 'prompt': + return + case 'spell': + return + default: + return null + } +} diff --git a/packages/core/client/src/components/Drawer/index.tsx b/packages/client/core/src/components/Drawer/index.tsx similarity index 100% rename from packages/core/client/src/components/Drawer/index.tsx rename to packages/client/core/src/components/Drawer/index.tsx diff --git a/packages/core/client/src/components/Drawer/logo-full.png b/packages/client/core/src/components/Drawer/logo-full.png similarity index 100% rename from packages/core/client/src/components/Drawer/logo-full.png rename to packages/client/core/src/components/Drawer/logo-full.png diff --git a/packages/core/client/src/components/Drawer/logo-small.png b/packages/client/core/src/components/Drawer/logo-small.png similarity index 100% rename from packages/core/client/src/components/Drawer/logo-small.png rename to packages/client/core/src/components/Drawer/logo-small.png diff --git a/packages/core/client/src/components/Drawer/menu.module.css b/packages/client/core/src/components/Drawer/menu.module.css similarity index 100% rename from packages/core/client/src/components/Drawer/menu.module.css rename to packages/client/core/src/components/Drawer/menu.module.css diff --git a/packages/core/client/src/components/Drawer/tooltiptext.ts b/packages/client/core/src/components/Drawer/tooltiptext.ts similarity index 100% rename from packages/core/client/src/components/Drawer/tooltiptext.ts rename to packages/client/core/src/components/Drawer/tooltiptext.ts diff --git a/packages/core/client/src/components/FileInput/FileInput.tsx b/packages/client/core/src/components/FileInput/FileInput.tsx similarity index 72% rename from packages/core/client/src/components/FileInput/FileInput.tsx rename to packages/client/core/src/components/FileInput/FileInput.tsx index 8e79636264..3c72e05045 100644 --- a/packages/core/client/src/components/FileInput/FileInput.tsx +++ b/packages/client/core/src/components/FileInput/FileInput.tsx @@ -1,27 +1,27 @@ -// DOCUMENTED -import React, { useRef, ChangeEvent } from 'react'; -import { Button } from '../Button'; +// DOCUMENTED +import React, { useRef, ChangeEvent } from 'react' +import { Button } from '../Button' interface FileInputProps { /** * Function to process loaded files. */ - loadFile: (file: File) => void; + loadFile: (file: File) => void /** * Optional custom styles. */ - sx?: React.CSSProperties; + sx?: React.CSSProperties /** * Button text. Defaults to 'Import'. */ - innerText?: string; + innerText?: string /** * Optional custom icon for the button. */ - Icon?: React.ReactNode; + Icon?: React.ReactNode } /** @@ -34,14 +34,14 @@ const FileInput: React.FC = ({ innerText = 'Import', Icon = <>, }) => { - const hiddenFileInput = useRef(null); + const hiddenFileInput = useRef(null) /** * Handle button click by trigerring the hidden file input. */ const handleClick = (): void => { - hiddenFileInput.current?.click(); - }; + hiddenFileInput.current?.click() + } /** * Handle file input change by processing selected files. @@ -49,9 +49,9 @@ const FileInput: React.FC = ({ */ const handleChange = (event: ChangeEvent): void => { if (event.target.files) { - Array.from(event.target.files).forEach(loadFile); + Array.from(event.target.files).forEach(loadFile) } - }; + } return ( <> @@ -68,7 +68,7 @@ const FileInput: React.FC = ({ style={{ display: 'none' }} /> - ); -}; + ) +} -export default FileInput; \ No newline at end of file +export default FileInput diff --git a/packages/core/client/src/components/Icon/icon.module.css b/packages/client/core/src/components/Icon/icon.module.css similarity index 98% rename from packages/core/client/src/components/Icon/icon.module.css rename to packages/client/core/src/components/Icon/icon.module.css index 0b33846803..448032edb2 100644 --- a/packages/core/client/src/components/Icon/icon.module.css +++ b/packages/client/core/src/components/Icon/icon.module.css @@ -4,4 +4,4 @@ background-position: center; background-repeat: no-repeat; position: relative; -} \ No newline at end of file +} diff --git a/packages/client/core/src/components/Icon/icon.module.css.d.ts b/packages/client/core/src/components/Icon/icon.module.css.d.ts new file mode 100644 index 0000000000..505aaf0d9a --- /dev/null +++ b/packages/client/core/src/components/Icon/icon.module.css.d.ts @@ -0,0 +1,48 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + account: string + add: string + ankh: string + bird: string + close: string + cloth: string + cup: string + feathers: string + fewshot: string + folder: string + hand: string + icon: string + info: string + merge: string + minus: string + moon: string + newnode: string + 'node-lock': string + pause: string + person: string + play: string + 'play-print': string + properties: string + refresh: string + search: string + seive: string + snake: string + state: string + 'state-read': string + 'state-write': string + stop: string + 'stop-sign': string + switch: string + temperature: string + text: string + tiles: string + time: string + trash: string + warn: string + water: string + 'water-play': string + 'water-run': string +} +export const cssExports: CssExports +export default cssExports diff --git a/packages/core/client/src/components/Icon/icons/Lock.svg b/packages/client/core/src/components/Icon/icons/Lock.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/Lock.svg rename to packages/client/core/src/components/Icon/icons/Lock.svg diff --git a/packages/core/client/src/components/Icon/icons/account.svg b/packages/client/core/src/components/Icon/icons/account.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/account.svg rename to packages/client/core/src/components/Icon/icons/account.svg diff --git a/packages/core/client/src/components/Icon/icons/add.svg b/packages/client/core/src/components/Icon/icons/add.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/add.svg rename to packages/client/core/src/components/Icon/icons/add.svg diff --git a/packages/core/client/src/components/Icon/icons/ankh.svg b/packages/client/core/src/components/Icon/icons/ankh.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/ankh.svg rename to packages/client/core/src/components/Icon/icons/ankh.svg diff --git a/packages/core/client/src/components/Icon/icons/bird.svg b/packages/client/core/src/components/Icon/icons/bird.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/bird.svg rename to packages/client/core/src/components/Icon/icons/bird.svg diff --git a/packages/core/client/src/components/Icon/icons/close.svg b/packages/client/core/src/components/Icon/icons/close.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/close.svg rename to packages/client/core/src/components/Icon/icons/close.svg diff --git a/packages/core/client/src/components/Icon/icons/cloth.svg b/packages/client/core/src/components/Icon/icons/cloth.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/cloth.svg rename to packages/client/core/src/components/Icon/icons/cloth.svg diff --git a/packages/core/client/src/components/Icon/icons/cup.svg b/packages/client/core/src/components/Icon/icons/cup.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/cup.svg rename to packages/client/core/src/components/Icon/icons/cup.svg diff --git a/packages/core/client/src/components/Icon/icons/danger-trash.svg b/packages/client/core/src/components/Icon/icons/danger-trash.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/danger-trash.svg rename to packages/client/core/src/components/Icon/icons/danger-trash.svg diff --git a/packages/core/client/src/components/Icon/icons/delete.svg b/packages/client/core/src/components/Icon/icons/delete.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/delete.svg rename to packages/client/core/src/components/Icon/icons/delete.svg diff --git a/packages/core/client/src/components/Icon/icons/feathers.svg b/packages/client/core/src/components/Icon/icons/feathers.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/feathers.svg rename to packages/client/core/src/components/Icon/icons/feathers.svg diff --git a/packages/core/client/src/components/Icon/icons/fewshot.svg b/packages/client/core/src/components/Icon/icons/fewshot.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/fewshot.svg rename to packages/client/core/src/components/Icon/icons/fewshot.svg diff --git a/packages/core/client/src/components/Icon/icons/folder.svg b/packages/client/core/src/components/Icon/icons/folder.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/folder.svg rename to packages/client/core/src/components/Icon/icons/folder.svg diff --git a/packages/core/client/src/components/Icon/icons/hand.svg b/packages/client/core/src/components/Icon/icons/hand.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/hand.svg rename to packages/client/core/src/components/Icon/icons/hand.svg diff --git a/packages/core/client/src/components/Icon/icons/info.svg b/packages/client/core/src/components/Icon/icons/info.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/info.svg rename to packages/client/core/src/components/Icon/icons/info.svg diff --git a/packages/core/client/src/components/Icon/icons/merge.svg b/packages/client/core/src/components/Icon/icons/merge.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/merge.svg rename to packages/client/core/src/components/Icon/icons/merge.svg diff --git a/packages/core/client/src/components/Icon/icons/minus.svg b/packages/client/core/src/components/Icon/icons/minus.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/minus.svg rename to packages/client/core/src/components/Icon/icons/minus.svg diff --git a/packages/core/client/src/components/Icon/icons/moon.svg b/packages/client/core/src/components/Icon/icons/moon.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/moon.svg rename to packages/client/core/src/components/Icon/icons/moon.svg diff --git a/packages/core/client/src/components/Icon/icons/newnode.svg b/packages/client/core/src/components/Icon/icons/newnode.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/newnode.svg rename to packages/client/core/src/components/Icon/icons/newnode.svg diff --git a/packages/core/client/src/components/Icon/icons/node-lock.svg b/packages/client/core/src/components/Icon/icons/node-lock.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/node-lock.svg rename to packages/client/core/src/components/Icon/icons/node-lock.svg diff --git a/packages/core/client/src/components/Icon/icons/pause.svg b/packages/client/core/src/components/Icon/icons/pause.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/pause.svg rename to packages/client/core/src/components/Icon/icons/pause.svg diff --git a/packages/core/client/src/components/Icon/icons/person.svg b/packages/client/core/src/components/Icon/icons/person.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/person.svg rename to packages/client/core/src/components/Icon/icons/person.svg diff --git a/packages/core/client/src/components/Icon/icons/play-print.svg b/packages/client/core/src/components/Icon/icons/play-print.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/play-print.svg rename to packages/client/core/src/components/Icon/icons/play-print.svg diff --git a/packages/core/client/src/components/Icon/icons/play.svg b/packages/client/core/src/components/Icon/icons/play.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/play.svg rename to packages/client/core/src/components/Icon/icons/play.svg diff --git a/packages/core/client/src/components/Icon/icons/properties.svg b/packages/client/core/src/components/Icon/icons/properties.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/properties.svg rename to packages/client/core/src/components/Icon/icons/properties.svg diff --git a/packages/core/client/src/components/Icon/icons/refresh.svg b/packages/client/core/src/components/Icon/icons/refresh.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/refresh.svg rename to packages/client/core/src/components/Icon/icons/refresh.svg diff --git a/packages/core/client/src/components/Icon/icons/search.svg b/packages/client/core/src/components/Icon/icons/search.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/search.svg rename to packages/client/core/src/components/Icon/icons/search.svg diff --git a/packages/core/client/src/components/Icon/icons/seive.svg b/packages/client/core/src/components/Icon/icons/seive.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/seive.svg rename to packages/client/core/src/components/Icon/icons/seive.svg diff --git a/packages/core/client/src/components/Icon/icons/snake.svg b/packages/client/core/src/components/Icon/icons/snake.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/snake.svg rename to packages/client/core/src/components/Icon/icons/snake.svg diff --git a/packages/core/client/src/components/Icon/icons/state-read.svg b/packages/client/core/src/components/Icon/icons/state-read.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/state-read.svg rename to packages/client/core/src/components/Icon/icons/state-read.svg diff --git a/packages/core/client/src/components/Icon/icons/state-write.svg b/packages/client/core/src/components/Icon/icons/state-write.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/state-write.svg rename to packages/client/core/src/components/Icon/icons/state-write.svg diff --git a/packages/core/client/src/components/Icon/icons/state.svg b/packages/client/core/src/components/Icon/icons/state.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/state.svg rename to packages/client/core/src/components/Icon/icons/state.svg diff --git a/packages/core/client/src/components/Icon/icons/stop-sign.svg b/packages/client/core/src/components/Icon/icons/stop-sign.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/stop-sign.svg rename to packages/client/core/src/components/Icon/icons/stop-sign.svg diff --git a/packages/core/client/src/components/Icon/icons/stop.svg b/packages/client/core/src/components/Icon/icons/stop.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/stop.svg rename to packages/client/core/src/components/Icon/icons/stop.svg diff --git a/packages/core/client/src/components/Icon/icons/switch.svg b/packages/client/core/src/components/Icon/icons/switch.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/switch.svg rename to packages/client/core/src/components/Icon/icons/switch.svg diff --git a/packages/core/client/src/components/Icon/icons/temperature.svg b/packages/client/core/src/components/Icon/icons/temperature.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/temperature.svg rename to packages/client/core/src/components/Icon/icons/temperature.svg diff --git a/packages/core/client/src/components/Icon/icons/text.svg b/packages/client/core/src/components/Icon/icons/text.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/text.svg rename to packages/client/core/src/components/Icon/icons/text.svg diff --git a/packages/core/client/src/components/Icon/icons/tiles.svg b/packages/client/core/src/components/Icon/icons/tiles.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/tiles.svg rename to packages/client/core/src/components/Icon/icons/tiles.svg diff --git a/packages/core/client/src/components/Icon/icons/time.svg b/packages/client/core/src/components/Icon/icons/time.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/time.svg rename to packages/client/core/src/components/Icon/icons/time.svg diff --git a/packages/core/client/src/components/Icon/icons/trash.svg b/packages/client/core/src/components/Icon/icons/trash.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/trash.svg rename to packages/client/core/src/components/Icon/icons/trash.svg diff --git a/packages/core/client/src/components/Icon/icons/warn.svg b/packages/client/core/src/components/Icon/icons/warn.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/warn.svg rename to packages/client/core/src/components/Icon/icons/warn.svg diff --git a/packages/core/client/src/components/Icon/icons/water-play.svg b/packages/client/core/src/components/Icon/icons/water-play.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/water-play.svg rename to packages/client/core/src/components/Icon/icons/water-play.svg diff --git a/packages/core/client/src/components/Icon/icons/water-run.svg b/packages/client/core/src/components/Icon/icons/water-run.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/water-run.svg rename to packages/client/core/src/components/Icon/icons/water-run.svg diff --git a/packages/core/client/src/components/Icon/icons/water.svg b/packages/client/core/src/components/Icon/icons/water.svg similarity index 100% rename from packages/core/client/src/components/Icon/icons/water.svg rename to packages/client/core/src/components/Icon/icons/water.svg diff --git a/packages/core/client/src/components/Icon/index.tsx b/packages/client/core/src/components/Icon/index.tsx similarity index 99% rename from packages/core/client/src/components/Icon/index.tsx rename to packages/client/core/src/components/Icon/index.tsx index fd361a3024..59f0452ed3 100644 --- a/packages/core/client/src/components/Icon/index.tsx +++ b/packages/client/core/src/components/Icon/index.tsx @@ -98,7 +98,7 @@ const icons = { // Categories for components and data controls export const componentCategories = { 'AI/ML': 'play-print', - 'IO': 'water', + IO: 'water', Logic: 'switch', State: 'state', Module: 'cup', diff --git a/packages/client/core/src/components/IconButton/index.tsx b/packages/client/core/src/components/IconButton/index.tsx new file mode 100644 index 0000000000..818db0d0ac --- /dev/null +++ b/packages/client/core/src/components/IconButton/index.tsx @@ -0,0 +1,37 @@ +// DOCUMENTED +import * as React from 'react' +import IconButton from '@mui/material/IconButton' + +/** + * Props interface for IconBtn component. + */ +interface Props { + Icon: React.ReactNode // Icon component to be rendered + label: string // Aria-label for the IconButton + onClick?: (e) => void // Optional onClick handler + style?: React.CSSProperties // Optional custom styles +} + +/** + * IconBtn component - IconButton with custom Icon and label. + * + * @param {Props} props - IconBtn component properties + * @returns {React.ReactElement} - Rendered IconBtn component + */ +export const IconBtn: React.FunctionComponent = ( + props: Props +): JSX.Element => { + const { Icon, label, onClick, style } = props + + return ( + + {Icon} + + ) +} diff --git a/packages/core/client/src/components/InfoDialog/index.module.scss b/packages/client/core/src/components/InfoDialog/index.module.scss similarity index 100% rename from packages/core/client/src/components/InfoDialog/index.module.scss rename to packages/client/core/src/components/InfoDialog/index.module.scss diff --git a/packages/core/client/src/components/InfoDialog/index.tsx b/packages/client/core/src/components/InfoDialog/index.tsx similarity index 75% rename from packages/core/client/src/components/InfoDialog/index.tsx rename to packages/client/core/src/components/InfoDialog/index.tsx index 23ba9b1da4..00caaf48d9 100644 --- a/packages/core/client/src/components/InfoDialog/index.tsx +++ b/packages/client/core/src/components/InfoDialog/index.tsx @@ -1,22 +1,22 @@ -// DOCUMENTED -import React, { useRef, useEffect } from 'react'; +// DOCUMENTED +import React, { useRef, useEffect } from 'react' import { DialogTitle, IconButton, Typography, DialogContent, Menu, -} from '@mui/material'; -import { Close } from '@mui/icons-material'; -import styles from './index.module.scss'; +} from '@mui/material' +import { Close } from '@mui/icons-material' +import styles from './index.module.scss' /** * The props for the DialogTitle component. */ export interface DialogTitleProps { - id: string; - children?: React.ReactNode; - onClose: () => void; + id: string + children?: React.ReactNode + onClose: () => void } /** @@ -26,7 +26,7 @@ export interface DialogTitleProps { * @returns The dialog title component. */ function BootstrapDialogTitle(props: DialogTitleProps) { - const { children, onClose, ...other } = props; + const { children, onClose, ...other } = props return ( @@ -39,7 +39,7 @@ function BootstrapDialogTitle(props: DialogTitleProps) { position: 'absolute', right: 8, top: 8, - color: (theme) => theme.palette.grey[500], + color: theme => theme.palette.grey[500], background: 'var(--dark-2)', }} > @@ -47,7 +47,7 @@ function BootstrapDialogTitle(props: DialogTitleProps) { ) : null} - ); + ) } /** @@ -60,22 +60,22 @@ function BootstrapDialogTitle(props: DialogTitleProps) { * @returns {JSX.Element} The info dialog component. */ const InfoDialog = ({ title, body, style }): JSX.Element => { - const anchorRef = useRef(null); - const [anchorEl, setAnchorEl] = React.useState(null); - const open = Boolean(anchorEl); + const anchorRef = useRef(null) + const [anchorEl, setAnchorEl] = React.useState(null) + const open = Boolean(anchorEl) - const handleClick = (event) => { - setAnchorEl(event.currentTarget); - }; + const handleClick = event => { + setAnchorEl(event.currentTarget) + } const handleClose = () => { - setAnchorEl(null); - }; + setAnchorEl(null) + } useEffect(() => { - if (!anchorRef.current) return; - anchorRef.current.click(); - }, []); + if (!anchorRef.current) return + anchorRef.current.click() + }, []) return ( <> @@ -105,7 +105,7 @@ const InfoDialog = ({ title, body, style }): JSX.Element => { )} - ); -}; + ) +} -export default InfoDialog; \ No newline at end of file +export default InfoDialog diff --git a/packages/core/client/src/components/Input/index.tsx b/packages/client/core/src/components/Input/index.tsx similarity index 100% rename from packages/core/client/src/components/Input/index.tsx rename to packages/client/core/src/components/Input/index.tsx diff --git a/packages/core/client/src/components/Input/input.module.css b/packages/client/core/src/components/Input/input.module.css similarity index 100% rename from packages/core/client/src/components/Input/input.module.css rename to packages/client/core/src/components/Input/input.module.css diff --git a/packages/core/client/src/components/LoadingScreen/index.tsx b/packages/client/core/src/components/LoadingScreen/index.tsx similarity index 100% rename from packages/core/client/src/components/LoadingScreen/index.tsx rename to packages/client/core/src/components/LoadingScreen/index.tsx diff --git a/packages/core/client/src/components/LoadingScreen/magick-loading.svg b/packages/client/core/src/components/LoadingScreen/magick-loading.svg similarity index 100% rename from packages/core/client/src/components/LoadingScreen/magick-loading.svg rename to packages/client/core/src/components/LoadingScreen/magick-loading.svg diff --git a/packages/core/client/src/components/Modal/index.module.scss b/packages/client/core/src/components/Modal/index.module.scss similarity index 100% rename from packages/core/client/src/components/Modal/index.module.scss rename to packages/client/core/src/components/Modal/index.module.scss diff --git a/packages/core/client/src/components/Modal/index.tsx b/packages/client/core/src/components/Modal/index.tsx similarity index 99% rename from packages/core/client/src/components/Modal/index.tsx rename to packages/client/core/src/components/Modal/index.tsx index f4e5fba23d..78c69ac53e 100644 --- a/packages/core/client/src/components/Modal/index.tsx +++ b/packages/client/core/src/components/Modal/index.tsx @@ -58,7 +58,6 @@ export const Modal = ({
) -} \ No newline at end of file +} diff --git a/packages/core/client/src/components/Window/window.module.css b/packages/client/core/src/components/Window/window.module.css similarity index 100% rename from packages/core/client/src/components/Window/window.module.css rename to packages/client/core/src/components/Window/window.module.css diff --git a/packages/client/core/src/components/Window/window.module.css.d.ts b/packages/client/core/src/components/Window/window.module.css.d.ts new file mode 100644 index 0000000000..5995251073 --- /dev/null +++ b/packages/client/core/src/components/Window/window.module.css.d.ts @@ -0,0 +1,15 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + bordered: string + darkened: string + darker: string + grid: string + 'lock-bar': string + unpadded: string + window: string + 'window-layout': string + 'window-toolbar': string +} +export const cssExports: CssExports +export default cssExports diff --git a/packages/core/client/src/components/index.ts b/packages/client/core/src/components/index.ts similarity index 100% rename from packages/core/client/src/components/index.ts rename to packages/client/core/src/components/index.ts diff --git a/packages/core/client/src/contexts/ProjectWindowContext.tsx b/packages/client/core/src/contexts/ProjectWindowContext.tsx similarity index 100% rename from packages/core/client/src/contexts/ProjectWindowContext.tsx rename to packages/client/core/src/contexts/ProjectWindowContext.tsx diff --git a/packages/core/client/src/contexts/TreeDataProvider.tsx b/packages/client/core/src/contexts/TreeDataProvider.tsx similarity index 98% rename from packages/core/client/src/contexts/TreeDataProvider.tsx rename to packages/client/core/src/contexts/TreeDataProvider.tsx index acb895b32e..1fef7f4fae 100644 --- a/packages/core/client/src/contexts/TreeDataProvider.tsx +++ b/packages/client/core/src/contexts/TreeDataProvider.tsx @@ -1,7 +1,7 @@ import React, { createContext, useContext, useState, useEffect } from 'react' import { NodeModel } from '@minoru/react-dnd-treeview' import { useSnackbar } from 'notistack' -import { useConfig, useFeathers } from '@magickml/client-core' +import { useConfig, useFeathers } from 'client/core' import { API_ROOT_URL } from 'shared/config' import { useSelector } from 'react-redux' import SampleData from './data/sampleData.json' diff --git a/packages/client/core/src/contexts/data/sampleData.json b/packages/client/core/src/contexts/data/sampleData.json new file mode 100644 index 0000000000..0d30b0fd5b --- /dev/null +++ b/packages/client/core/src/contexts/data/sampleData.json @@ -0,0 +1,21 @@ +[ + { + "id": 1, + "parent": 0, + "droppable": true, + "text": "Documents" + }, + { + "id": 3, + "parent": 1, + "droppable": true, + "text": "Uploaded Knowledge" + }, + + { + "id": 6, + "parent": 0, + "droppable": true, + "text": "Spells & Prompts" + } +] diff --git a/packages/core/client/src/contexts/index.ts b/packages/client/core/src/contexts/index.ts similarity index 97% rename from packages/core/client/src/contexts/index.ts rename to packages/client/core/src/contexts/index.ts index 9f868597d5..5fda6a8c45 100644 --- a/packages/core/client/src/contexts/index.ts +++ b/packages/client/core/src/contexts/index.ts @@ -1,2 +1,2 @@ export { ProjectWindowProvider, useProjectWindow } from './ProjectWindowContext' -export { TreeDataProvider, useTreeData } from './TreeDataProvider' \ No newline at end of file +export { TreeDataProvider, useTreeData } from './TreeDataProvider' diff --git a/packages/core/client/src/index.ts b/packages/client/core/src/index.ts similarity index 99% rename from packages/core/client/src/index.ts rename to packages/client/core/src/index.ts index 0a423daf39..23a37c52c6 100644 --- a/packages/core/client/src/index.ts +++ b/packages/client/core/src/index.ts @@ -33,4 +33,4 @@ const getProjectTemplates = () => export const getTemplates = () => ({ projects: [...defaultTemplates.projects, ...getProjectTemplates()], spells: [...defaultTemplates.spells, ...getSpellTemplates()], -}) \ No newline at end of file +}) diff --git a/packages/core/client/src/providers/ConfigProvider.tsx b/packages/client/core/src/providers/ConfigProvider.tsx similarity index 100% rename from packages/core/client/src/providers/ConfigProvider.tsx rename to packages/client/core/src/providers/ConfigProvider.tsx diff --git a/packages/core/client/src/providers/FeathersProvider.tsx b/packages/client/core/src/providers/FeathersProvider.tsx similarity index 94% rename from packages/core/client/src/providers/FeathersProvider.tsx rename to packages/client/core/src/providers/FeathersProvider.tsx index d4eef16582..27dc0c1ec9 100644 --- a/packages/core/client/src/providers/FeathersProvider.tsx +++ b/packages/client/core/src/providers/FeathersProvider.tsx @@ -54,7 +54,17 @@ const configureCustomServices = ( }) app.use('agents', socketClient.service('agents'), { - methods: ['find', 'get', 'create', 'patch', 'remove', 'log', 'run', 'subscribe', 'command'], + methods: [ + 'find', + 'get', + 'create', + 'patch', + 'remove', + 'log', + 'run', + 'subscribe', + 'command', + ], events: ['log', 'result', 'spell'], }) app.use('request', socketClient.service('request'), { @@ -73,7 +83,7 @@ const buildFeathersClient = async (config, token): Promise => { const socket = io(`${config.apiUrl}?token=${token}`, { transports: ['websocket'], extraHeaders: { - Authorization: `Bearer ${token}` + Authorization: `Bearer ${token}`, }, withCredentials: true, }) @@ -112,7 +122,7 @@ export const FeathersProvider = ({ children, token }): JSX.Element => { const logger = getLogger() useEffect(() => { - ; (async (): Promise => { + ;(async (): Promise => { const client = await buildFeathersClient(config, token) client.io.on('connect', async (): Promise => { diff --git a/packages/core/client/src/providers/PubSubProvider.tsx b/packages/client/core/src/providers/PubSubProvider.tsx similarity index 97% rename from packages/core/client/src/providers/PubSubProvider.tsx rename to packages/client/core/src/providers/PubSubProvider.tsx index 2846d129c8..bab5713bea 100644 --- a/packages/core/client/src/providers/PubSubProvider.tsx +++ b/packages/client/core/src/providers/PubSubProvider.tsx @@ -85,7 +85,7 @@ export const PubSubProvider = ({ children }) => { publish(events.TOGGLE_FILE_DRAWER, {}) }) - useHotkeys('ctrl+c', (event) => { + useHotkeys('ctrl+c', event => { console.log('TRIGGER TAB SWITCH') }) @@ -98,11 +98,10 @@ export const PubSubProvider = ({ children }) => { }) const unsubscribeCommand = subscribe(events.SEND_COMMAND, (event, data) => { - console.log("SENDING COMMAND DATA", data) + console.log('SENDING COMMAND DATA', data) client.service('agents').command(data) }) - return () => { unsubscribeRun() unsubscribeCommand() diff --git a/packages/core/client/src/providers/index.tsx b/packages/client/core/src/providers/index.tsx similarity index 65% rename from packages/core/client/src/providers/index.tsx rename to packages/client/core/src/providers/index.tsx index e07f260eba..e043a5573c 100644 --- a/packages/core/client/src/providers/index.tsx +++ b/packages/client/core/src/providers/index.tsx @@ -1,3 +1,3 @@ export * from './ConfigProvider' export * from './PubSubProvider' -export * from './FeathersProvider' \ No newline at end of file +export * from './FeathersProvider' diff --git a/packages/core/client/src/templates/index.ts b/packages/client/core/src/templates/index.ts similarity index 63% rename from packages/core/client/src/templates/index.ts rename to packages/client/core/src/templates/index.ts index 8c3e5ff754..393d4f33e0 100644 --- a/packages/core/client/src/templates/index.ts +++ b/packages/client/core/src/templates/index.ts @@ -1,26 +1,26 @@ -// DOCUMENTED +// DOCUMENTED /** * An array of spell templates in JSON format. - * + * * @typedef {Object[]} SpellTemplates */ -import Starter from './spells/Starter.spell.json'; -import Blank from './spells/Blank.spell.json'; +import Starter from './spells/Starter.spell.json' +import Blank from './spells/Blank.spell.json' /** * An array of spell templates in JSON format. - * + * * @type {SpellTemplates} */ -const spellTemplates = [Starter, Blank]; +const spellTemplates = [Starter, Blank] /** * An empty array to hold project templates. - * + * * @type {any[]} */ -const projectTemplates = []; +const projectTemplates = [] /** * An object that exports spellTemplates and projectTemplates. @@ -28,6 +28,6 @@ const projectTemplates = []; const templateData = { spells: spellTemplates, projects: projectTemplates, -}; +} -export default templateData; \ No newline at end of file +export default templateData diff --git a/packages/client/core/src/templates/spells/Blank.spell.json b/packages/client/core/src/templates/spells/Blank.spell.json new file mode 100644 index 0000000000..7c3ebb3836 --- /dev/null +++ b/packages/client/core/src/templates/spells/Blank.spell.json @@ -0,0 +1,66 @@ +{ + "id": "ee0cd8da-85a6-484d-90d4-b85b652d8063", + "name": "Blank", + "projectId": "clmp2r33q0003vyxy4dh2uz8e", + "hash": "c8a6becf74079c8ec523e38a21565171", + "createdAt": "1695319385395", + "updatedAt": "1695319412520", + "graph": { + "id": "demo@0.1.0", + "nodes": { + "524": { + "id": 524, + "data": { + "log": false, + "name": "Input - Default", + "isInput": true, + "inputName": "Default", + "socketKey": "5bd194d8-0cb0-4f2f-aaec-f706e941b300" + }, + "inputs": {}, + "outputs": { + "trigger": { + "connections": [] + }, + "output": { + "connections": [] + } + }, + "position": [-206, -2.5], + "name": "Input" + }, + "525": { + "id": 525, + "data": { + "log": false, + "name": "Output - Default", + "isOutput": true, + "socketKey": "4495a612-83a1-4dc8-8868-baaecd23c6ff", + "sendToPlaytest": true + }, + "inputs": { + "trigger": { + "connections": [] + }, + "input": { + "connections": [] + }, + "event": { + "connections": [] + } + }, + "outputs": { + "trigger": { + "connections": [] + }, + "output": { + "connections": [] + } + }, + "position": [206, 2.5], + "name": "Output" + } + }, + "comments": [] + } +} diff --git a/packages/client/core/src/templates/spells/Starter.spell.json b/packages/client/core/src/templates/spells/Starter.spell.json new file mode 100644 index 0000000000..b4b5aabf31 --- /dev/null +++ b/packages/client/core/src/templates/spells/Starter.spell.json @@ -0,0 +1,244 @@ +{ + "id": "30e438fe-8ce3-402f-bcf2-1c433b43a4f4", + "name": "Starter", + "projectId": "clmp2r33q0003vyxy4dh2uz8e", + "hash": "b9d6637c48f4a1edba20427a561a77d5", + "createdAt": "1695319267522", + "updatedAt": "1695319318544", + "graph": { + "id": "demo@0.1.0", + "nodes": { + "518": { + "id": 518, + "data": { + "log": false, + "isInput": true, + "socketKey": "fc6abca2-1806-42c6-a0a9-690df28e3c57", + "name": "Input - Default", + "inputName": "Default" + }, + "inputs": {}, + "outputs": { + "trigger": { + "connections": [ + { + "node": 519, + "input": "trigger", + "data": { + "hello": "hello" + } + } + ] + }, + "output": { + "connections": [ + { + "node": 519, + "input": "event", + "data": { + "hello": "hello" + } + } + ] + } + }, + "position": [-499.888916015625, -26.888902452256943], + "name": "Input" + }, + "519": { + "id": 519, + "data": { + "log": false, + "socketKey": "d13533fc-1926-45f2-a87d-f355662e9f6d" + }, + "inputs": { + "trigger": { + "connections": [ + { + "node": 518, + "output": "trigger", + "data": { + "hello": "hello" + } + } + ] + }, + "event": { + "connections": [ + { + "node": 518, + "output": "output", + "data": { + "hello": "hello" + } + } + ] + } + }, + "outputs": { + "trigger": { + "connections": [ + { + "node": 520, + "input": "trigger", + "data": { + "hello": "hello" + } + } + ] + }, + "agentId": { + "connections": [] + }, + "content": { + "connections": [ + { + "node": 520, + "input": "source", + "data": { + "hello": "hello" + } + } + ] + }, + "client": { + "connections": [] + }, + "channel": { + "connections": [] + }, + "channelType": { + "connections": [] + }, + "connector": { + "connections": [] + }, + "entities": { + "connections": [] + }, + "projectId": { + "connections": [] + }, + "observer": { + "connections": [] + }, + "sender": { + "connections": [] + }, + "embedding": { + "connections": [] + }, + "rawData": { + "connections": [] + } + }, + "position": [-188.77780490451389, -25.777791341145832], + "name": "Event Destructure" + }, + "520": { + "id": 520, + "data": { + "log": false + }, + "inputs": { + "trigger": { + "connections": [ + { + "node": 519, + "output": "trigger", + "data": { + "hello": "hello" + } + } + ] + }, + "source": { + "connections": [ + { + "node": 519, + "output": "content", + "data": { + "hello": "hello" + } + } + ] + } + }, + "outputs": { + "trigger": { + "connections": [ + { + "node": 521, + "input": "trigger", + "data": { + "hello": "hello" + } + } + ] + }, + "output": { + "connections": [ + { + "node": 521, + "input": "input", + "data": { + "hello": "hello" + } + } + ] + } + }, + "position": [104.55552842881946, -15.777791341145829], + "name": "Echo" + }, + "521": { + "id": 521, + "data": { + "log": false, + "sendToPlaytest": true, + "isOutput": true, + "name": "Output - Default", + "socketKey": "37505ffa-b5d0-4720-9525-6d832bcd160d" + }, + "inputs": { + "trigger": { + "connections": [ + { + "node": 520, + "output": "trigger", + "data": { + "hello": "hello" + } + } + ] + }, + "input": { + "connections": [ + { + "node": 520, + "output": "output", + "data": { + "hello": "hello" + } + } + ] + }, + "event": { + "connections": [] + } + }, + "outputs": { + "trigger": { + "connections": [] + }, + "output": { + "connections": [] + } + }, + "position": [372.33330620659723, -14.666680230034714], + "name": "Output" + } + }, + "comments": [] + } +} diff --git a/packages/core/client/tsconfig.json b/packages/client/core/tsconfig.json similarity index 100% rename from packages/core/client/tsconfig.json rename to packages/client/core/tsconfig.json diff --git a/packages/core/client/tsconfig.lib.json b/packages/client/core/tsconfig.lib.json similarity index 100% rename from packages/core/client/tsconfig.lib.json rename to packages/client/core/tsconfig.lib.json diff --git a/packages/core/client/tsconfig.spec.json b/packages/client/core/tsconfig.spec.json similarity index 100% rename from packages/core/client/tsconfig.spec.json rename to packages/client/core/tsconfig.spec.json diff --git a/packages/core/client/vite.config.ts b/packages/client/core/vite.config.ts similarity index 100% rename from packages/core/client/vite.config.ts rename to packages/client/core/vite.config.ts diff --git a/packages/client/editor/src/DataControls/CodeControl.tsx b/packages/client/editor/src/DataControls/CodeControl.tsx index 2302ce5223..2497da9dcc 100644 --- a/packages/client/editor/src/DataControls/CodeControl.tsx +++ b/packages/client/editor/src/DataControls/CodeControl.tsx @@ -3,7 +3,7 @@ * Imports */ import React from 'react' -import { Button } from '@magickml/client-core' +import { Button } from 'client/core' import { useLayout } from '../contexts/LayoutProvider' /** diff --git a/packages/client/editor/src/DataControls/DropdownSelect.tsx b/packages/client/editor/src/DataControls/DropdownSelect.tsx index a110af9723..3183e176fa 100644 --- a/packages/client/editor/src/DataControls/DropdownSelect.tsx +++ b/packages/client/editor/src/DataControls/DropdownSelect.tsx @@ -6,7 +6,7 @@ * @param initialValue - The initial selected value */ -import { Select } from '@magickml/client-core' +import { Select } from 'client/core' import useSWR from 'swr' import { OpenAI } from '../types/openai' import { useEffect, useState } from 'react' diff --git a/packages/client/editor/src/DataControls/Form.tsx b/packages/client/editor/src/DataControls/Form.tsx index 8d24e1aee4..4d0aada7af 100644 --- a/packages/client/editor/src/DataControls/Form.tsx +++ b/packages/client/editor/src/DataControls/Form.tsx @@ -9,7 +9,7 @@ * @property {(e: React.MouseEvent) => void} onAdd - function to be called when the add button is clicked */ -import { Button } from '@magickml/client-core' +import { Button } from 'client/core' /** * Form component that renders a form with an input field and a button to add input value diff --git a/packages/client/editor/src/DataControls/Input.tsx b/packages/client/editor/src/DataControls/Input.tsx index 365544b3f6..43cc21c472 100644 --- a/packages/client/editor/src/DataControls/Input.tsx +++ b/packages/client/editor/src/DataControls/Input.tsx @@ -8,7 +8,7 @@ */ import React, { useState } from 'react' -import { Input } from '@magickml/client-core' +import { Input } from 'client/core' const InputControl: React.FC<{ control: { name: string; dataKey: string } diff --git a/packages/client/editor/src/DataControls/LongTextControl.tsx b/packages/client/editor/src/DataControls/LongTextControl.tsx index 9c6be1db1c..98b0b22764 100644 --- a/packages/client/editor/src/DataControls/LongTextControl.tsx +++ b/packages/client/editor/src/DataControls/LongTextControl.tsx @@ -3,7 +3,7 @@ * Imports */ import React from 'react' -import { Button } from '@magickml/client-core' +import { Button } from 'client/core' import { useLayout } from '../contexts/LayoutProvider' /** diff --git a/packages/client/editor/src/DataControls/PlaytestControl.tsx b/packages/client/editor/src/DataControls/PlaytestControl.tsx index 6c00cbf018..2dab4ae1da 100644 --- a/packages/client/editor/src/DataControls/PlaytestControl.tsx +++ b/packages/client/editor/src/DataControls/PlaytestControl.tsx @@ -1,7 +1,7 @@ // DOCUMENTED import { useState } from 'react' -import { Switch } from '@magickml/client-core' +import { Switch } from 'client/core' /** * A control component for a switch UI element that updates data in the parent component. diff --git a/packages/client/editor/src/DataControls/SingleElement.tsx b/packages/client/editor/src/DataControls/SingleElement.tsx index ce3634ae42..35749ca4f5 100644 --- a/packages/client/editor/src/DataControls/SingleElement.tsx +++ b/packages/client/editor/src/DataControls/SingleElement.tsx @@ -1,6 +1,6 @@ // DOCUMENTED import { GridViewRounded } from '@mui/icons-material' -import { Icon, IconBtn } from '@magickml/client-core' +import { Icon, IconBtn } from 'client/core' import styles from './datacontrols.module.css' /** diff --git a/packages/client/editor/src/DataControls/SpellSelect.tsx b/packages/client/editor/src/DataControls/SpellSelect.tsx index 2a8636a16d..7f74404f09 100644 --- a/packages/client/editor/src/DataControls/SpellSelect.tsx +++ b/packages/client/editor/src/DataControls/SpellSelect.tsx @@ -1,12 +1,12 @@ // DOCUMENTED -import { Select } from '@magickml/client-core' +import { Select } from 'client/core' import { GraphData } from '@magickml/core' -import { getTemplates } from '@magickml/client-core' +import { getTemplates } from 'client/core' import md5 from 'md5' import { useSnackbar } from 'notistack' import { useEffect } from 'react' -import { useConfig } from '@magickml/client-core' +import { useConfig } from 'client/core' import { openTab, spellApi, useAppDispatch } from 'client/state' /** diff --git a/packages/client/editor/src/DataControls/SwitchControl.tsx b/packages/client/editor/src/DataControls/SwitchControl.tsx index 3f95f7d202..583e3682e9 100644 --- a/packages/client/editor/src/DataControls/SwitchControl.tsx +++ b/packages/client/editor/src/DataControls/SwitchControl.tsx @@ -7,7 +7,7 @@ * @param initialValue a boolean that represents the initial value of the switch. */ import { useState } from 'react' -import { Switch } from '@magickml/client-core' +import { Switch } from 'client/core' const SwitchControl = ({ control, updateData, initialValue }) => { // Destructure the dataKey and data properties from the control object. diff --git a/packages/client/editor/src/components/EventHandler.tsx b/packages/client/editor/src/components/EventHandler.tsx index f7a5e16ff7..a259a8e94e 100644 --- a/packages/client/editor/src/components/EventHandler.tsx +++ b/packages/client/editor/src/components/EventHandler.tsx @@ -9,7 +9,7 @@ import { useLayout } from '../contexts/LayoutProvider' import { useEditor } from '../contexts/EditorProvider' import { diff } from '../utils/json0' -import { useConfig, useFeathers } from '@magickml/client-core' +import { useConfig, useFeathers } from 'client/core' import { useLazyGetSpellByIdQuery, useSaveSpellMutation, diff --git a/packages/client/editor/src/components/FileInput.tsx b/packages/client/editor/src/components/FileInput.tsx index 94ffb25d29..cf4268fab7 100644 --- a/packages/client/editor/src/components/FileInput.tsx +++ b/packages/client/editor/src/components/FileInput.tsx @@ -1,5 +1,5 @@ // DOCUMENTED -import { Button } from '@magickml/client-core' +import { Button } from 'client/core' import React from 'react' /** diff --git a/packages/client/editor/src/components/MenuBar/OldMenuBar/index.tsx b/packages/client/editor/src/components/MenuBar/OldMenuBar/index.tsx index 367d8638d1..e7ab420dbf 100644 --- a/packages/client/editor/src/components/MenuBar/OldMenuBar/index.tsx +++ b/packages/client/editor/src/components/MenuBar/OldMenuBar/index.tsx @@ -1,5 +1,5 @@ // DOCUMENTED -import { useProjectWindow, usePubSub } from '@magickml/client-core' +import { useProjectWindow, usePubSub } from 'client/core' import { useEffect, useRef, useState } from 'react' import { useHotkeys } from 'react-hotkeys-hook' import { useDispatch, useSelector } from 'react-redux' diff --git a/packages/client/editor/src/components/MenuBar/newMenuBar/index.tsx b/packages/client/editor/src/components/MenuBar/newMenuBar/index.tsx index 5113214c27..9b4423b3a1 100644 --- a/packages/client/editor/src/components/MenuBar/newMenuBar/index.tsx +++ b/packages/client/editor/src/components/MenuBar/newMenuBar/index.tsx @@ -1,5 +1,5 @@ // DOCUMENTED -import { useProjectWindow, usePubSub } from '@magickml/client-core' +import { useProjectWindow, usePubSub } from 'client/core' import { useEffect, useRef, useState } from 'react' import { useHotkeys } from 'react-hotkeys-hook' import { useDispatch, useSelector } from 'react-redux' diff --git a/packages/client/editor/src/components/Modal/Modal.tsx b/packages/client/editor/src/components/Modal/Modal.tsx index e46357a6bb..61d470dfa8 100644 --- a/packages/client/editor/src/components/Modal/Modal.tsx +++ b/packages/client/editor/src/components/Modal/Modal.tsx @@ -9,8 +9,8 @@ */ import React from 'react' import { useModal } from '../../contexts/ModalProvider' -import { Button } from '@magickml/client-core' -import { Icon } from '@magickml/client-core' +import { Button } from 'client/core' +import { Icon } from 'client/core' import css from './modal.module.css' import { useHotkeys } from 'react-hotkeys-hook' diff --git a/packages/client/editor/src/components/Modals/SaveAsModal.tsx b/packages/client/editor/src/components/Modals/SaveAsModal.tsx index ad56e01319..0a730329ae 100644 --- a/packages/client/editor/src/components/Modals/SaveAsModal.tsx +++ b/packages/client/editor/src/components/Modals/SaveAsModal.tsx @@ -5,8 +5,8 @@ import { useForm } from 'react-hook-form' import Modal from '../Modal/Modal' import css from './modalForms.module.css' import { useNavigate } from 'react-router' -import { getTemplates } from '@magickml/client-core' -import { useConfig } from '@magickml/client-core' +import { getTemplates } from 'client/core' +import { useConfig } from 'client/core' import md5 from 'md5' import { v4 as uuidv4 } from 'uuid' import { spellApi } from 'client/state' diff --git a/packages/client/editor/src/components/Node/Node.tsx b/packages/client/editor/src/components/Node/Node.tsx index eaf67a9335..1f3d320765 100644 --- a/packages/client/editor/src/components/Node/Node.tsx +++ b/packages/client/editor/src/components/Node/Node.tsx @@ -4,7 +4,7 @@ import { Socket } from '../../plugins/reactRenderPlugin/Socket' import { Control } from '../../plugins/reactRenderPlugin/Control' import { Upload } from '../../plugins/reactRenderPlugin/Upload' import { Tooltip } from '@mui/material' -import { Icon, componentCategories } from '@magickml/client-core' +import { Icon, componentCategories } from 'client/core' import css from './Node.module.css' import { styled } from '@mui/material/styles' diff --git a/packages/client/editor/src/components/ProjectRow.tsx b/packages/client/editor/src/components/ProjectRow.tsx index a595f39217..78e02693a5 100644 --- a/packages/client/editor/src/components/ProjectRow.tsx +++ b/packages/client/editor/src/components/ProjectRow.tsx @@ -1,7 +1,7 @@ // DOCUMENTED import { SpellInterface } from '@magickml/core' import { CSSProperties, useState } from 'react' -import { Icon, Modal } from '@magickml/client-core' +import { Icon, Modal } from 'client/core' import css from '../screens/HomeScreen/homeScreen.module.css' /** diff --git a/packages/client/editor/src/components/TabBar/TabBar.tsx b/packages/client/editor/src/components/TabBar/TabBar.tsx index 81303cc5db..cbc8e2dd11 100644 --- a/packages/client/editor/src/components/TabBar/TabBar.tsx +++ b/packages/client/editor/src/components/TabBar/TabBar.tsx @@ -7,7 +7,7 @@ import { useNavigate } from 'react-router-dom' import MenuBar from '../MenuBar/MenuBar' import CreateTab from './CreateTab' import css from './tabBar.module.css' -import { Icon } from '@magickml/client-core' +import { Icon } from 'client/core' import { RootState, changeActive, closeTab, selectAllTabs } from 'client/state' /** diff --git a/packages/client/editor/src/components/TemplatePanel.tsx b/packages/client/editor/src/components/TemplatePanel.tsx index 30d5db0051..4cea72468e 100644 --- a/packages/client/editor/src/components/TemplatePanel.tsx +++ b/packages/client/editor/src/components/TemplatePanel.tsx @@ -1,5 +1,5 @@ // DOCUMENTED -import { Panel } from '@magickml/client-core' +import { Panel } from 'client/core' import css from '../screens/HomeScreen/homeScreen.module.css' /** diff --git a/packages/client/editor/src/components/VideoInput.tsx b/packages/client/editor/src/components/VideoInput.tsx index b0dfc10076..084727d02a 100644 --- a/packages/client/editor/src/components/VideoInput.tsx +++ b/packages/client/editor/src/components/VideoInput.tsx @@ -3,7 +3,7 @@ * A React component that allows the user to import a video file. */ import React from 'react' -import { Icon } from '@magickml/client-core' +import { Icon } from 'client/core' interface Props { /** diff --git a/packages/client/editor/src/components/Workspace.tsx b/packages/client/editor/src/components/Workspace.tsx index 8de227eee4..92381f196b 100644 --- a/packages/client/editor/src/components/Workspace.tsx +++ b/packages/client/editor/src/components/Workspace.tsx @@ -4,7 +4,7 @@ import { useSelector } from 'react-redux' import { SpellInterface } from '@magickml/core' -import { useConfig, useFeathers, usePubSub } from '@magickml/client-core' +import { useConfig, useFeathers, usePubSub } from 'client/core' import { useEditor } from '../contexts/EditorProvider' import { Layout } from '../contexts/LayoutProvider' import { debounce } from '../utils/debounce' diff --git a/packages/client/editor/src/contexts/AppProviders.tsx b/packages/client/editor/src/contexts/AppProviders.tsx index 78d74379a6..c702430e15 100644 --- a/packages/client/editor/src/contexts/AppProviders.tsx +++ b/packages/client/editor/src/contexts/AppProviders.tsx @@ -1,9 +1,5 @@ // DOCUMENTED -import { - ConfigProvider, - FeathersProvider, - PubSubProvider, -} from '@magickml/client-core' +import { ConfigProvider, FeathersProvider, PubSubProvider } from 'client/core' import { createTheme, ThemeProvider } from '@mui/material' import React from 'react' import ToastProvider from './ToastProvider' diff --git a/packages/client/editor/src/contexts/EditorProvider.tsx b/packages/client/editor/src/contexts/EditorProvider.tsx index ad57e6e268..562e825285 100644 --- a/packages/client/editor/src/contexts/EditorProvider.tsx +++ b/packages/client/editor/src/contexts/EditorProvider.tsx @@ -1,5 +1,5 @@ // DOCUMENTED -import { LoadingScreen, useFeathers } from '@magickml/client-core' +import { LoadingScreen, useFeathers } from 'client/core' import { EditorContext, GraphData, @@ -15,7 +15,7 @@ import React, { } from 'react' import { useSelector } from 'react-redux' -import { useConfig, usePubSub } from '@magickml/client-core' +import { useConfig, usePubSub } from 'client/core' import { MyNode } from '../components/Node/Node' import { initEditor } from '../editor' import { zoomAt } from '../plugins/areaPlugin/zoom-at' diff --git a/packages/client/editor/src/contexts/InspectorProvider.tsx b/packages/client/editor/src/contexts/InspectorProvider.tsx index fc8fc7d7e3..78a30fecc3 100644 --- a/packages/client/editor/src/contexts/InspectorProvider.tsx +++ b/packages/client/editor/src/contexts/InspectorProvider.tsx @@ -1,5 +1,5 @@ // DOCUMENTED -import { usePubSub } from '@magickml/client-core' +import { usePubSub } from 'client/core' import { InspectorData, SupportedLanguages } from '@magickml/core' import { createContext, useContext, useEffect, useState } from 'react' diff --git a/packages/client/editor/src/contexts/LayoutProvider.tsx b/packages/client/editor/src/contexts/LayoutProvider.tsx index d905eec8c8..bae5b3b153 100644 --- a/packages/client/editor/src/contexts/LayoutProvider.tsx +++ b/packages/client/editor/src/contexts/LayoutProvider.tsx @@ -1,5 +1,5 @@ // DOCUMENTED -import { LoadingScreen } from '@magickml/client-core' +import { LoadingScreen } from 'client/core' import { activeTabSelector, saveTabLayout } from 'client/state' import { Actions, diff --git a/packages/client/editor/src/contexts/MagickInterfaceProvider.tsx b/packages/client/editor/src/contexts/MagickInterfaceProvider.tsx index af28d2913b..80431a3705 100644 --- a/packages/client/editor/src/contexts/MagickInterfaceProvider.tsx +++ b/packages/client/editor/src/contexts/MagickInterfaceProvider.tsx @@ -1,5 +1,5 @@ // DOCUMENTED -import { useConfig, usePubSub } from '@magickml/client-core' +import { useConfig, usePubSub } from 'client/core' import { EditorContext, GetSpell, diff --git a/packages/client/editor/src/contexts/TabProvider.tsx b/packages/client/editor/src/contexts/TabProvider.tsx index 351925fdab..1c558e01a7 100644 --- a/packages/client/editor/src/contexts/TabProvider.tsx +++ b/packages/client/editor/src/contexts/TabProvider.tsx @@ -6,7 +6,7 @@ import { IDockviewPanelProps, SerializedDockview, } from 'dockview' -import { usePubSub } from '@magickml/client-core' +import { usePubSub } from 'client/core' import { getWorkspaceLayout } from 'client/layouts' type DockviewTheme = 'dockview-theme-abyss' diff --git a/packages/client/editor/src/layouts/MainLayout/MainLayout.tsx b/packages/client/editor/src/layouts/MainLayout/MainLayout.tsx index 39d7b98d8f..10e506b6c3 100644 --- a/packages/client/editor/src/layouts/MainLayout/MainLayout.tsx +++ b/packages/client/editor/src/layouts/MainLayout/MainLayout.tsx @@ -5,7 +5,7 @@ */ import { Outlet } from 'react-router-dom' import ModalProvider from '../../contexts/ModalProvider' -import { DrawerProvider, TreeDataProvider } from '@magickml/client-core' +import { DrawerProvider, TreeDataProvider } from 'client/core' /** * Main layout component. diff --git a/packages/client/editor/src/main.tsx b/packages/client/editor/src/main.tsx index f345880570..0bcb23d9eb 100644 --- a/packages/client/editor/src/main.tsx +++ b/packages/client/editor/src/main.tsx @@ -18,7 +18,7 @@ import AppProviders from './contexts/AppProviders' import { LocalizationProvider } from '@mui/x-date-pickers' import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs' -import { AppConfig } from '@magickml/client-core' +import { AppConfig } from 'client/core' import { MagickmlChatbox } from 'client/magickml-chatbox' import { createStore } from 'client/state' diff --git a/packages/client/editor/src/plugins/areaPlugin/snap.ts b/packages/client/editor/src/plugins/areaPlugin/snap.ts index f30d062729..f5ef27315b 100644 --- a/packages/client/editor/src/plugins/areaPlugin/snap.ts +++ b/packages/client/editor/src/plugins/areaPlugin/snap.ts @@ -1,4 +1,4 @@ -import { PubSub, events } from '@magickml/client-core' +import { PubSub, events } from 'client/core' import { MagickEditor } from '@magickml/core' export class SnapGrid { diff --git a/packages/client/editor/src/screens/Composer/index.tsx b/packages/client/editor/src/screens/Composer/index.tsx index 39686c8eec..709d46ce2e 100644 --- a/packages/client/editor/src/screens/Composer/index.tsx +++ b/packages/client/editor/src/screens/Composer/index.tsx @@ -4,7 +4,7 @@ import { useSelector } from 'react-redux' import { SpellInterface } from '@magickml/core' -import { useConfig, useFeathers, usePubSub } from '@magickml/client-core' +import { useConfig, useFeathers, usePubSub } from 'client/core' import { useEditor } from '../../contexts/EditorProvider' import { Layout } from '../../contexts/LayoutProvider' import { debounce } from '../../utils/debounce' diff --git a/packages/client/editor/src/screens/DocumentWindow/DocContentModal.tsx b/packages/client/editor/src/screens/DocumentWindow/DocContentModal.tsx index dea6e1c920..228cfc270c 100644 --- a/packages/client/editor/src/screens/DocumentWindow/DocContentModal.tsx +++ b/packages/client/editor/src/screens/DocumentWindow/DocContentModal.tsx @@ -1,4 +1,4 @@ -import { Modal, useTreeData } from '@magickml/client-core' +import { Modal, useTreeData } from 'client/core' import { Typography } from '@mui/material' import styles from './index.module.scss' diff --git a/packages/client/editor/src/screens/DocumentWindow/DocumentModal.tsx b/packages/client/editor/src/screens/DocumentWindow/DocumentModal.tsx index f01f0308df..7c06b36174 100644 --- a/packages/client/editor/src/screens/DocumentWindow/DocumentModal.tsx +++ b/packages/client/editor/src/screens/DocumentWindow/DocumentModal.tsx @@ -1,4 +1,4 @@ -import { Modal } from '@magickml/client-core' +import { Modal } from 'client/core' import { Backdrop, Button, diff --git a/packages/client/editor/src/screens/DocumentWindow/DocumentTable.tsx b/packages/client/editor/src/screens/DocumentWindow/DocumentTable.tsx index 34f60fecbf..f64c903fdf 100644 --- a/packages/client/editor/src/screens/DocumentWindow/DocumentTable.tsx +++ b/packages/client/editor/src/screens/DocumentWindow/DocumentTable.tsx @@ -1,6 +1,6 @@ // DOCUMENTED // Import statements kept as-is -import { TableComponent } from '@magickml/client-core' +import { TableComponent } from 'client/core' import { CompletionProvider, pluginManager } from '@magickml/core' import { API_ROOT_URL } from 'shared/config' import { MoreHoriz, NewReleases, Refresh } from '@mui/icons-material' @@ -14,7 +14,7 @@ import { Typography, } from '@mui/material' import { useSnackbar } from 'notistack' -import { useConfig } from '@magickml/client-core' +import { useConfig } from 'client/core' import { useEffect, useMemo, useState } from 'react' import { CSVLink } from 'react-csv' import { FaFileCsv } from 'react-icons/fa' diff --git a/packages/client/editor/src/screens/DocumentWindow/index.tsx b/packages/client/editor/src/screens/DocumentWindow/index.tsx index b7d9e36884..6c2a6d6ee3 100644 --- a/packages/client/editor/src/screens/DocumentWindow/index.tsx +++ b/packages/client/editor/src/screens/DocumentWindow/index.tsx @@ -2,7 +2,7 @@ import { API_ROOT_URL } from 'shared/config' import { useEffect, useState } from 'react' import { useSelector } from 'react-redux' -import { LoadingScreen, useConfig } from '@magickml/client-core' +import { LoadingScreen, useConfig } from 'client/core' import DocumentTable from './DocumentTable' /** diff --git a/packages/client/editor/src/screens/EventWindow/EventTable.tsx b/packages/client/editor/src/screens/EventWindow/EventTable.tsx index 3c9bf77639..b580b3c424 100644 --- a/packages/client/editor/src/screens/EventWindow/EventTable.tsx +++ b/packages/client/editor/src/screens/EventWindow/EventTable.tsx @@ -1,8 +1,8 @@ // DOCUMENTED // Import statements kept as-is -import { TableComponent } from '@magickml/client-core' +import { TableComponent } from 'client/core' import { API_ROOT_URL } from 'shared/config' -import { useFeathers } from '@magickml/client-core' +import { useFeathers } from 'client/core' import { Delete, MoreHoriz, Refresh } from '@mui/icons-material' import { Button, diff --git a/packages/client/editor/src/screens/EventWindow/index.tsx b/packages/client/editor/src/screens/EventWindow/index.tsx index a0c871753b..12057fa3ff 100644 --- a/packages/client/editor/src/screens/EventWindow/index.tsx +++ b/packages/client/editor/src/screens/EventWindow/index.tsx @@ -2,7 +2,7 @@ import { API_ROOT_URL } from 'shared/config' import { useEffect, useState } from 'react' import { useSelector } from 'react-redux' -import { LoadingScreen, useConfig } from '@magickml/client-core' +import { LoadingScreen, useConfig } from 'client/core' import EventTable from './EventTable' /** diff --git a/packages/client/editor/src/screens/HomeScreen/AllProjects.tsx b/packages/client/editor/src/screens/HomeScreen/AllProjects.tsx index 704483667d..3bace46529 100644 --- a/packages/client/editor/src/screens/HomeScreen/AllProjects.tsx +++ b/packages/client/editor/src/screens/HomeScreen/AllProjects.tsx @@ -1,6 +1,6 @@ // DOCUMENTED import React, { useEffect, useState } from 'react' -import { Button, Icon, Panel } from '@magickml/client-core' +import { Button, Icon, Panel } from 'client/core' import { Scrollbars } from 'react-custom-scrollbars-2' import FileInput from '../../components/FileInput' import ProjectRow from '../../components/ProjectRow' diff --git a/packages/client/editor/src/screens/HomeScreen/CreateNew.tsx b/packages/client/editor/src/screens/HomeScreen/CreateNew.tsx index 6be1992b78..549e550686 100644 --- a/packages/client/editor/src/screens/HomeScreen/CreateNew.tsx +++ b/packages/client/editor/src/screens/HomeScreen/CreateNew.tsx @@ -1,7 +1,7 @@ // DOCUMENTED -import { Button, Panel } from '@magickml/client-core' +import { Button, Panel } from 'client/core' import { GraphData } from '@magickml/core' -import { getTemplates } from '@magickml/client-core' +import { getTemplates } from 'client/core' import md5 from 'md5' import { useSnackbar } from 'notistack' import { useState } from 'react' @@ -13,7 +13,7 @@ import { uniqueNamesGenerator, } from 'unique-names-generator' import TemplatePanel from '../../components/TemplatePanel' -import { useConfig } from '@magickml/client-core' +import { useConfig } from 'client/core' import LoadingButton from '@mui/lab/LoadingButton' import emptyImg from './empty.png' import css from './homeScreen.module.css' diff --git a/packages/client/editor/src/screens/HomeScreen/HomeScreen.tsx b/packages/client/editor/src/screens/HomeScreen/HomeScreen.tsx index 17de529c3f..054c56798d 100644 --- a/packages/client/editor/src/screens/HomeScreen/HomeScreen.tsx +++ b/packages/client/editor/src/screens/HomeScreen/HomeScreen.tsx @@ -1,9 +1,9 @@ // DOCUMENTED -import { LoadingScreen } from '@magickml/client-core' +import { LoadingScreen } from 'client/core' import { useState } from 'react' import { useDispatch, useSelector } from 'react-redux' import { Route, Routes, useNavigate } from 'react-router-dom' -import { useConfig } from '@magickml/client-core' +import { useConfig } from 'client/core' import AllProjects from './AllProjects' import CreateNew from './CreateNew' import css from './homeScreen.module.css' diff --git a/packages/client/editor/src/screens/HomeScreen/OpenProject.tsx b/packages/client/editor/src/screens/HomeScreen/OpenProject.tsx index 04cc98c914..515080b3f9 100644 --- a/packages/client/editor/src/screens/HomeScreen/OpenProject.tsx +++ b/packages/client/editor/src/screens/HomeScreen/OpenProject.tsx @@ -1,5 +1,5 @@ // DOCUMENTED -import { Button, Icon, Panel } from '@magickml/client-core' +import { Button, Icon, Panel } from 'client/core' import { useSelector } from 'react-redux' import { useNavigate } from 'react-router-dom' diff --git a/packages/client/editor/src/screens/Magick/Magick.tsx b/packages/client/editor/src/screens/Magick/Magick.tsx index 54d38ece49..da62318df1 100644 --- a/packages/client/editor/src/screens/Magick/Magick.tsx +++ b/packages/client/editor/src/screens/Magick/Magick.tsx @@ -1,5 +1,5 @@ // DOCUMENTED -import { LoadingScreen, TabLayout, usePubSub } from '@magickml/client-core' +import { LoadingScreen, TabLayout, usePubSub } from 'client/core' import { useEffect } from 'react' import { useDispatch, useSelector } from 'react-redux' import { useNavigate } from 'react-router-dom' diff --git a/packages/client/editor/src/screens/MagickV2/panels/fileDrawer.tsx b/packages/client/editor/src/screens/MagickV2/panels/fileDrawer.tsx index 1912b9aefa..1bca021cfb 100644 --- a/packages/client/editor/src/screens/MagickV2/panels/fileDrawer.tsx +++ b/packages/client/editor/src/screens/MagickV2/panels/fileDrawer.tsx @@ -1,4 +1,4 @@ -import { NewSidebar, TreeDataProvider, usePubSub } from '@magickml/client-core' +import { NewSidebar, TreeDataProvider, usePubSub } from 'client/core' import { IGridviewPanelProps } from 'dockview' import { useEffect, useState } from 'react' import { useHotkeys } from 'react-hotkeys-hook' diff --git a/packages/client/editor/src/screens/MagickV2/workspaces/composer.tsx b/packages/client/editor/src/screens/MagickV2/workspaces/composer.tsx index 0957326863..7320ec38c0 100644 --- a/packages/client/editor/src/screens/MagickV2/workspaces/composer.tsx +++ b/packages/client/editor/src/screens/MagickV2/workspaces/composer.tsx @@ -1,4 +1,4 @@ -import { useConfig, useFeathers, usePubSub } from '@magickml/client-core' +import { useConfig, useFeathers, usePubSub } from 'client/core' import { DockviewApi, DockviewReact, diff --git a/packages/client/editor/src/screens/RequestWindow/RequestTable.tsx b/packages/client/editor/src/screens/RequestWindow/RequestTable.tsx index 0218674f36..6ec6333bc6 100644 --- a/packages/client/editor/src/screens/RequestWindow/RequestTable.tsx +++ b/packages/client/editor/src/screens/RequestWindow/RequestTable.tsx @@ -22,7 +22,7 @@ import { import { useSelector } from 'react-redux' import styles from './index.module.scss' import { Delete, Refresh, MoreHoriz } from '@mui/icons-material' -import { TableComponent, useFeathers } from '@magickml/client-core' +import { TableComponent, useFeathers } from 'client/core' import { DocumentData, columns } from './requests' import { useSnackbar } from 'notistack' diff --git a/packages/client/editor/src/screens/RequestWindow/index.tsx b/packages/client/editor/src/screens/RequestWindow/index.tsx index 0959051940..17dabb0d9e 100644 --- a/packages/client/editor/src/screens/RequestWindow/index.tsx +++ b/packages/client/editor/src/screens/RequestWindow/index.tsx @@ -9,7 +9,7 @@ import { useEffect, useState } from 'react' import RequestTable from './RequestTable' import { API_ROOT_URL } from 'shared/config' -import { LoadingScreen, useConfig } from '@magickml/client-core' +import { LoadingScreen, useConfig } from 'client/core' import { useSelector } from 'react-redux' /** diff --git a/packages/client/editor/src/screens/agents/AgentManagerWindow.tsx b/packages/client/editor/src/screens/agents/AgentManagerWindow.tsx index 3955929344..0ff09e903e 100644 --- a/packages/client/editor/src/screens/agents/AgentManagerWindow.tsx +++ b/packages/client/editor/src/screens/agents/AgentManagerWindow.tsx @@ -1,11 +1,11 @@ // DOCUMENTED -import { LoadingScreen } from '@magickml/client-core' +import { LoadingScreen } from 'client/core' import { type ClientPluginManager, pluginManager } from '@magickml/core' import { DEFAULT_USER_TOKEN, PRODUCTION, STANDALONE } from 'shared/config' import { useSnackbar } from 'notistack' import { useEffect, useState } from 'react' import { useSelector } from 'react-redux' -import { useConfig } from '@magickml/client-core' +import { useConfig } from 'client/core' import AgentWindow from './AgentWindow' import validateSpellData from './AgentWindow/spellValidator' import { useTreeData } from '../../../../core/client/src/contexts/TreeDataProvider' diff --git a/packages/client/editor/src/screens/agents/AgentWindow/AgentDetails.tsx b/packages/client/editor/src/screens/agents/AgentWindow/AgentDetails.tsx index 666c1a4ea9..edcff93469 100644 --- a/packages/client/editor/src/screens/agents/AgentWindow/AgentDetails.tsx +++ b/packages/client/editor/src/screens/agents/AgentWindow/AgentDetails.tsx @@ -1,5 +1,5 @@ // DOCUMENTED -import { IconBtn, CustomizedSwitch, useFeathers } from '@magickml/client-core' +import { IconBtn, CustomizedSwitch, useFeathers } from 'client/core' import { ClientPluginManager, pluginManager } from '@magickml/core' import { Close, Done, Edit } from '@mui/icons-material' @@ -7,7 +7,7 @@ import { Avatar, Button, Input, Typography, Tooltip } from '@mui/material' import { enqueueSnackbar } from 'notistack' import { useEffect, useState } from 'react' import { useSelector } from 'react-redux' -import { useConfig } from '@magickml/client-core' +import { useConfig } from 'client/core' import AgentPubVariables from './AgentPubVariables' import styles from './index.module.scss' import { tooltip_text } from './tooltip_texts' diff --git a/packages/client/editor/src/screens/agents/AgentWindow/AgentItem.tsx b/packages/client/editor/src/screens/agents/AgentWindow/AgentItem.tsx index ebd222fbc5..cffe6cbda0 100644 --- a/packages/client/editor/src/screens/agents/AgentWindow/AgentItem.tsx +++ b/packages/client/editor/src/screens/agents/AgentWindow/AgentItem.tsx @@ -1,6 +1,6 @@ -import { Icon, IconBtn } from '@magickml/client-core' +import { Icon, IconBtn } from 'client/core' import { Avatar, Typography } from '@mui/material' -import { Modal } from '@magickml/client-core' +import { Modal } from 'client/core' import styles from './index.module.scss' import { useState } from 'react' diff --git a/packages/client/editor/src/screens/agents/AgentWindow/AgentPubVariables.tsx b/packages/client/editor/src/screens/agents/AgentWindow/AgentPubVariables.tsx index ed431ef4d6..a57f2eb888 100644 --- a/packages/client/editor/src/screens/agents/AgentWindow/AgentPubVariables.tsx +++ b/packages/client/editor/src/screens/agents/AgentWindow/AgentPubVariables.tsx @@ -1,7 +1,7 @@ // DOCUMENTED import { Grid } from '@mui/material' import styles from '../AgentWindowStyle.module.css' -import { Input, Switch } from '@magickml/client-core' +import { Input, Switch } from 'client/core' /** * Interface for Props. diff --git a/packages/client/editor/src/screens/agents/AgentWindow/index.tsx b/packages/client/editor/src/screens/agents/AgentWindow/index.tsx index 1b9b10496d..396551c3ab 100644 --- a/packages/client/editor/src/screens/agents/AgentWindow/index.tsx +++ b/packages/client/editor/src/screens/agents/AgentWindow/index.tsx @@ -5,7 +5,7 @@ import styles from './index.module.scss' import AgentDetails from './AgentDetails' import FileInput from '../../../components/FileInput' import { useEffect } from 'react' -import { useConfig } from '@magickml/client-core' +import { useConfig } from 'client/core' /** * Props for AgentWindow component diff --git a/packages/client/editor/src/screens/settings/SettingsWindow.tsx b/packages/client/editor/src/screens/settings/SettingsWindow.tsx index 5ac24714a2..a449647ccb 100644 --- a/packages/client/editor/src/screens/settings/SettingsWindow.tsx +++ b/packages/client/editor/src/screens/settings/SettingsWindow.tsx @@ -1,4 +1,4 @@ -import { Tooltip } from '@magickml/client-core' +import { Tooltip } from 'client/core' import { pluginManager } from '@magickml/core' import { Clear } from '@mui/icons-material/' import { IconButton, Input, Button } from '@mui/material' diff --git a/packages/client/editor/src/windows/AgentControlWindow.tsx b/packages/client/editor/src/windows/AgentControlWindow.tsx index 05d44f69de..4864655a4a 100644 --- a/packages/client/editor/src/windows/AgentControlWindow.tsx +++ b/packages/client/editor/src/windows/AgentControlWindow.tsx @@ -1,5 +1,5 @@ // DOCUMENTED -import { Window } from '@magickml/client-core' +import { Window } from 'client/core' /** * The Inspector component displays the selected component's data in a window with controls for modifying the data. diff --git a/packages/client/editor/src/windows/DebugConsole/index.tsx b/packages/client/editor/src/windows/DebugConsole/index.tsx index 038055c4e1..07bc936736 100644 --- a/packages/client/editor/src/windows/DebugConsole/index.tsx +++ b/packages/client/editor/src/windows/DebugConsole/index.tsx @@ -1,5 +1,5 @@ // DOCUMENTED -import { Window, usePubSub } from '@magickml/client-core' +import { Window, usePubSub } from 'client/core' import { useCallback, useEffect, useRef, useState } from 'react' import Terminal from 'react-console-emulator' import ReactJson from 'react-json-view' diff --git a/packages/client/editor/src/windows/InspectorWindow.tsx b/packages/client/editor/src/windows/InspectorWindow.tsx index 1508ab2ecb..926138a997 100644 --- a/packages/client/editor/src/windows/InspectorWindow.tsx +++ b/packages/client/editor/src/windows/InspectorWindow.tsx @@ -1,10 +1,5 @@ // DOCUMENTED -import { - componentCategories, - Icon, - Tooltip, - Window, -} from '@magickml/client-core' +import { componentCategories, Icon, Tooltip, Window } from 'client/core' import { Help } from '@mui/icons-material' import { IconButton } from '@mui/material' import { useEffect, useState } from 'react' diff --git a/packages/client/editor/src/windows/PlaytestWindow.tsx b/packages/client/editor/src/windows/PlaytestWindow.tsx index ead27dd9c0..0afb930acc 100644 --- a/packages/client/editor/src/windows/PlaytestWindow.tsx +++ b/packages/client/editor/src/windows/PlaytestWindow.tsx @@ -1,5 +1,5 @@ // DOCUMENTED -import { Button, Select, Window, useConfig } from '@magickml/client-core' +import { Button, Select, Window, useConfig } from 'client/core' import Editor from '@monaco-editor/react' import { useSnackbar } from 'notistack' import React, { useCallback, useEffect, useRef, useState } from 'react' @@ -8,7 +8,7 @@ import { useHotkeys } from 'react-hotkeys-hook' import { useDispatch, useSelector } from 'react-redux' import { useEditor } from '../contexts/EditorProvider' import { useInspector } from '../contexts/InspectorProvider' -import { usePubSub } from '@magickml/client-core' +import { usePubSub } from 'client/core' import css from '../screens/Magick/magick.module.css' import { RootState, diff --git a/packages/client/editor/src/windows/TextEditorWindow/index.tsx b/packages/client/editor/src/windows/TextEditorWindow/index.tsx index 3b8b63d07a..0031567671 100644 --- a/packages/client/editor/src/windows/TextEditorWindow/index.tsx +++ b/packages/client/editor/src/windows/TextEditorWindow/index.tsx @@ -1,4 +1,4 @@ -import { Button, Window } from '@magickml/client-core' +import { Button, Window } from 'client/core' import Editor from '@monaco-editor/react' import { useEffect, useRef, useState } from 'react' import '../../screens/Magick/magick.module.css' diff --git a/packages/core/client/package.json b/packages/core/client/package.json deleted file mode 100644 index cb83f178ff..0000000000 --- a/packages/core/client/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "@magickml/client-core", - "version": "0.1.0" -} diff --git a/packages/core/client/src/components/Chip/chip.module.css.d.ts b/packages/core/client/src/components/Chip/chip.module.css.d.ts deleted file mode 100644 index b1a142d54d..0000000000 --- a/packages/core/client/src/components/Chip/chip.module.css.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file is automatically generated. -// Please do not change this file! -interface CssExports { - 'chip': string; - 'no-events': string; -} -export const cssExports: CssExports; -export default cssExports; diff --git a/packages/core/client/src/components/Drawer/TypeIcon.tsx b/packages/core/client/src/components/Drawer/TypeIcon.tsx deleted file mode 100644 index bf938c2de3..0000000000 --- a/packages/core/client/src/components/Drawer/TypeIcon.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import React from "react"; -import FolderOpenOutlinedIcon from '@mui/icons-material/FolderOpenOutlined'; -import DescriptionOutlinedIcon from '@mui/icons-material/DescriptionOutlined'; -import StarBorderPurple500OutlinedIcon from '@mui/icons-material/StarBorderPurple500Outlined'; -import HistoryEduOutlinedIcon from '@mui/icons-material/HistoryEduOutlined'; - -type Props = { - droppable: boolean; - fileType?: string; -}; - -export const TypeIcon: React.FC = (props) => { - if (props.droppable) { - return ; - } - - switch (props.fileType) { - case "txt": - return ; - case "prompt": - return ; - case "spell": - return ; - default: - return null; - } -}; \ No newline at end of file diff --git a/packages/core/client/src/components/Icon/icon.module.css.d.ts b/packages/core/client/src/components/Icon/icon.module.css.d.ts deleted file mode 100644 index d966413260..0000000000 --- a/packages/core/client/src/components/Icon/icon.module.css.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -// This file is automatically generated. -// Please do not change this file! -interface CssExports { - 'account': string; - 'add': string; - 'ankh': string; - 'bird': string; - 'close': string; - 'cloth': string; - 'cup': string; - 'feathers': string; - 'fewshot': string; - 'folder': string; - 'hand': string; - 'icon': string; - 'info': string; - 'merge': string; - 'minus': string; - 'moon': string; - 'newnode': string; - 'node-lock': string; - 'pause': string; - 'person': string; - 'play': string; - 'play-print': string; - 'properties': string; - 'refresh': string; - 'search': string; - 'seive': string; - 'snake': string; - 'state': string; - 'state-read': string; - 'state-write': string; - 'stop': string; - 'stop-sign': string; - 'switch': string; - 'temperature': string; - 'text': string; - 'tiles': string; - 'time': string; - 'trash': string; - 'warn': string; - 'water': string; - 'water-play': string; - 'water-run': string; -} -export const cssExports: CssExports; -export default cssExports; diff --git a/packages/core/client/src/components/IconButton/index.tsx b/packages/core/client/src/components/IconButton/index.tsx deleted file mode 100644 index 5903bd215a..0000000000 --- a/packages/core/client/src/components/IconButton/index.tsx +++ /dev/null @@ -1,35 +0,0 @@ -// DOCUMENTED -import * as React from 'react'; -import IconButton from '@mui/material/IconButton'; - -/** - * Props interface for IconBtn component. - */ -interface Props { - Icon: React.ReactNode; // Icon component to be rendered - label: string; // Aria-label for the IconButton - onClick?: (e) => void; // Optional onClick handler - style?: React.CSSProperties; // Optional custom styles -} - -/** - * IconBtn component - IconButton with custom Icon and label. - * - * @param {Props} props - IconBtn component properties - * @returns {React.ReactElement} - Rendered IconBtn component - */ -export const IconBtn: React.FunctionComponent = (props: Props): JSX.Element => { - const { Icon, label, onClick, style } = props; - - return ( - - {Icon} - - ); -}; diff --git a/packages/core/client/src/components/Panel/panel.module.css.d.ts b/packages/core/client/src/components/Panel/panel.module.css.d.ts deleted file mode 100644 index 6055242223..0000000000 --- a/packages/core/client/src/components/Panel/panel.module.css.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file is automatically generated. -// Please do not change this file! -interface CssExports { - 'panel': string; - 'round': string; - 'rounder': string; - 'roundest': string; - 'shadow': string; - 'square': string; - 'unpadded': string; -} -export const cssExports: CssExports; -export default cssExports; diff --git a/packages/core/client/src/components/Select/select.module.css.d.ts b/packages/core/client/src/components/Select/select.module.css.d.ts deleted file mode 100644 index 0deb1775a2..0000000000 --- a/packages/core/client/src/components/Select/select.module.css.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -// This file is automatically generated. -// Please do not change this file! -interface CssExports { - 'dropdown-indicator': string; - 'group-header': string; - 'select-dropdown-container': string; -} -export const cssExports: CssExports; -export default cssExports; diff --git a/packages/core/client/src/components/Window/window.module.css.d.ts b/packages/core/client/src/components/Window/window.module.css.d.ts deleted file mode 100644 index bb79e5f82a..0000000000 --- a/packages/core/client/src/components/Window/window.module.css.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file is automatically generated. -// Please do not change this file! -interface CssExports { - 'bordered': string; - 'darkened': string; - 'darker': string; - 'grid': string; - 'lock-bar': string; - 'unpadded': string; - 'window': string; - 'window-layout': string; - 'window-toolbar': string; -} -export const cssExports: CssExports; -export default cssExports; diff --git a/packages/core/client/src/contexts/data/sampleData.json b/packages/core/client/src/contexts/data/sampleData.json deleted file mode 100644 index 651446836e..0000000000 --- a/packages/core/client/src/contexts/data/sampleData.json +++ /dev/null @@ -1,24 +0,0 @@ -[ - { - "id": 1, - "parent": 0, - "droppable": true, - "text": "Documents" - }, - { - "id": 3, - "parent": 1, - "droppable": true, - "text": "Uploaded Knowledge" - }, - - - { - "id": 6, - "parent": 0, - "droppable": true, - "text": "Spells & Prompts" - } - - ] - \ No newline at end of file diff --git a/packages/core/client/src/templates/spells/Blank.spell.json b/packages/core/client/src/templates/spells/Blank.spell.json deleted file mode 100644 index d7fc77d233..0000000000 --- a/packages/core/client/src/templates/spells/Blank.spell.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "id": "ee0cd8da-85a6-484d-90d4-b85b652d8063", - "name": "Blank", - "projectId": "clmp2r33q0003vyxy4dh2uz8e", - "hash": "c8a6becf74079c8ec523e38a21565171", - "createdAt": "1695319385395", - "updatedAt": "1695319412520", - "graph": { - "id": "demo@0.1.0", - "nodes": { - "524": { - "id": 524, - "data": { - "log": false, - "name": "Input - Default", - "isInput": true, - "inputName": "Default", - "socketKey": "5bd194d8-0cb0-4f2f-aaec-f706e941b300" - }, - "inputs": {}, - "outputs": { - "trigger": { - "connections": [] - }, - "output": { - "connections": [] - } - }, - "position": [ - -206, - -2.5 - ], - "name": "Input" - }, - "525": { - "id": 525, - "data": { - "log": false, - "name": "Output - Default", - "isOutput": true, - "socketKey": "4495a612-83a1-4dc8-8868-baaecd23c6ff", - "sendToPlaytest": true - }, - "inputs": { - "trigger": { - "connections": [] - }, - "input": { - "connections": [] - }, - "event": { - "connections": [] - } - }, - "outputs": { - "trigger": { - "connections": [] - }, - "output": { - "connections": [] - } - }, - "position": [ - 206, - 2.5 - ], - "name": "Output" - } - }, - "comments": [] - } -} \ No newline at end of file diff --git a/packages/core/client/src/templates/spells/Starter.spell.json b/packages/core/client/src/templates/spells/Starter.spell.json deleted file mode 100644 index dcd3061e6b..0000000000 --- a/packages/core/client/src/templates/spells/Starter.spell.json +++ /dev/null @@ -1,256 +0,0 @@ -{ - "id": "30e438fe-8ce3-402f-bcf2-1c433b43a4f4", - "name": "Starter", - "projectId": "clmp2r33q0003vyxy4dh2uz8e", - "hash": "b9d6637c48f4a1edba20427a561a77d5", - "createdAt": "1695319267522", - "updatedAt": "1695319318544", - "graph": { - "id": "demo@0.1.0", - "nodes": { - "518": { - "id": 518, - "data": { - "log": false, - "isInput": true, - "socketKey": "fc6abca2-1806-42c6-a0a9-690df28e3c57", - "name": "Input - Default", - "inputName": "Default" - }, - "inputs": {}, - "outputs": { - "trigger": { - "connections": [ - { - "node": 519, - "input": "trigger", - "data": { - "hello": "hello" - } - } - ] - }, - "output": { - "connections": [ - { - "node": 519, - "input": "event", - "data": { - "hello": "hello" - } - } - ] - } - }, - "position": [ - -499.888916015625, - -26.888902452256943 - ], - "name": "Input" - }, - "519": { - "id": 519, - "data": { - "log": false, - "socketKey": "d13533fc-1926-45f2-a87d-f355662e9f6d" - }, - "inputs": { - "trigger": { - "connections": [ - { - "node": 518, - "output": "trigger", - "data": { - "hello": "hello" - } - } - ] - }, - "event": { - "connections": [ - { - "node": 518, - "output": "output", - "data": { - "hello": "hello" - } - } - ] - } - }, - "outputs": { - "trigger": { - "connections": [ - { - "node": 520, - "input": "trigger", - "data": { - "hello": "hello" - } - } - ] - }, - "agentId": { - "connections": [] - }, - "content": { - "connections": [ - { - "node": 520, - "input": "source", - "data": { - "hello": "hello" - } - } - ] - }, - "client": { - "connections": [] - }, - "channel": { - "connections": [] - }, - "channelType": { - "connections": [] - }, - "connector": { - "connections": [] - }, - "entities": { - "connections": [] - }, - "projectId": { - "connections": [] - }, - "observer": { - "connections": [] - }, - "sender": { - "connections": [] - }, - "embedding": { - "connections": [] - }, - "rawData": { - "connections": [] - } - }, - "position": [ - -188.77780490451389, - -25.777791341145832 - ], - "name": "Event Destructure" - }, - "520": { - "id": 520, - "data": { - "log": false - }, - "inputs": { - "trigger": { - "connections": [ - { - "node": 519, - "output": "trigger", - "data": { - "hello": "hello" - } - } - ] - }, - "source": { - "connections": [ - { - "node": 519, - "output": "content", - "data": { - "hello": "hello" - } - } - ] - } - }, - "outputs": { - "trigger": { - "connections": [ - { - "node": 521, - "input": "trigger", - "data": { - "hello": "hello" - } - } - ] - }, - "output": { - "connections": [ - { - "node": 521, - "input": "input", - "data": { - "hello": "hello" - } - } - ] - } - }, - "position": [ - 104.55552842881946, - -15.777791341145829 - ], - "name": "Echo" - }, - "521": { - "id": 521, - "data": { - "log": false, - "sendToPlaytest": true, - "isOutput": true, - "name": "Output - Default", - "socketKey": "37505ffa-b5d0-4720-9525-6d832bcd160d" - }, - "inputs": { - "trigger": { - "connections": [ - { - "node": 520, - "output": "trigger", - "data": { - "hello": "hello" - } - } - ] - }, - "input": { - "connections": [ - { - "node": 520, - "output": "output", - "data": { - "hello": "hello" - } - } - ] - }, - "event": { - "connections": [] - } - }, - "outputs": { - "trigger": { - "connections": [] - }, - "output": { - "connections": [] - } - }, - "position": [ - 372.33330620659723, - -14.666680230034714 - ], - "name": "Output" - } - }, - "comments": [] - } -} \ No newline at end of file diff --git a/packages/plugins/avatar/client/project.json b/packages/plugins/avatar/client/project.json index eb14be5949..f7d58e8aa2 100644 --- a/packages/plugins/avatar/client/project.json +++ b/packages/plugins/avatar/client/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/avatar/client/src", "projectType": "library", - "implicitDependencies": ["@magickml/core", "@magickml/client-core"], + "implicitDependencies": ["@magickml/core", "client-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/avatar/client/src/components/Chat/ChatBox.tsx b/packages/plugins/avatar/client/src/components/Chat/ChatBox.tsx index b133820cf5..684d9c9dcb 100644 --- a/packages/plugins/avatar/client/src/components/Chat/ChatBox.tsx +++ b/packages/plugins/avatar/client/src/components/Chat/ChatBox.tsx @@ -1,4 +1,4 @@ -import { useConfig, useFeathers } from '@magickml/client-core' +import { useConfig, useFeathers } from 'client/core' import { v4 } from 'uuid' import Mic from '@mui/icons-material/Mic' import MicOff from '@mui/icons-material/MicOff' @@ -11,7 +11,7 @@ import styles from './Chat.module.css' import { useLipSync } from '../../hooks/useLipSync' import { useAgentList } from '../../hooks/useAgentList' import { useZustand } from '../../store/useZustand' -import { usePubSub } from '@magickml/client-core' +import { usePubSub } from 'client/core' import { nullEvent } from 'xstate/lib/actionTypes' const voices = { @@ -53,7 +53,7 @@ export async function pruneMessages(messages) { const sessionId = localStorage.getItem('sessionId') ?? Math.random().toString(36).substring(2, 15) + - Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15) localStorage.setItem('sessionId', sessionId) @@ -66,7 +66,9 @@ const SpeechRecognition = export default function ChatBox() { const [micEnabled, setMicEnabled] = useState(false) - const [speechRecognition, setSpeechRecognition] = useState(null) + const [speechRecognition, setSpeechRecognition] = useState< + typeof SpeechRecognition | null + >(null) const { avatarVrm } = useZustand() const lipSync = useLipSync(avatarVrm) const agentList = useAgentList() @@ -153,7 +155,7 @@ export default function ChatBox() { handleUserChatInput(value) } - const printToConsole = useCallback((text) => { + const printToConsole = useCallback(text => { setWaitingForResponse(false) setMessages(messages => [...messages, name + ': ' + text]) try { @@ -202,13 +204,12 @@ export default function ChatBox() { entities: ['user', 'assistant'], } - const data = { id: 'avatar', - agentName: currentAgent ? currentAgent.name : "lost agent name", + agentName: currentAgent ? currentAgent.name : 'lost agent name', projectId: config.projectId, sessionId, - agentId: currentAgent ? currentAgent.id : "lost agent id", + agentId: currentAgent ? currentAgent.id : 'lost agent id', inputs: { 'Input - Default': toSend, }, @@ -233,7 +234,6 @@ export default function ChatBox() { printToConsole(output) }) - }, [client]) useEffect(() => { @@ -275,7 +275,7 @@ export default function ChatBox() { className={styles.agentSelector} name="agentList" id="agentList" - defaultValue={currentAgent ? currentAgent.name : ""} + defaultValue={currentAgent ? currentAgent.name : ''} onChange={e => { const newAgent = agentList?.find(agent => { if (agent.name === e.target.value) { @@ -313,10 +313,7 @@ export default function ChatBox() { ))}
- + {/* Disabled until state error is fixed */} { - setChecked(!checked); + onChange={e => { + setChecked(!checked) debouncedFunction(selectedAgentData.id, { ...selectedAgentData, data: { ...selectedAgentData.data, ethereum_enabled: e.target.checked, }, - }); + }) setSelectedAgentData({ ...selectedAgentData, @@ -111,7 +114,7 @@ export const EthereumAgentWindow: FC = ({ selectedAgentData, props ...selectedAgentData.data, ethereum_enabled: e.target.checked, }, - }); + }) }} label={''} /> @@ -125,7 +128,7 @@ export const EthereumAgentWindow: FC = ({ selectedAgentData, props + setValue={value => setState({ ...state, ethereum_private_key: value, @@ -150,5 +153,5 @@ export const EthereumAgentWindow: FC = ({ selectedAgentData, props )} - ); -}; \ No newline at end of file + ) +} diff --git a/packages/plugins/github/client/src/components/VariableModal.tsx b/packages/plugins/github/client/src/components/VariableModal.tsx index 7cf59def91..7f1b1f6b48 100644 --- a/packages/plugins/github/client/src/components/VariableModal.tsx +++ b/packages/plugins/github/client/src/components/VariableModal.tsx @@ -1,4 +1,4 @@ -import { Modal } from '@magickml/client-core' +import { Modal } from 'client/core' import { useState } from 'react' import { Tooltip } from "@mui/material" @@ -10,7 +10,7 @@ const VariableModal = ({ }) => { const [state, setState] = useState({ github_access_token: selectedAgentData?.data?.github_access_token, - github_repos: selectedAgentData?.data?.github_repos + github_repos: selectedAgentData?.data?.github_repos, }) const handleSave = async () => { @@ -36,7 +36,7 @@ const VariableModal = ({ update(selectedAgentData.id, data) } - const handleAccessToken = async (e) => { + const handleAccessToken = async e => { const access_token = e.target.value.trim() setState({ @@ -45,7 +45,7 @@ const VariableModal = ({ }) } - const handleChange = async (e) => { + const handleChange = async e => { const repoInfos = e.target.value.split(',') setState({ @@ -56,7 +56,12 @@ const VariableModal = ({ return ( editMode && ( - + <>
@@ -91,4 +96,3 @@ const VariableModal = ({ } export default VariableModal - diff --git a/packages/plugins/github/client/src/components/agent.component.tsx b/packages/plugins/github/client/src/components/agent.component.tsx index e3d9360192..5fc5a0ee93 100644 --- a/packages/plugins/github/client/src/components/agent.component.tsx +++ b/packages/plugins/github/client/src/components/agent.component.tsx @@ -1,7 +1,7 @@ import React, { FC, useEffect, useState } from 'react' import { debounce } from 'lodash' -import { Switch } from '@magickml/client-core' +import { Switch } from 'client/core' import VariableModal from './VariableModal' import { Tooltip } from "@mui/material" @@ -95,4 +95,4 @@ export const GithubAgentWindow: FC = props => { )} ) -} \ No newline at end of file +} diff --git a/packages/plugins/intent/client/src/windows/IntentWindow/IntentModal.tsx b/packages/plugins/intent/client/src/windows/IntentWindow/IntentModal.tsx index b92938c913..a7672e9027 100644 --- a/packages/plugins/intent/client/src/windows/IntentWindow/IntentModal.tsx +++ b/packages/plugins/intent/client/src/windows/IntentWindow/IntentModal.tsx @@ -1,63 +1,94 @@ -import { Modal } from '@magickml/client-core'; -import { Backdrop, CircularProgress, Grid, MenuItem, Select, Typography } from '@mui/material'; -import TextField from '@mui/material/TextField'; -import { useEffect, useState } from 'react'; +import { Modal } from 'client/core' +import { + Backdrop, + CircularProgress, + Grid, + MenuItem, + Select, + Typography, +} from '@mui/material' +import TextField from '@mui/material/TextField' +import { useEffect, useState } from 'react' import { useSnackbar } from 'notistack' -const IntentModal = ({ createMode, setCreateMode, handleSave, setNewIntent, providerList, chatProviderList }) => { - const [loading, setLoading] = useState(false); +const IntentModal = ({ + createMode, + setCreateMode, + handleSave, + setNewIntent, + providerList, + chatProviderList, +}) => { + const [loading, setLoading] = useState(false) const { enqueueSnackbar } = useSnackbar() const [newIntent, setIntent] = useState({ type: '', content: '', intent: '', - variations: 0 - }); + variations: 0, + }) useEffect(() => { - setNewIntent(newIntent); - }, [newIntent]); + setNewIntent(newIntent) + }, [newIntent]) - const [selectedModel, setSelectedModel] = useState(null); + const [selectedModel, setSelectedModel] = useState(null) - const handleModelChange = (event) => { - const selectedModelValue = event.target.value; - const selectedObject = providerList.find( - (provider) => provider.models.includes(selectedModelValue) - ); - setSelectedModel({ model: selectedModelValue, object: selectedObject }); - }; + const handleModelChange = event => { + const selectedModelValue = event.target.value + const selectedObject = providerList.find(provider => + provider.models.includes(selectedModelValue) + ) + setSelectedModel({ model: selectedModelValue, object: selectedObject }) + } const handleSaveIntent = () => { - setLoading(true); + setLoading(true) if (newIntent.type) { - handleSave(selectedModel); - setLoading(false); + handleSave(selectedModel) + setLoading(false) } else { - setLoading(false); - enqueueSnackbar('Please fill in all required fields.', { variant: 'error' }); + setLoading(false) + enqueueSnackbar('Please fill in all required fields.', { + variant: 'error', + }) } - }; + } return ( { setCreateMode(!createMode) }} + onClose={() => { + setCreateMode(!createMode) + }} submitText="Generate Embeddings and Save" handleAction={handleSaveIntent} > - {loading && theme.zIndex.drawer + 1 }}>} + {loading && ( + theme.zIndex.drawer + 1 }} + > + + + )} - - Add intents + + Add intents + + style={{ display: 'flex', gap: '5rem', alignItems: 'center' }} + > {/* Name */} - Select Embedding Model + + Select Embedding Model + - Type + + Type + setIntent({ ...newIntent, type: e.target.value })} + onChange={e => setIntent({ ...newIntent, type: e.target.value })} required /> - Intent + + Intent + setIntent({ ...newIntent, intent: e.target.value })} + onChange={e => + setIntent({ ...newIntent, intent: e.target.value }) + } required /> - Content + + Content + setIntent({ ...newIntent, content: e.target.value })} + onChange={e => setIntent({ ...newIntent, content: e.target.value })} required multiline rows={5} @@ -122,20 +179,29 @@ const IntentModal = ({ createMode, setCreateMode, handleSave, setNewIntent, prov + style={{ display: 'flex', gap: '5rem', alignItems: 'center' }} + > - Variations + + Variations + setIntent({ ...newIntent, variations: parseInt(e.target.value) })} + onChange={e => + setIntent({ ...newIntent, variations: parseInt(e.target.value) }) + } required /> - ); -}; + ) +} -export default IntentModal; \ No newline at end of file +export default IntentModal diff --git a/packages/plugins/intent/client/src/windows/IntentWindow/IntentTable.tsx b/packages/plugins/intent/client/src/windows/IntentWindow/IntentTable.tsx index 7b3fd8efef..fe0952477b 100644 --- a/packages/plugins/intent/client/src/windows/IntentWindow/IntentTable.tsx +++ b/packages/plugins/intent/client/src/windows/IntentWindow/IntentTable.tsx @@ -1,6 +1,6 @@ // DOCUMENTED // Import statements kept as-is -import { TableComponent } from '@magickml/client-core' +import { TableComponent } from 'client/core' import { CompletionProvider, pluginManager } from '@magickml/core' import { API_ROOT_URL } from 'shared/config' import { MoreHoriz, NewReleases, Refresh } from '@mui/icons-material' @@ -14,7 +14,7 @@ import { Typography, } from '@mui/material' import { useSnackbar } from 'notistack' -import { useConfig } from '@magickml/client-core' +import { useConfig } from 'client/core' import { useEffect, useMemo, useState } from 'react' import { useSelector } from 'react-redux' import { diff --git a/packages/plugins/intent/client/src/windows/IntentWindow/index.tsx b/packages/plugins/intent/client/src/windows/IntentWindow/index.tsx index d9ee4fa248..907e7dfa10 100644 --- a/packages/plugins/intent/client/src/windows/IntentWindow/index.tsx +++ b/packages/plugins/intent/client/src/windows/IntentWindow/index.tsx @@ -2,7 +2,7 @@ import { API_ROOT_URL } from 'shared/config' import { useEffect, useState } from 'react' import { useSelector } from 'react-redux' -import { LoadingScreen, useConfig } from '@magickml/client-core' +import { LoadingScreen, useConfig } from 'client/core' import IntentTable from './IntentTable' /** diff --git a/packages/plugins/loop/client/src/components/loop.component.tsx b/packages/plugins/loop/client/src/components/loop.component.tsx index 14c47b5ff1..51e96f48b2 100644 --- a/packages/plugins/loop/client/src/components/loop.component.tsx +++ b/packages/plugins/loop/client/src/components/loop.component.tsx @@ -1,7 +1,7 @@ // DOCUMENTED import React, { FC, useEffect, useState } from 'react' import { debounce } from 'lodash' -import { Modal, Switch } from '@magickml/client-core' +import { Modal, Switch } from 'client/core' import { Tooltip } from '@mui/material' /** diff --git a/packages/plugins/rest/client/src/components/rest.component.tsx b/packages/plugins/rest/client/src/components/rest.component.tsx index 58c447464e..c60455b55c 100644 --- a/packages/plugins/rest/client/src/components/rest.component.tsx +++ b/packages/plugins/rest/client/src/components/rest.component.tsx @@ -1,7 +1,7 @@ // DOCUMENTED import React, { FC, useEffect, useState } from 'react' import Grid from '@mui/material/Grid' -import { Modal, Switch } from '@magickml/client-core' +import { Modal, Switch } from 'client/core' import md5 from 'md5' import { Button, Input } from '@mui/material' import { enqueueSnackbar } from 'notistack' diff --git a/packages/plugins/task/client/src/components/task.component.tsx b/packages/plugins/task/client/src/components/task.component.tsx index 8ef73449a7..df38b3bb7b 100644 --- a/packages/plugins/task/client/src/components/task.component.tsx +++ b/packages/plugins/task/client/src/components/task.component.tsx @@ -1,5 +1,5 @@ // DOCUMENTED -import { Switch } from '@magickml/client-core' +import { Switch } from 'client/core' import { debounce } from 'lodash' import { FC, useEffect, useState } from 'react' import { Tooltip } from '@mui/material' diff --git a/packages/plugins/task/client/src/windows/TaskWindow/TaskTable.tsx b/packages/plugins/task/client/src/windows/TaskWindow/TaskTable.tsx index 94ce29b24b..0ee2d2ec0a 100644 --- a/packages/plugins/task/client/src/windows/TaskWindow/TaskTable.tsx +++ b/packages/plugins/task/client/src/windows/TaskWindow/TaskTable.tsx @@ -2,7 +2,7 @@ // Import statements kept as-is // TODO this whole file is a mess of typescript errors. Fix. //@ts-nocheck -import { Button } from '@magickml/client-core' +import { Button } from 'client/core' import { API_ROOT_URL } from 'shared/config' import { Grid, @@ -33,7 +33,7 @@ import { useSortBy, useTable, } from 'react-table' -import { useConfig } from '@magickml/client-core' +import { useConfig } from 'client/core' /** * GlobalFilter component for applying search filter on the whole table. diff --git a/packages/plugins/task/client/src/windows/TaskWindow/index.tsx b/packages/plugins/task/client/src/windows/TaskWindow/index.tsx index a98ab3a496..04135b4506 100644 --- a/packages/plugins/task/client/src/windows/TaskWindow/index.tsx +++ b/packages/plugins/task/client/src/windows/TaskWindow/index.tsx @@ -2,7 +2,7 @@ import { API_ROOT_URL } from 'shared/config' import { useEffect, useState } from 'react' import { useSelector } from 'react-redux' -import { useConfig } from '@magickml/client-core' +import { useConfig } from 'client/core' import TaskTable from './TaskTable' /** diff --git a/packages/plugins/twitter/client/src/components/VariableModal.tsx b/packages/plugins/twitter/client/src/components/VariableModal.tsx index ca2378e72b..dffcb845aa 100644 --- a/packages/plugins/twitter/client/src/components/VariableModal.tsx +++ b/packages/plugins/twitter/client/src/components/VariableModal.tsx @@ -1,4 +1,4 @@ -import { Modal, Switch } from '@magickml/client-core' +import { Modal, Switch } from 'client/core' import Grid from '@mui/material/Grid' import { useState } from 'react' import { Tooltip } from '@mui/material' diff --git a/packages/plugins/twitter/client/src/components/agent.component.tsx b/packages/plugins/twitter/client/src/components/agent.component.tsx index 4e9ee0148e..ce30cfedf9 100644 --- a/packages/plugins/twitter/client/src/components/agent.component.tsx +++ b/packages/plugins/twitter/client/src/components/agent.component.tsx @@ -1,4 +1,4 @@ -import { Switch } from '@magickml/client-core' +import { Switch } from 'client/core' import { debounce } from 'lodash' import { FC, useEffect, useState } from 'react' import VariableModal from './VariableModal' @@ -14,7 +14,6 @@ export const TwitterAgentWindow: FC = props => { ) const [disable, setDisable] = useState(false) - useEffect(() => { if (props.enable['TwitterPlugin'] == false) { setChecked(false) diff --git a/tsconfig.base.json b/tsconfig.base.json index aa0ac9fdf1..fab50cef9f 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -27,7 +27,6 @@ "paths": { "@magickml/agent": ["apps/agent/src/index.ts"], "@magickml/client": ["apps/client/src/index.ts"], - "@magickml/client-core": ["packages/core/client/src/index.ts"], "@magickml/core": ["packages/core/shared/src/index.ts"], "@magickml/docs": ["apps/docs/src/index.ts"], "@magickml/plugin-anthropic-client": [ @@ -190,6 +189,7 @@ "@magickml/ui/components": ["packages/utils/components/src/index.ts"], "@magickml/ui/utils": ["packages/ui/src/utils.ts"], "server/event-tracker": ["packages/server/event-tracker/src/index.ts"], + "client/core": ["packages/client/core/src/index.ts"], "client/editor": ["packages/client/editor/src/index.ts"], "client/layouts": ["packages/client/layouts/src/index.ts"], "client/magickml-chatbox": [ From 63af5f8b4547f4b3e727d3a2f070e173b4466951 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 27 Sep 2023 11:53:22 -0700 Subject: [PATCH 124/349] Move core shared into shared core folder --- apps/agent/project.json | 4 +- apps/agent/src/index.ts | 4 +- apps/agent/test/app.test.ts | 4 +- apps/client/project.json | 2 +- apps/client/src/main.tsx | 2 +- apps/cloud-agent-manager/src/main.ts | 4 +- apps/cloud-agent-worker/src/main.ts | 4 +- apps/server/project.json | 4 +- apps/server/src/index.ts | 16 +- .../core/src/components/Drawer/AgentMenu.tsx | 2 +- .../core/src/components/Drawer/CustomNode.tsx | 2 +- .../components/Drawer/Newsidebar/index.tsx | 2 +- .../components/Drawer/OldSidebar/index.tsx | 2 +- .../components/Drawer/ProjectWindow/index.tsx | 2 +- packages/client/core/src/index.ts | 2 +- .../core/src/providers/FeathersProvider.tsx | 2 +- .../core/src/providers/PubSubProvider.tsx | 2 +- packages/client/editor/project.json | 2 +- .../editor/src/DataControls/DataControls.tsx | 2 +- .../editor/src/DataControls/SpellSelect.tsx | 2 +- .../editor/src/components/EventHandler.tsx | 2 +- .../editor/src/components/ProjectRow.tsx | 2 +- .../editor/src/components/Workspace.tsx | 2 +- .../editor/src/components/Workspaces.tsx | 2 +- .../editor/src/contexts/EditorProvider.tsx | 2 +- .../editor/src/contexts/InspectorProvider.tsx | 2 +- .../src/contexts/MagickInterfaceProvider.tsx | 2 +- packages/client/editor/src/editor.ts | 6 +- .../editor/src/plugins/areaPlugin/snap.ts | 2 +- .../src/plugins/highlightPlugin/utils.ts | 2 +- packages/client/editor/src/routes.tsx | 2 +- .../editor/src/screens/Composer/index.tsx | 2 +- .../screens/DocumentWindow/DocumentTable.tsx | 2 +- .../src/screens/HomeScreen/AllProjects.tsx | 2 +- .../src/screens/HomeScreen/CreateNew.tsx | 2 +- .../editor/src/screens/Magick/Magick.tsx | 2 +- .../src/screens/MagickV2/panels/mainPanel.tsx | 2 +- .../screens/MagickV2/workspaces/composer.tsx | 2 +- .../src/screens/agents/AgentManagerWindow.tsx | 2 +- .../agents/AgentWindow/AgentDetails.tsx | 2 +- .../src/screens/settings/SettingsWindow.tsx | 2 +- packages/client/editor/src/types/index.ts | 2 +- packages/core/server/.eslintrc.json | 33 - .../server/src/communication/PubSub/PubSub.ts | 23 - .../src/communication/Workers/Worker.ts | 6 - .../src/dataControls/CustomDropdown.tsx | 29 - .../shared/src/plugins/historyPlugin/index.ts | 82 -- packages/core/shared/src/utils/index.ts | 3 - .../core/shared/test/jest-import-meta-env.ts | 5 - .../shared/test/nodes/utility/Echo.spell.json | 247 ----- .../plugins/anthropic/client/project.json | 2 +- .../plugins/anthropic/client/src/index.ts | 2 +- .../plugins/anthropic/server/project.json | 2 +- .../src/functions/makeChatCompletion.ts | 2 +- .../plugins/anthropic/server/src/index.ts | 2 +- .../plugins/anthropic/shared/project.json | 2 +- .../plugins/anthropic/shared/src/index.ts | 2 +- packages/plugins/avatar/client/project.json | 2 +- packages/plugins/avatar/client/src/index.ts | 4 +- packages/plugins/banana/client/project.json | 2 +- packages/plugins/banana/client/src/index.ts | 8 +- packages/plugins/banana/server/project.json | 2 +- packages/plugins/banana/server/src/index.ts | 24 +- packages/plugins/bluesky/client/project.json | 2 +- packages/plugins/bluesky/client/src/index.ts | 6 +- packages/plugins/bluesky/server/project.json | 2 +- .../bluesky/server/src/connectors/bluesky.ts | 2 +- packages/plugins/bluesky/server/src/index.ts | 2 +- packages/plugins/database/client/project.json | 2 +- packages/plugins/database/client/src/index.ts | 14 +- packages/plugins/database/server/project.json | 2 +- .../database/server/src/functions/delete.ts | 2 +- .../database/server/src/functions/insert.ts | 2 +- .../database/server/src/functions/select.ts | 2 +- .../database/server/src/functions/update.ts | 2 +- .../database/server/src/functions/upsert.ts | 2 +- packages/plugins/database/server/src/index.ts | 2 +- packages/plugins/database/shared/project.json | 2 +- packages/plugins/database/shared/src/index.ts | 2 +- packages/plugins/discord/client/project.json | 2 +- packages/plugins/discord/client/src/index.ts | 2 +- packages/plugins/discord/server/project.json | 2 +- .../server/src/connectors/discord-voice.ts | 2 +- .../discord/server/src/connectors/discord.ts | 4 +- packages/plugins/discord/server/src/index.ts | 2 +- packages/plugins/discord/shared/project.json | 2 +- packages/plugins/discord/shared/src/index.ts | 31 +- .../src/nodes/DiscordCurrentChannelName.ts | 2 +- .../shared/src/nodes/DiscordJoinVoice.ts | 2 +- .../shared/src/nodes/DiscordLeaveVoice.ts | 2 +- .../DiscordLeaveVoiceChannelsInServer.ts | 2 +- .../src/nodes/DiscordListTextChannels.ts | 2 +- .../src/nodes/DiscordListVoiceChannels.ts | 2 +- .../src/nodes/DiscordVoiceChannelForSender.ts | 2 +- .../plugins/discord/shared/src/nodes/utils.ts | 2 +- .../plugins/elevenlabs/client/project.json | 2 +- .../plugins/elevenlabs/client/src/index.ts | 10 +- .../plugins/elevenlabs/server/project.json | 2 +- .../server/src/functions/textToSpeech.ts | 52 +- .../plugins/elevenlabs/server/src/index.ts | 8 +- .../plugins/elevenlabs/shared/project.json | 2 +- .../plugins/elevenlabs/shared/src/index.ts | 38 +- packages/plugins/ethereum/client/project.json | 2 +- packages/plugins/ethereum/client/src/index.ts | 20 +- packages/plugins/ethereum/server/project.json | 2 +- packages/plugins/ethereum/server/src/index.ts | 52 +- .../src/services/solidity/solidity.class.ts | 65 +- .../server/src/services/solidity/solidity.ts | 24 +- packages/plugins/ethereum/shared/project.json | 2 +- .../src/nodes/CallContractFunctionRead.ts | 2 +- .../src/nodes/CallContractFunctionWrite.ts | 2 +- .../src/nodes/CheckForRecentTxFromWallet.ts | 2 +- .../shared/src/nodes/CompileContract.ts | 2 +- .../shared/src/nodes/DeployContract.ts | 2 +- .../src/nodes/GetERC20BalanceFromWallet.ts | 2 +- .../src/nodes/GetNativeBalanceFromWallet.ts | 2 +- .../src/nodes/GetRecentTxsFromWallet.ts | 2 +- packages/plugins/github/client/project.json | 2 +- packages/plugins/github/client/src/index.ts | 2 +- packages/plugins/github/server/project.json | 2 +- .../github/server/src/connectors/github.ts | 912 +++++++++--------- packages/plugins/github/server/src/index.ts | 7 +- packages/plugins/github/shared/project.json | 2 +- packages/plugins/github/shared/src/index.ts | 6 +- .../shared/src/nodes/GithubIssueSearch.ts | 2 +- packages/plugins/googleai/client/project.json | 2 +- packages/plugins/googleai/client/src/index.ts | 10 +- packages/plugins/googleai/server/project.json | 2 +- .../src/functions/makeChatCompletion.ts | 4 +- .../src/functions/makeTextCompletion.ts | 4 +- .../server/src/functions/makeTextEmbedding.ts | 4 +- packages/plugins/googleai/server/src/index.ts | 2 +- packages/plugins/googleai/shared/project.json | 2 +- packages/plugins/googleai/shared/src/index.ts | 2 +- packages/plugins/intent/client/project.json | 2 +- packages/plugins/intent/client/src/index.ts | 2 +- .../src/windows/IntentWindow/IntentTable.tsx | 2 +- packages/plugins/intent/server/project.json | 2 +- packages/plugins/intent/server/src/index.ts | 2 +- .../src/services/intent/intent.class.ts | 4 +- .../src/services/intent/intent.schema.ts | 4 +- .../server/src/services/intent/intent.ts | 4 +- packages/plugins/intent/shared/project.json | 2 +- packages/plugins/intent/shared/src/index.ts | 2 +- .../intent/shared/src/nodes/IntentSearch.ts | 4 +- .../plugins/localmodel/client/project.json | 2 +- .../plugins/localmodel/client/src/index.ts | 10 +- .../plugins/localmodel/server/project.json | 2 +- .../src/functions/makeChatCompletion.ts | 2 +- .../src/functions/makeTextCompletion.ts | 2 +- .../server/src/functions/makeTextEmbedding.ts | 2 +- .../plugins/localmodel/server/src/index.ts | 2 +- .../plugins/localmodel/shared/project.json | 2 +- .../plugins/localmodel/shared/src/index.ts | 70 +- packages/plugins/loop/client/project.json | 2 +- packages/plugins/loop/client/src/index.ts | 12 +- packages/plugins/loop/server/project.json | 2 +- packages/plugins/loop/server/src/index.ts | 4 +- packages/plugins/loop/shared/project.json | 2 +- packages/plugins/openai/client/project.json | 2 +- packages/plugins/openai/client/src/index.ts | 2 +- packages/plugins/openai/server/project.json | 2 +- .../src/functions/makeChatCompletion.ts | 4 +- .../src/functions/makeTextCompletion.ts | 4 +- .../server/src/functions/makeTextEmbedding.ts | 4 +- .../src/functions/makeTypeChatCompletion.ts | 2 +- packages/plugins/openai/server/src/index.ts | 3 +- packages/plugins/openai/shared/project.json | 2 +- packages/plugins/openai/shared/src/index.ts | 2 +- packages/plugins/pinecone/client/project.json | 2 +- packages/plugins/pinecone/client/src/index.ts | 8 +- packages/plugins/pinecone/server/project.json | 2 +- packages/plugins/pinecone/server/src/index.ts | 12 +- packages/plugins/pinecone/shared/project.json | 2 +- .../shared/src/nodes/QueryPinecone.ts | 2 +- packages/plugins/rest/client/project.json | 2 +- packages/plugins/rest/client/src/index.ts | 16 +- packages/plugins/rest/server/project.json | 2 +- packages/plugins/rest/server/src/index.ts | 2 +- .../src/services/agentHttp/agentHttp.class.ts | 4 +- .../services/agentHttp/agentHttp.schema.ts | 4 +- .../src/services/agentHttp/agentHttp.ts | 4 +- packages/plugins/search/client/project.json | 2 +- packages/plugins/search/client/src/index.ts | 2 +- packages/plugins/search/server/project.json | 2 +- packages/plugins/search/server/src/index.ts | 2 +- .../services/google-search/google-search.ts | 2 +- packages/plugins/search/shared/project.json | 2 +- .../shared/src/functions/SearchMetaphor.ts | 4 +- packages/plugins/search/shared/src/index.ts | 2 +- .../search/shared/src/nodes/SearchGoogle.ts | 2 +- .../search/shared/src/nodes/SearchMetaphor.ts | 2 +- packages/plugins/task/client/project.json | 2 +- packages/plugins/task/client/src/index.ts | 4 +- packages/plugins/task/server/project.json | 2 +- packages/plugins/task/server/src/index.ts | 4 +- packages/plugins/task/shared/project.json | 2 +- packages/plugins/task/shared/src/index.ts | 2 +- .../task/shared/src/nodes/CancelTask.ts | 2 +- .../task/shared/src/nodes/CompleteTask.ts | 2 +- .../task/shared/src/nodes/CreateTask.ts | 2 +- .../task/shared/src/nodes/DeleteTask.ts | 2 +- .../task/shared/src/nodes/FinishTaskStep.ts | 2 +- packages/plugins/twitter/client/project.json | 2 +- packages/plugins/twitter/client/src/index.ts | 2 +- packages/plugins/twitter/server/project.json | 2 +- .../twitter/server/src/connectors/twitter.ts | 2 +- packages/plugins/twitter/server/src/index.ts | 2 +- packages/server/agents/src/index.ts | 2 +- packages/server/agents/src/lib/Agent.ts | 5 +- .../server/agents/src/lib/AgentCommander.ts | 6 +- .../server/agents/src/lib/AgentManager.ts | 4 +- packages/server/agents/src/lib/CommandHub.ts | 4 +- .../src/lib/CloudAgentManager.ts | 4 +- .../src/lib/Reporters/FeathersSyncReporter.ts | 4 +- .../src/lib/Reporters/PgNotifyReporter.ts | 2 +- .../src/lib/cloud-agent-worker.ts | 4 +- .../{core/server => server/core}/.babelrc | 0 packages/server/core/.eslintrc.json | 18 + .../{core/server => server/core}/README.md | 3 - .../server => server/core}/jest.config.ts | 2 +- .../{core/server => server/core}/package.json | 2 +- .../{core/server => server/core}/project.json | 8 +- .../core}/src/@types/index.d.ts | 0 .../server => server/core}/src/api/apis.ts | 0 .../server => server/core}/src/api/index.ts | 45 +- .../{core/server => server/core}/src/app.ts | 3 +- .../core}/src/auth/authentication.ts | 0 .../core}/src/auth/cloudAuthentication.ts | 0 .../server => server/core}/src/client.ts | 0 .../src/communication/MessageQueues/BullMQ.ts | 4 +- .../MessageQueues/MessageQueue.ts | 0 .../src/communication/MessageQueues/index.ts | 0 .../core/src/communication/PubSub/PubSub.ts | 23 + .../core}/src/communication/PubSub/Redis.ts | 2 +- .../core}/src/communication/PubSub/index.ts | 0 .../core}/src/communication/Workers/BullMQ.ts | 2 +- .../core/src/communication/Workers/Worker.ts | 6 + .../core}/src/communication/Workers/index.ts | 0 .../core}/src/communication/index.ts | 0 .../core}/src/config/configuration.ts | 37 +- .../core}/src/config/types.ts | 12 +- .../core}/src/config/validators.ts | 36 +- .../core}/src/customEmbeddings.ts | 2 +- .../server => server/core}/src/dbClient.ts | 0 .../core}/src/declarations.ts | 2 +- .../core}/src/helpers/getSpell.ts | 0 .../core}/src/hooks/authenticateApiKey.ts | 0 .../server => server/core}/src/hooks/index.ts | 9 +- .../core}/src/hooks/spellmanagerHooks.ts | 4 +- .../{core/server => server/core}/src/index.ts | 0 .../core}/src/metering/index.ts | 6 +- .../core}/src/metering/meteringClient.ts | 2 +- .../core}/src/metering/meters.ts | 0 .../core}/src/servers/fileServer.ts | 0 .../core}/src/servers/googleSpeechToText.ts | 0 .../core}/src/servers/googleTextToSpeech.ts | 18 +- .../core}/src/servers/tiktalknet.ts | 0 .../core}/src/services/Upload.class.ts | 0 .../services/agentImage/agentImage.class.ts | 0 .../src/services/agentImage/agentImage.ts | 0 .../core}/src/services/agents/agents.class.ts | 2 +- .../src/services/agents/agents.schema.ts | 2 +- .../core}/src/services/agents/agents.ts | 0 .../src/services/documents/documents.class.ts | 0 .../services/documents/documents.schema.ts | 2 +- .../core}/src/services/documents/documents.ts | 0 .../core}/src/services/events/events.class.ts | 2 - .../src/services/events/events.schema.ts | 0 .../core}/src/services/events/events.ts | 0 .../core}/src/services/index.ts | 2 +- .../src/services/projects/projects.class.ts | 0 .../core}/src/services/projects/projects.ts | 0 .../src/services/requests/requests.class.ts | 0 .../src/services/requests/requests.schema.ts | 0 .../core}/src/services/requests/requests.ts | 0 .../core}/src/services/spells/spells.class.ts | 2 +- .../src/services/spells/spells.schema.ts | 2 +- .../core}/src/services/spells/spells.ts | 0 .../core}/src/services/tasks/tasks.class.ts | 8 +- .../core}/src/services/tasks/tasks.schema.ts | 4 +- .../core}/src/services/tasks/tasks.ts | 0 .../core}/src/services/utils.ts | 23 +- .../core}/src/sockets/channels.ts | 0 .../core}/src/sockets/sockets.ts | 2 +- .../server => server/core}/src/vectordb.ts | 3 +- .../server => server/core}/tsconfig.json | 0 .../server => server/core}/tsconfig.lib.json | 0 .../server => server/core}/tsconfig.spec.json | 0 .../shared => shared/core}/.eslintrc.json | 3 +- .../{core/shared => shared/core}/.gitignore | 0 .../{core/shared => shared/core}/.gitkeep | 0 .../shared => shared/core}/jest.config.ts | 2 +- .../shared => shared/core}/jest.setup.ts | 4 +- .../{core/shared => shared/core}/package.json | 2 +- .../{core/shared => shared/core}/project.json | 12 +- .../src/communication/agentEventTypes.ts | 0 .../core}/src/communication/agentJobTypes.ts | 0 .../core}/src/communication/index.ts | 0 .../core}/src/cost-calculator.ts | 0 .../core}/src/data/layouts/defaultLayout.json | 0 .../src/data/layouts/fullScreenLayout.json | 0 .../data/layouts/promptEngineeringLayout.json | 0 .../data/layouts/troubleshootingLayout.json | 0 .../core}/src/dataControls/ArrayControl.ts | 0 .../core}/src/dataControls/BooleanControl.ts | 0 .../core}/src/dataControls/CodeControl.ts | 0 .../core/src/dataControls/CustomDropdown.tsx | 65 ++ .../core}/src/dataControls/DropdownControl.ts | 16 +- .../core}/src/dataControls/EmptyControl.ts | 0 .../core}/src/dataControls/FewshotControl.ts | 0 .../core}/src/dataControls/InputControl.ts | 24 +- .../core}/src/dataControls/InputGenerator.ts | 0 .../core}/src/dataControls/ModelControl.ts | 22 +- .../src/dataControls/MultiSocketGenerator.ts | 30 +- .../core}/src/dataControls/NumberControl.ts | 0 .../core}/src/dataControls/OutputGenerator.ts | 0 .../core}/src/dataControls/PlaytestControl.ts | 15 +- .../core}/src/dataControls/SocketGenerator.ts | 43 +- .../core}/src/dataControls/SpellControl.ts | 9 +- .../core}/src/dataControls/SwitchControl.ts | 5 +- .../src/dataControls/TextInputControl.tsx | 0 .../shared => shared/core}/src/engine.ts | 2 +- .../core}/src/functions/ProcessPython.ts | 0 .../core}/src/functions/expandVector.ts | 0 .../core}/src/functions/index.ts | 0 .../core}/src/functions/processCode.ts | 0 .../core}/src/functions/saveRequest.ts | 0 .../core}/src/functions/speechUtils.ts | 0 .../shared => shared/core}/src/globals.ts | 20 +- .../{core/shared => shared/core}/src/index.ts | 0 .../core}/src/logger/index.ts | 0 .../core}/src/nodes/array/ArrayToJSON.ts | 0 .../core}/src/nodes/array/ArrayVariable.ts | 0 .../core}/src/nodes/array/ExtractFromArray.ts | 0 .../src/nodes/array/GetValueFromArray.ts | 0 .../core}/src/nodes/array/JSONToArray.ts | 0 .../core}/src/nodes/array/JoinList.ts | 0 .../core}/src/nodes/array/RemapArray.ts | 0 .../core}/src/nodes/audio/TextToSpeech.ts | 0 .../src/nodes/boolean/BooleanVariable.ts | 0 .../core}/src/nodes/boolean/IsVariableTrue.ts | 0 .../src/nodes/boolean/LogicalOperator.ts | 0 .../core}/src/nodes/code/Javascript.ts | 0 .../core}/src/nodes/code/Python.ts | 0 .../core}/src/nodes/database/Delete.ts | 0 .../core}/src/nodes/database/Insert.ts | 0 .../core}/src/nodes/database/Select.ts | 0 .../core}/src/nodes/database/Update.ts | 0 .../core}/src/nodes/database/Upsert.ts | 0 .../src/nodes/document/DocumentToContent.ts | 0 .../core}/src/nodes/document/GetDocuments.ts | 0 .../core}/src/nodes/document/StoreDocument.ts | 0 .../src/nodes/embedding/CosineSimilarity.ts | 0 .../nodes/embedding/CreateTextEmbedding.ts | 0 .../nodes/embedding/ExtractRelationship.ts | 0 .../src/nodes/embedding/FindTextEmbedding.ts | 0 .../core}/src/nodes/events/EventDelete.ts | 0 .../src/nodes/events/EventDestructure.ts | 0 .../core}/src/nodes/events/EventRecall.ts | 0 .../src/nodes/events/EventRestructure.ts | 0 .../core}/src/nodes/events/EventStore.ts | 0 .../src/nodes/events/EventsToConversation.ts | 0 .../core}/src/nodes/flow/BooleanGate.ts | 0 .../core}/src/nodes/flow/CommandParser.ts | 0 .../core}/src/nodes/flow/ExclusiveGate.ts | 0 .../core}/src/nodes/flow/IsNullOrUndefined.ts | 0 .../core}/src/nodes/flow/OrGate.ts | 0 .../core}/src/nodes/flow/RandomGate.ts | 0 .../core}/src/nodes/flow/SwitchGate.ts | 0 .../core}/src/nodes/flow/WaitForAll.ts | 0 .../shared => shared/core}/src/nodes/index.ts | 0 .../core}/src/nodes/io/Input.ts | 0 .../core}/src/nodes/io/JupyterNotebook.ts | 0 .../core}/src/nodes/io/Output.ts | 0 .../core}/src/nodes/io/Request.ts | 0 .../core}/src/nodes/io/Respond.ts | 0 .../core}/src/nodes/io/Skill.ts | 0 .../core}/src/nodes/io/SocketInput.ts | 2 +- .../core}/src/nodes/io/SocketOutput.ts | 2 +- .../core}/src/nodes/io/Spell.ts | 0 .../core}/src/nodes/io/SpellByName.ts | 0 .../core}/src/nodes/magick/runSpell.ts | 0 .../core}/src/nodes/number/Add.ts | 0 .../core}/src/nodes/number/Divide.ts | 0 .../core}/src/nodes/number/Equal.ts | 0 .../core}/src/nodes/number/GreaterThan.ts | 0 .../src/nodes/number/GreaterThanOrEqual.ts | 0 .../core}/src/nodes/number/InRange.ts | 0 .../core}/src/nodes/number/IsANumber.ts | 0 .../core}/src/nodes/number/LessThan.ts | 0 .../core}/src/nodes/number/LessThanOrEqual.ts | 0 .../core}/src/nodes/number/Multiply.ts | 0 .../core}/src/nodes/number/NumberVariable.ts | 0 .../core}/src/nodes/number/Subtract.ts | 0 .../core}/src/nodes/object/ComposeObject.ts | 0 .../src/nodes/object/GetValuesFromObject.ts | 0 .../core}/src/nodes/object/JSONToObject.ts | 0 .../core}/src/nodes/object/MergeObjects.ts | 0 .../core}/src/nodes/object/ObjectToJSON.ts | 0 .../core}/src/nodes/text/CombineText.ts | 0 .../src/nodes/text/ComplexStringMatcher.ts | 0 .../core}/src/nodes/text/EvaluateText.ts | 0 .../core}/src/nodes/text/GenerateText.ts | 0 .../core}/src/nodes/text/GenerateUUID.ts | 0 .../core}/src/nodes/text/GetLength.ts | 0 .../core}/src/nodes/text/ProfanityFilter.ts | 0 .../core}/src/nodes/text/RegularExpression.ts | 0 .../core}/src/nodes/text/ReplaceText.ts | 0 .../core}/src/nodes/text/SplitBySentence.ts | 0 .../core}/src/nodes/text/StringVariable.ts | 0 .../core}/src/nodes/text/TextTemplate.ts | 0 .../core}/src/nodes/text/TextVariable.ts | 0 .../core}/src/nodes/text/Trim.ts | 0 .../core}/src/nodes/text/TypeChat.ts | 0 .../core}/src/nodes/utility/AlertMessage.ts | 0 .../core}/src/nodes/utility/Cast.ts | 0 .../core}/src/nodes/utility/CurrentTime.ts | 0 .../core}/src/nodes/utility/Echo.ts | 0 .../core}/src/nodes/utility/Error.ts | 0 .../core}/src/nodes/utility/Log.ts | 0 .../shared => shared/core}/src/plugin.ts | 0 .../plugins/cachePlugin/RunLastArguments.tsx | 0 .../core}/src/plugins/cachePlugin/index.ts | 0 .../plugins/consolePlugin/MagickConsole.ts | 0 .../core}/src/plugins/consolePlugin/index.ts | 0 .../core}/src/plugins/debuggerPlugin/index.ts | 0 .../core}/src/plugins/emitPlugin/index.ts | 0 .../core}/src/plugins/historyPlugin/action.ts | 6 +- .../historyPlugin/actions/connection.ts | 0 .../src/plugins/historyPlugin/actions/node.ts | 0 .../src/plugins/historyPlugin/history.ts | 54 +- .../core/src/plugins/historyPlugin/index.ts | 88 ++ .../plugins/inspectorPlugin/DataControl.ts | 0 .../src/plugins/inspectorPlugin/Inspector.ts | 0 .../dataControls/InfoControl.tsx | 15 +- .../src/plugins/inspectorPlugin/index.ts | 56 +- .../core}/src/plugins/keyCodePlugin/index.ts | 2 +- .../src/plugins/lifecyclePlugin/index.ts | 0 .../src/plugins/lifecyclePlugin/interfaces.ts | 0 .../src/plugins/lifecyclePlugin/utils.ts | 0 .../core}/src/plugins/modulePlugin/index.ts | 0 .../plugins/modulePlugin/module-manager.ts | 0 .../core}/src/plugins/modulePlugin/module.ts | 0 .../core}/src/plugins/modulePlugin/utils.ts | 0 .../src/plugins/multiCopyPlugin/index.ts | 0 .../src/plugins/multiSocketGenerator/index.ts | 0 .../src/plugins/nodeClickPlugin/index.ts | 2 +- .../core}/src/plugins/remotePlugin/index.ts | 0 .../src/plugins/selectionPlugin/index.ts | 0 .../src/plugins/socketGenerator/index.ts | 0 .../src/plugins/socketOverridePlugin/index.ts | 2 +- .../core}/src/plugins/socketPlugin/index.ts | 0 .../core}/src/plugins/taskPlugin/index.ts | 0 .../core}/src/plugins/taskPlugin/task.ts | 0 .../core}/src/plugins/taskPlugin2/index.ts | 0 .../core}/src/plugins/taskPlugin2/task.ts | 0 .../shared => shared/core}/src/schemas.ts | 0 .../shared => shared/core}/src/sockets.ts | 0 .../core}/src/spellManager/Spell.ts | 0 .../core}/src/spellManager/SpellManager.ts | 2 +- .../core}/src/spellManager/SpellRunner.ts | 2 +- .../src/spellManager/configureManager.ts | 4 +- .../core}/src/spellManager/graphHelpers.ts | 0 .../core}/src/spellManager/index.ts | 0 .../core}/src/spellManager/runSpell.ts | 0 .../core}/src/state/api/api.ts | 130 +-- .../core}/src/state/api/spells.ts | 2 +- .../core}/src/state/globalConfig.ts | 9 +- .../shared => shared/core}/src/state/hooks.ts | 0 .../core}/src/state/localState.ts | 7 +- .../core}/src/state/preferences.ts | 0 .../shared => shared/core}/src/state/store.ts | 0 .../shared => shared/core}/src/state/tabs.ts | 0 .../{core/shared => shared/core}/src/types.ts | 0 .../core}/src/utils/SpellError.ts | 4 +- .../core}/src/utils/getSpell.ts | 0 packages/shared/core/src/utils/index.ts | 3 + .../core}/src/utils/runSpell.ts | 0 .../shared => shared/core}/src/vite-env.d.ts | 0 .../shared/core/test/jest-import-meta-env.ts | 5 + .../core}/test/nodes/index.test.ts | 2 +- .../core}/test/nodes/utility/Echo.result.json | 2 +- .../core/test/nodes/utility/Echo.spell.json | 235 +++++ .../core}/test/nodes/utility/Echo.test.ts | 2 +- .../test/nodes/utility/Template.spell.json | 0 .../core}/test/nodes/utility/Template.test.ts | 2 +- .../core}/test/utils/runSpell.ts | 2 +- .../core}/test/utils/spellHandler.ts | 2 +- .../shared => shared/core}/tsconfig.json | 0 .../shared => shared/core}/tsconfig.lib.json | 0 .../shared => shared/core}/tsconfig.spec.json | 0 .../shared => shared/core}/vite.config.ts | 6 +- tsconfig.base.json | 4 +- 494 files changed, 1765 insertions(+), 1764 deletions(-) delete mode 100644 packages/core/server/.eslintrc.json delete mode 100644 packages/core/server/src/communication/PubSub/PubSub.ts delete mode 100644 packages/core/server/src/communication/Workers/Worker.ts delete mode 100644 packages/core/shared/src/dataControls/CustomDropdown.tsx delete mode 100644 packages/core/shared/src/plugins/historyPlugin/index.ts delete mode 100644 packages/core/shared/src/utils/index.ts delete mode 100644 packages/core/shared/test/jest-import-meta-env.ts delete mode 100644 packages/core/shared/test/nodes/utility/Echo.spell.json rename packages/{core/server => server/core}/.babelrc (100%) create mode 100644 packages/server/core/.eslintrc.json rename packages/{core/server => server/core}/README.md (98%) rename packages/{core/server => server/core}/jest.config.ts (84%) rename packages/{core/server => server/core}/package.json (86%) rename packages/{core/server => server/core}/project.json (74%) rename packages/{core/server => server/core}/src/@types/index.d.ts (100%) rename packages/{core/server => server/core}/src/api/apis.ts (100%) rename packages/{core/server => server/core}/src/api/index.ts (55%) rename packages/{core/server => server/core}/src/app.ts (98%) rename packages/{core/server => server/core}/src/auth/authentication.ts (100%) rename packages/{core/server => server/core}/src/auth/cloudAuthentication.ts (100%) rename packages/{core/server => server/core}/src/client.ts (100%) rename packages/{core/server => server/core}/src/communication/MessageQueues/BullMQ.ts (88%) rename packages/{core/server => server/core}/src/communication/MessageQueues/MessageQueue.ts (100%) rename packages/{core/server => server/core}/src/communication/MessageQueues/index.ts (100%) create mode 100644 packages/server/core/src/communication/PubSub/PubSub.ts rename packages/{core/server => server/core}/src/communication/PubSub/Redis.ts (93%) rename packages/{core/server => server/core}/src/communication/PubSub/index.ts (100%) rename packages/{core/server => server/core}/src/communication/Workers/BullMQ.ts (88%) create mode 100644 packages/server/core/src/communication/Workers/Worker.ts rename packages/{core/server => server/core}/src/communication/Workers/index.ts (100%) rename packages/{core/server => server/core}/src/communication/index.ts (100%) rename packages/{core/server => server/core}/src/config/configuration.ts (57%) rename packages/{core/server => server/core}/src/config/types.ts (71%) rename packages/{core/server => server/core}/src/config/validators.ts (56%) rename packages/{core/server => server/core}/src/customEmbeddings.ts (98%) rename packages/{core/server => server/core}/src/dbClient.ts (100%) rename packages/{core/server => server/core}/src/declarations.ts (95%) rename packages/{core/server => server/core}/src/helpers/getSpell.ts (100%) rename packages/{core/server => server/core}/src/hooks/authenticateApiKey.ts (100%) rename packages/{core/server => server/core}/src/hooks/index.ts (83%) rename packages/{core/server => server/core}/src/hooks/spellmanagerHooks.ts (97%) rename packages/{core/server => server/core}/src/index.ts (100%) rename packages/{core/server => server/core}/src/metering/index.ts (73%) rename packages/{core/server => server/core}/src/metering/meteringClient.ts (97%) rename packages/{core/server => server/core}/src/metering/meters.ts (100%) rename packages/{core/server => server/core}/src/servers/fileServer.ts (100%) rename packages/{core/server => server/core}/src/servers/googleSpeechToText.ts (100%) rename packages/{core/server => server/core}/src/servers/googleTextToSpeech.ts (96%) rename packages/{core/server => server/core}/src/servers/tiktalknet.ts (100%) rename packages/{core/server => server/core}/src/services/Upload.class.ts (100%) rename packages/{core/server => server/core}/src/services/agentImage/agentImage.class.ts (100%) rename packages/{core/server => server/core}/src/services/agentImage/agentImage.ts (100%) rename packages/{core/server => server/core}/src/services/agents/agents.class.ts (99%) rename packages/{core/server => server/core}/src/services/agents/agents.schema.ts (98%) rename packages/{core/server => server/core}/src/services/agents/agents.ts (100%) rename packages/{core/server => server/core}/src/services/documents/documents.class.ts (100%) rename packages/{core/server => server/core}/src/services/documents/documents.schema.ts (97%) rename packages/{core/server => server/core}/src/services/documents/documents.ts (100%) rename packages/{core/server => server/core}/src/services/events/events.class.ts (99%) rename packages/{core/server => server/core}/src/services/events/events.schema.ts (100%) rename packages/{core/server => server/core}/src/services/events/events.ts (100%) rename packages/{core/server => server/core}/src/services/index.ts (96%) rename packages/{core/server => server/core}/src/services/projects/projects.class.ts (100%) rename packages/{core/server => server/core}/src/services/projects/projects.ts (100%) rename packages/{core/server => server/core}/src/services/requests/requests.class.ts (100%) rename packages/{core/server => server/core}/src/services/requests/requests.schema.ts (100%) rename packages/{core/server => server/core}/src/services/requests/requests.ts (100%) rename packages/{core/server => server/core}/src/services/spells/spells.class.ts (97%) rename packages/{core/server => server/core}/src/services/spells/spells.schema.ts (97%) rename packages/{core/server => server/core}/src/services/spells/spells.ts (100%) rename packages/{core/server => server/core}/src/services/tasks/tasks.class.ts (97%) rename packages/{core/server => server/core}/src/services/tasks/tasks.schema.ts (97%) rename packages/{core/server => server/core}/src/services/tasks/tasks.ts (100%) rename packages/{core/server => server/core}/src/services/utils.ts (63%) rename packages/{core/server => server/core}/src/sockets/channels.ts (100%) rename packages/{core/server => server/core}/src/sockets/sockets.ts (98%) rename packages/{core/server => server/core}/src/vectordb.ts (98%) rename packages/{core/server => server/core}/tsconfig.json (100%) rename packages/{core/server => server/core}/tsconfig.lib.json (100%) rename packages/{core/server => server/core}/tsconfig.spec.json (100%) rename packages/{core/shared => shared/core}/.eslintrc.json (94%) rename packages/{core/shared => shared/core}/.gitignore (100%) rename packages/{core/shared => shared/core}/.gitkeep (100%) rename packages/{core/shared => shared/core}/jest.config.ts (93%) rename packages/{core/shared => shared/core}/jest.setup.ts (52%) rename packages/{core/shared => shared/core}/package.json (86%) rename packages/{core/shared => shared/core}/project.json (75%) rename packages/{core/shared => shared/core}/src/communication/agentEventTypes.ts (100%) rename packages/{core/shared => shared/core}/src/communication/agentJobTypes.ts (100%) rename packages/{core/shared => shared/core}/src/communication/index.ts (100%) rename packages/{core/shared => shared/core}/src/cost-calculator.ts (100%) rename packages/{core/shared => shared/core}/src/data/layouts/defaultLayout.json (100%) rename packages/{core/shared => shared/core}/src/data/layouts/fullScreenLayout.json (100%) rename packages/{core/shared => shared/core}/src/data/layouts/promptEngineeringLayout.json (100%) rename packages/{core/shared => shared/core}/src/data/layouts/troubleshootingLayout.json (100%) rename packages/{core/shared => shared/core}/src/dataControls/ArrayControl.ts (100%) rename packages/{core/shared => shared/core}/src/dataControls/BooleanControl.ts (100%) rename packages/{core/shared => shared/core}/src/dataControls/CodeControl.ts (100%) create mode 100644 packages/shared/core/src/dataControls/CustomDropdown.tsx rename packages/{core/shared => shared/core}/src/dataControls/DropdownControl.ts (94%) rename packages/{core/shared => shared/core}/src/dataControls/EmptyControl.ts (100%) rename packages/{core/shared => shared/core}/src/dataControls/FewshotControl.ts (100%) rename packages/{core/shared => shared/core}/src/dataControls/InputControl.ts (83%) rename packages/{core/shared => shared/core}/src/dataControls/InputGenerator.ts (100%) rename packages/{core/shared => shared/core}/src/dataControls/ModelControl.ts (79%) rename packages/{core/shared => shared/core}/src/dataControls/MultiSocketGenerator.ts (75%) rename packages/{core/shared => shared/core}/src/dataControls/NumberControl.ts (100%) rename packages/{core/shared => shared/core}/src/dataControls/OutputGenerator.ts (100%) rename packages/{core/shared => shared/core}/src/dataControls/PlaytestControl.ts (87%) rename packages/{core/shared => shared/core}/src/dataControls/SocketGenerator.ts (68%) rename packages/{core/shared => shared/core}/src/dataControls/SpellControl.ts (90%) rename packages/{core/shared => shared/core}/src/dataControls/SwitchControl.ts (98%) rename packages/{core/shared => shared/core}/src/dataControls/TextInputControl.tsx (100%) rename packages/{core/shared => shared/core}/src/engine.ts (99%) rename packages/{core/shared => shared/core}/src/functions/ProcessPython.ts (100%) rename packages/{core/shared => shared/core}/src/functions/expandVector.ts (100%) rename packages/{core/shared => shared/core}/src/functions/index.ts (100%) rename packages/{core/shared => shared/core}/src/functions/processCode.ts (100%) rename packages/{core/shared => shared/core}/src/functions/saveRequest.ts (100%) rename packages/{core/shared => shared/core}/src/functions/speechUtils.ts (100%) rename packages/{core/shared => shared/core}/src/globals.ts (82%) rename packages/{core/shared => shared/core}/src/index.ts (100%) rename packages/{core/shared => shared/core}/src/logger/index.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/array/ArrayToJSON.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/array/ArrayVariable.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/array/ExtractFromArray.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/array/GetValueFromArray.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/array/JSONToArray.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/array/JoinList.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/array/RemapArray.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/audio/TextToSpeech.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/boolean/BooleanVariable.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/boolean/IsVariableTrue.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/boolean/LogicalOperator.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/code/Javascript.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/code/Python.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/database/Delete.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/database/Insert.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/database/Select.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/database/Update.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/database/Upsert.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/document/DocumentToContent.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/document/GetDocuments.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/document/StoreDocument.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/embedding/CosineSimilarity.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/embedding/CreateTextEmbedding.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/embedding/ExtractRelationship.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/embedding/FindTextEmbedding.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/events/EventDelete.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/events/EventDestructure.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/events/EventRecall.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/events/EventRestructure.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/events/EventStore.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/events/EventsToConversation.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/flow/BooleanGate.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/flow/CommandParser.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/flow/ExclusiveGate.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/flow/IsNullOrUndefined.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/flow/OrGate.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/flow/RandomGate.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/flow/SwitchGate.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/flow/WaitForAll.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/index.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/io/Input.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/io/JupyterNotebook.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/io/Output.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/io/Request.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/io/Respond.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/io/Skill.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/io/SocketInput.ts (98%) rename packages/{core/shared => shared/core}/src/nodes/io/SocketOutput.ts (98%) rename packages/{core/shared => shared/core}/src/nodes/io/Spell.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/io/SpellByName.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/magick/runSpell.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/number/Add.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/number/Divide.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/number/Equal.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/number/GreaterThan.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/number/GreaterThanOrEqual.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/number/InRange.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/number/IsANumber.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/number/LessThan.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/number/LessThanOrEqual.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/number/Multiply.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/number/NumberVariable.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/number/Subtract.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/object/ComposeObject.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/object/GetValuesFromObject.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/object/JSONToObject.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/object/MergeObjects.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/object/ObjectToJSON.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/text/CombineText.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/text/ComplexStringMatcher.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/text/EvaluateText.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/text/GenerateText.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/text/GenerateUUID.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/text/GetLength.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/text/ProfanityFilter.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/text/RegularExpression.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/text/ReplaceText.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/text/SplitBySentence.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/text/StringVariable.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/text/TextTemplate.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/text/TextVariable.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/text/Trim.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/text/TypeChat.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/utility/AlertMessage.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/utility/Cast.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/utility/CurrentTime.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/utility/Echo.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/utility/Error.ts (100%) rename packages/{core/shared => shared/core}/src/nodes/utility/Log.ts (100%) rename packages/{core/shared => shared/core}/src/plugin.ts (100%) rename packages/{core/shared => shared/core}/src/plugins/cachePlugin/RunLastArguments.tsx (100%) rename packages/{core/shared => shared/core}/src/plugins/cachePlugin/index.ts (100%) rename packages/{core/shared => shared/core}/src/plugins/consolePlugin/MagickConsole.ts (100%) rename packages/{core/shared => shared/core}/src/plugins/consolePlugin/index.ts (100%) rename packages/{core/shared => shared/core}/src/plugins/debuggerPlugin/index.ts (100%) rename packages/{core/shared => shared/core}/src/plugins/emitPlugin/index.ts (100%) rename packages/{core/shared => shared/core}/src/plugins/historyPlugin/action.ts (92%) rename packages/{core/shared => shared/core}/src/plugins/historyPlugin/actions/connection.ts (100%) rename packages/{core/shared => shared/core}/src/plugins/historyPlugin/actions/node.ts (100%) rename packages/{core/shared => shared/core}/src/plugins/historyPlugin/history.ts (64%) create mode 100644 packages/shared/core/src/plugins/historyPlugin/index.ts rename packages/{core/shared => shared/core}/src/plugins/inspectorPlugin/DataControl.ts (100%) rename packages/{core/shared => shared/core}/src/plugins/inspectorPlugin/Inspector.ts (100%) rename packages/{core/shared => shared/core}/src/plugins/inspectorPlugin/dataControls/InfoControl.tsx (84%) rename packages/{core/shared => shared/core}/src/plugins/inspectorPlugin/index.ts (59%) rename packages/{core/shared => shared/core}/src/plugins/keyCodePlugin/index.ts (99%) rename packages/{core/shared => shared/core}/src/plugins/lifecyclePlugin/index.ts (100%) rename packages/{core/shared => shared/core}/src/plugins/lifecyclePlugin/interfaces.ts (100%) rename packages/{core/shared => shared/core}/src/plugins/lifecyclePlugin/utils.ts (100%) rename packages/{core/shared => shared/core}/src/plugins/modulePlugin/index.ts (100%) rename packages/{core/shared => shared/core}/src/plugins/modulePlugin/module-manager.ts (100%) rename packages/{core/shared => shared/core}/src/plugins/modulePlugin/module.ts (100%) rename packages/{core/shared => shared/core}/src/plugins/modulePlugin/utils.ts (100%) rename packages/{core/shared => shared/core}/src/plugins/multiCopyPlugin/index.ts (100%) rename packages/{core/shared => shared/core}/src/plugins/multiSocketGenerator/index.ts (100%) rename packages/{core/shared => shared/core}/src/plugins/nodeClickPlugin/index.ts (95%) rename packages/{core/shared => shared/core}/src/plugins/remotePlugin/index.ts (100%) rename packages/{core/shared => shared/core}/src/plugins/selectionPlugin/index.ts (100%) rename packages/{core/shared => shared/core}/src/plugins/socketGenerator/index.ts (100%) rename packages/{core/shared => shared/core}/src/plugins/socketOverridePlugin/index.ts (99%) rename packages/{core/shared => shared/core}/src/plugins/socketPlugin/index.ts (100%) rename packages/{core/shared => shared/core}/src/plugins/taskPlugin/index.ts (100%) rename packages/{core/shared => shared/core}/src/plugins/taskPlugin/task.ts (100%) rename packages/{core/shared => shared/core}/src/plugins/taskPlugin2/index.ts (100%) rename packages/{core/shared => shared/core}/src/plugins/taskPlugin2/task.ts (100%) rename packages/{core/shared => shared/core}/src/schemas.ts (100%) rename packages/{core/shared => shared/core}/src/sockets.ts (100%) rename packages/{core/shared => shared/core}/src/spellManager/Spell.ts (100%) rename packages/{core/shared => shared/core}/src/spellManager/SpellManager.ts (99%) rename packages/{core/shared => shared/core}/src/spellManager/SpellRunner.ts (99%) rename packages/{core/shared => shared/core}/src/spellManager/configureManager.ts (67%) rename packages/{core/shared => shared/core}/src/spellManager/graphHelpers.ts (100%) rename packages/{core/shared => shared/core}/src/spellManager/index.ts (100%) rename packages/{core/shared => shared/core}/src/spellManager/runSpell.ts (100%) rename packages/{core/shared => shared/core}/src/state/api/api.ts (96%) rename packages/{core/shared => shared/core}/src/state/api/spells.ts (99%) rename packages/{core/shared => shared/core}/src/state/globalConfig.ts (88%) rename packages/{core/shared => shared/core}/src/state/hooks.ts (100%) rename packages/{core/shared => shared/core}/src/state/localState.ts (91%) rename packages/{core/shared => shared/core}/src/state/preferences.ts (100%) rename packages/{core/shared => shared/core}/src/state/store.ts (100%) rename packages/{core/shared => shared/core}/src/state/tabs.ts (100%) rename packages/{core/shared => shared/core}/src/types.ts (100%) rename packages/{core/shared => shared/core}/src/utils/SpellError.ts (99%) rename packages/{core/shared => shared/core}/src/utils/getSpell.ts (100%) create mode 100644 packages/shared/core/src/utils/index.ts rename packages/{core/shared => shared/core}/src/utils/runSpell.ts (100%) rename packages/{core/shared => shared/core}/src/vite-env.d.ts (100%) create mode 100644 packages/shared/core/test/jest-import-meta-env.ts rename packages/{core/shared => shared/core}/test/nodes/index.test.ts (98%) rename packages/{core/shared => shared/core}/test/nodes/utility/Echo.result.json (93%) create mode 100644 packages/shared/core/test/nodes/utility/Echo.spell.json rename packages/{core/shared => shared/core}/test/nodes/utility/Echo.test.ts (99%) rename packages/{core/shared => shared/core}/test/nodes/utility/Template.spell.json (100%) rename packages/{core/shared => shared/core}/test/nodes/utility/Template.test.ts (98%) rename packages/{core/shared => shared/core}/test/utils/runSpell.ts (97%) rename packages/{core/shared => shared/core}/test/utils/spellHandler.ts (95%) rename packages/{core/shared => shared/core}/tsconfig.json (100%) rename packages/{core/shared => shared/core}/tsconfig.lib.json (100%) rename packages/{core/shared => shared/core}/tsconfig.spec.json (100%) rename packages/{core/shared => shared/core}/vite.config.ts (95%) diff --git a/apps/agent/project.json b/apps/agent/project.json index d54d37f91b..19ecc88793 100644 --- a/apps/agent/project.json +++ b/apps/agent/project.json @@ -4,8 +4,8 @@ "sourceRoot": "apps/agent/src", "projectType": "application", "implicitDependencies": [ - "@magickml/server-core", - "@magickml/core", + "server-core", + "shared-core", "server-agents", "@magickml/plugin-*" ], diff --git a/apps/agent/src/index.ts b/apps/agent/src/index.ts index fdb846da19..800799a749 100644 --- a/apps/agent/src/index.ts +++ b/apps/agent/src/index.ts @@ -6,8 +6,8 @@ */ import { AgentManager } from 'server/agents' -import { app, initApp } from '@magickml/server-core' -import { initLogger, getLogger } from '@magickml/core' +import { app, initApp } from 'server/core' +import { initLogger, getLogger } from 'shared/core' import 'regenerator-runtime/runtime' import pluginExports from './plugins' import { PRODUCTION, DONT_CRASH_ON_ERROR } from 'shared/config' diff --git a/apps/agent/test/app.test.ts b/apps/agent/test/app.test.ts index 59c3b180ed..68a0ee6f1a 100644 --- a/apps/agent/test/app.test.ts +++ b/apps/agent/test/app.test.ts @@ -1,7 +1,7 @@ // For more information about this file see https://dove.feathersjs.com/guides/cli/app.test.html import assert from 'assert' import axios from 'axios' -import { app } from '@magickml/server-core' +import { app } from 'server/core' const port = app.get('port') const appUrl = `http://${app.get('host')}:${port}` @@ -16,7 +16,7 @@ describe('Feathers application tests', () => { it('shows a 404 JSON error', async () => { try { await axios.get(`${appUrl}/path/to/nowhere`, { - responseType: 'json', + responseType: 'json' }) assert.fail('should never get here') } catch (error: any) { diff --git a/apps/client/project.json b/apps/client/project.json index 5a0de8c101..d25d6caa59 100644 --- a/apps/client/project.json +++ b/apps/client/project.json @@ -3,7 +3,7 @@ "$schema": "../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "apps/client/src", "projectType": "application", - "implicitDependencies": ["client-editor", "@magickml/core"], + "implicitDependencies": ["client-editor", "shared-core"], "targets": { "build": { "executor": "@nx/vite:build", diff --git a/apps/client/src/main.tsx b/apps/client/src/main.tsx index 27d8c7297a..b851f22a65 100644 --- a/apps/client/src/main.tsx +++ b/apps/client/src/main.tsx @@ -12,7 +12,7 @@ import { STANDALONE, } from 'shared/config' import { PostHogProvider } from 'posthog-js/react' -import { initLogger, getLogger } from '@magickml/core' +import { initLogger, getLogger } from 'shared/core' import plugins from './plugins' diff --git a/apps/cloud-agent-manager/src/main.ts b/apps/cloud-agent-manager/src/main.ts index 990dde3d14..a5700a36c4 100644 --- a/apps/cloud-agent-manager/src/main.ts +++ b/apps/cloud-agent-manager/src/main.ts @@ -2,8 +2,8 @@ import { CloudAgentManager, FeathersSyncReporter, } from 'server/cloud-agent-manager' -import { initLogger, getLogger } from '@magickml/core' -import { app, BullQueue, initApp } from '@magickml/server-core' +import { initLogger, getLogger } from 'shared/core' +import { app, BullQueue, initApp } from 'server/core' import { DONT_CRASH_ON_ERROR, PRODUCTION } from 'shared/config' import { initAgentCommander } from 'server/agents' import { getPinoTransport } from '@hyperdx/node-opentelemetry' diff --git a/apps/cloud-agent-worker/src/main.ts b/apps/cloud-agent-worker/src/main.ts index 8e26e99c22..828d4f385e 100644 --- a/apps/cloud-agent-worker/src/main.ts +++ b/apps/cloud-agent-worker/src/main.ts @@ -1,6 +1,6 @@ import { CloudAgentWorker } from 'server/cloud-agent-worker' -import { initLogger, getLogger } from '@magickml/core' -import { initApp } from '@magickml/server-core' +import { initLogger, getLogger } from 'shared/core' +import { initApp } from 'server/core' import pluginExports from './plugins' import { initAgentCommander } from 'server/agents' import { DONT_CRASH_ON_ERROR, PRODUCTION } from 'shared/config' diff --git a/apps/server/project.json b/apps/server/project.json index 142fc4ce3d..f4100fc4ac 100644 --- a/apps/server/project.json +++ b/apps/server/project.json @@ -4,8 +4,8 @@ "sourceRoot": "apps/server/src", "projectType": "application", "implicitDependencies": [ - "@magickml/server-core", - "@magickml/core", + "server-core", + "shared-core", "@magickml/plugin-*" ], "targets": { diff --git a/apps/server/src/index.ts b/apps/server/src/index.ts index bbabe4d4f0..8ffcb2b8d9 100644 --- a/apps/server/src/index.ts +++ b/apps/server/src/index.ts @@ -5,19 +5,9 @@ import cors from '@koa/cors' import Router from '@koa/router' -import { pluginManager } from '@magickml/core' -import { - apis, - initApp, - app, - Handler, - initFileServer, - Method, - Middleware, - Route, - spells -} from '@magickml/server-core' -import { initLogger, getLogger } from '@magickml/core' +import { pluginManager } from 'shared/core' +import { apis, initApp, app, Handler, initFileServer, Method, Middleware, Route, spells } from 'server/core' +import { initLogger, getLogger } from 'shared/core' import { Context } from 'koa' import koaBody from 'koa-body' import compose from 'koa-compose' diff --git a/packages/client/core/src/components/Drawer/AgentMenu.tsx b/packages/client/core/src/components/Drawer/AgentMenu.tsx index e86bf31c64..15b104f86f 100644 --- a/packages/client/core/src/components/Drawer/AgentMenu.tsx +++ b/packages/client/core/src/components/Drawer/AgentMenu.tsx @@ -28,7 +28,7 @@ import { useFeathers } from '../../providers/FeathersProvider' import { useSpellList } from '../../../../../plugins/avatar/client/src/hooks/useSpellList' import { useTreeData } from '../../../../client/src/contexts/TreeDataProvider' import NewMenuBar from '../../../../../editor/src/components/MenuBar/newMenuBar' -import { AgentInterface, SpellInterface } from '@magickml/core' +import { AgentInterface, SpellInterface } from 'shared/core' import { setCurrentAgentId } from 'client/state' import { useTabLayout } from '../../../../../editor/src/contexts/TabProvider' diff --git a/packages/client/core/src/components/Drawer/CustomNode.tsx b/packages/client/core/src/components/Drawer/CustomNode.tsx index 59bd380687..779df51e0f 100644 --- a/packages/client/core/src/components/Drawer/CustomNode.tsx +++ b/packages/client/core/src/components/Drawer/CustomNode.tsx @@ -19,7 +19,7 @@ import { selectAllTabs, spellApi, activeTabSelector, -} from '@magickml/core' +} from 'shared/core' import { useDispatch, useSelector } from 'react-redux' import { useSnackbar } from 'notistack' diff --git a/packages/client/core/src/components/Drawer/Newsidebar/index.tsx b/packages/client/core/src/components/Drawer/Newsidebar/index.tsx index 497993556c..fe4efe8e43 100644 --- a/packages/client/core/src/components/Drawer/Newsidebar/index.tsx +++ b/packages/client/core/src/components/Drawer/Newsidebar/index.tsx @@ -1,5 +1,5 @@ // DOCUMENTED -import { ClientPluginManager, pluginManager } from '@magickml/core' +import { ClientPluginManager, pluginManager } from 'shared/core' import BoltIcon from '@mui/icons-material/Bolt' import SettingsIcon from '@mui/icons-material/Settings' import StorageIcon from '@mui/icons-material/Storage' diff --git a/packages/client/core/src/components/Drawer/OldSidebar/index.tsx b/packages/client/core/src/components/Drawer/OldSidebar/index.tsx index adda6cb640..0c955c61f0 100644 --- a/packages/client/core/src/components/Drawer/OldSidebar/index.tsx +++ b/packages/client/core/src/components/Drawer/OldSidebar/index.tsx @@ -1,5 +1,5 @@ // DOCUMENTED -import { ClientPluginManager, pluginManager } from '@magickml/core' +import { ClientPluginManager, pluginManager } from 'shared/core' import AppsIcon from '@mui/icons-material/Apps' import ArticleIcon from '@mui/icons-material/Article' import AutoFixHighIcon from '@mui/icons-material/AutoFixHigh' diff --git a/packages/client/core/src/components/Drawer/ProjectWindow/index.tsx b/packages/client/core/src/components/Drawer/ProjectWindow/index.tsx index 20690bfa75..4ff21ff8ba 100644 --- a/packages/client/core/src/components/Drawer/ProjectWindow/index.tsx +++ b/packages/client/core/src/components/Drawer/ProjectWindow/index.tsx @@ -1,7 +1,7 @@ // DOCUMENTED /** @module ProjectWindow */ -import { SpellInterface } from '@magickml/core' +import { SpellInterface } from 'shared/core' import { API_ROOT_URL, PRODUCTION } from 'shared/config' import { Apps, diff --git a/packages/client/core/src/index.ts b/packages/client/core/src/index.ts index 23a37c52c6..2387c52660 100644 --- a/packages/client/core/src/index.ts +++ b/packages/client/core/src/index.ts @@ -4,7 +4,7 @@ * @module optimizedClientCore */ -import { ClientPluginManager, pluginManager } from '@magickml/core' +import { ClientPluginManager, pluginManager } from 'shared/core' import defaultTemplates from './templates' export * from './components' diff --git a/packages/client/core/src/providers/FeathersProvider.tsx b/packages/client/core/src/providers/FeathersProvider.tsx index 27dc0c1ec9..b24105865b 100644 --- a/packages/client/core/src/providers/FeathersProvider.tsx +++ b/packages/client/core/src/providers/FeathersProvider.tsx @@ -6,7 +6,7 @@ import { } from '@feathersjs/feathers' import type { SocketService } from '@feathersjs/socketio-client' import socketio from '@feathersjs/socketio-client' -import { getLogger, SpellInterface } from '@magickml/core' +import { getLogger, SpellInterface } from 'shared/core' import { createContext, useContext, useEffect, useState } from 'react' import io from 'socket.io-client' import { useConfig } from './ConfigProvider' diff --git a/packages/client/core/src/providers/PubSubProvider.tsx b/packages/client/core/src/providers/PubSubProvider.tsx index bab5713bea..88e06992c3 100644 --- a/packages/client/core/src/providers/PubSubProvider.tsx +++ b/packages/client/core/src/providers/PubSubProvider.tsx @@ -1,7 +1,7 @@ // DOCUMENTED // Import required modules -import { PubSubContext, PubSubData, PubSubEvents } from '@magickml/core' +import { PubSubContext, PubSubData, PubSubEvents } from 'shared/core' import PubSub from 'pubsub-js' import { createContext, useContext, useEffect } from 'react' import { useFeathers } from './FeathersProvider' diff --git a/packages/client/editor/project.json b/packages/client/editor/project.json index 3fd95b0d76..7f0235779f 100644 --- a/packages/client/editor/project.json +++ b/packages/client/editor/project.json @@ -3,7 +3,7 @@ "$schema": "../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/client/editor/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "tags": [], "targets": { "lint": { diff --git a/packages/client/editor/src/DataControls/DataControls.tsx b/packages/client/editor/src/DataControls/DataControls.tsx index c7c996d275..efdd5154c0 100644 --- a/packages/client/editor/src/DataControls/DataControls.tsx +++ b/packages/client/editor/src/DataControls/DataControls.tsx @@ -13,7 +13,7 @@ import PlaytestControl from './PlaytestControl' import SwitchControl from './SwitchControl' import SpellSelect from './SpellSelect' import CheckBoxControl from './CheckBox' -import { ControlData } from '@magickml/core' +import { ControlData } from 'shared/core' import { Tooltip } from '@mui/material' /** diff --git a/packages/client/editor/src/DataControls/SpellSelect.tsx b/packages/client/editor/src/DataControls/SpellSelect.tsx index 7f74404f09..79a4efbf05 100644 --- a/packages/client/editor/src/DataControls/SpellSelect.tsx +++ b/packages/client/editor/src/DataControls/SpellSelect.tsx @@ -1,6 +1,6 @@ // DOCUMENTED import { Select } from 'client/core' -import { GraphData } from '@magickml/core' +import { GraphData } from 'shared/core' import { getTemplates } from 'client/core' import md5 from 'md5' import { useSnackbar } from 'notistack' diff --git a/packages/client/editor/src/components/EventHandler.tsx b/packages/client/editor/src/components/EventHandler.tsx index a259a8e94e..7b3b9c07ca 100644 --- a/packages/client/editor/src/components/EventHandler.tsx +++ b/packages/client/editor/src/components/EventHandler.tsx @@ -1,7 +1,7 @@ // DOCUMENTED import { useEffect, useRef } from 'react' import { useSnackbar } from 'notistack' -import { GraphData, SpellInterface } from '@magickml/core' +import { GraphData, SpellInterface } from 'shared/core' import md5 from 'md5' diff --git a/packages/client/editor/src/components/ProjectRow.tsx b/packages/client/editor/src/components/ProjectRow.tsx index 78e02693a5..913e4ee78f 100644 --- a/packages/client/editor/src/components/ProjectRow.tsx +++ b/packages/client/editor/src/components/ProjectRow.tsx @@ -1,5 +1,5 @@ // DOCUMENTED -import { SpellInterface } from '@magickml/core' +import { SpellInterface } from 'shared/core' import { CSSProperties, useState } from 'react' import { Icon, Modal } from 'client/core' import css from '../screens/HomeScreen/homeScreen.module.css' diff --git a/packages/client/editor/src/components/Workspace.tsx b/packages/client/editor/src/components/Workspace.tsx index 92381f196b..0485d0d113 100644 --- a/packages/client/editor/src/components/Workspace.tsx +++ b/packages/client/editor/src/components/Workspace.tsx @@ -2,7 +2,7 @@ import React, { useEffect, useRef } from 'react' import { useSelector } from 'react-redux' -import { SpellInterface } from '@magickml/core' +import { SpellInterface } from 'shared/core' import { useConfig, useFeathers, usePubSub } from 'client/core' import { useEditor } from '../contexts/EditorProvider' diff --git a/packages/client/editor/src/components/Workspaces.tsx b/packages/client/editor/src/components/Workspaces.tsx index 86bb835dad..5de46a39a7 100644 --- a/packages/client/editor/src/components/Workspaces.tsx +++ b/packages/client/editor/src/components/Workspaces.tsx @@ -2,7 +2,7 @@ import { memo, useEffect } from 'react' import isEqual from 'lodash/isEqual' import WorkspaceProvider from '../contexts/WorkspaceProvider' -import { ClientPluginManager, pluginManager } from '@magickml/core' +import { ClientPluginManager, pluginManager } from 'shared/core' import Composer from './Workspace' import { Tab } from 'client/state' import Events from '../screens/EventWindow' diff --git a/packages/client/editor/src/contexts/EditorProvider.tsx b/packages/client/editor/src/contexts/EditorProvider.tsx index 562e825285..62dd0907c8 100644 --- a/packages/client/editor/src/contexts/EditorProvider.tsx +++ b/packages/client/editor/src/contexts/EditorProvider.tsx @@ -5,7 +5,7 @@ import { GraphData, MagickEditor, SpellInterface, -} from '@magickml/core' +} from 'shared/core' import React, { createContext, useContext, diff --git a/packages/client/editor/src/contexts/InspectorProvider.tsx b/packages/client/editor/src/contexts/InspectorProvider.tsx index 78a30fecc3..b08da2db39 100644 --- a/packages/client/editor/src/contexts/InspectorProvider.tsx +++ b/packages/client/editor/src/contexts/InspectorProvider.tsx @@ -1,6 +1,6 @@ // DOCUMENTED import { usePubSub } from 'client/core' -import { InspectorData, SupportedLanguages } from '@magickml/core' +import { InspectorData, SupportedLanguages } from 'shared/core' import { createContext, useContext, useEffect, useState } from 'react' /** diff --git a/packages/client/editor/src/contexts/MagickInterfaceProvider.tsx b/packages/client/editor/src/contexts/MagickInterfaceProvider.tsx index 80431a3705..97da687217 100644 --- a/packages/client/editor/src/contexts/MagickInterfaceProvider.tsx +++ b/packages/client/editor/src/contexts/MagickInterfaceProvider.tsx @@ -13,7 +13,7 @@ import { runSpellType, SpellInterface, SupportedLanguages, -} from '@magickml/core' +} from 'shared/core' import { spellApi } from 'client/state' import { createContext, useContext } from 'react' diff --git a/packages/client/editor/src/editor.ts b/packages/client/editor/src/editor.ts index 9256fc3a57..273d7ff27d 100644 --- a/packages/client/editor/src/editor.ts +++ b/packages/client/editor/src/editor.ts @@ -16,7 +16,7 @@ import { SelectionPlugin, SpellInterface, DebuggerPlugin, -} from '@magickml/core' +} from 'shared/core' import ReactRenderPlugin, { ReactRenderPluginOptions, } from './plugins/reactRenderPlugin' @@ -35,11 +35,11 @@ import { MultiCopyPlugin, NodeClickPlugin, SocketGeneratorPlugin, -} from '@magickml/core' +} from 'shared/core' import AreaPlugin from './plugins/areaPlugin' import AutoArrangePlugin from './plugins/autoArrangePlugin' -import { initSharedEngine, MagickEngine } from '@magickml/core' +import { initSharedEngine, MagickEngine } from 'shared/core' /** * Extend MagickEngine with additional properties diff --git a/packages/client/editor/src/plugins/areaPlugin/snap.ts b/packages/client/editor/src/plugins/areaPlugin/snap.ts index f5ef27315b..e4dc0bcdeb 100644 --- a/packages/client/editor/src/plugins/areaPlugin/snap.ts +++ b/packages/client/editor/src/plugins/areaPlugin/snap.ts @@ -1,5 +1,5 @@ import { PubSub, events } from 'client/core' -import { MagickEditor } from '@magickml/core' +import { MagickEditor } from 'shared/core' export class SnapGrid { editor: MagickEditor diff --git a/packages/client/editor/src/plugins/highlightPlugin/utils.ts b/packages/client/editor/src/plugins/highlightPlugin/utils.ts index d80e181329..e025353f41 100644 --- a/packages/client/editor/src/plugins/highlightPlugin/utils.ts +++ b/packages/client/editor/src/plugins/highlightPlugin/utils.ts @@ -1,4 +1,4 @@ -import { MagickEditor } from '@magickml/core' +import { MagickEditor } from 'shared/core' import { Connection } from 'shared/rete' export const removeClassFromNodeConnections = ( diff --git a/packages/client/editor/src/routes.tsx b/packages/client/editor/src/routes.tsx index 660423fddc..dbded77d60 100644 --- a/packages/client/editor/src/routes.tsx +++ b/packages/client/editor/src/routes.tsx @@ -1,5 +1,5 @@ // DOCUMENTED -import { ClientPluginManager, pluginManager } from '@magickml/core' +import { ClientPluginManager, pluginManager } from 'shared/core' import 'flexlayout-react/style/dark.css' import { Suspense } from 'react' import { Route, Routes } from 'react-router-dom' diff --git a/packages/client/editor/src/screens/Composer/index.tsx b/packages/client/editor/src/screens/Composer/index.tsx index 709d46ce2e..48d7d43c51 100644 --- a/packages/client/editor/src/screens/Composer/index.tsx +++ b/packages/client/editor/src/screens/Composer/index.tsx @@ -2,7 +2,7 @@ import React, { useEffect, useRef } from 'react' import { useSelector } from 'react-redux' -import { SpellInterface } from '@magickml/core' +import { SpellInterface } from 'shared/core' import { useConfig, useFeathers, usePubSub } from 'client/core' import { useEditor } from '../../contexts/EditorProvider' diff --git a/packages/client/editor/src/screens/DocumentWindow/DocumentTable.tsx b/packages/client/editor/src/screens/DocumentWindow/DocumentTable.tsx index f64c903fdf..c74629be59 100644 --- a/packages/client/editor/src/screens/DocumentWindow/DocumentTable.tsx +++ b/packages/client/editor/src/screens/DocumentWindow/DocumentTable.tsx @@ -1,7 +1,7 @@ // DOCUMENTED // Import statements kept as-is import { TableComponent } from 'client/core' -import { CompletionProvider, pluginManager } from '@magickml/core' +import { CompletionProvider, pluginManager } from 'shared/core' import { API_ROOT_URL } from 'shared/config' import { MoreHoriz, NewReleases, Refresh } from '@mui/icons-material' import { diff --git a/packages/client/editor/src/screens/HomeScreen/AllProjects.tsx b/packages/client/editor/src/screens/HomeScreen/AllProjects.tsx index 3bace46529..9812ca5078 100644 --- a/packages/client/editor/src/screens/HomeScreen/AllProjects.tsx +++ b/packages/client/editor/src/screens/HomeScreen/AllProjects.tsx @@ -8,7 +8,7 @@ import css from './homeScreen.module.css' import SearchIcon from '@mui/icons-material/Search' import { IconButton } from '@mui/material' import { useNavigate } from 'react-router-dom' -import { SpellInterface } from '@magickml/core' +import { SpellInterface } from 'shared/core' /** * @description AllProjects component props diff --git a/packages/client/editor/src/screens/HomeScreen/CreateNew.tsx b/packages/client/editor/src/screens/HomeScreen/CreateNew.tsx index 549e550686..c39172949d 100644 --- a/packages/client/editor/src/screens/HomeScreen/CreateNew.tsx +++ b/packages/client/editor/src/screens/HomeScreen/CreateNew.tsx @@ -1,6 +1,6 @@ // DOCUMENTED import { Button, Panel } from 'client/core' -import { GraphData } from '@magickml/core' +import { GraphData } from 'shared/core' import { getTemplates } from 'client/core' import md5 from 'md5' import { useSnackbar } from 'notistack' diff --git a/packages/client/editor/src/screens/Magick/Magick.tsx b/packages/client/editor/src/screens/Magick/Magick.tsx index da62318df1..67117f3542 100644 --- a/packages/client/editor/src/screens/Magick/Magick.tsx +++ b/packages/client/editor/src/screens/Magick/Magick.tsx @@ -6,7 +6,7 @@ import { useNavigate } from 'react-router-dom' import TabBar from '../../components/TabBar/TabBar' import Workspaces from '../../components/Workspaces' -import { ClientPluginManager, pluginManager } from '@magickml/core' +import { ClientPluginManager, pluginManager } from 'shared/core' import { RootState, activeTabIdSelector, diff --git a/packages/client/editor/src/screens/MagickV2/panels/mainPanel.tsx b/packages/client/editor/src/screens/MagickV2/panels/mainPanel.tsx index 20e4212494..ad56db5c94 100644 --- a/packages/client/editor/src/screens/MagickV2/panels/mainPanel.tsx +++ b/packages/client/editor/src/screens/MagickV2/panels/mainPanel.tsx @@ -10,7 +10,7 @@ import Requests from '../../RequestWindow' import Settings from '../../settings/SettingsWindow' import Documents from '../../DocumentWindow' import Agents from '../../agents/AgentManagerWindow' -import { ClientPluginManager, pluginManager } from '@magickml/core' +import { ClientPluginManager, pluginManager } from 'shared/core' import Composer from '../workspaces/composer' // we will move this out into the layouts package diff --git a/packages/client/editor/src/screens/MagickV2/workspaces/composer.tsx b/packages/client/editor/src/screens/MagickV2/workspaces/composer.tsx index 7320ec38c0..4e018e3f68 100644 --- a/packages/client/editor/src/screens/MagickV2/workspaces/composer.tsx +++ b/packages/client/editor/src/screens/MagickV2/workspaces/composer.tsx @@ -6,7 +6,7 @@ import { IDockviewPanelProps, } from 'dockview' import { useEffect, useRef } from 'react' -import { SpellInterface, spellApi } from '@magickml/core' +import { SpellInterface, spellApi } from 'shared/core' import WorkspaceProvider from '../../../contexts/WorkspaceProvider' import { debounce } from '../../../utils/debounce' diff --git a/packages/client/editor/src/screens/agents/AgentManagerWindow.tsx b/packages/client/editor/src/screens/agents/AgentManagerWindow.tsx index 0ff09e903e..6a4379b0ef 100644 --- a/packages/client/editor/src/screens/agents/AgentManagerWindow.tsx +++ b/packages/client/editor/src/screens/agents/AgentManagerWindow.tsx @@ -1,6 +1,6 @@ // DOCUMENTED import { LoadingScreen } from 'client/core' -import { type ClientPluginManager, pluginManager } from '@magickml/core' +import { type ClientPluginManager, pluginManager } from 'shared/core' import { DEFAULT_USER_TOKEN, PRODUCTION, STANDALONE } from 'shared/config' import { useSnackbar } from 'notistack' import { useEffect, useState } from 'react' diff --git a/packages/client/editor/src/screens/agents/AgentWindow/AgentDetails.tsx b/packages/client/editor/src/screens/agents/AgentWindow/AgentDetails.tsx index edcff93469..6ad9630986 100644 --- a/packages/client/editor/src/screens/agents/AgentWindow/AgentDetails.tsx +++ b/packages/client/editor/src/screens/agents/AgentWindow/AgentDetails.tsx @@ -1,6 +1,6 @@ // DOCUMENTED import { IconBtn, CustomizedSwitch, useFeathers } from 'client/core' -import { ClientPluginManager, pluginManager } from '@magickml/core' +import { ClientPluginManager, pluginManager } from 'shared/core' import { Close, Done, Edit } from '@mui/icons-material' import { Avatar, Button, Input, Typography, Tooltip } from '@mui/material' diff --git a/packages/client/editor/src/screens/settings/SettingsWindow.tsx b/packages/client/editor/src/screens/settings/SettingsWindow.tsx index a449647ccb..2bcac57eb1 100644 --- a/packages/client/editor/src/screens/settings/SettingsWindow.tsx +++ b/packages/client/editor/src/screens/settings/SettingsWindow.tsx @@ -1,5 +1,5 @@ import { Tooltip } from 'client/core' -import { pluginManager } from '@magickml/core' +import { pluginManager } from 'shared/core' import { Clear } from '@mui/icons-material/' import { IconButton, Input, Button } from '@mui/material' import { useState } from 'react' diff --git a/packages/client/editor/src/types/index.ts b/packages/client/editor/src/types/index.ts index 0e221ef5af..70d92444f0 100644 --- a/packages/client/editor/src/types/index.ts +++ b/packages/client/editor/src/types/index.ts @@ -1,4 +1,4 @@ -import { SpellInterface } from '@magickml/core' +import { SpellInterface } from 'shared/core' export interface Spells { data: SpellInterface[] diff --git a/packages/core/server/.eslintrc.json b/packages/core/server/.eslintrc.json deleted file mode 100644 index 19a99c9d96..0000000000 --- a/packages/core/server/.eslintrc.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "extends": [ - "../../../.eslintrc.json" - ], - "ignorePatterns": [ - "!**/*" - ], - "overrides": [ - { - "files": [ - "*.ts", - "*.tsx", - "*.js", - "*.jsx" - ], - "rules": {} - }, - { - "files": [ - "*.ts", - "*.tsx" - ], - "rules": {} - }, - { - "files": [ - "*.js", - "*.jsx" - ], - "rules": {} - } - ] -} diff --git a/packages/core/server/src/communication/PubSub/PubSub.ts b/packages/core/server/src/communication/PubSub/PubSub.ts deleted file mode 100644 index 0ae04f3d7f..0000000000 --- a/packages/core/server/src/communication/PubSub/PubSub.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { EventEmitter } from 'events' - -export abstract class PubSub extends EventEmitter { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - async publish(channel: string, message: string): Promise { - throw new Error('Method not implemented.'); - } - - // eslint-disable-next-line @typescript-eslint/no-unused-vars - async subscribe(channel: string, callback: Function): Promise { - throw new Error('Method not implemented.'); - } - - // eslint-disable-next-line @typescript-eslint/no-unused-vars - async unsubscribe(channel: string): Promise { - throw new Error('Method not implemented.'); - } - - // eslint-disable-next-line @typescript-eslint/no-unused-vars - async patternSubscribe(pattern: string, callback: Function): Promise { - throw new Error('Method not implemented.'); - } -} diff --git a/packages/core/server/src/communication/Workers/Worker.ts b/packages/core/server/src/communication/Workers/Worker.ts deleted file mode 100644 index 5e09c19241..0000000000 --- a/packages/core/server/src/communication/Workers/Worker.ts +++ /dev/null @@ -1,6 +0,0 @@ -export abstract class Worker { - constructor() {} - - // eslint-disable-next-line @typescript-eslint/no-unused-vars - initialize(queueName: string, callback: (job: any) => Promise): void {} -} diff --git a/packages/core/shared/src/dataControls/CustomDropdown.tsx b/packages/core/shared/src/dataControls/CustomDropdown.tsx deleted file mode 100644 index 70ef958a2a..0000000000 --- a/packages/core/shared/src/dataControls/CustomDropdown.tsx +++ /dev/null @@ -1,29 +0,0 @@ -// DOCUMENTED -/** - * A dropdown component that can be customized with a title and options. - * @param {object} props - The props object contains a title string and an array of options. - * @param {string} props.title - The title of the dropdown. - * @param {string[]} props.data - The options to be displayed in the dropdown. - */ -export default function CustomDropdown(props: { title: string, data: string[] }): React.ReactElement { - return ( -
-
-
- {props.title} -
-
-
    - {props.data.map((option, index) => ( -
  • {option}
  • - ))} -
-
-
-
- ) -} - -/* - We disable @typescript-eslint/no-unused-vars because `props` is actually used in this Component -*/ \ No newline at end of file diff --git a/packages/core/shared/src/plugins/historyPlugin/index.ts b/packages/core/shared/src/plugins/historyPlugin/index.ts deleted file mode 100644 index 15795fadf6..0000000000 --- a/packages/core/shared/src/plugins/historyPlugin/index.ts +++ /dev/null @@ -1,82 +0,0 @@ -// DOCUMENTED -import Act from './action'; -import { - AddConnectionAction, - RemoveConnectionAction, -} from './actions/connection'; -import { AddNodeAction, DragNodeAction, RemoveNodeAction } from './actions/node'; -import History from './history'; - -/** - * Tracks node events and adds corresponding actions to history - * @param {object} editor - The editor instance - * @param {History} history - The history instance - */ -function trackNodes(editor, history) { - editor.on('nodecreated', (node) => history.add(new AddNodeAction(editor, node))); - editor.on('noderemoved', (node) =>history.add(new RemoveNodeAction(editor, node))); - editor.on('nodetranslated', ({ node, prev }) => { - if (history.last instanceof DragNodeAction && history.last.node === node) { - history.last.update(node); - } else { - history.add(new DragNodeAction(editor, node, prev)); - } - }); -} - -/** - * Tracks connection events and adds corresponding actions to history - * @param {object} editor - The editor instance - * @param {History} history - The history instance - */ -function trackConnections(editor, history) { - editor.on('connectioncreated', (c) => history.add(new AddConnectionAction(editor, c))); - editor.on('connectionremoved', (c) => history.add(new RemoveConnectionAction(editor, c))); -} - -/** - * Installs the history plugin on the editor - * @param {object} editor - The editor instance - * @param {{keyboard: boolean}} options - Configuration options for the plugin - */ -function install(editor, {keyboard = true}) { - editor.bind('undo'); - editor.bind('redo'); - editor.bind('addhistory'); - - const history = new History(); - - editor.on('undo', () => history.undo()); - editor.on('redo', () => history.redo()); - editor.on('addhistory', (action) => history.add(action)); - editor.on('clear', () => { - history.clear(); - }); - - if (keyboard) { - document.addEventListener('keydown', (e) => { - if (!e.ctrlKey) return; - switch (e.code) { - case 'KeyZ': - editor.trigger('undo'); - break; - case 'KeyY': - editor.trigger('redo'); - break; - default: - } - }); - } - - trackNodes(editor, history); - trackConnections(editor, history); -} - -export const Action = Act; - -const defaultExport = { - name: 'history', - install, -}; - -export default defaultExport; \ No newline at end of file diff --git a/packages/core/shared/src/utils/index.ts b/packages/core/shared/src/utils/index.ts deleted file mode 100644 index 0594d8683f..0000000000 --- a/packages/core/shared/src/utils/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './runSpell'; -export * from './getSpell'; -export * from './SpellError'; \ No newline at end of file diff --git a/packages/core/shared/test/jest-import-meta-env.ts b/packages/core/shared/test/jest-import-meta-env.ts deleted file mode 100644 index 192ce059fd..0000000000 --- a/packages/core/shared/test/jest-import-meta-env.ts +++ /dev/null @@ -1,5 +0,0 @@ -// DOCUMENTED -/** - * An empty importMetaEnv object. - */ -export const importMetaEnv = ({} as any); // Turn off ESLint rule for explicit any usage. \ No newline at end of file diff --git a/packages/core/shared/test/nodes/utility/Echo.spell.json b/packages/core/shared/test/nodes/utility/Echo.spell.json deleted file mode 100644 index 62dc02159b..0000000000 --- a/packages/core/shared/test/nodes/utility/Echo.spell.json +++ /dev/null @@ -1,247 +0,0 @@ -{ - "id": "183dd904-3d9f-4275-979f-a0fede13559b", - "name": "Echo", - "projectId": "bb1b3d24-84e0-424e-b4f1-57603f307a89", - "hash": "d0a78e00349429107d0f9c8557fa2130", - "createdAt": "1679459565853", - "updatedAt": "1679460534365", - "graph": { - "id": "demo@0.1.0", - "nodes": { - "234": { - "id": 234, - "data": { - "success": false - }, - "inputs": { - "trigger": { - "connections": [ - { - "node": 519, - "output": "trigger", - "data": { - "hello": "hello" - } - } - ] - }, - "string": { - "connections": [ - { - "node": 519, - "output": "content", - "data": { - "hello": "hello" - } - } - ] - } - }, - "outputs": { - "trigger": { - "connections": [ - { - "node": 521, - "input": "trigger", - "data": { - "hello": "hello" - } - } - ] - }, - "output": { - "connections": [ - { - "node": 521, - "input": "input", - "data": { - "hello": "hello" - } - } - ] - } - }, - "position": [ - -125.16726300656339, - -435.0319261111516 - ], - "name": "Echo" - }, - "519": { - "id": 519, - "data": { - "socketKey": "39e93504-3dc1-4919-9080-7bf8a7f69cf0", - "success": false - }, - "inputs": { - "trigger": { - "connections": [ - { - "node": 520, - "output": "trigger", - "data": { - "hello": "hello" - } - } - ] - }, - "event": { - "connections": [ - { - "node": 520, - "output": "output", - "data": { - "hello": "hello" - } - } - ] - } - }, - "outputs": { - "trigger": { - "connections": [ - { - "node": 234, - "input": "trigger", - "data": { - "hello": "hello" - } - } - ] - }, - "agentId": { - "connections": [] - }, - "content": { - "connections": [ - { - "node": 234, - "input": "string", - "data": { - "hello": "hello" - } - } - ] - }, - "client": { - "connections": [] - }, - "channel": { - "connections": [] - }, - "channelType": { - "connections": [] - }, - "entities": { - "connections": [] - }, - "projectId": { - "connections": [] - }, - "observer": { - "connections": [] - }, - "sender": { - "connections": [] - } - }, - "position": [ - -431.6445158203237, - -436.9747968225492 - ], - "name": "Event Destructure" - }, - "520": { - "id": 520, - "data": { - "isInput": true, - "name": "Input - Default", - "useDefault": false, - "defaultValue": "Hello world", - "socketKey": "c6582114-e0fb-4c6c-baab-b48934e07c90", - "success": false - }, - "inputs": {}, - "outputs": { - "trigger": { - "connections": [ - { - "node": 519, - "input": "trigger", - "data": { - "hello": "hello" - } - } - ] - }, - "output": { - "connections": [ - { - "node": 519, - "input": "event", - "data": { - "hello": "hello" - } - } - ] - } - }, - "position": [ - -731.2978535902487, - -434.48770700846876 - ], - "name": "Input" - }, - "521": { - "id": 521, - "data": { - "isOutput": true, - "name": "Output - Default", - "socketKey": "f4d76f20-fee1-4ee3-a551-4b26ff7b81ec", - "success": false - }, - "inputs": { - "trigger": { - "connections": [ - { - "node": 234, - "output": "trigger", - "data": { - "hello": "hello" - } - } - ] - }, - "input": { - "connections": [ - { - "node": 234, - "output": "output", - "data": { - "hello": "hello" - } - } - ] - }, - "event": { - "connections": [] - } - }, - "outputs": { - "trigger": { - "connections": [] - }, - "output": { - "connections": [] - } - }, - "position": [ - 177.2501870715851, - -434.47957489745335 - ], - "name": "Output" - } - }, - "comments": [] - } -} \ No newline at end of file diff --git a/packages/plugins/anthropic/client/project.json b/packages/plugins/anthropic/client/project.json index 30ed3ff2f7..c0c6537d3a 100644 --- a/packages/plugins/anthropic/client/project.json +++ b/packages/plugins/anthropic/client/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/anthropic/client/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/anthropic/client/src/index.ts b/packages/plugins/anthropic/client/src/index.ts index 22c6eb80d5..02dccd1630 100644 --- a/packages/plugins/anthropic/client/src/index.ts +++ b/packages/plugins/anthropic/client/src/index.ts @@ -3,7 +3,7 @@ * A plugin for interacting with anthropic's API. * @class */ -import { ClientPlugin, InputControl } from '@magickml/core' +import { ClientPlugin, InputControl } from 'shared/core' import shared from '@magickml/plugin-anthropic-shared' // Importing shared variables from plugin-anthropic-shared module diff --git a/packages/plugins/anthropic/server/project.json b/packages/plugins/anthropic/server/project.json index a3e4251117..de951ea68f 100644 --- a/packages/plugins/anthropic/server/project.json +++ b/packages/plugins/anthropic/server/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "plugin-anthropic/server/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/anthropic/server/src/functions/makeChatCompletion.ts b/packages/plugins/anthropic/server/src/functions/makeChatCompletion.ts index 885703ec50..7bb3d0fcff 100644 --- a/packages/plugins/anthropic/server/src/functions/makeChatCompletion.ts +++ b/packages/plugins/anthropic/server/src/functions/makeChatCompletion.ts @@ -1,5 +1,5 @@ // UNDOCUMENTED -import { CompletionHandlerInputData, saveRequest } from '@magickml/core' +import { CompletionHandlerInputData, saveRequest } from 'shared/core' import Anthropic from '@anthropic-ai/sdk' import { countTokens } from '@anthropic-ai/tokenizer' diff --git a/packages/plugins/anthropic/server/src/index.ts b/packages/plugins/anthropic/server/src/index.ts index 818d65c94d..1dc4066530 100644 --- a/packages/plugins/anthropic/server/src/index.ts +++ b/packages/plugins/anthropic/server/src/index.ts @@ -9,7 +9,7 @@ * @packageDocumentation */ -import { ServerPlugin } from '@magickml/core' +import { ServerPlugin } from 'shared/core' import shared from '@magickml/plugin-anthropic-shared' import { makeChatCompletion } from './functions' diff --git a/packages/plugins/anthropic/shared/project.json b/packages/plugins/anthropic/shared/project.json index c811b08f62..e938b50058 100644 --- a/packages/plugins/anthropic/shared/project.json +++ b/packages/plugins/anthropic/shared/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/anthropic/shared/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/anthropic/shared/src/index.ts b/packages/plugins/anthropic/shared/src/index.ts index 9cb7f69279..aa73179169 100644 --- a/packages/plugins/anthropic/shared/src/index.ts +++ b/packages/plugins/anthropic/shared/src/index.ts @@ -4,7 +4,7 @@ import { CompletionProvider, PluginSecret, stringSocket, -} from '@magickml/core' +} from 'shared/core' /** * An array of PluginSecret objects containing information about API key secrets. diff --git a/packages/plugins/avatar/client/project.json b/packages/plugins/avatar/client/project.json index f7d58e8aa2..9d0965aa91 100644 --- a/packages/plugins/avatar/client/project.json +++ b/packages/plugins/avatar/client/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/avatar/client/src", "projectType": "library", - "implicitDependencies": ["@magickml/core", "client-core"], + "implicitDependencies": ["shared-core", "client-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/avatar/client/src/index.ts b/packages/plugins/avatar/client/src/index.ts index 30c849f0b4..13229ab630 100644 --- a/packages/plugins/avatar/client/src/index.ts +++ b/packages/plugins/avatar/client/src/index.ts @@ -8,7 +8,7 @@ import App from './App' * @module AvatarPlugin */ -import { ClientPlugin } from '@magickml/core' +import { ClientPlugin } from 'shared/core' /** * Represents a new avatar system. @@ -23,7 +23,7 @@ const AvatarPlugin = new ClientPlugin({ path: '/avatar', icon: AvatarIcon, text: 'Avatar', - tooltip: 'Chat with your agents embodied with a 3D avatar' + tooltip: 'Chat with your agents embodied with a 3D avatar', }, ], clientRoutes: [ diff --git a/packages/plugins/banana/client/project.json b/packages/plugins/banana/client/project.json index c40eb9af0d..25906db200 100644 --- a/packages/plugins/banana/client/project.json +++ b/packages/plugins/banana/client/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/banana/client/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/banana/client/src/index.ts b/packages/plugins/banana/client/src/index.ts index 80d3025b0b..0c8c960b0c 100644 --- a/packages/plugins/banana/client/src/index.ts +++ b/packages/plugins/banana/client/src/index.ts @@ -1,9 +1,9 @@ -// DOCUMENTED +// DOCUMENTED /** * A plugin class that extends the `ClientPlugin` and contains the `name` and `secrets`. * `secrets` is an array containing objects that contain names, keys, global URLs, and get URLs. */ -import { ClientPlugin } from '@magickml/core' +import { ClientPlugin } from 'shared/core' const BananaPlugin = new ClientPlugin({ name: 'BananaPlugin', @@ -13,9 +13,9 @@ const BananaPlugin = new ClientPlugin({ name: 'Banana API Key', key: 'banana_api_key', global: true, - getUrl: 'https://app.banana.dev/' + getUrl: 'https://app.banana.dev/', }, ], }) -export default BananaPlugin \ No newline at end of file +export default BananaPlugin diff --git a/packages/plugins/banana/server/project.json b/packages/plugins/banana/server/project.json index aa09c0d9ce..dec101cb87 100644 --- a/packages/plugins/banana/server/project.json +++ b/packages/plugins/banana/server/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "plugin-banana/server/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/banana/server/src/index.ts b/packages/plugins/banana/server/src/index.ts index c31b3f0780..3ce6d7277e 100644 --- a/packages/plugins/banana/server/src/index.ts +++ b/packages/plugins/banana/server/src/index.ts @@ -1,17 +1,19 @@ -// DOCUMENTED +// DOCUMENTED /** * A ServerPlugin that adds the BananaPlugin with a single secret - API key. */ -import { ServerPlugin } from '@magickml/core'; +import { ServerPlugin } from 'shared/core' const BananaPlugin = new ServerPlugin({ - name: 'BananaPlugin', - // The list of secrets required by the 'BananaPlugin'. - secrets: [{ - name: 'Banana API Key', - key: 'banana_api_key', - global: true, - }] -}); + name: 'BananaPlugin', + // The list of secrets required by the 'BananaPlugin'. + secrets: [ + { + name: 'Banana API Key', + key: 'banana_api_key', + global: true, + }, + ], +}) -export default BananaPlugin; \ No newline at end of file +export default BananaPlugin diff --git a/packages/plugins/bluesky/client/project.json b/packages/plugins/bluesky/client/project.json index 44fec269ed..7ba7905584 100644 --- a/packages/plugins/bluesky/client/project.json +++ b/packages/plugins/bluesky/client/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/bluesky/client/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/bluesky/client/src/index.ts b/packages/plugins/bluesky/client/src/index.ts index e5ca9721f6..73f5dccce2 100644 --- a/packages/plugins/bluesky/client/src/index.ts +++ b/packages/plugins/bluesky/client/src/index.ts @@ -1,4 +1,4 @@ -import { ClientPlugin, eventSocket, triggerSocket } from '@magickml/core' +import { ClientPlugin, eventSocket, triggerSocket } from 'shared/core' import { BlueskyAgentWindow } from './components/agent.component' const inputSockets = [ @@ -27,12 +27,12 @@ const BlueskyPlugin = new ClientPlugin({ agentComponents: [BlueskyAgentWindow], inputTypes: [ { name: 'Bluesky (Reply)', sockets: inputSockets }, - { name: 'Bluesky (Mention)', sockets: inputSockets } + { name: 'Bluesky (Mention)', sockets: inputSockets }, ], outputTypes: [ { name: 'Bluesky (Reply)', sockets: outputSockets }, { name: 'Bluesky (Mention)', sockets: outputSockets }, - { name: 'Bluesky (Post)', sockets: outputSockets } + { name: 'Bluesky (Post)', sockets: outputSockets }, ], secrets: [ { diff --git a/packages/plugins/bluesky/server/project.json b/packages/plugins/bluesky/server/project.json index 6e3d1bd622..a7ffa715d2 100644 --- a/packages/plugins/bluesky/server/project.json +++ b/packages/plugins/bluesky/server/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "plugin-bluesky/server/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/bluesky/server/src/connectors/bluesky.ts b/packages/plugins/bluesky/server/src/connectors/bluesky.ts index 690f8ed372..f88d60cc24 100644 --- a/packages/plugins/bluesky/server/src/connectors/bluesky.ts +++ b/packages/plugins/bluesky/server/src/connectors/bluesky.ts @@ -1,5 +1,5 @@ import { BskyAgent, AppBskyNotificationGetUnreadCount } from '@atproto/api' -import { app } from '@magickml/server-core' +import { app } from 'server/core' export class BlueskyConnector { declare bskyAgent: BskyAgent diff --git a/packages/plugins/bluesky/server/src/index.ts b/packages/plugins/bluesky/server/src/index.ts index 53b1512f6f..4acbcf9014 100644 --- a/packages/plugins/bluesky/server/src/index.ts +++ b/packages/plugins/bluesky/server/src/index.ts @@ -1,4 +1,4 @@ -import { eventSocket, ServerPlugin, triggerSocket } from '@magickml/core' +import { eventSocket, ServerPlugin, triggerSocket } from 'shared/core' let BlueskyConnector = null as any // dynamically import { BlueskyConnector } from './connectors/bluesky' if we are in node.js using esm syntax diff --git a/packages/plugins/database/client/project.json b/packages/plugins/database/client/project.json index e916867d62..58cebe81b3 100644 --- a/packages/plugins/database/client/project.json +++ b/packages/plugins/database/client/project.json @@ -3,7 +3,7 @@ "$schema": "../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/database/client/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/database/client/src/index.ts b/packages/plugins/database/client/src/index.ts index 026cc09b3c..56abca37a4 100644 --- a/packages/plugins/database/client/src/index.ts +++ b/packages/plugins/database/client/src/index.ts @@ -3,7 +3,7 @@ * A plugin for interacting with database's API. * @class */ -import { ClientPlugin, InputControl } from '@magickml/core' +import { ClientPlugin, InputControl } from 'shared/core' import shared from '@magickml/plugin-database-shared' // Importing shared variables from plugin-database-shared module @@ -18,7 +18,7 @@ const selectControls = [ name: 'Table', icon: 'database', defaultValue: '', - tooltip: 'Enter table here' + tooltip: 'Enter table here', }, ] @@ -29,7 +29,7 @@ const insertControls = [ name: 'Table', icon: 'database', defaultValue: '', - tooltip: 'Enter table here' + tooltip: 'Enter table here', }, ] @@ -40,7 +40,7 @@ const updateControls = [ name: 'Table', icon: 'database', defaultValue: '', - tooltip: 'Enter table here' + tooltip: 'Enter table here', }, ] @@ -51,7 +51,7 @@ const upsertControls = [ name: 'Table', icon: 'database', defaultValue: '', - tooltip: 'Enter table here' + tooltip: 'Enter table here', }, { type: InputControl, @@ -59,7 +59,7 @@ const upsertControls = [ name: 'On Conflict', icon: 'database', defaultValue: '', - tooltip: 'Enter On conflict' + tooltip: 'Enter On conflict', }, ] @@ -70,7 +70,7 @@ const deleteControls = [ name: 'Table', icon: 'database', defaultValue: '', - tooltip: 'Enter table here' + tooltip: 'Enter table here', }, ] diff --git a/packages/plugins/database/server/project.json b/packages/plugins/database/server/project.json index b774f5078a..6520733d9d 100644 --- a/packages/plugins/database/server/project.json +++ b/packages/plugins/database/server/project.json @@ -3,7 +3,7 @@ "$schema": "../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugin/database/server/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/database/server/src/functions/delete.ts b/packages/plugins/database/server/src/functions/delete.ts index dbd7b9b438..d3d1067e8d 100644 --- a/packages/plugins/database/server/src/functions/delete.ts +++ b/packages/plugins/database/server/src/functions/delete.ts @@ -1,4 +1,4 @@ -import { CompletionHandlerInputData, saveRequest } from '@magickml/core' +import { CompletionHandlerInputData, saveRequest } from 'shared/core' import { knex } from 'knex' /** diff --git a/packages/plugins/database/server/src/functions/insert.ts b/packages/plugins/database/server/src/functions/insert.ts index cae2882ab5..3391cfc364 100644 --- a/packages/plugins/database/server/src/functions/insert.ts +++ b/packages/plugins/database/server/src/functions/insert.ts @@ -1,5 +1,5 @@ // UNDOCUMENTED -import { CompletionHandlerInputData, saveRequest } from '@magickml/core' +import { CompletionHandlerInputData, saveRequest } from 'shared/core' import { knex } from 'knex' /** diff --git a/packages/plugins/database/server/src/functions/select.ts b/packages/plugins/database/server/src/functions/select.ts index 5f0d588aab..393c04e2c7 100644 --- a/packages/plugins/database/server/src/functions/select.ts +++ b/packages/plugins/database/server/src/functions/select.ts @@ -1,5 +1,5 @@ // UNDOCUMENTED -import { CompletionHandlerInputData, saveRequest } from '@magickml/core' +import { CompletionHandlerInputData, saveRequest } from 'shared/core' import { knex } from 'knex' /** diff --git a/packages/plugins/database/server/src/functions/update.ts b/packages/plugins/database/server/src/functions/update.ts index 551b6c7606..075b532b89 100644 --- a/packages/plugins/database/server/src/functions/update.ts +++ b/packages/plugins/database/server/src/functions/update.ts @@ -1,5 +1,5 @@ // UNDOCUMENTED -import { CompletionHandlerInputData, saveRequest } from '@magickml/core' +import { CompletionHandlerInputData, saveRequest } from 'shared/core' import { knex } from 'knex' /** diff --git a/packages/plugins/database/server/src/functions/upsert.ts b/packages/plugins/database/server/src/functions/upsert.ts index c6092f5455..57d649b6d3 100644 --- a/packages/plugins/database/server/src/functions/upsert.ts +++ b/packages/plugins/database/server/src/functions/upsert.ts @@ -1,4 +1,4 @@ -import { CompletionHandlerInputData, saveRequest } from '@magickml/core' +import { CompletionHandlerInputData, saveRequest } from 'shared/core' import { knex } from 'knex' /** diff --git a/packages/plugins/database/server/src/index.ts b/packages/plugins/database/server/src/index.ts index dba267da3e..350e0c13b3 100644 --- a/packages/plugins/database/server/src/index.ts +++ b/packages/plugins/database/server/src/index.ts @@ -9,7 +9,7 @@ * @packageDocumentation */ -import { ServerPlugin } from '@magickml/core' +import { ServerPlugin } from 'shared/core' import shared from '@magickml/plugin-database-shared' import { select, deleteRow, insert, update, upsert } from './functions' diff --git a/packages/plugins/database/shared/project.json b/packages/plugins/database/shared/project.json index 801e3dde2b..70582ea8b4 100644 --- a/packages/plugins/database/shared/project.json +++ b/packages/plugins/database/shared/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/database/shared/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/database/shared/src/index.ts b/packages/plugins/database/shared/src/index.ts index 4c515e698a..e6f5dcb6ae 100644 --- a/packages/plugins/database/shared/src/index.ts +++ b/packages/plugins/database/shared/src/index.ts @@ -5,7 +5,7 @@ import { objectSocket, PluginSecret, stringSocket, -} from '@magickml/core' +} from 'shared/core' /** * An array of PluginSecret objects containing information about API key secrets. diff --git a/packages/plugins/discord/client/project.json b/packages/plugins/discord/client/project.json index 88577bd166..57c712596c 100644 --- a/packages/plugins/discord/client/project.json +++ b/packages/plugins/discord/client/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/discord/client/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/discord/client/src/index.ts b/packages/plugins/discord/client/src/index.ts index b8a79c5f39..c445e1d303 100644 --- a/packages/plugins/discord/client/src/index.ts +++ b/packages/plugins/discord/client/src/index.ts @@ -11,7 +11,7 @@ import { eventSocket, SpellInterface, triggerSocket, -} from '@magickml/core' +} from 'shared/core' import { DiscordAgentWindow } from './components/agent.component' import _DiscordSpellTemplate from './templates/spells/Discord Bot.spell.json' diff --git a/packages/plugins/discord/server/project.json b/packages/plugins/discord/server/project.json index 06a0d56c95..b8fc92ef85 100644 --- a/packages/plugins/discord/server/project.json +++ b/packages/plugins/discord/server/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "plugin-discord/server/src", "projectType": "library", - "implicitDependencies": ["@magickml/core", "@magickml/server-core"], + "implicitDependencies": ["shared-core", "server-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/discord/server/src/connectors/discord-voice.ts b/packages/plugins/discord/server/src/connectors/discord-voice.ts index cfecdf1a16..2d53439e28 100644 --- a/packages/plugins/discord/server/src/connectors/discord-voice.ts +++ b/packages/plugins/discord/server/src/connectors/discord-voice.ts @@ -7,7 +7,7 @@ import { getVoiceConnection, AudioPlayerStatus, } from '@discordjs/voice' -import { app } from '@magickml/server-core' +import { app } from 'server/core' import { addSpeechEvent } from './voiceUtils/addSpeechEvent' /** diff --git a/packages/plugins/discord/server/src/connectors/discord.ts b/packages/plugins/discord/server/src/connectors/discord.ts index 6bd8092697..2639d0ec88 100644 --- a/packages/plugins/discord/server/src/connectors/discord.ts +++ b/packages/plugins/discord/server/src/connectors/discord.ts @@ -1,6 +1,6 @@ // DOCUMENTED -import { getLogger } from '@magickml/core' -import { app } from '@magickml/server-core' +import { getLogger } from 'shared/core' +import { app } from 'server/core' import Discord, { AttachmentBuilder, EmbedBuilder, diff --git a/packages/plugins/discord/server/src/index.ts b/packages/plugins/discord/server/src/index.ts index 52bb492b60..7ae981c4e9 100644 --- a/packages/plugins/discord/server/src/index.ts +++ b/packages/plugins/discord/server/src/index.ts @@ -4,7 +4,7 @@ import { eventSocket, ServerPlugin, triggerSocket, -} from '@magickml/core' +} from 'shared/core' import { DiscordConnector } from './connectors/discord' import { handleVoiceResponse } from './connectors/discord-voice' diff --git a/packages/plugins/discord/shared/project.json b/packages/plugins/discord/shared/project.json index 3963f184e0..9a146fe095 100644 --- a/packages/plugins/discord/shared/project.json +++ b/packages/plugins/discord/shared/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/discord/shared/src", "projectType": "library", - "implicitDependencies": ["@magickml/core", "server-agents"], + "implicitDependencies": ["shared-core", "server-agents"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/discord/shared/src/index.ts b/packages/plugins/discord/shared/src/index.ts index c9a1366811..00cec7d977 100644 --- a/packages/plugins/discord/shared/src/index.ts +++ b/packages/plugins/discord/shared/src/index.ts @@ -1,25 +1,24 @@ -// DOCUMENTED +// DOCUMENTED /** * Imports */ -import { DiscordListTextChannels } from './nodes/DiscordListTextChannels'; -import { DiscordListVoiceChannels } from './nodes/DiscordListVoiceChannels'; -import { DiscordJoinVoice } from './nodes/DiscordJoinVoice'; -import { DiscordLeaveVoice } from './nodes/DiscordLeaveVoice'; -import { DiscordVoiceChannelForSender } from './nodes/DiscordVoiceChannelForSender'; +import { DiscordListTextChannels } from './nodes/DiscordListTextChannels' +import { DiscordListVoiceChannels } from './nodes/DiscordListVoiceChannels' +import { DiscordJoinVoice } from './nodes/DiscordJoinVoice' +import { DiscordLeaveVoice } from './nodes/DiscordLeaveVoice' +import { DiscordVoiceChannelForSender } from './nodes/DiscordVoiceChannelForSender' import { DiscordLeaveVoiceChannelsInServer } from './nodes/DiscordLeaveVoiceChannelsInServer' -import { MagickComponent } from '@magickml/core'; - +import { MagickComponent } from 'shared/core' export function getNodes(): MagickComponent[] { return [ - DiscordJoinVoice as any, - DiscordListTextChannels as any, - DiscordListVoiceChannels as any, - DiscordLeaveVoice as any, - DiscordVoiceChannelForSender as any, - DiscordLeaveVoiceChannelsInServer as any, -] + DiscordJoinVoice as any, + DiscordListTextChannels as any, + DiscordListVoiceChannels as any, + DiscordLeaveVoice as any, + DiscordVoiceChannelForSender as any, + DiscordLeaveVoiceChannelsInServer as any, + ] } /** * Export an array of nodes @@ -28,4 +27,4 @@ export default [ DiscordJoinVoice, DiscordListTextChannels, DiscordListVoiceChannels, -]; \ No newline at end of file +] diff --git a/packages/plugins/discord/shared/src/nodes/DiscordCurrentChannelName.ts b/packages/plugins/discord/shared/src/nodes/DiscordCurrentChannelName.ts index 1552f9a07f..14420c2131 100644 --- a/packages/plugins/discord/shared/src/nodes/DiscordCurrentChannelName.ts +++ b/packages/plugins/discord/shared/src/nodes/DiscordCurrentChannelName.ts @@ -16,7 +16,7 @@ import { MagickWorkerOutputs, ModuleContext, stringSocket, -} from '@magickml/core' +} from 'shared/core' /** * The return type of the worker function. diff --git a/packages/plugins/discord/shared/src/nodes/DiscordJoinVoice.ts b/packages/plugins/discord/shared/src/nodes/DiscordJoinVoice.ts index cd0d3757ee..17a5ae8d0d 100644 --- a/packages/plugins/discord/shared/src/nodes/DiscordJoinVoice.ts +++ b/packages/plugins/discord/shared/src/nodes/DiscordJoinVoice.ts @@ -13,7 +13,7 @@ import { WorkerData, MagickWorkerInputs, MagickWorkerOutputs, -} from '@magickml/core' +} from 'shared/core' import { ChannelType } from '../types/ChannelType' /** diff --git a/packages/plugins/discord/shared/src/nodes/DiscordLeaveVoice.ts b/packages/plugins/discord/shared/src/nodes/DiscordLeaveVoice.ts index ed685e742a..7298db7241 100644 --- a/packages/plugins/discord/shared/src/nodes/DiscordLeaveVoice.ts +++ b/packages/plugins/discord/shared/src/nodes/DiscordLeaveVoice.ts @@ -13,7 +13,7 @@ import { WorkerData, MagickWorkerInputs, MagickWorkerOutputs, -} from '@magickml/core' +} from 'shared/core' import { ChannelType } from '../types/ChannelType' /** diff --git a/packages/plugins/discord/shared/src/nodes/DiscordLeaveVoiceChannelsInServer.ts b/packages/plugins/discord/shared/src/nodes/DiscordLeaveVoiceChannelsInServer.ts index d8fc09e129..d350c335ff 100644 --- a/packages/plugins/discord/shared/src/nodes/DiscordLeaveVoiceChannelsInServer.ts +++ b/packages/plugins/discord/shared/src/nodes/DiscordLeaveVoiceChannelsInServer.ts @@ -16,7 +16,7 @@ import { MagickWorkerOutputs, ModuleContext, booleanSocket, -} from '@magickml/core' +} from 'shared/core' /** * The return type of the worker function. diff --git a/packages/plugins/discord/shared/src/nodes/DiscordListTextChannels.ts b/packages/plugins/discord/shared/src/nodes/DiscordListTextChannels.ts index d37604fc59..20ad5abda9 100644 --- a/packages/plugins/discord/shared/src/nodes/DiscordListTextChannels.ts +++ b/packages/plugins/discord/shared/src/nodes/DiscordListTextChannels.ts @@ -16,7 +16,7 @@ import { MagickWorkerOutputs, ModuleContext, arraySocket, -} from '@magickml/core' +} from 'shared/core' import type { Client, TextChannel } from 'discord.js' import { ChannelType } from '../types/ChannelType' //This is required because this is a shared module, the discord.js lib has dependencies that break on the client diff --git a/packages/plugins/discord/shared/src/nodes/DiscordListVoiceChannels.ts b/packages/plugins/discord/shared/src/nodes/DiscordListVoiceChannels.ts index bcfc92f44a..1e146fe462 100644 --- a/packages/plugins/discord/shared/src/nodes/DiscordListVoiceChannels.ts +++ b/packages/plugins/discord/shared/src/nodes/DiscordListVoiceChannels.ts @@ -16,7 +16,7 @@ import { MagickWorkerOutputs, ModuleContext, arraySocket, -} from '@magickml/core' +} from 'shared/core' import { ChannelType } from '../types/ChannelType' /** diff --git a/packages/plugins/discord/shared/src/nodes/DiscordVoiceChannelForSender.ts b/packages/plugins/discord/shared/src/nodes/DiscordVoiceChannelForSender.ts index 31820a4ba0..c1101ef5d4 100644 --- a/packages/plugins/discord/shared/src/nodes/DiscordVoiceChannelForSender.ts +++ b/packages/plugins/discord/shared/src/nodes/DiscordVoiceChannelForSender.ts @@ -16,7 +16,7 @@ import { MagickWorkerOutputs, ModuleContext, stringSocket, -} from '@magickml/core' +} from 'shared/core' /** * The return type of the worker function. diff --git a/packages/plugins/discord/shared/src/nodes/utils.ts b/packages/plugins/discord/shared/src/nodes/utils.ts index cfe9c63e09..540e33be71 100644 --- a/packages/plugins/discord/shared/src/nodes/utils.ts +++ b/packages/plugins/discord/shared/src/nodes/utils.ts @@ -1,5 +1,5 @@ import { Application } from '@feathersjs/koa/lib' -import { SpellRunner } from '@magickml/core' +import { SpellRunner } from 'shared/core' import TaskCreation from './spells/TaskCreation.spell' import TaskExecution from './spells/TaskExecution.spell' import TaskReprioritization from './spells/TaskReprioritization.spell' diff --git a/packages/plugins/elevenlabs/client/project.json b/packages/plugins/elevenlabs/client/project.json index b1c3d05d92..3b65cc7837 100644 --- a/packages/plugins/elevenlabs/client/project.json +++ b/packages/plugins/elevenlabs/client/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/elevenlabs/client/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/elevenlabs/client/src/index.ts b/packages/plugins/elevenlabs/client/src/index.ts index e2f91c8ab7..1bd5fe472f 100644 --- a/packages/plugins/elevenlabs/client/src/index.ts +++ b/packages/plugins/elevenlabs/client/src/index.ts @@ -1,9 +1,9 @@ -// DOCUMENTED +// DOCUMENTED /** * A plugin for interacting with elevenlabs's API. * @class */ -import { ClientPlugin, InputControl } from '@magickml/core' +import { ClientPlugin, InputControl } from 'shared/core' import shared from '@magickml/plugin-elevenlabs-shared' // Importing shared variables from plugin-elevenlabs-shared module @@ -32,7 +32,7 @@ const textToSpeechControls = [ icon: 'moon', defaultValue: '', }, -]; +] // Object containing all input controls for different completion types const inspectorControls = { @@ -44,7 +44,7 @@ const elevenlabsPlugin = new ClientPlugin({ name: 'elevenlabsPlugin', secrets, // API Key and Model ID secrets completionProviders: completionProviders.map(provider => { - // Adding custom input controls for each completion type + // Adding custom input controls for each completion type return { ...provider, inspectorControls: inspectorControls[provider.subtype], @@ -52,4 +52,4 @@ const elevenlabsPlugin = new ClientPlugin({ }), }) -export default elevenlabsPlugin \ No newline at end of file +export default elevenlabsPlugin diff --git a/packages/plugins/elevenlabs/server/project.json b/packages/plugins/elevenlabs/server/project.json index 0e8d4a046a..a9ba9425c2 100644 --- a/packages/plugins/elevenlabs/server/project.json +++ b/packages/plugins/elevenlabs/server/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "plugin-elevenlabs/server/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/elevenlabs/server/src/functions/textToSpeech.ts b/packages/plugins/elevenlabs/server/src/functions/textToSpeech.ts index 6f46c0994d..96c8458593 100644 --- a/packages/plugins/elevenlabs/server/src/functions/textToSpeech.ts +++ b/packages/plugins/elevenlabs/server/src/functions/textToSpeech.ts @@ -1,31 +1,33 @@ -// UNDOCUMENTED -import { - CompletionHandlerInputData, -} from '@magickml/core' +// UNDOCUMENTED +import { CompletionHandlerInputData } from 'shared/core' import axios from 'axios' - -async function callTextToSpeechApi(text: string, voice_id: string, stability: number, similarity_boost: number, apiKey: string) { +async function callTextToSpeechApi( + text: string, + voice_id: string, + stability: number, + similarity_boost: number, + apiKey: string +) { const apiUrl = `https://api.elevenlabs.io/v1/text-to-speech/${voice_id}` const requestBody = { text, voice_settings: { stability, - similarity_boost - } + similarity_boost, + }, } const response = await axios.post(apiUrl, requestBody, { headers: { - 'xi-api-key': apiKey + 'xi-api-key': apiKey, }, - responseType: 'blob' - }); + responseType: 'blob', + }) - return response.data; + return response.data } - /** * Generate speech from text. * @param data - CompletionHandlerInputData object. @@ -33,21 +35,31 @@ async function callTextToSpeechApi(text: string, voice_id: string, stability: nu */ export async function textToSpeech( data: CompletionHandlerInputData -): Promise<{ success: boolean, result?: ArrayBuffer | null, error?: string | null }> { +): Promise<{ + success: boolean + result?: ArrayBuffer | null + error?: string | null +}> { const { node, inputs, context } = data const settings = { - stability: parseFloat(node?.data?.stability as string ?? "0.5"), - similarity_boost: parseFloat(node?.data?.stability as string ?? "0.5"), - voice_id: node?.data.voice_id as string ?? 'MF3mGyEYCl7XYWbV9V6O' + stability: parseFloat((node?.data?.stability as string) ?? '0.5'), + similarity_boost: parseFloat((node?.data?.stability as string) ?? '0.5'), + voice_id: (node?.data.voice_id as string) ?? 'MF3mGyEYCl7XYWbV9V6O', } - + const text = inputs['input']?.[0] as string // @ts-ignore const key = context.module.secrets['elevenlabs_api_key'] as string try { - const audioBuffer = await callTextToSpeechApi(text, settings.voice_id, settings.stability, settings.similarity_boost, key); + const audioBuffer = await callTextToSpeechApi( + text, + settings.voice_id, + settings.stability, + settings.similarity_boost, + key + ) // TODO: handle event storage @@ -58,4 +70,4 @@ export async function textToSpeech( } catch (err: any) { return { success: false, error: err.message } } -} \ No newline at end of file +} diff --git a/packages/plugins/elevenlabs/server/src/index.ts b/packages/plugins/elevenlabs/server/src/index.ts index 2d9de34e6e..840e4d0202 100644 --- a/packages/plugins/elevenlabs/server/src/index.ts +++ b/packages/plugins/elevenlabs/server/src/index.ts @@ -9,11 +9,9 @@ * @packageDocumentation */ -import { ServerPlugin } from '@magickml/core' +import { ServerPlugin } from 'shared/core' import shared from '@magickml/plugin-elevenlabs-shared' -import { - textToSpeech, -} from './functions' +import { textToSpeech } from './functions' /** * The secrets used by the elevenlabs API @@ -25,7 +23,7 @@ const { secrets } = shared */ const completionHandlers = { audio: { - 'text2speech': textToSpeech, + text2speech: textToSpeech, }, } diff --git a/packages/plugins/elevenlabs/shared/project.json b/packages/plugins/elevenlabs/shared/project.json index 80828ca7d2..39c7447497 100644 --- a/packages/plugins/elevenlabs/shared/project.json +++ b/packages/plugins/elevenlabs/shared/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/elevenlabs/shared/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/elevenlabs/shared/src/index.ts b/packages/plugins/elevenlabs/shared/src/index.ts index 781058a1cd..b7ae57a354 100644 --- a/packages/plugins/elevenlabs/shared/src/index.ts +++ b/packages/plugins/elevenlabs/shared/src/index.ts @@ -1,50 +1,44 @@ -// DOCUMENTED -import { - CompletionProvider, - PluginSecret, - stringSocket, -} from "@magickml/core"; +// DOCUMENTED +import { CompletionProvider, PluginSecret, stringSocket } from 'shared/core' /** * An array of PluginSecret objects containing information about API key secrets. */ const secrets: PluginSecret[] = [ { - name: "ElevenLabs API Key", - key: "elevenlabs_api_key", + name: 'ElevenLabs API Key', + key: 'elevenlabs_api_key', global: true, - getUrl: "https://beta.elevenlabs.io/", + getUrl: 'https://beta.elevenlabs.io/', }, -]; +] /** * An array of CompletionProvider objects containing information about supported completion providers. */ const completionProviders: CompletionProvider[] = [ { - type: "audio", - subtype: "text2speech", + type: 'audio', + subtype: 'text2speech', inputs: [ { - socket: "input", - name: "Input", + socket: 'input', + name: 'Input', type: stringSocket, }, ], outputs: [ { - socket: "result", - name: "Result", + socket: 'result', + name: 'Result', type: stringSocket, - } - ], - models: [ - "elevenlabs", + }, ], + models: ['elevenlabs'], }, -]; +] export default { secrets, completionProviders, -}; \ No newline at end of file +} diff --git a/packages/plugins/ethereum/client/project.json b/packages/plugins/ethereum/client/project.json index df90321f71..a0ddf03141 100644 --- a/packages/plugins/ethereum/client/project.json +++ b/packages/plugins/ethereum/client/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/ethereum/client/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/ethereum/client/src/index.ts b/packages/plugins/ethereum/client/src/index.ts index e83fef5915..712c03e994 100644 --- a/packages/plugins/ethereum/client/src/index.ts +++ b/packages/plugins/ethereum/client/src/index.ts @@ -1,4 +1,4 @@ -// DOCUMENTED +// DOCUMENTED /** * This is a Typescript module that exports a ClientPlugin instance named EthereumPlugin * @@ -10,12 +10,12 @@ * @packageDocumentation */ -import { ClientPlugin } from '@magickml/core'; -import { EthereumAgentWindow } from './components/agent.component'; -import Nodes from '@magickml/plugin-ethereum-shared'; -import MoneyIcon from '@mui/icons-material/AttachMoney'; -import { EthereumComponent } from './components/ethereum.route'; -import { ContractComponent } from './components/contract.route'; +import { ClientPlugin } from 'shared/core' +import { EthereumAgentWindow } from './components/agent.component' +import Nodes from '@magickml/plugin-ethereum-shared' +import MoneyIcon from '@mui/icons-material/AttachMoney' +import { EthereumComponent } from './components/ethereum.route' +import { ContractComponent } from './components/contract.route' /** * An object of the StartEthereumArgs type. @@ -59,8 +59,8 @@ const EthereumPlugin = new ClientPlugin({ name: 'Ethereum Public Address', key: 'ethereum_public_address', global: false, - } - ] + }, + ], }) -export default EthereumPlugin; \ No newline at end of file +export default EthereumPlugin diff --git a/packages/plugins/ethereum/server/project.json b/packages/plugins/ethereum/server/project.json index bd66d6deb9..a406e82a08 100644 --- a/packages/plugins/ethereum/server/project.json +++ b/packages/plugins/ethereum/server/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/ethereum/server/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/ethereum/server/src/index.ts b/packages/plugins/ethereum/server/src/index.ts index 884fc55e1a..41d9c2b17b 100644 --- a/packages/plugins/ethereum/server/src/index.ts +++ b/packages/plugins/ethereum/server/src/index.ts @@ -1,13 +1,13 @@ -// DOCUMENTED +// DOCUMENTED /** * @fileoverview A module that exports an optimized version of the original Typescript module * that conforms to the Google code standards. * @module optimized-ts */ -import { ServerPlugin } from "@magickml/core"; -import Nodes from "@magickml/plugin-ethereum-shared"; -import { solidity } from "./services/solidity/solidity"; +import { ServerPlugin } from 'shared/core' +import Nodes from '@magickml/plugin-ethereum-shared' +import { solidity } from './services/solidity/solidity' /** * An object containing the arguments to start the Ethereum websocket. @@ -30,9 +30,9 @@ import { solidity } from "./services/solidity/solidity"; */ function getAgentMethods() { // If we are in node, we need to import the Ethereum client. - if (typeof window !== "undefined") return; + if (typeof window !== 'undefined') return - let ethereum_client; + let ethereum_client /** * Starts the Ethereum websocket. @@ -42,20 +42,18 @@ function getAgentMethods() { * @returns {void} */ async function startEthereumWs({ agent, spellRunner }) { - console.log("Starting Ethereum WS..."); + console.log('Starting Ethereum WS...') // Ignore import if using Vite. const module = await import( /* @vite-ignore */ `${ - typeof window === "undefined" - ? "./connectors/ethereum" - : "./dummy" + typeof window === 'undefined' ? './connectors/ethereum' : './dummy' }` - ); - ethereum_client = module.ethereum_client; + ) + ethereum_client = module.ethereum_client - const ethereum = new ethereum_client(); - agent.ethereum = ethereum; - await ethereum.createEthereumClient(agent, spellRunner); + const ethereum = new ethereum_client() + agent.ethereum = ethereum + await ethereum.createEthereumClient(agent, spellRunner) } /** @@ -66,16 +64,16 @@ function getAgentMethods() { * @returns {void} */ async function stopEthereumWs(agent) { - if (!agent.ethereum) return; - await agent.ethereum.destroy(); - agent.ethereum = null; - console.log(`Stopped Ethereum WS client for agent ${agent.name}.`); + if (!agent.ethereum) return + await agent.ethereum.destroy() + agent.ethereum = null + console.log(`Stopped Ethereum WS client for agent ${agent.name}.`) } return { start: startEthereumWs, stop: stopEthereumWs, - }; + } } /** @@ -84,22 +82,22 @@ function getAgentMethods() { * @type {ServerPlugin} */ const EthereumPlugin = new ServerPlugin({ - name: "EthereumPlugin", + name: 'EthereumPlugin', nodes: Nodes, services: [solidity], agentMethods: getAgentMethods(), secrets: [ { - name: "Ethereum Private Key", - key: "ethereum_private_key", + name: 'Ethereum Private Key', + key: 'ethereum_private_key', global: false, }, { - name: "Ethereum Public Address", - key: "ethereum_public_address", + name: 'Ethereum Public Address', + key: 'ethereum_public_address', global: false, }, ], -}); +}) -export default EthereumPlugin; \ No newline at end of file +export default EthereumPlugin diff --git a/packages/plugins/ethereum/server/src/services/solidity/solidity.class.ts b/packages/plugins/ethereum/server/src/services/solidity/solidity.class.ts index 87669e3919..8c93a44ddb 100644 --- a/packages/plugins/ethereum/server/src/services/solidity/solidity.class.ts +++ b/packages/plugins/ethereum/server/src/services/solidity/solidity.class.ts @@ -1,4 +1,4 @@ -// DOCUMENTED +// DOCUMENTED /** * This file contains a SolidityService class that implements the ServiceInterface. * The class exposes a create() method that compiles Solidity code using the `solc` package. @@ -6,22 +6,22 @@ * @packageDocumentation */ -import type { Params, ServiceInterface } from '@feathersjs/feathers'; -import solc from 'solc'; -import { Application } from '@magickml/server-core'; -import type { Solidity, SolidityData, SolidityQuery } from './solidity.schema'; +import type { Params, ServiceInterface } from '@feathersjs/feathers' +import solc from 'solc' +import { Application } from 'server/core' +import type { Solidity, SolidityData, SolidityQuery } from './solidity.schema' /** * An object representing options for the SolidityService class. */ export interface SolidityServiceOptions { - app: Application; + app: Application } /** * Alias for the Params type with SolidityQuery type parameters. */ -type SolidityParams = Params; +type SolidityParams = Params /** * The response object of SolidityService's get() method. @@ -34,8 +34,10 @@ export type SolidityGetResponse = { * The SolidityService class that implements the ServiceInterface. * The class compiles Solidity code using the `solc` package. */ -export class SolidityService -implements ServiceInterface { +export class SolidityService< + ServiceParams extends SolidityParams = SolidityParams +> implements ServiceInterface +{ /** * Initializes a new instance of the SolidityService class. * @param options An object representing the options for SolidityService. @@ -48,49 +50,52 @@ implements ServiceInterface { * @param params An object representing additional parameters. * @returns An object representing the compiled Solidity code. */ - async create(data: SolidityData, params?: ServiceParams): Promise; - + async create(data: SolidityData, params?: ServiceParams): Promise + /** * Compiles an array of Solidity code objects using the `solc` package and returns the results. * @param data An array of objects representing Solidity code. * @param params An object representing additional parameters. * @returns An array of objects representing the compiled Solidity code. */ - async create(data: SolidityData[], params?: ServiceParams): Promise; - async create( - data: SolidityData | SolidityData[], + data: SolidityData[], + params?: ServiceParams + ): Promise + + async create( + data: SolidityData | SolidityData[] ): Promise { - const { code } = data as any; + const { code } = data as any if (!code) { return { - error: 'The `code` field is required.' - }; + error: 'The `code` field is required.', + } } const input = { language: 'Solidity', sources: { 'code.sol': { - content: code - } + content: code, + }, }, settings: { outputSelection: { '*': { - '*': ['*'] - } - } - } - }; - - const output = JSON.parse(solc.compile(JSON.stringify(input))); - console.log(output); + '*': ['*'], + }, + }, + }, + } + + const output = JSON.parse(solc.compile(JSON.stringify(input))) + console.log(output) return { - result: output - }; + result: output, + } } } @@ -100,5 +105,5 @@ implements ServiceInterface { * @returns An object representing the SolidityService options. */ export const getOptions = (app: Application): SolidityServiceOptions => { - return { app }; + return { app } } diff --git a/packages/plugins/ethereum/server/src/services/solidity/solidity.ts b/packages/plugins/ethereum/server/src/services/solidity/solidity.ts index 2d5af12751..7003681110 100644 --- a/packages/plugins/ethereum/server/src/services/solidity/solidity.ts +++ b/packages/plugins/ethereum/server/src/services/solidity/solidity.ts @@ -1,4 +1,4 @@ -// DOCUMENTED +// DOCUMENTED /** * This file contains code related to SolidityService, a Feathers service for compiling Solidity contracts. * @@ -6,7 +6,7 @@ */ import { hooks as schemaHooks } from '@feathersjs/schema' -import type { Application } from '@magickml/server-core' +import type { Application } from 'server/core' import { SolidityService, getOptions } from './solidity.class' import { @@ -28,21 +28,17 @@ export const solidityMethods = ['create'] as const /** * This function registers the Solidity service and its hooks via `app.configure`. - * + * * @param app - The Feathers application. */ export const solidity = (app: Application): void => { // Register our service on the Feathers application - app.use( - solidityPath, - new SolidityService(getOptions(app)), - { - // A list of all methods this service exposes externally - methods: solidityMethods, - // You can add additional custom events to be sent to clients here - events: [], - } - ) + app.use(solidityPath, new SolidityService(getOptions(app)), { + // A list of all methods this service exposes externally + methods: solidityMethods, + // You can add additional custom events to be sent to clients here + events: [], + }) // Initialize hooks app.service(solidityPath).hooks({ @@ -69,4 +65,4 @@ export const solidity = (app: Application): void => { } export * from './solidity.class' -export * from './solidity.schema' \ No newline at end of file +export * from './solidity.schema' diff --git a/packages/plugins/ethereum/shared/project.json b/packages/plugins/ethereum/shared/project.json index aee74d07ed..e5a626ac93 100644 --- a/packages/plugins/ethereum/shared/project.json +++ b/packages/plugins/ethereum/shared/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/ethereum/shared/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/ethereum/shared/src/nodes/CallContractFunctionRead.ts b/packages/plugins/ethereum/shared/src/nodes/CallContractFunctionRead.ts index 9f213779ef..9b0bf456a9 100644 --- a/packages/plugins/ethereum/shared/src/nodes/CallContractFunctionRead.ts +++ b/packages/plugins/ethereum/shared/src/nodes/CallContractFunctionRead.ts @@ -9,7 +9,7 @@ import { MagickWorkerOutputs, stringSocket, triggerSocket, -} from '@magickml/core' +} from 'shared/core' const info = `Call an arbitrary function from a contract` diff --git a/packages/plugins/ethereum/shared/src/nodes/CallContractFunctionWrite.ts b/packages/plugins/ethereum/shared/src/nodes/CallContractFunctionWrite.ts index 0cf653fa14..53935f7b60 100644 --- a/packages/plugins/ethereum/shared/src/nodes/CallContractFunctionWrite.ts +++ b/packages/plugins/ethereum/shared/src/nodes/CallContractFunctionWrite.ts @@ -12,7 +12,7 @@ import { numberSocket, triggerSocket, WorkerData, -} from '@magickml/core' +} from 'shared/core' /** Info for the component */ const info = `Call a write function from a contract` diff --git a/packages/plugins/ethereum/shared/src/nodes/CheckForRecentTxFromWallet.ts b/packages/plugins/ethereum/shared/src/nodes/CheckForRecentTxFromWallet.ts index 984452618f..1589fea403 100644 --- a/packages/plugins/ethereum/shared/src/nodes/CheckForRecentTxFromWallet.ts +++ b/packages/plugins/ethereum/shared/src/nodes/CheckForRecentTxFromWallet.ts @@ -13,7 +13,7 @@ import { stringSocket, triggerSocket, WorkerData, -} from '@magickml/core' +} from 'shared/core' /** * Check the recent transactions from another wallet diff --git a/packages/plugins/ethereum/shared/src/nodes/CompileContract.ts b/packages/plugins/ethereum/shared/src/nodes/CompileContract.ts index 290b5425c6..71a4ed508b 100644 --- a/packages/plugins/ethereum/shared/src/nodes/CompileContract.ts +++ b/packages/plugins/ethereum/shared/src/nodes/CompileContract.ts @@ -16,7 +16,7 @@ import { CodeControl, triggerSocket, WorkerData, -} from '@magickml/core' +} from 'shared/core' // Default solidity code const defaultCode = ` diff --git a/packages/plugins/ethereum/shared/src/nodes/DeployContract.ts b/packages/plugins/ethereum/shared/src/nodes/DeployContract.ts index 36ed860a0c..2c2c6b642c 100644 --- a/packages/plugins/ethereum/shared/src/nodes/DeployContract.ts +++ b/packages/plugins/ethereum/shared/src/nodes/DeployContract.ts @@ -16,7 +16,7 @@ import { numberSocket, triggerSocket, WorkerData, -} from '@magickml/core' +} from 'shared/core' const info = `Deploys a contract from Solidity code, a standard for defining non-fungible tokens on EVM machines.` diff --git a/packages/plugins/ethereum/shared/src/nodes/GetERC20BalanceFromWallet.ts b/packages/plugins/ethereum/shared/src/nodes/GetERC20BalanceFromWallet.ts index c3b24d8167..7c06092e49 100644 --- a/packages/plugins/ethereum/shared/src/nodes/GetERC20BalanceFromWallet.ts +++ b/packages/plugins/ethereum/shared/src/nodes/GetERC20BalanceFromWallet.ts @@ -13,7 +13,7 @@ import { stringSocket, triggerSocket, WorkerData, -} from '@magickml/core' +} from 'shared/core' const info = `Check the balance of an ethereum wallet for an ERC20 at a contract address` diff --git a/packages/plugins/ethereum/shared/src/nodes/GetNativeBalanceFromWallet.ts b/packages/plugins/ethereum/shared/src/nodes/GetNativeBalanceFromWallet.ts index 7cd9057840..6146b3d5b8 100644 --- a/packages/plugins/ethereum/shared/src/nodes/GetNativeBalanceFromWallet.ts +++ b/packages/plugins/ethereum/shared/src/nodes/GetNativeBalanceFromWallet.ts @@ -15,7 +15,7 @@ import { numberSocket, triggerSocket, WorkerData, -} from '@magickml/core' +} from 'shared/core' const info = `Check the balance of an ethereum wallet` diff --git a/packages/plugins/ethereum/shared/src/nodes/GetRecentTxsFromWallet.ts b/packages/plugins/ethereum/shared/src/nodes/GetRecentTxsFromWallet.ts index a3bab571e6..749906ac22 100644 --- a/packages/plugins/ethereum/shared/src/nodes/GetRecentTxsFromWallet.ts +++ b/packages/plugins/ethereum/shared/src/nodes/GetRecentTxsFromWallet.ts @@ -17,7 +17,7 @@ import { stringSocket, triggerSocket, WorkerData, -} from '@magickml/core' +} from 'shared/core' // A string variable that describes the component’s functionality. const info = `Check the recent transactions of an Ethereum wallet` diff --git a/packages/plugins/github/client/project.json b/packages/plugins/github/client/project.json index 5cef32967f..b357810e1a 100644 --- a/packages/plugins/github/client/project.json +++ b/packages/plugins/github/client/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/github/client/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nrwl/linter:eslint", diff --git a/packages/plugins/github/client/src/index.ts b/packages/plugins/github/client/src/index.ts index 352fc82d54..23fd36bf42 100644 --- a/packages/plugins/github/client/src/index.ts +++ b/packages/plugins/github/client/src/index.ts @@ -1,4 +1,4 @@ -import { ClientPlugin, eventSocket, triggerSocket } from '@magickml/core' +import { ClientPlugin, eventSocket, triggerSocket } from 'shared/core' import { GithubAgentWindow } from './components/agent.component' import { getNodes } from '@magickml/plugin-github-shared' diff --git a/packages/plugins/github/server/project.json b/packages/plugins/github/server/project.json index a769f6e0f8..973359a44e 100644 --- a/packages/plugins/github/server/project.json +++ b/packages/plugins/github/server/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/github/server/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/github/server/src/connectors/github.ts b/packages/plugins/github/server/src/connectors/github.ts index 9cb9fdc5b3..306dc0eb6a 100644 --- a/packages/plugins/github/server/src/connectors/github.ts +++ b/packages/plugins/github/server/src/connectors/github.ts @@ -1,456 +1,456 @@ -import { app } from '@magickml/server-core' -import { Octokit } from '@octokit/rest' -import http from 'http' -import { Webhooks, createNodeMiddleware } from '@octokit/webhooks' -import ngrok from 'ngrok' -import { v4 as uuidv4 } from 'uuid' -import { getLogger } from '@magickml/core' - -export class GithubConnector { - spellRunner - data - agent - lastTime - webhooks - middleware - webhookListeners = [] as any[] - octokit - secret - numbers - logger - - constructor({ spellRunner, agent }) { - this.logger = getLogger() - agent.github = this - this.spellRunner = spellRunner - const { data } = agent.data - this.data = data - this.agent = agent - this.numbers = [] - this.initialize({ data }) - } - - async initialize({ data }) { - if (!data.github_enabled) { - this.logger.info('Github is not enabled, skipping') - } - - if (!data.github_access_token) { - this.logger.info('Github is not enabled for this agent') - } - - this.logger.info( - 'Github enabled, initializing... %s, %o', - data.github_access_token, - data.github_repos - ) - - this.startWebhookServer() - - this.octokit = new Octokit({ - auth: data.github_access_token, - }) - - const repos = data.github_repos - - if (!repos) { - this.logger.error( - 'Github repos not configured correctly. No repos found. skipping' - ) - throw new Error( - 'Github repos not configured correctly. No repos found. skipping' - ) - } - - // repos is an array of owner/repos, separated by comma - // split it and add each repo to the webhook - repos.forEach(async repo => { - const [owner, name] = repo.trim().split('/') - this.logger.info('**** GITHUB: Added repo %s, %s to webhook', owner, name) - this.webhookListeners.push( - await this.startNgrokAndConfigureWebhook(owner, name) - ) - }) - } - - startWebhookServer() { - this.secret = uuidv4() - - this.logger.info('webhook start >') - this.webhooks = new Webhooks({ - secret: this.secret, - }) - - this.webhooks.on('pull_request.opened', ({ payload }) => { - this.logger.info('payload pull_request: %o', payload.pull_request) - const repo = { - owner: payload.repository.owner.login, - name: payload.repository.name, - } - this.newSpellInput('Pull Request', 'new_prs', payload.pull_request, repo) - }) - - this.webhooks.on('issues.opened', ({ payload }) => { - this.logger.info('payload issue: %o', payload.issue) - const repo = { - owner: payload.repository.owner.login, - name: payload.repository.name, - } - this.newSpellInput('Issue', 'new_issues', payload.issue, repo) - }) - - this.webhooks.on('issue_comment.created', ({ payload }) => { - this.logger.info('payload comment: %o', payload.comment) - const params = { - ...payload.comment, - number: payload.issue.number, - } - const repo = { - owner: payload.repository.owner.login, - name: payload.repository.name, - } - this.newSpellInput('Comment', 'issue_response', params, repo) - }) - - this.middleware = createNodeMiddleware(this.webhooks, { - path: '/payload', - }) - } - - async startNgrokAndConfigureWebhook(owner, repo) { - try { - // Generate a random port number between 4000 and 10000 - const randomPort = Math.floor(Math.random() * (10000 - 4000 + 1)) + 4000 - - // Start ngrok with the random port and retrieve the URL - const ngrokUrl = await ngrok.connect({ - addr: randomPort, - }) - - // Check if the webhook exists - const { data: webhooks } = await this.octokit.repos.listWebhooks({ - owner, - repo, - }) - - let webhookId, repoWebhook - this.logger.info('webhooks: %o', webhooks) - // If the webhook exists, update it with the new configuration - const events = [ - 'issues', - 'issue_comment', - 'pull_request', - 'push', - 'repository', - ] - if (webhooks.length > 0) { - const webhook = webhooks.find(hook => hook.config.url.includes('ngrok')) - - if (webhook) { - webhookId = webhook.id - webhook.config.port = randomPort - webhook.config.url = ngrokUrl + '/payload' - // config webhook secret - webhook.config.secret = this.secret - webhook.config.insecure_ssl = 0 - webhook.events = events - - await this.octokit.repos.updateWebhook({ - owner, - repo, - webhook_id: webhookId, - ...webhook, - }) - repoWebhook = webhook - this.logger.info('updateWebhook: %o', webhook.data) - } - } - - // If the webhook doesn't exist, create a new one - if (!webhookId) { - this.logger.info('webhookId > null') - const newWebhook = await this.octokit.repos.createWebhook({ - owner, - repo, - config: { - url: ngrokUrl + '/payload', - content_type: 'json', - insecure_ssl: 0, - port: randomPort, - secret: this.secret, - }, - events, - }) - - webhookId = newWebhook.data.id - repoWebhook = newWebhook - this.logger.info('createWebhook: %o', repoWebhook.data) - } - - // createServer with randomPort - http - .createServer(async (req, res) => { - if (await this.middleware(req, res)) return - res.writeHead(404) - res.end() - }) - .listen(randomPort) - - this.logger.info(`Ngrok URL: ${ngrokUrl}`) - this.logger.info(`Random Port: ${randomPort}`) - this.logger.info(`Webhook ID: ${webhookId}`) - return repoWebhook - } catch (error) { - this.logger.error('Error: %o', error) - return null - } - } - - newSpellInput = async ( - pretext: string, - type: string, - content: any, - repo: any - ) => { - const { number, title, body, id } = content - const { owner, name } = repo - const entities = [owner, name, title, body] - return app.get('agentCommander').runSpell({ - inputs: { - [`Input - Github (${pretext})`]: { - connector: `Github (${pretext})`, - content: body, - sender: owner, - observer: id, - client: 'github', - channel: number, - agentId: this.agent.id, - entities, - channelType: type, - rawData: JSON.stringify({ - number, - title, - body, - id, - owner, - name, - }), - }, - }, - agentId: this.agent.id, - spellId: this.agent.rootSpellId, - agent: this.agent, - secrets: this.agent.secrets, - publicVariables: this.agent.publicVariables, - runSubspell: true, - }) - } - - createComment = async ( - data: any, - number: number, - repo: any, - body: string, - type: 'issue' | 'pull_request' | 'comment' - ): Promise => { - const { github_access_token } = data - const owner = repo[0] - const name = repo[1] - this.logger.info( - 'GITHUB CREATE COMMENT: type:%s, [%s, %s]', - type, - owner, - name - ) - try { - if (!github_access_token || github_access_token[0] != 'g') { - this.logger.info('github access token is invalid') - return [] - } - if (!owner || owner == '') { - this.logger.info('owner/repo are invalid') - return [] - } - if (!name || name == '') { - this.logger.info('owner/repo are invalid') - return [] - } - if (!number || !body) { - this.logger.info('number/body are invalid') - return null - } - - const comment = await this.octokit.rest.issues.createComment({ - owner: owner, - repo: name, - issue_number: number, - body, - }) - this.logger.info( - 'new comment: %s, %o', - comment.data.id, - comment.data.body - ) - - return comment.data - } catch (error) { - this.logger.error('createComment error: %o', error) - return null - } - } - - getNewIssues = async (data: any, repo: any) => { - const { github_access_token } = data - const { owner, name } = repo - try { - if (!github_access_token || github_access_token[0] != 'g') { - this.logger.info('github access token is invalid') - return [] - } - if (!owner || owner == '') { - this.logger.info('owner/repo are invalid') - return [] - } - if (!name || name == '') { - this.logger.info('owner/repo are invalid') - return [] - } - - const since = new Date(this.lastTime).toISOString() - this.logger.info(`since = ${since}`) - - const newIssues = await this.octokit.rest.issues.listForRepo({ - owner: owner, - repo: name, - sort: 'created', - direction: 'desc', - since: since, - }) - - const filters = newIssues.data.filter(item => { - const created = new Date(item.created_at).getTime() - return created > this.lastTime - }) - this.logger.info('new issues: %o', filters) - - return filters - } catch (error) { - this.logger.error('%o', error) - return [] - } - } - - getNewPRs = async (data: any, repo: any) => { - const { github_access_token } = data - const { owner, name } = repo - try { - if (!github_access_token || github_access_token[0] != 'g') { - this.logger.info('github access token is invalid') - return [] - } - if (!owner || owner == '') { - this.logger.info('owner/repo are invalid') - return [] - } - if (!name || name == '') { - this.logger.info('owner/repo are invalid') - return [] - } - - const newPRs = await this.octokit.rest.pulls.list({ - owner: owner, - repo: name, - sort: 'created', - direction: 'desc', - }) - - const filters = newPRs.data.filter(item => { - const created = new Date(item.created_at).getTime() - return created > this.lastTime - }) - - this.logger.info('new PRs: %o', filters) - - return filters - } catch (error) { - this.logger.error('%o', error) - return [] - } - } - - getIssueComments = async (data: any, repo: any) => { - const { github_access_token } = data - const { owner, name } = repo - try { - if (!github_access_token || github_access_token[0] != 'g') { - this.logger.info('github access token is invalid') - return [] - } - if (!owner || owner == '') { - this.logger.info('owner/repo are invalid') - return [] - } - if (!name || name == '') { - this.logger.info('owner/repo are invalid') - return [] - } - - const since = new Date(this.lastTime).toISOString() - - const issueComments = await this.octokit.rest.issues.listCommentsForRepo({ - owner: owner, - repo: name, - sort: 'created', - direction: 'desc', - since: since, - }) - - this.logger.info('issue comments: %d', issueComments.data.length) - - return issueComments.data - } catch (error) { - this.logger.error('%o', error) - return [] - } - } - - async handleMessage( - event: any, - content: string, - type: 'issue' | 'pull_request' | 'comment' - ) { - this.logger.info('handleMessage: %o, %s | %s', event, content, type) - if (!content) { - this.logger.error('output is undefined') - return - } - if (!event.channel) { - this.logger.error('number is undefined') - return - } - if (!this.numbers) { - this.logger.info('null >> ') - this.numbers = [] - } - if (type === 'comment') { - const count = this.numbers.length - this.numbers = this.numbers.filter(num => num != event.observer) - if (this.numbers.length != count) { - // is existed - this.logger.error('duplicate created') - return - } - } - - const comment = await this.createComment( - this.data, - event.channel, - event.entities, - content, - type - ) - if (comment) { - this.numbers.push(comment.id) - } - } -} +import { app } from 'server/core' +import { Octokit } from '@octokit/rest' +import http from 'http' +import { Webhooks, createNodeMiddleware } from '@octokit/webhooks' +import ngrok from 'ngrok' +import { v4 as uuidv4 } from 'uuid' +import { getLogger } from 'shared/core' + +export class GithubConnector { + spellRunner + data + agent + lastTime + webhooks + middleware + webhookListeners = [] as any[] + octokit + secret + numbers + logger + + constructor({ spellRunner, agent }) { + this.logger = getLogger() + agent.github = this + this.spellRunner = spellRunner + const { data } = agent.data + this.data = data + this.agent = agent + this.numbers = [] + this.initialize({ data }) + } + + async initialize({ data }) { + if (!data.github_enabled) { + this.logger.info('Github is not enabled, skipping') + } + + if (!data.github_access_token) { + this.logger.info('Github is not enabled for this agent') + } + + this.logger.info( + 'Github enabled, initializing... %s, %o', + data.github_access_token, + data.github_repos + ) + + this.startWebhookServer() + + this.octokit = new Octokit({ + auth: data.github_access_token, + }) + + const repos = data.github_repos + + if (!repos) { + this.logger.error( + 'Github repos not configured correctly. No repos found. skipping' + ) + throw new Error( + 'Github repos not configured correctly. No repos found. skipping' + ) + } + + // repos is an array of owner/repos, separated by comma + // split it and add each repo to the webhook + repos.forEach(async repo => { + const [owner, name] = repo.trim().split('/') + this.logger.info('**** GITHUB: Added repo %s, %s to webhook', owner, name) + this.webhookListeners.push( + await this.startNgrokAndConfigureWebhook(owner, name) + ) + }) + } + + startWebhookServer() { + this.secret = uuidv4() + + this.logger.info('webhook start >') + this.webhooks = new Webhooks({ + secret: this.secret, + }) + + this.webhooks.on('pull_request.opened', ({ payload }) => { + this.logger.info('payload pull_request: %o', payload.pull_request) + const repo = { + owner: payload.repository.owner.login, + name: payload.repository.name, + } + this.newSpellInput('Pull Request', 'new_prs', payload.pull_request, repo) + }) + + this.webhooks.on('issues.opened', ({ payload }) => { + this.logger.info('payload issue: %o', payload.issue) + const repo = { + owner: payload.repository.owner.login, + name: payload.repository.name, + } + this.newSpellInput('Issue', 'new_issues', payload.issue, repo) + }) + + this.webhooks.on('issue_comment.created', ({ payload }) => { + this.logger.info('payload comment: %o', payload.comment) + const params = { + ...payload.comment, + number: payload.issue.number, + } + const repo = { + owner: payload.repository.owner.login, + name: payload.repository.name, + } + this.newSpellInput('Comment', 'issue_response', params, repo) + }) + + this.middleware = createNodeMiddleware(this.webhooks, { + path: '/payload', + }) + } + + async startNgrokAndConfigureWebhook(owner, repo) { + try { + // Generate a random port number between 4000 and 10000 + const randomPort = Math.floor(Math.random() * (10000 - 4000 + 1)) + 4000 + + // Start ngrok with the random port and retrieve the URL + const ngrokUrl = await ngrok.connect({ + addr: randomPort, + }) + + // Check if the webhook exists + const { data: webhooks } = await this.octokit.repos.listWebhooks({ + owner, + repo, + }) + + let webhookId, repoWebhook + this.logger.info('webhooks: %o', webhooks) + // If the webhook exists, update it with the new configuration + const events = [ + 'issues', + 'issue_comment', + 'pull_request', + 'push', + 'repository', + ] + if (webhooks.length > 0) { + const webhook = webhooks.find(hook => hook.config.url.includes('ngrok')) + + if (webhook) { + webhookId = webhook.id + webhook.config.port = randomPort + webhook.config.url = ngrokUrl + '/payload' + // config webhook secret + webhook.config.secret = this.secret + webhook.config.insecure_ssl = 0 + webhook.events = events + + await this.octokit.repos.updateWebhook({ + owner, + repo, + webhook_id: webhookId, + ...webhook, + }) + repoWebhook = webhook + this.logger.info('updateWebhook: %o', webhook.data) + } + } + + // If the webhook doesn't exist, create a new one + if (!webhookId) { + this.logger.info('webhookId > null') + const newWebhook = await this.octokit.repos.createWebhook({ + owner, + repo, + config: { + url: ngrokUrl + '/payload', + content_type: 'json', + insecure_ssl: 0, + port: randomPort, + secret: this.secret, + }, + events, + }) + + webhookId = newWebhook.data.id + repoWebhook = newWebhook + this.logger.info('createWebhook: %o', repoWebhook.data) + } + + // createServer with randomPort + http + .createServer(async (req, res) => { + if (await this.middleware(req, res)) return + res.writeHead(404) + res.end() + }) + .listen(randomPort) + + this.logger.info(`Ngrok URL: ${ngrokUrl}`) + this.logger.info(`Random Port: ${randomPort}`) + this.logger.info(`Webhook ID: ${webhookId}`) + return repoWebhook + } catch (error) { + this.logger.error('Error: %o', error) + return null + } + } + + newSpellInput = async ( + pretext: string, + type: string, + content: any, + repo: any + ) => { + const { number, title, body, id } = content + const { owner, name } = repo + const entities = [owner, name, title, body] + return app.get('agentCommander').runSpell({ + inputs: { + [`Input - Github (${pretext})`]: { + connector: `Github (${pretext})`, + content: body, + sender: owner, + observer: id, + client: 'github', + channel: number, + agentId: this.agent.id, + entities, + channelType: type, + rawData: JSON.stringify({ + number, + title, + body, + id, + owner, + name, + }), + }, + }, + agentId: this.agent.id, + spellId: this.agent.rootSpellId, + agent: this.agent, + secrets: this.agent.secrets, + publicVariables: this.agent.publicVariables, + runSubspell: true, + }) + } + + createComment = async ( + data: any, + number: number, + repo: any, + body: string, + type: 'issue' | 'pull_request' | 'comment' + ): Promise => { + const { github_access_token } = data + const owner = repo[0] + const name = repo[1] + this.logger.info( + 'GITHUB CREATE COMMENT: type:%s, [%s, %s]', + type, + owner, + name + ) + try { + if (!github_access_token || github_access_token[0] != 'g') { + this.logger.info('github access token is invalid') + return [] + } + if (!owner || owner == '') { + this.logger.info('owner/repo are invalid') + return [] + } + if (!name || name == '') { + this.logger.info('owner/repo are invalid') + return [] + } + if (!number || !body) { + this.logger.info('number/body are invalid') + return null + } + + const comment = await this.octokit.rest.issues.createComment({ + owner: owner, + repo: name, + issue_number: number, + body, + }) + this.logger.info( + 'new comment: %s, %o', + comment.data.id, + comment.data.body + ) + + return comment.data + } catch (error) { + this.logger.error('createComment error: %o', error) + return null + } + } + + getNewIssues = async (data: any, repo: any) => { + const { github_access_token } = data + const { owner, name } = repo + try { + if (!github_access_token || github_access_token[0] != 'g') { + this.logger.info('github access token is invalid') + return [] + } + if (!owner || owner == '') { + this.logger.info('owner/repo are invalid') + return [] + } + if (!name || name == '') { + this.logger.info('owner/repo are invalid') + return [] + } + + const since = new Date(this.lastTime).toISOString() + this.logger.info(`since = ${since}`) + + const newIssues = await this.octokit.rest.issues.listForRepo({ + owner: owner, + repo: name, + sort: 'created', + direction: 'desc', + since: since, + }) + + const filters = newIssues.data.filter(item => { + const created = new Date(item.created_at).getTime() + return created > this.lastTime + }) + this.logger.info('new issues: %o', filters) + + return filters + } catch (error) { + this.logger.error('%o', error) + return [] + } + } + + getNewPRs = async (data: any, repo: any) => { + const { github_access_token } = data + const { owner, name } = repo + try { + if (!github_access_token || github_access_token[0] != 'g') { + this.logger.info('github access token is invalid') + return [] + } + if (!owner || owner == '') { + this.logger.info('owner/repo are invalid') + return [] + } + if (!name || name == '') { + this.logger.info('owner/repo are invalid') + return [] + } + + const newPRs = await this.octokit.rest.pulls.list({ + owner: owner, + repo: name, + sort: 'created', + direction: 'desc', + }) + + const filters = newPRs.data.filter(item => { + const created = new Date(item.created_at).getTime() + return created > this.lastTime + }) + + this.logger.info('new PRs: %o', filters) + + return filters + } catch (error) { + this.logger.error('%o', error) + return [] + } + } + + getIssueComments = async (data: any, repo: any) => { + const { github_access_token } = data + const { owner, name } = repo + try { + if (!github_access_token || github_access_token[0] != 'g') { + this.logger.info('github access token is invalid') + return [] + } + if (!owner || owner == '') { + this.logger.info('owner/repo are invalid') + return [] + } + if (!name || name == '') { + this.logger.info('owner/repo are invalid') + return [] + } + + const since = new Date(this.lastTime).toISOString() + + const issueComments = await this.octokit.rest.issues.listCommentsForRepo({ + owner: owner, + repo: name, + sort: 'created', + direction: 'desc', + since: since, + }) + + this.logger.info('issue comments: %d', issueComments.data.length) + + return issueComments.data + } catch (error) { + this.logger.error('%o', error) + return [] + } + } + + async handleMessage( + event: any, + content: string, + type: 'issue' | 'pull_request' | 'comment' + ) { + this.logger.info('handleMessage: %o, %s | %s', event, content, type) + if (!content) { + this.logger.error('output is undefined') + return + } + if (!event.channel) { + this.logger.error('number is undefined') + return + } + if (!this.numbers) { + this.logger.info('null >> ') + this.numbers = [] + } + if (type === 'comment') { + const count = this.numbers.length + this.numbers = this.numbers.filter(num => num != event.observer) + if (this.numbers.length != count) { + // is existed + this.logger.error('duplicate created') + return + } + } + + const comment = await this.createComment( + this.data, + event.channel, + event.entities, + content, + type + ) + if (comment) { + this.numbers.push(comment.id) + } + } +} diff --git a/packages/plugins/github/server/src/index.ts b/packages/plugins/github/server/src/index.ts index 3a8a7d86f4..6b81f3fcbd 100644 --- a/packages/plugins/github/server/src/index.ts +++ b/packages/plugins/github/server/src/index.ts @@ -2,8 +2,8 @@ import { eventSocket, ServerPlugin, triggerSocket, - getLogger -} from '@magickml/core' + getLogger, +} from 'shared/core' import { GithubConnector } from './connectors/github' import { getNodes } from '@magickml/plugin-github-shared' @@ -36,8 +36,7 @@ function getAgentMethods() { async function stopGithub({ agent }) { const logger = getLogger() - if (!agent.github) - return logger.info("Github isn't running, can't stop it") + if (!agent.github) return logger.info("Github isn't running, can't stop it") try { await agent.github.destroy() agent.github = null diff --git a/packages/plugins/github/shared/project.json b/packages/plugins/github/shared/project.json index efc729ae92..8412c90eb6 100644 --- a/packages/plugins/github/shared/project.json +++ b/packages/plugins/github/shared/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/github/shared/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nrwl/linter:eslint", diff --git a/packages/plugins/github/shared/src/index.ts b/packages/plugins/github/shared/src/index.ts index 667d903cd8..f05faf5e57 100644 --- a/packages/plugins/github/shared/src/index.ts +++ b/packages/plugins/github/shared/src/index.ts @@ -1,10 +1,10 @@ -// DOCUMENTED +// DOCUMENTED /** * Imports */ -import { MagickComponent } from '@magickml/core' -import { GithubIssueSearch } from './nodes/GithubIssueSearch'; +import { MagickComponent } from 'shared/core' +import { GithubIssueSearch } from './nodes/GithubIssueSearch' /** * Export an array of all nodes used in the app. diff --git a/packages/plugins/github/shared/src/nodes/GithubIssueSearch.ts b/packages/plugins/github/shared/src/nodes/GithubIssueSearch.ts index de026e38a3..a948736e26 100644 --- a/packages/plugins/github/shared/src/nodes/GithubIssueSearch.ts +++ b/packages/plugins/github/shared/src/nodes/GithubIssueSearch.ts @@ -15,7 +15,7 @@ import { objectSocket, MagickWorkerOutputs, getLogger, -} from '@magickml/core' +} from 'shared/core' import axios from 'axios' diff --git a/packages/plugins/googleai/client/project.json b/packages/plugins/googleai/client/project.json index 6550dc133c..a280575508 100644 --- a/packages/plugins/googleai/client/project.json +++ b/packages/plugins/googleai/client/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/googleai/client/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/googleai/client/src/index.ts b/packages/plugins/googleai/client/src/index.ts index ebfb1bc1c3..64ad6af7a9 100644 --- a/packages/plugins/googleai/client/src/index.ts +++ b/packages/plugins/googleai/client/src/index.ts @@ -3,7 +3,7 @@ * A plugin for interacting with GoogleAI's API. * @class */ -import { ClientPlugin, InputControl } from '@magickml/core' +import { ClientPlugin, InputControl } from 'shared/core' import shared from '@magickml/plugin-googleai-shared' // Importing shared variables from plugin-googleai-shared module @@ -17,7 +17,7 @@ const textCompletionControls = [ name: 'Temperature (0-1.0)', icon: 'moon', defaultValue: 0.5, - tooltip: 'Change the Temperature' + tooltip: 'Change the Temperature', }, { type: InputControl, @@ -25,7 +25,7 @@ const textCompletionControls = [ name: 'Top K (0-100)', icon: 'moon', defaultValue: 50, - tooltip: 'Change the top_k ' + tooltip: 'Change the top_k ', }, { type: InputControl, @@ -33,7 +33,7 @@ const textCompletionControls = [ name: 'Top P (0-1.0)', icon: 'moon', defaultValue: 1, - tooltip: 'Change the top_p' + tooltip: 'Change the top_p', }, { type: InputControl, @@ -41,7 +41,7 @@ const textCompletionControls = [ name: 'Stop Sequences (comma separated)', icon: 'moon', defaultValue: '', - tooltip: 'Add Stop Sequence' + tooltip: 'Add Stop Sequence', }, ] diff --git a/packages/plugins/googleai/server/project.json b/packages/plugins/googleai/server/project.json index f82b1f3ba7..c59462d8ac 100644 --- a/packages/plugins/googleai/server/project.json +++ b/packages/plugins/googleai/server/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "plugin-googleai/server/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/googleai/server/src/functions/makeChatCompletion.ts b/packages/plugins/googleai/server/src/functions/makeChatCompletion.ts index 6f479c39ea..6884330c57 100644 --- a/packages/plugins/googleai/server/src/functions/makeChatCompletion.ts +++ b/packages/plugins/googleai/server/src/functions/makeChatCompletion.ts @@ -1,7 +1,7 @@ // DOCUMENTED -import { CompletionHandlerInputData, saveRequest } from '@magickml/core' +import { CompletionHandlerInputData, saveRequest } from 'shared/core' import { GOOGLEAI_ENDPOINT } from '../constants' -import { trackGoogleAIUsage } from '@magickml/server-core' +import { trackGoogleAIUsage } from 'server/core' import { wordCount } from './shared' import { DEFAULT_GOOGLEAI_API_KEY } from '@magickml/config' diff --git a/packages/plugins/googleai/server/src/functions/makeTextCompletion.ts b/packages/plugins/googleai/server/src/functions/makeTextCompletion.ts index aa758e359f..7cb7b75ae3 100644 --- a/packages/plugins/googleai/server/src/functions/makeTextCompletion.ts +++ b/packages/plugins/googleai/server/src/functions/makeTextCompletion.ts @@ -1,7 +1,7 @@ // DOCUMENTED -import { CompletionHandlerInputData, saveRequest } from '@magickml/core' +import { CompletionHandlerInputData, saveRequest } from 'shared/core' import { GOOGLEAI_ENDPOINT } from '../constants' -import { trackGoogleAIUsage } from '@magickml/server-core' +import { trackGoogleAIUsage } from 'server/core' import { wordCount } from './shared' import { DEFAULT_GOOGLEAI_API_KEY } from '@magickml/config' diff --git a/packages/plugins/googleai/server/src/functions/makeTextEmbedding.ts b/packages/plugins/googleai/server/src/functions/makeTextEmbedding.ts index bd5829bc6a..1e08313b4a 100644 --- a/packages/plugins/googleai/server/src/functions/makeTextEmbedding.ts +++ b/packages/plugins/googleai/server/src/functions/makeTextEmbedding.ts @@ -3,9 +3,9 @@ import { CompletionHandlerInputData, EmbeddingModel, saveRequest, -} from '@magickml/core' +} from 'shared/core' import { GOOGLEAI_ENDPOINT } from '../constants' -import { trackGoogleAIUsage } from '@magickml/server-core' +import { trackGoogleAIUsage } from 'server/core' import { wordCount } from './shared' import { DEFAULT_GOOGLEAI_API_KEY } from '@magickml/config' diff --git a/packages/plugins/googleai/server/src/index.ts b/packages/plugins/googleai/server/src/index.ts index b64944a7f0..3820399b5b 100644 --- a/packages/plugins/googleai/server/src/index.ts +++ b/packages/plugins/googleai/server/src/index.ts @@ -9,7 +9,7 @@ * @packageDocumentation */ -import { ServerPlugin } from '@magickml/core' +import { ServerPlugin } from 'shared/core' import shared from '@magickml/plugin-googleai-shared' import { makeChatCompletion, diff --git a/packages/plugins/googleai/shared/project.json b/packages/plugins/googleai/shared/project.json index 88e2d7d6a4..54461a7471 100644 --- a/packages/plugins/googleai/shared/project.json +++ b/packages/plugins/googleai/shared/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/googleai/shared/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/googleai/shared/src/index.ts b/packages/plugins/googleai/shared/src/index.ts index 09e1e0b8cf..bc24b3a301 100644 --- a/packages/plugins/googleai/shared/src/index.ts +++ b/packages/plugins/googleai/shared/src/index.ts @@ -5,7 +5,7 @@ import { embeddingSocket, PluginSecret, stringSocket, -} from '@magickml/core' +} from 'shared/core' /** * An array of PluginSecret objects containing information about API key secrets. diff --git a/packages/plugins/intent/client/project.json b/packages/plugins/intent/client/project.json index 8208792706..ffb9341669 100644 --- a/packages/plugins/intent/client/project.json +++ b/packages/plugins/intent/client/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/intent/client/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nrwl/linter:eslint", diff --git a/packages/plugins/intent/client/src/index.ts b/packages/plugins/intent/client/src/index.ts index 13e3f959d2..987dc46457 100644 --- a/packages/plugins/intent/client/src/index.ts +++ b/packages/plugins/intent/client/src/index.ts @@ -1,4 +1,4 @@ -import { ClientPlugin } from '@magickml/core' +import { ClientPlugin } from 'shared/core' import { getNodes } from '@magickml/plugin-intent-shared' import MediationIcon from '@mui/icons-material/Mediation' import IntentWindow from './windows/IntentWindow' diff --git a/packages/plugins/intent/client/src/windows/IntentWindow/IntentTable.tsx b/packages/plugins/intent/client/src/windows/IntentWindow/IntentTable.tsx index fe0952477b..46b5ecb9c9 100644 --- a/packages/plugins/intent/client/src/windows/IntentWindow/IntentTable.tsx +++ b/packages/plugins/intent/client/src/windows/IntentWindow/IntentTable.tsx @@ -1,7 +1,7 @@ // DOCUMENTED // Import statements kept as-is import { TableComponent } from 'client/core' -import { CompletionProvider, pluginManager } from '@magickml/core' +import { CompletionProvider, pluginManager } from 'shared/core' import { API_ROOT_URL } from 'shared/config' import { MoreHoriz, NewReleases, Refresh } from '@mui/icons-material' import { diff --git a/packages/plugins/intent/server/project.json b/packages/plugins/intent/server/project.json index dac6bc4947..6b78b642d6 100644 --- a/packages/plugins/intent/server/project.json +++ b/packages/plugins/intent/server/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/intent/server/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/intent/server/src/index.ts b/packages/plugins/intent/server/src/index.ts index 84c8233a89..daaff26627 100644 --- a/packages/plugins/intent/server/src/index.ts +++ b/packages/plugins/intent/server/src/index.ts @@ -1,4 +1,4 @@ -import { ServerPlugin } from '@magickml/core' +import { ServerPlugin } from 'shared/core' import { getNodes } from '@magickml/plugin-intent-shared' import { intent } from './services/intent/intent' diff --git a/packages/plugins/intent/server/src/services/intent/intent.class.ts b/packages/plugins/intent/server/src/services/intent/intent.class.ts index 766d55c750..dc180c0339 100644 --- a/packages/plugins/intent/server/src/services/intent/intent.class.ts +++ b/packages/plugins/intent/server/src/services/intent/intent.class.ts @@ -6,7 +6,7 @@ import type { Params } from '@feathersjs/feathers' import type { KnexAdapterOptions, KnexAdapterParams } from '@feathersjs/knex' import { KnexService } from '@feathersjs/knex' -import { Application, app } from '@magickml/server-core' +import { Application, app } from 'server/core' import type { Intent, IntentData, @@ -18,7 +18,7 @@ import { MagickWorkerOutputs, WorkerData, pluginManager, -} from '@magickml/core' +} from 'shared/core' import { v4 as uuidv4 } from 'uuid' /** Type for Intent Params */ diff --git a/packages/plugins/intent/server/src/services/intent/intent.schema.ts b/packages/plugins/intent/server/src/services/intent/intent.schema.ts index b9c7e3d491..99caf4a04b 100644 --- a/packages/plugins/intent/server/src/services/intent/intent.schema.ts +++ b/packages/plugins/intent/server/src/services/intent/intent.schema.ts @@ -8,8 +8,8 @@ import { } from '@feathersjs/typebox' import type { Static } from '@feathersjs/typebox' -import type { HookContext } from '@magickml/server-core' -import { dataValidator, queryValidator } from '@magickml/server-core' +import type { HookContext } from 'server/core' +import { dataValidator, queryValidator } from 'server/core' /** * Full data model schema for a document. diff --git a/packages/plugins/intent/server/src/services/intent/intent.ts b/packages/plugins/intent/server/src/services/intent/intent.ts index 6ab11fd8fd..3dd77e9a12 100644 --- a/packages/plugins/intent/server/src/services/intent/intent.ts +++ b/packages/plugins/intent/server/src/services/intent/intent.ts @@ -15,14 +15,14 @@ import { checkPermissions, type Application, type HookContext, -} from '@magickml/server-core' +} from 'server/core' import { IntentService, getOptions } from './intent.class' // Array with 1536 elements containing 0 const nullArray = new Array(1536).fill(0) // Add this service to the service type index -declare module '@magickml/server-core' { +declare module 'server/core' { interface ServiceTypes { [intentPath]: IntentService } diff --git a/packages/plugins/intent/shared/project.json b/packages/plugins/intent/shared/project.json index 6b313bd013..8de40889a8 100644 --- a/packages/plugins/intent/shared/project.json +++ b/packages/plugins/intent/shared/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/intent/shared/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nrwl/linter:eslint", diff --git a/packages/plugins/intent/shared/src/index.ts b/packages/plugins/intent/shared/src/index.ts index 0560362359..f78b6fcea1 100644 --- a/packages/plugins/intent/shared/src/index.ts +++ b/packages/plugins/intent/shared/src/index.ts @@ -3,7 +3,7 @@ * Imports */ -import { MagickComponent } from '@magickml/core' +import { MagickComponent } from 'shared/core' import { IntentSearch } from './nodes/IntentSearch' /** diff --git a/packages/plugins/intent/shared/src/nodes/IntentSearch.ts b/packages/plugins/intent/shared/src/nodes/IntentSearch.ts index 7a4cd5688b..5899b38c42 100644 --- a/packages/plugins/intent/shared/src/nodes/IntentSearch.ts +++ b/packages/plugins/intent/shared/src/nodes/IntentSearch.ts @@ -4,7 +4,7 @@ * @category Intent */ import Rete from 'shared/rete' -import { InputControl } from '@magickml/core' +import { InputControl } from 'shared/core' import { MagickComponent, numberSocket, @@ -16,7 +16,7 @@ import { ModuleContext, WorkerData, MagickWorkerOutputs, -} from '@magickml/core' +} from 'shared/core' /** * The return type of the worker function. diff --git a/packages/plugins/localmodel/client/project.json b/packages/plugins/localmodel/client/project.json index 2be7a4aaf0..bcf4ee2975 100644 --- a/packages/plugins/localmodel/client/project.json +++ b/packages/plugins/localmodel/client/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/localmodel/client/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/localmodel/client/src/index.ts b/packages/plugins/localmodel/client/src/index.ts index 6965ba678c..4b2f68a1da 100644 --- a/packages/plugins/localmodel/client/src/index.ts +++ b/packages/plugins/localmodel/client/src/index.ts @@ -1,9 +1,9 @@ -// DOCUMENTED +// DOCUMENTED /** * A plugin for interacting with local models. * @class */ -import { ClientPlugin, InputControl } from '@magickml/core' +import { ClientPlugin, InputControl } from 'shared/core' import shared from '@magickml/plugin-localmodel-shared' // Importing shared variables from plugin-localmodel-shared module @@ -84,7 +84,7 @@ const chatCompletionControls = [ name: 'Presence Penalty (0-2.0)', icon: 'moon', defaultValue: 0, - } + }, ] // Object containing all input controls for different completion types @@ -99,7 +99,7 @@ const LocalModelPlugin = new ClientPlugin({ name: 'LocalModelPlugin', secrets, // API Key and Model ID secrets completionProviders: completionProviders.map(provider => { - // Adding custom input controls for each completion type + // Adding custom input controls for each completion type return { ...provider, inspectorControls: inspectorControls[provider.subtype], @@ -107,4 +107,4 @@ const LocalModelPlugin = new ClientPlugin({ }), }) -export default LocalModelPlugin \ No newline at end of file +export default LocalModelPlugin diff --git a/packages/plugins/localmodel/server/project.json b/packages/plugins/localmodel/server/project.json index 8531017605..96f3eea67f 100644 --- a/packages/plugins/localmodel/server/project.json +++ b/packages/plugins/localmodel/server/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "plugin-localmodel/server/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/localmodel/server/src/functions/makeChatCompletion.ts b/packages/plugins/localmodel/server/src/functions/makeChatCompletion.ts index d764a795a9..357927e2aa 100644 --- a/packages/plugins/localmodel/server/src/functions/makeChatCompletion.ts +++ b/packages/plugins/localmodel/server/src/functions/makeChatCompletion.ts @@ -3,7 +3,7 @@ import { ChatMessage, CompletionHandlerInputData, saveRequest, -} from '@magickml/core' +} from 'shared/core' import axios from 'axios' import { LOCALMODEL_ENPOINT } from '../constants' diff --git a/packages/plugins/localmodel/server/src/functions/makeTextCompletion.ts b/packages/plugins/localmodel/server/src/functions/makeTextCompletion.ts index 6d9e4d6b13..135286436a 100644 --- a/packages/plugins/localmodel/server/src/functions/makeTextCompletion.ts +++ b/packages/plugins/localmodel/server/src/functions/makeTextCompletion.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import { CompletionHandlerInputData, saveRequest } from '@magickml/core' +import { CompletionHandlerInputData, saveRequest } from 'shared/core' import axios from 'axios' import { LOCALMODEL_ENPOINT } from '../constants' diff --git a/packages/plugins/localmodel/server/src/functions/makeTextEmbedding.ts b/packages/plugins/localmodel/server/src/functions/makeTextEmbedding.ts index 93ea268069..528335b3f5 100644 --- a/packages/plugins/localmodel/server/src/functions/makeTextEmbedding.ts +++ b/packages/plugins/localmodel/server/src/functions/makeTextEmbedding.ts @@ -3,7 +3,7 @@ import { CompletionHandlerInputData, EmbeddingModel, saveRequest, -} from '@magickml/core' +} from 'shared/core' import axios from 'axios' import { LOCALMODEL_ENPOINT } from '../constants' diff --git a/packages/plugins/localmodel/server/src/index.ts b/packages/plugins/localmodel/server/src/index.ts index d2dfde2ee3..28d1825031 100644 --- a/packages/plugins/localmodel/server/src/index.ts +++ b/packages/plugins/localmodel/server/src/index.ts @@ -9,7 +9,7 @@ * @packageDocumentation */ -import { ServerPlugin } from '@magickml/core' +import { ServerPlugin } from 'shared/core' import shared from '@magickml/plugin-localmodel-shared' import { makeChatCompletion, diff --git a/packages/plugins/localmodel/shared/project.json b/packages/plugins/localmodel/shared/project.json index ca10a96b46..c72d6577ef 100644 --- a/packages/plugins/localmodel/shared/project.json +++ b/packages/plugins/localmodel/shared/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/localmodel/shared/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/localmodel/shared/src/index.ts b/packages/plugins/localmodel/shared/src/index.ts index 5d573a76e8..accfe0bbdd 100644 --- a/packages/plugins/localmodel/shared/src/index.ts +++ b/packages/plugins/localmodel/shared/src/index.ts @@ -1,98 +1,96 @@ -// DOCUMENTED +// DOCUMENTED import { arraySocket, CompletionProvider, embeddingSocket, PluginSecret, stringSocket, -} from "@magickml/core"; +} from 'shared/core' /** * An array of PluginSecret objects containing information about API key secrets. */ -const secrets: PluginSecret[] = []; +const secrets: PluginSecret[] = [] /** * An array of CompletionProvider objects containing information about supported completion providers. */ const completionProviders: CompletionProvider[] = [ { - type: "text", - subtype: "text", + type: 'text', + subtype: 'text', inputs: [ { - socket: "input", - name: "Input", + socket: 'input', + name: 'Input', type: stringSocket, }, ], outputs: [ { - socket: "result", - name: "Result", + socket: 'result', + name: 'Result', type: stringSocket, - } - ], - models: [ - "Loaded Text Completion Model", + }, ], + models: ['Loaded Text Completion Model'], }, { - type: "text", - subtype: "embedding", + type: 'text', + subtype: 'embedding', inputs: [ { - socket: "input", - name: "Input", + socket: 'input', + name: 'Input', type: stringSocket, }, ], outputs: [ { - socket: "embedding", - name: "Embedding", + socket: 'embedding', + name: 'Embedding', type: embeddingSocket, - } + }, ], - models: ["all-mpnet-base-v2"], + models: ['all-mpnet-base-v2'], }, { - type: "text", - subtype: "chat", + type: 'text', + subtype: 'chat', inputs: [ { - socket: "system", - name: "System Directive", + socket: 'system', + name: 'System Directive', type: stringSocket, }, { - socket: "conversation", - name: "Conversation ", + socket: 'conversation', + name: 'Conversation ', type: arraySocket, }, { - socket: "input", - name: "Input", + socket: 'input', + name: 'Input', type: stringSocket, }, ], outputs: [ { - socket: "result", - name: "Result", + socket: 'result', + name: 'Result', type: stringSocket, }, { - socket: "error", - name: "Error", + socket: 'error', + name: 'Error', type: stringSocket, }, ], - models: ["Loaded Chat Completion Model"], + models: ['Loaded Chat Completion Model'], }, -]; +] export default { secrets, completionProviders, -}; \ No newline at end of file +} diff --git a/packages/plugins/loop/client/project.json b/packages/plugins/loop/client/project.json index 97ba382920..31fbcd1cfc 100644 --- a/packages/plugins/loop/client/project.json +++ b/packages/plugins/loop/client/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/loop/client/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/loop/client/src/index.ts b/packages/plugins/loop/client/src/index.ts index 3b1180b1c5..331e3a807f 100644 --- a/packages/plugins/loop/client/src/index.ts +++ b/packages/plugins/loop/client/src/index.ts @@ -1,6 +1,6 @@ -// DOCUMENTED -import { eventSocket, ClientPlugin, triggerSocket } from '@magickml/core'; -import { AgentLoopWindow } from './components/loop.component'; +// DOCUMENTED +import { eventSocket, ClientPlugin, triggerSocket } from 'shared/core' +import { AgentLoopWindow } from './components/loop.component' /** * The sockets that the `LoopPlugin` accepts as input. @@ -16,7 +16,7 @@ const inputSockets = [ name: 'trigger', type: triggerSocket, }, -]; +] /** * The `LoopPlugin` class provides loop functionality to the engine. @@ -31,8 +31,8 @@ class LoopPlugin extends ClientPlugin { agentComponents: [AgentLoopWindow], inputTypes: [{ name: 'Loop In', sockets: inputSockets }], spellTemplates: [], - }); + }) } } -export default new LoopPlugin(); \ No newline at end of file +export default new LoopPlugin() diff --git a/packages/plugins/loop/server/project.json b/packages/plugins/loop/server/project.json index 7ce3b2b2eb..e6779fb00b 100644 --- a/packages/plugins/loop/server/project.json +++ b/packages/plugins/loop/server/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/loop/server/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/loop/server/src/index.ts b/packages/plugins/loop/server/src/index.ts index fe997202fc..6bf7165e9a 100644 --- a/packages/plugins/loop/server/src/index.ts +++ b/packages/plugins/loop/server/src/index.ts @@ -4,8 +4,8 @@ import { getLogger, ServerPlugin, triggerSocket, -} from '@magickml/core' -import { app } from '@magickml/server-core' +} from 'shared/core' +import { app } from 'server/core' import { LoopHandler } from './loopHandler' import { Agent } from 'server/agents' import pino from 'pino' diff --git a/packages/plugins/loop/shared/project.json b/packages/plugins/loop/shared/project.json index 83352226ad..364c020d02 100644 --- a/packages/plugins/loop/shared/project.json +++ b/packages/plugins/loop/shared/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/loop/shared/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nrwl/linter:eslint", diff --git a/packages/plugins/openai/client/project.json b/packages/plugins/openai/client/project.json index 92b4dcf1e6..e9fc5bfb85 100644 --- a/packages/plugins/openai/client/project.json +++ b/packages/plugins/openai/client/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/openai/client/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/openai/client/src/index.ts b/packages/plugins/openai/client/src/index.ts index e9d9800e56..fb7a7a8846 100644 --- a/packages/plugins/openai/client/src/index.ts +++ b/packages/plugins/openai/client/src/index.ts @@ -3,7 +3,7 @@ * A plugin for interacting with OpenAI's API. * @class */ -import { ClientPlugin, InputControl } from '@magickml/core' +import { ClientPlugin, InputControl } from 'shared/core' import shared from '@magickml/plugin-openai-shared' // Importing shared variables from plugin-openai-shared module diff --git a/packages/plugins/openai/server/project.json b/packages/plugins/openai/server/project.json index 083d6caa91..15e1680aa0 100644 --- a/packages/plugins/openai/server/project.json +++ b/packages/plugins/openai/server/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "plugin-openai/server/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/openai/server/src/functions/makeChatCompletion.ts b/packages/plugins/openai/server/src/functions/makeChatCompletion.ts index 2d2ce3805c..fc2a59425a 100644 --- a/packages/plugins/openai/server/src/functions/makeChatCompletion.ts +++ b/packages/plugins/openai/server/src/functions/makeChatCompletion.ts @@ -3,7 +3,7 @@ import { ChatMessage, CompletionHandlerInputData, saveRequest, -} from '@magickml/core' +} from 'shared/core' import axios from 'axios' import { OPENAI_ENDPOINT } from '../constants' import { @@ -12,7 +12,7 @@ import { BACKOFF_RETRY_LIMIT, } from 'shared/config' import { GPT4_MODELS } from '@magickml/plugin-openai-shared' -import { trackOpenAIUsage } from '@magickml/server-core' +import { trackOpenAIUsage } from 'server/core' import axiosRetry from 'axios-retry' /** diff --git a/packages/plugins/openai/server/src/functions/makeTextCompletion.ts b/packages/plugins/openai/server/src/functions/makeTextCompletion.ts index f1a58617b8..42b4a09f3d 100644 --- a/packages/plugins/openai/server/src/functions/makeTextCompletion.ts +++ b/packages/plugins/openai/server/src/functions/makeTextCompletion.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import { CompletionHandlerInputData, saveRequest } from '@magickml/core' +import { CompletionHandlerInputData, saveRequest } from 'shared/core' import axios from 'axios' import { OPENAI_ENDPOINT } from '../constants' import { @@ -8,7 +8,7 @@ import { BACKOFF_RETRY_LIMIT, } from 'shared/config' import { GPT4_MODELS } from '@magickml/plugin-openai-shared' -import { trackOpenAIUsage } from '@magickml/server-core' +import { trackOpenAIUsage } from 'server/core' import axiosRetry from 'axios-retry' /** diff --git a/packages/plugins/openai/server/src/functions/makeTextEmbedding.ts b/packages/plugins/openai/server/src/functions/makeTextEmbedding.ts index b32e6722ab..e8b84b5f9e 100644 --- a/packages/plugins/openai/server/src/functions/makeTextEmbedding.ts +++ b/packages/plugins/openai/server/src/functions/makeTextEmbedding.ts @@ -3,11 +3,11 @@ import { CompletionHandlerInputData, EmbeddingModel, saveRequest, -} from '@magickml/core' +} from 'shared/core' import axios from 'axios' import { OPENAI_ENDPOINT } from '../constants' import { DEFAULT_OPENAI_KEY } from 'shared/config' -import { trackOpenAIUsage } from '@magickml/server-core' +import { trackOpenAIUsage } from 'server/core' /** * A function that makes a request to create a text embedding using OpenAI's diff --git a/packages/plugins/openai/server/src/functions/makeTypeChatCompletion.ts b/packages/plugins/openai/server/src/functions/makeTypeChatCompletion.ts index 7a21e64963..ff7df4c6b9 100644 --- a/packages/plugins/openai/server/src/functions/makeTypeChatCompletion.ts +++ b/packages/plugins/openai/server/src/functions/makeTypeChatCompletion.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import { CompletionHandlerInputData, saveRequest } from '@magickml/core' +import { CompletionHandlerInputData, saveRequest } from 'shared/core' import { createLanguageModel, createJsonTranslator, diff --git a/packages/plugins/openai/server/src/index.ts b/packages/plugins/openai/server/src/index.ts index 9d724d9ce1..3902b84d2b 100644 --- a/packages/plugins/openai/server/src/index.ts +++ b/packages/plugins/openai/server/src/index.ts @@ -9,7 +9,7 @@ * @packageDocumentation */ -import { ServerPlugin } from '@magickml/core' +import { ServerPlugin } from 'shared/core' import shared from '@magickml/plugin-openai-shared' import { makeChatCompletion, @@ -18,7 +18,6 @@ import { makeTypeChatCompletion, } from './functions' - /** * The secrets used by the OpenAI API */ diff --git a/packages/plugins/openai/shared/project.json b/packages/plugins/openai/shared/project.json index a142d07ea8..eb74cd2f6a 100644 --- a/packages/plugins/openai/shared/project.json +++ b/packages/plugins/openai/shared/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/openai/shared/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/openai/shared/src/index.ts b/packages/plugins/openai/shared/src/index.ts index 92043f6a7d..4f9bcd3a15 100644 --- a/packages/plugins/openai/shared/src/index.ts +++ b/packages/plugins/openai/shared/src/index.ts @@ -6,7 +6,7 @@ import { objectSocket, PluginSecret, stringSocket, -} from '@magickml/core' +} from 'shared/core' export const GPT4_MODELS = ['gpt-4', 'gpt-4-0613'] diff --git a/packages/plugins/pinecone/client/project.json b/packages/plugins/pinecone/client/project.json index cb755cb3d5..61be1c457d 100644 --- a/packages/plugins/pinecone/client/project.json +++ b/packages/plugins/pinecone/client/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/pinecone/client/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/pinecone/client/src/index.ts b/packages/plugins/pinecone/client/src/index.ts index 895f7cd612..fac86abb39 100644 --- a/packages/plugins/pinecone/client/src/index.ts +++ b/packages/plugins/pinecone/client/src/index.ts @@ -1,9 +1,9 @@ -// DOCUMENTED +// DOCUMENTED /** * Represents the Pinecone plugin for the MagickML engine. * @class */ -import { ClientPlugin } from '@magickml/core' +import { ClientPlugin } from 'shared/core' import Nodes from '@magickml/plugin-pinecone-shared' const PineconePlugin = new ClientPlugin({ @@ -33,8 +33,8 @@ const PineconePlugin = new ClientPlugin({ * URL that is used to retrieve the Pinecone API key. * @type {string} */ - getUrl: 'https://app.pinecone.io/' - } + getUrl: 'https://app.pinecone.io/', + }, ], }) diff --git a/packages/plugins/pinecone/server/project.json b/packages/plugins/pinecone/server/project.json index f099765744..843f600886 100644 --- a/packages/plugins/pinecone/server/project.json +++ b/packages/plugins/pinecone/server/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/pinecone/server/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/pinecone/server/src/index.ts b/packages/plugins/pinecone/server/src/index.ts index 9f19dd1025..52d0931f38 100644 --- a/packages/plugins/pinecone/server/src/index.ts +++ b/packages/plugins/pinecone/server/src/index.ts @@ -1,4 +1,4 @@ -// DOCUMENTED +// DOCUMENTED /** * A plugin used for the Pinecone integration with MagickML engine. * @@ -6,7 +6,7 @@ * @param nodes - the nodes used by the plugin. * @param secrets - an array of secrets used by the plugin. */ -import { ServerPlugin } from "@magickml/core" +import { ServerPlugin } from 'shared/core' import Nodes from '@magickml/plugin-pinecone-shared' const PineconePlugin = new ServerPlugin({ @@ -17,9 +17,9 @@ const PineconePlugin = new ServerPlugin({ name: 'Pinecone API Key', key: 'pinecone_api_key', global: true, - getUrl: 'https://app.pinecone.io/' - } + getUrl: 'https://app.pinecone.io/', + }, ], -}); +}) -export default PineconePlugin; \ No newline at end of file +export default PineconePlugin diff --git a/packages/plugins/pinecone/shared/project.json b/packages/plugins/pinecone/shared/project.json index 27428fc3a6..92aca9d175 100644 --- a/packages/plugins/pinecone/shared/project.json +++ b/packages/plugins/pinecone/shared/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/pinecone/shared/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/pinecone/shared/src/nodes/QueryPinecone.ts b/packages/plugins/pinecone/shared/src/nodes/QueryPinecone.ts index 051bb17c61..7876d6d72e 100644 --- a/packages/plugins/pinecone/shared/src/nodes/QueryPinecone.ts +++ b/packages/plugins/pinecone/shared/src/nodes/QueryPinecone.ts @@ -11,7 +11,7 @@ import { MagickNodeData, stringSocket, triggerSocket, -} from '@magickml/core' +} from 'shared/core' import { PineconeClient } from '@pinecone-database/pinecone' diff --git a/packages/plugins/rest/client/project.json b/packages/plugins/rest/client/project.json index 66d5998a43..0b2e06226e 100644 --- a/packages/plugins/rest/client/project.json +++ b/packages/plugins/rest/client/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/rest/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/rest/client/src/index.ts b/packages/plugins/rest/client/src/index.ts index bc2b4842c8..942a96a820 100644 --- a/packages/plugins/rest/client/src/index.ts +++ b/packages/plugins/rest/client/src/index.ts @@ -1,14 +1,10 @@ -// DOCUMENTED +// DOCUMENTED /** * This module contains a Typescript script for a RestPlugin ClientPlugin. * The plugin allows access to REST API through GET, POST, PUT, and DELETE requests. */ -import { - ClientPlugin, - eventSocket, - triggerSocket -} from '@magickml/core' +import { ClientPlugin, eventSocket, triggerSocket } from 'shared/core' import { RestAgentWindow } from './components/rest.component' import RestSpellTemplate from './templates/spells/REST API.spell.json' @@ -37,7 +33,7 @@ const outputSockets = [ socket: 'output', name: 'output', type: eventSocket, - } + }, ] /** @@ -53,9 +49,7 @@ const RestPlugin = new ClientPlugin({ { name: 'REST API (PUT)', sockets: inputSockets }, { name: 'REST API (DELETE)', sockets: inputSockets }, ], - outputTypes: [ - { name: 'REST API (Response)', sockets: outputSockets }, - ], + outputTypes: [{ name: 'REST API (Response)', sockets: outputSockets }], }) -export default RestPlugin \ No newline at end of file +export default RestPlugin diff --git a/packages/plugins/rest/server/project.json b/packages/plugins/rest/server/project.json index 5a97751e39..ef6e1e022f 100644 --- a/packages/plugins/rest/server/project.json +++ b/packages/plugins/rest/server/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/rest/server/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/rest/server/src/index.ts b/packages/plugins/rest/server/src/index.ts index 63c757eb49..7576a64357 100644 --- a/packages/plugins/rest/server/src/index.ts +++ b/packages/plugins/rest/server/src/index.ts @@ -15,7 +15,7 @@ * @property {string} type - The socket type, always `eventSocket`. */ -import { eventSocket, ServerPlugin, triggerSocket } from '@magickml/core' +import { eventSocket, ServerPlugin, triggerSocket } from 'shared/core' import { agentHttp } from './services/agentHttp/agentHttp' /** diff --git a/packages/plugins/rest/server/src/services/agentHttp/agentHttp.class.ts b/packages/plugins/rest/server/src/services/agentHttp/agentHttp.class.ts index ee4dc538b5..3e75773d6f 100644 --- a/packages/plugins/rest/server/src/services/agentHttp/agentHttp.class.ts +++ b/packages/plugins/rest/server/src/services/agentHttp/agentHttp.class.ts @@ -3,7 +3,7 @@ * For more information about this file see * https://dove.feathersjs.com/guides/cli/service.class.html#custom-services */ -import { Application, app } from '@magickml/server-core' +import { Application, app } from 'server/core' import type { Agent } from 'server/agents' import type { Params, ServiceInterface } from '@feathersjs/feathers' import { GeneralError } from '@feathersjs/errors' @@ -15,7 +15,7 @@ import type { } from './agentHttp.schema' import { BadRequest, NotFound } from '@feathersjs/errors/lib' import { pino } from 'pino' -import { getLogger } from '@magickml/core' +import { getLogger } from 'shared/core' import { CLOUD_AGENT_KEY, STANDALONE } from 'shared/config' export type { AgentHttp, AgentHttpData, AgentHttpPatch, AgentHttpQuery } diff --git a/packages/plugins/rest/server/src/services/agentHttp/agentHttp.schema.ts b/packages/plugins/rest/server/src/services/agentHttp/agentHttp.schema.ts index dadad00d79..6103bffd2e 100644 --- a/packages/plugins/rest/server/src/services/agentHttp/agentHttp.schema.ts +++ b/packages/plugins/rest/server/src/services/agentHttp/agentHttp.schema.ts @@ -3,8 +3,8 @@ import { resolve } from '@feathersjs/schema' import { Type, getValidator } from '@feathersjs/typebox' import type { Static } from '@feathersjs/typebox' -import type { HookContext } from '@magickml/server-core' -import { dataValidator, queryValidator } from '@magickml/server-core' +import type { HookContext } from 'server/core' +import { dataValidator, queryValidator } from 'server/core' /** * Main data model schema diff --git a/packages/plugins/rest/server/src/services/agentHttp/agentHttp.ts b/packages/plugins/rest/server/src/services/agentHttp/agentHttp.ts index c4d65fb8fb..bd17a310c7 100644 --- a/packages/plugins/rest/server/src/services/agentHttp/agentHttp.ts +++ b/packages/plugins/rest/server/src/services/agentHttp/agentHttp.ts @@ -17,11 +17,11 @@ import { } from './agentHttp.schema' // Import types and classes -import { checkPermissions, type Application } from '@magickml/server-core' +import { checkPermissions, type Application } from 'server/core' import { AgentHttpService } from './agentHttp.class' // Add this service to the service type index -declare module '@magickml/server-core' { +declare module 'server/core' { interface ServiceTypes { [agentHttpPath]: AgentHttpService } diff --git a/packages/plugins/search/client/project.json b/packages/plugins/search/client/project.json index 03bfccc341..97f95c0fa5 100644 --- a/packages/plugins/search/client/project.json +++ b/packages/plugins/search/client/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/search/client/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/search/client/src/index.ts b/packages/plugins/search/client/src/index.ts index d07134add3..9574a4b97e 100644 --- a/packages/plugins/search/client/src/index.ts +++ b/packages/plugins/search/client/src/index.ts @@ -3,7 +3,7 @@ * The `ClientPlugin` interface represents a plugin used by the application. * @interface */ -import { ClientPlugin } from '@magickml/core' +import { ClientPlugin } from 'shared/core' /** * This is the `Nodes` object from the search shared plugin. diff --git a/packages/plugins/search/server/project.json b/packages/plugins/search/server/project.json index c3b622daaf..ebb14d1b2e 100644 --- a/packages/plugins/search/server/project.json +++ b/packages/plugins/search/server/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/search/server/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/search/server/src/index.ts b/packages/plugins/search/server/src/index.ts index 0add129fa7..2bf77a3e96 100644 --- a/packages/plugins/search/server/src/index.ts +++ b/packages/plugins/search/server/src/index.ts @@ -2,7 +2,7 @@ /** * Class representing a server plugin for search functionality */ -import { ServerPlugin } from '@magickml/core' +import { ServerPlugin } from 'shared/core' /** * Nodes that are shared between search plugins diff --git a/packages/plugins/search/server/src/services/google-search/google-search.ts b/packages/plugins/search/server/src/services/google-search/google-search.ts index b3a44932ce..9624a55f54 100644 --- a/packages/plugins/search/server/src/services/google-search/google-search.ts +++ b/packages/plugins/search/server/src/services/google-search/google-search.ts @@ -6,7 +6,7 @@ * @returns void */ -import type { Application } from '@magickml/server-core' +import type { Application } from 'server/core' import { GoogleSearchService } from './google-search.class' // Add this service to the service type index diff --git a/packages/plugins/search/shared/project.json b/packages/plugins/search/shared/project.json index 9296de0003..9de556fef1 100644 --- a/packages/plugins/search/shared/project.json +++ b/packages/plugins/search/shared/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/search/shared/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/search/shared/src/functions/SearchMetaphor.ts b/packages/plugins/search/shared/src/functions/SearchMetaphor.ts index 7b214f16a8..38e8194784 100644 --- a/packages/plugins/search/shared/src/functions/SearchMetaphor.ts +++ b/packages/plugins/search/shared/src/functions/SearchMetaphor.ts @@ -1,7 +1,7 @@ // DOCUMENTED -import { CompletionHandlerInputData } from '@magickml/core' +import { CompletionHandlerInputData } from 'shared/core' import metaphor from 'metaphor-node' -import { saveRequest } from '@magickml/core' +import { saveRequest } from 'shared/core' /** * Makes an API request to an AI text completion service. diff --git a/packages/plugins/search/shared/src/index.ts b/packages/plugins/search/shared/src/index.ts index 2c3833f126..353b20f288 100644 --- a/packages/plugins/search/shared/src/index.ts +++ b/packages/plugins/search/shared/src/index.ts @@ -3,7 +3,7 @@ * This is the main file exporting the nodes used in the app */ -import { MagickComponent, PluginSecret } from '@magickml/core' +import { MagickComponent, PluginSecret } from 'shared/core' import { SearchGoogle } from './nodes/SearchGoogle' import { SearchMetaphor } from './nodes/SearchMetaphor' diff --git a/packages/plugins/search/shared/src/nodes/SearchGoogle.ts b/packages/plugins/search/shared/src/nodes/SearchGoogle.ts index 5f71fae6bb..95d9567c34 100644 --- a/packages/plugins/search/shared/src/nodes/SearchGoogle.ts +++ b/packages/plugins/search/shared/src/nodes/SearchGoogle.ts @@ -14,7 +14,7 @@ import { WorkerData, MagickWorkerOutputs, ModuleContext, -} from '@magickml/core' +} from 'shared/core' const info = `When the alert component is triggered, it will fire an alert with the message in the input box.` diff --git a/packages/plugins/search/shared/src/nodes/SearchMetaphor.ts b/packages/plugins/search/shared/src/nodes/SearchMetaphor.ts index a196ee8035..79172c57bf 100644 --- a/packages/plugins/search/shared/src/nodes/SearchMetaphor.ts +++ b/packages/plugins/search/shared/src/nodes/SearchMetaphor.ts @@ -9,7 +9,7 @@ import { MagickWorkerOutputs, ModuleContext, arraySocket, -} from '@magickml/core' +} from 'shared/core' import { makeMetaphorSearch } from '../functions/SearchMetaphor' diff --git a/packages/plugins/task/client/project.json b/packages/plugins/task/client/project.json index 45481bbb86..ed1a882f7b 100644 --- a/packages/plugins/task/client/project.json +++ b/packages/plugins/task/client/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/task/client/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/task/client/src/index.ts b/packages/plugins/task/client/src/index.ts index 1975943020..b9d1c3e5d0 100644 --- a/packages/plugins/task/client/src/index.ts +++ b/packages/plugins/task/client/src/index.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import { ClientPlugin, eventSocket, triggerSocket } from '@magickml/core' +import { ClientPlugin, eventSocket, triggerSocket } from 'shared/core' import AssignmentTurnedInIcon from '@mui/icons-material/AssignmentTurnedIn' import { AgentTaskWindow } from './components/task.component' import TaskWindow from './windows/TaskWindow' @@ -39,7 +39,7 @@ class TaskPlugin extends ClientPlugin { path: '/tasks', icon: AssignmentTurnedInIcon, text: 'Tasks', - tooltip: 'Objectives for agents to iterate through and complete' + tooltip: 'Objectives for agents to iterate through and complete', }, ], clientRoutes: [ diff --git a/packages/plugins/task/server/project.json b/packages/plugins/task/server/project.json index 87fb0bb376..6b91940e8d 100644 --- a/packages/plugins/task/server/project.json +++ b/packages/plugins/task/server/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/task/server/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/task/server/src/index.ts b/packages/plugins/task/server/src/index.ts index 95125a90a9..938e30d243 100644 --- a/packages/plugins/task/server/src/index.ts +++ b/packages/plugins/task/server/src/index.ts @@ -1,6 +1,6 @@ // DOCUMENTED -import { eventSocket, ServerPlugin, triggerSocket } from '@magickml/core' -import { app } from '@magickml/server-core' +import { eventSocket, ServerPlugin, triggerSocket } from 'shared/core' +import { app } from 'server/core' import { getNodes } from '@magickml/plugin-task-shared' type StartTaskArgs = { diff --git a/packages/plugins/task/shared/project.json b/packages/plugins/task/shared/project.json index fbe7339724..3e80b2ba58 100644 --- a/packages/plugins/task/shared/project.json +++ b/packages/plugins/task/shared/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/task/shared/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/task/shared/src/index.ts b/packages/plugins/task/shared/src/index.ts index 0b0c8a12ff..09bae36235 100644 --- a/packages/plugins/task/shared/src/index.ts +++ b/packages/plugins/task/shared/src/index.ts @@ -3,7 +3,7 @@ * This is the main file exporting the nodes used in the app */ -import { MagickComponent } from '@magickml/core' +import { MagickComponent } from 'shared/core' import { CancelTask } from './nodes/CancelTask' import { CompleteTask } from './nodes/CompleteTask' import { CreateTask } from './nodes/CreateTask' diff --git a/packages/plugins/task/shared/src/nodes/CancelTask.ts b/packages/plugins/task/shared/src/nodes/CancelTask.ts index f106473719..9cebbc0247 100644 --- a/packages/plugins/task/shared/src/nodes/CancelTask.ts +++ b/packages/plugins/task/shared/src/nodes/CancelTask.ts @@ -7,7 +7,7 @@ import { WorkerData, taskSocket, triggerSocket, -} from '@magickml/core' +} from 'shared/core' import Rete from 'shared/rete' const info = 'Cancel a task.' diff --git a/packages/plugins/task/shared/src/nodes/CompleteTask.ts b/packages/plugins/task/shared/src/nodes/CompleteTask.ts index 6d4f5c29a1..2e2f637898 100644 --- a/packages/plugins/task/shared/src/nodes/CompleteTask.ts +++ b/packages/plugins/task/shared/src/nodes/CompleteTask.ts @@ -7,7 +7,7 @@ import { WorkerData, taskSocket, triggerSocket, -} from '@magickml/core' +} from 'shared/core' import Rete from 'shared/rete' const info = 'Complete a task.' diff --git a/packages/plugins/task/shared/src/nodes/CreateTask.ts b/packages/plugins/task/shared/src/nodes/CreateTask.ts index 344029fae2..82cdab9726 100644 --- a/packages/plugins/task/shared/src/nodes/CreateTask.ts +++ b/packages/plugins/task/shared/src/nodes/CreateTask.ts @@ -14,7 +14,7 @@ import { ModuleContext, WorkerData, Event, -} from '@magickml/core' +} from 'shared/core' import Rete from 'shared/rete' /** diff --git a/packages/plugins/task/shared/src/nodes/DeleteTask.ts b/packages/plugins/task/shared/src/nodes/DeleteTask.ts index eebd6d147f..059fdc88d6 100644 --- a/packages/plugins/task/shared/src/nodes/DeleteTask.ts +++ b/packages/plugins/task/shared/src/nodes/DeleteTask.ts @@ -6,7 +6,7 @@ import { WorkerData, taskSocket, triggerSocket, -} from '@magickml/core' +} from 'shared/core' import Rete from 'shared/rete' const info = 'Delete a task.' diff --git a/packages/plugins/task/shared/src/nodes/FinishTaskStep.ts b/packages/plugins/task/shared/src/nodes/FinishTaskStep.ts index a8ed54bc86..009757419f 100644 --- a/packages/plugins/task/shared/src/nodes/FinishTaskStep.ts +++ b/packages/plugins/task/shared/src/nodes/FinishTaskStep.ts @@ -10,7 +10,7 @@ import { stringSocket, taskSocket, triggerSocket, -} from '@magickml/core' +} from 'shared/core' import Rete from 'shared/rete' /** diff --git a/packages/plugins/twitter/client/project.json b/packages/plugins/twitter/client/project.json index 074080e7c7..3a891aad4d 100644 --- a/packages/plugins/twitter/client/project.json +++ b/packages/plugins/twitter/client/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/plugins/twitter/client/src", "projectType": "library", - "implicitDependencies": ["@magickml/core"], + "implicitDependencies": ["shared-core"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/twitter/client/src/index.ts b/packages/plugins/twitter/client/src/index.ts index 55fcc9afe9..bcb85e1f1a 100644 --- a/packages/plugins/twitter/client/src/index.ts +++ b/packages/plugins/twitter/client/src/index.ts @@ -1,4 +1,4 @@ -import { ClientPlugin, eventSocket, triggerSocket } from '@magickml/core' +import { ClientPlugin, eventSocket, triggerSocket } from 'shared/core' import { TwitterAgentWindow } from './components/agent.component' const inputSockets = [ diff --git a/packages/plugins/twitter/server/project.json b/packages/plugins/twitter/server/project.json index d985faf2bb..cae346fc5e 100644 --- a/packages/plugins/twitter/server/project.json +++ b/packages/plugins/twitter/server/project.json @@ -3,7 +3,7 @@ "$schema": "../../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "plugin-twitter/server/src", "projectType": "library", - "implicitDependencies": ["@magickml/core", "server-agents"], + "implicitDependencies": ["shared-core", "server-agents"], "targets": { "lint": { "executor": "@nx/linter:eslint", diff --git a/packages/plugins/twitter/server/src/connectors/twitter.ts b/packages/plugins/twitter/server/src/connectors/twitter.ts index 5aaf5e7582..919db81a1d 100644 --- a/packages/plugins/twitter/server/src/connectors/twitter.ts +++ b/packages/plugins/twitter/server/src/connectors/twitter.ts @@ -1,6 +1,6 @@ import { ETwitterStreamEvent, TwitterApi } from 'twitter-api-v2' import { DMEventV2 } from 'twitter-api-v2/dist/esm/types/v2/dm.v2.types' -import { app } from '@magickml/server-core' +import { app } from 'server/core' export class TwitterConnector { twitterv1: TwitterApi | undefined diff --git a/packages/plugins/twitter/server/src/index.ts b/packages/plugins/twitter/server/src/index.ts index 0124fa0b20..c4fba2e840 100644 --- a/packages/plugins/twitter/server/src/index.ts +++ b/packages/plugins/twitter/server/src/index.ts @@ -1,4 +1,4 @@ -import { eventSocket, ServerPlugin, triggerSocket } from '@magickml/core' +import { eventSocket, ServerPlugin, triggerSocket } from 'shared/core' let TwitterConnector = null as any // dynamically import { TwitterConnector } from './connectors/twitter' if we are in node.js using esm syntax diff --git a/packages/server/agents/src/index.ts b/packages/server/agents/src/index.ts index 5555f5a498..98cdd06704 100644 --- a/packages/server/agents/src/index.ts +++ b/packages/server/agents/src/index.ts @@ -1,4 +1,4 @@ -import { app } from '@magickml/server-core' +import { app } from 'server/core' import { AgentCommander } from './lib/AgentCommander' export * from './lib/Agent' diff --git a/packages/server/agents/src/lib/Agent.ts b/packages/server/agents/src/lib/Agent.ts index c8461b6deb..17109953a9 100644 --- a/packages/server/agents/src/lib/Agent.ts +++ b/packages/server/agents/src/lib/Agent.ts @@ -13,7 +13,8 @@ import { AGENT_RUN_JOB, MagickSpellOutput, type Event, -} from '@magickml/core' +} from 'shared/core' +import { PING_AGENT_TIME_MSEC } from 'shared/config' import { AgentManager } from './AgentManager' import { @@ -23,7 +24,7 @@ import { BullQueue, MessageQueue, Application, -} from '@magickml/server-core' +} from 'server/core' import { AgentEvents, EventMetadata } from 'server/event-tracker' import { CommandHub } from './CommandHub' diff --git a/packages/server/agents/src/lib/AgentCommander.ts b/packages/server/agents/src/lib/AgentCommander.ts index e0cacf408a..29f563acae 100644 --- a/packages/server/agents/src/lib/AgentCommander.ts +++ b/packages/server/agents/src/lib/AgentCommander.ts @@ -1,6 +1,6 @@ import EventEmitter from 'events' import type { Agent } from 'server/agents' -import { type PubSub, type Job } from '@magickml/server-core' +import { type PubSub, type Job } from 'server/core' import { AGENT_RUN_JOB, AGENT_RUN_ERROR, @@ -9,8 +9,8 @@ import { getLogger, AGENT_COMMAND, AGENT_COMMAND_PROJECT, -} from '@magickml/core' -import type { MagickSpellInput } from '@magickml/core' +} from 'shared/core' +import type { MagickSpellInput } from 'shared/core' import { v4 as uuidv4 } from 'uuid' import type pino from 'pino' import { AgentResult, AgentRunJob } from './Agent' diff --git a/packages/server/agents/src/lib/AgentManager.ts b/packages/server/agents/src/lib/AgentManager.ts index 640ab22dcf..9777bed169 100644 --- a/packages/server/agents/src/lib/AgentManager.ts +++ b/packages/server/agents/src/lib/AgentManager.ts @@ -2,9 +2,9 @@ import Agent from './Agent' import _ from 'lodash' import pino from 'pino' -import { getLogger } from '@magickml/core' +import { getLogger } from 'shared/core' import { AGENT_UPDATE_TIME_MSEC, PING_AGENT_TIME_MSEC } from 'shared/config' -import { BullMQWorker, RedisPubSubWrapper } from '@magickml/server-core' +import { BullMQWorker, RedisPubSubWrapper } from 'server/core' /** * Class for managing agents. diff --git a/packages/server/agents/src/lib/CommandHub.ts b/packages/server/agents/src/lib/CommandHub.ts index 0c41d3fad9..68d33316e3 100644 --- a/packages/server/agents/src/lib/CommandHub.ts +++ b/packages/server/agents/src/lib/CommandHub.ts @@ -1,6 +1,6 @@ -import { type PubSub } from '@magickml/server-core' +import { type PubSub } from 'server/core' import Agent from './Agent' -import { AGENT_COMMAND, AGENT_COMMAND_PROJECT } from '@magickml/core' +import { AGENT_COMMAND, AGENT_COMMAND_PROJECT } from 'shared/core' export interface CommandListener { callback: (data: T, agent: Agent) => void diff --git a/packages/server/cloud-agent-manager/src/lib/CloudAgentManager.ts b/packages/server/cloud-agent-manager/src/lib/CloudAgentManager.ts index 14a262e091..da51864e4e 100644 --- a/packages/server/cloud-agent-manager/src/lib/CloudAgentManager.ts +++ b/packages/server/cloud-agent-manager/src/lib/CloudAgentManager.ts @@ -5,9 +5,9 @@ import { AGENT_DELETE_JOB, AGENT_UPDATE_JOB, getLogger, -} from '@magickml/core' +} from 'shared/core' import type { Reporter } from './Reporters' -import { type PubSub, type MessageQueue, app } from '@magickml/server-core' +import { type PubSub, type MessageQueue, app } from 'server/core' import type { AgentListRecord } from 'server/cloud-agent-worker' import { Agent } from 'packages/core/server/src/services/agents/agents.schema' diff --git a/packages/server/cloud-agent-manager/src/lib/Reporters/FeathersSyncReporter.ts b/packages/server/cloud-agent-manager/src/lib/Reporters/FeathersSyncReporter.ts index 34bda9e6fd..42bf2ee3dd 100644 --- a/packages/server/cloud-agent-manager/src/lib/Reporters/FeathersSyncReporter.ts +++ b/packages/server/cloud-agent-manager/src/lib/Reporters/FeathersSyncReporter.ts @@ -1,5 +1,5 @@ -import { AGENT_DELETE, getLogger } from '@magickml/core' -import { app } from '@magickml/server-core' +import { AGENT_DELETE, getLogger } from 'shared/core' +import { app } from 'server/core' import { Reporter } from '.' import { EventEmitter } from 'events' diff --git a/packages/server/cloud-agent-manager/src/lib/Reporters/PgNotifyReporter.ts b/packages/server/cloud-agent-manager/src/lib/Reporters/PgNotifyReporter.ts index 26c7520632..7b1ca9ecf6 100644 --- a/packages/server/cloud-agent-manager/src/lib/Reporters/PgNotifyReporter.ts +++ b/packages/server/cloud-agent-manager/src/lib/Reporters/PgNotifyReporter.ts @@ -1,6 +1,6 @@ import { Reporter } from '.' import createSubscriber, { Subscriber } from 'pg-listen' -import { getLogger } from '@magickml/core' +import { getLogger } from 'shared/core' export class PgNotifyReporter implements Reporter { logger = getLogger() diff --git a/packages/server/cloud-agent-worker/src/lib/cloud-agent-worker.ts b/packages/server/cloud-agent-worker/src/lib/cloud-agent-worker.ts index 731c032c10..e18afcf708 100644 --- a/packages/server/cloud-agent-worker/src/lib/cloud-agent-worker.ts +++ b/packages/server/cloud-agent-worker/src/lib/cloud-agent-worker.ts @@ -6,7 +6,7 @@ import { RedisPubSubWrapper, app, BullQueue, -} from '@magickml/server-core' +} from 'server/core' import { Agent, AgentManager, type AgentRunJob } from 'server/agents' import { v4 as uuidv4 } from 'uuid' import { @@ -14,7 +14,7 @@ import { AGENT_DELETE_JOB, AGENT_RUN_JOB, AGENT_UPDATE_JOB, -} from '@magickml/core' +} from 'shared/core' export interface AgentListRecord { id: string diff --git a/packages/core/server/.babelrc b/packages/server/core/.babelrc similarity index 100% rename from packages/core/server/.babelrc rename to packages/server/core/.babelrc diff --git a/packages/server/core/.eslintrc.json b/packages/server/core/.eslintrc.json new file mode 100644 index 0000000000..3456be9b90 --- /dev/null +++ b/packages/server/core/.eslintrc.json @@ -0,0 +1,18 @@ +{ + "extends": ["../../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], + "rules": {} + }, + { + "files": ["*.ts", "*.tsx"], + "rules": {} + }, + { + "files": ["*.js", "*.jsx"], + "rules": {} + } + ] +} diff --git a/packages/core/server/README.md b/packages/server/core/README.md similarity index 98% rename from packages/core/server/README.md rename to packages/server/core/README.md index e1829fd6dc..0cd55f9556 100644 --- a/packages/core/server/README.md +++ b/packages/server/core/README.md @@ -2,13 +2,10 @@ This library was generated with [Nx](https://nx.dev). - ## Running unit tests Run `nx test systems` to execute the unit tests via [Jest](https://jestjs.io). - ## Running lint Run `nx lint systems` to execute the lint via [ESLint](https://eslint.org/). - diff --git a/packages/core/server/jest.config.ts b/packages/server/core/jest.config.ts similarity index 84% rename from packages/core/server/jest.config.ts rename to packages/server/core/jest.config.ts index 3624e05dda..9383e4eecb 100644 --- a/packages/core/server/jest.config.ts +++ b/packages/server/core/jest.config.ts @@ -13,5 +13,5 @@ export default { ], }, moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], - coverageDirectory: '../../coverage/packages/core/server', + coverageDirectory: '../../coverage/packages/server/core', } diff --git a/packages/core/server/package.json b/packages/server/core/package.json similarity index 86% rename from packages/core/server/package.json rename to packages/server/core/package.json index 1610dd1eb3..7e537e1477 100644 --- a/packages/core/server/package.json +++ b/packages/server/core/package.json @@ -1,5 +1,5 @@ { - "name": "@magickml/server-core", + "name": "server/core", "version": "0.1.0", "feathers": { "language": "ts", diff --git a/packages/core/server/project.json b/packages/server/core/project.json similarity index 74% rename from packages/core/server/project.json rename to packages/server/core/project.json index 890aa6b71d..adedabc2e0 100644 --- a/packages/core/server/project.json +++ b/packages/server/core/project.json @@ -1,7 +1,7 @@ { - "name": "@magickml/server-core", + "name": "server-core", "$schema": "../../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "packages/core/server/src", + "sourceRoot": "packages/server/core/src", "projectType": "library", "implicitDependencies": [], "targets": { @@ -9,14 +9,14 @@ "executor": "@nx/linter:eslint", "outputs": ["{options.outputFile}"], "options": { - "lintFilePatterns": ["packages/core/server/**/*.ts"] + "lintFilePatterns": ["packages/server/core/**/*.ts"] } }, "test": { "executor": "@nx/jest:jest", "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], "options": { - "jestConfig": "packages/core/server/jest.config.ts", + "jestConfig": "packages/server/core/jest.config.ts", "passWithNoTests": true }, "configurations": { diff --git a/packages/core/server/src/@types/index.d.ts b/packages/server/core/src/@types/index.d.ts similarity index 100% rename from packages/core/server/src/@types/index.d.ts rename to packages/server/core/src/@types/index.d.ts diff --git a/packages/core/server/src/api/apis.ts b/packages/server/core/src/api/apis.ts similarity index 100% rename from packages/core/server/src/api/apis.ts rename to packages/server/core/src/api/apis.ts diff --git a/packages/core/server/src/api/index.ts b/packages/server/core/src/api/index.ts similarity index 55% rename from packages/core/server/src/api/index.ts rename to packages/server/core/src/api/index.ts index ad25f87055..e139a152df 100644 --- a/packages/core/server/src/api/index.ts +++ b/packages/server/core/src/api/index.ts @@ -1,48 +1,45 @@ -// DOCUMENTED -import { SpellInterface, SpellError } from '@magickml/core'; -import { app } from '../app'; -import Koa from 'koa'; -import otJson0 from 'ot-json0'; +// DOCUMENTED +import { SpellInterface, SpellError } from 'shared/core' +import { app } from '../app' +import Koa from 'koa' +import otJson0 from 'ot-json0' -import { Route } from '../config/types'; +import { Route } from '../config/types' -import md5 from 'md5'; +import md5 from 'md5' /** * Saves a diff of a spell and updates it. * @param {Koa.Context} ctx - The Koa context of the request. */ const saveDiffHandler = async (ctx: Koa.Context): Promise => { - const { body } = ctx.request; - const { name, diff, projectId } = body as any; + const { body } = ctx.request + const { name, diff, projectId } = body as any - if (!body) throw new SpellError('input-failed', 'No parameters provided'); + if (!body) throw new SpellError('input-failed', 'No parameters provided') - const spell = await app.service('spells').find({ query: { projectId, name } }); + const spell = await app.service('spells').find({ query: { projectId, name } }) if (!spell) - throw new SpellError('input-failed', `No spell with ${name} name found.`); + throw new SpellError('input-failed', `No spell with ${name} name found.`) if (!diff) - throw new SpellError('input-failed', 'No diff provided in request body'); + throw new SpellError('input-failed', 'No diff provided in request body') - const spellUpdate = otJson0.type.apply(spell, diff); + const spellUpdate = otJson0.type.apply(spell, diff) if (Object.keys((spellUpdate as SpellInterface).graph.nodes).length === 0) - throw new SpellError( - 'input-failed', - 'Graph would be cleared. Aborting.' - ); + throw new SpellError('input-failed', 'Graph would be cleared. Aborting.') - const hash = md5(JSON.stringify(spellUpdate.graph.nodes)); + const hash = md5(JSON.stringify(spellUpdate.graph.nodes)) // In feathers.js, get the spells service and update the spell with the name of 'name'. const updatedSpell = await app .service('spells') - .update(name, { ...spellUpdate, hash }); + .update(name, { ...spellUpdate, hash }) - ctx.response.status = 200; - ctx.body = updatedSpell; -}; + ctx.response.status = 200 + ctx.body = updatedSpell +} /** * Export the spells routes for use in other modules. @@ -52,4 +49,4 @@ export const spells: Route[] = [ path: '/spells/saveDiff', post: saveDiffHandler, }, -]; +] diff --git a/packages/core/server/src/app.ts b/packages/server/core/src/app.ts similarity index 98% rename from packages/core/server/src/app.ts rename to packages/server/core/src/app.ts index 5a7561d5ef..2450356f27 100644 --- a/packages/core/server/src/app.ts +++ b/packages/server/core/src/app.ts @@ -18,9 +18,9 @@ import pino from 'pino' import Redis from 'ioredis' import { RedisPubSub } from 'server/redis-pubsub' import sync from 'feathers-sync' +import { configureManager, globalsManager } from 'shared/core' import { REDISCLOUD_URL, API_ACCESS_KEY, bullMQConnection } from 'shared/config' -import { getLogger } from '@magickml/core' import type { AgentCommander } from '@magickml/agents' import { configureManager, globalsManager } from '@magickml/core' import { createPosthogClient } from 'server/event-tracker' @@ -38,6 +38,7 @@ import handleSockets from './sockets/sockets' import { PostgresVectorStoreCustom, ExtendedEmbeddings } from './vectordb' import { PluginEmbeddings } from './customEmbeddings' +import { getLogger } from 'shared/core' import { authenticateApiKey } from './hooks/authenticateApiKey' // Initialize the Feathers Koa app diff --git a/packages/core/server/src/auth/authentication.ts b/packages/server/core/src/auth/authentication.ts similarity index 100% rename from packages/core/server/src/auth/authentication.ts rename to packages/server/core/src/auth/authentication.ts diff --git a/packages/core/server/src/auth/cloudAuthentication.ts b/packages/server/core/src/auth/cloudAuthentication.ts similarity index 100% rename from packages/core/server/src/auth/cloudAuthentication.ts rename to packages/server/core/src/auth/cloudAuthentication.ts diff --git a/packages/core/server/src/client.ts b/packages/server/core/src/client.ts similarity index 100% rename from packages/core/server/src/client.ts rename to packages/server/core/src/client.ts diff --git a/packages/core/server/src/communication/MessageQueues/BullMQ.ts b/packages/server/core/src/communication/MessageQueues/BullMQ.ts similarity index 88% rename from packages/core/server/src/communication/MessageQueues/BullMQ.ts rename to packages/server/core/src/communication/MessageQueues/BullMQ.ts index f3727091c6..c7e0b77754 100644 --- a/packages/core/server/src/communication/MessageQueues/BullMQ.ts +++ b/packages/server/core/src/communication/MessageQueues/BullMQ.ts @@ -1,7 +1,7 @@ import { Queue } from 'bullmq' -import { app } from '@magickml/server-core' +import { app } from 'server/core' import pino from 'pino' -import { getLogger } from '@magickml/core' +import { getLogger } from 'shared/core' import { MessageQueue } from '../MessageQueues' import { AgentJob } from 'server/agents' diff --git a/packages/core/server/src/communication/MessageQueues/MessageQueue.ts b/packages/server/core/src/communication/MessageQueues/MessageQueue.ts similarity index 100% rename from packages/core/server/src/communication/MessageQueues/MessageQueue.ts rename to packages/server/core/src/communication/MessageQueues/MessageQueue.ts diff --git a/packages/core/server/src/communication/MessageQueues/index.ts b/packages/server/core/src/communication/MessageQueues/index.ts similarity index 100% rename from packages/core/server/src/communication/MessageQueues/index.ts rename to packages/server/core/src/communication/MessageQueues/index.ts diff --git a/packages/server/core/src/communication/PubSub/PubSub.ts b/packages/server/core/src/communication/PubSub/PubSub.ts new file mode 100644 index 0000000000..a4714c931a --- /dev/null +++ b/packages/server/core/src/communication/PubSub/PubSub.ts @@ -0,0 +1,23 @@ +import { EventEmitter } from 'events' + +export abstract class PubSub extends EventEmitter { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + async publish(channel: string, message: string): Promise { + throw new Error('Method not implemented.') + } + + // eslint-disable-next-line @typescript-eslint/no-unused-vars + async subscribe(channel: string, callback: Function): Promise { + throw new Error('Method not implemented.') + } + + // eslint-disable-next-line @typescript-eslint/no-unused-vars + async unsubscribe(channel: string): Promise { + throw new Error('Method not implemented.') + } + + // eslint-disable-next-line @typescript-eslint/no-unused-vars + async patternSubscribe(pattern: string, callback: Function): Promise { + throw new Error('Method not implemented.') + } +} diff --git a/packages/core/server/src/communication/PubSub/Redis.ts b/packages/server/core/src/communication/PubSub/Redis.ts similarity index 93% rename from packages/core/server/src/communication/PubSub/Redis.ts rename to packages/server/core/src/communication/PubSub/Redis.ts index 932a2faa0b..7325430f5c 100644 --- a/packages/core/server/src/communication/PubSub/Redis.ts +++ b/packages/server/core/src/communication/PubSub/Redis.ts @@ -1,7 +1,7 @@ import { RedisPubSub } from 'server/redis-pubsub' import { PubSub } from './PubSub' -import { app } from '@magickml/server-core' +import { app } from 'server/core' export class RedisPubSubWrapper extends PubSub { pubsub: RedisPubSub diff --git a/packages/core/server/src/communication/PubSub/index.ts b/packages/server/core/src/communication/PubSub/index.ts similarity index 100% rename from packages/core/server/src/communication/PubSub/index.ts rename to packages/server/core/src/communication/PubSub/index.ts diff --git a/packages/core/server/src/communication/Workers/BullMQ.ts b/packages/server/core/src/communication/Workers/BullMQ.ts similarity index 88% rename from packages/core/server/src/communication/Workers/BullMQ.ts rename to packages/server/core/src/communication/Workers/BullMQ.ts index 2da3558223..58c06dd124 100644 --- a/packages/core/server/src/communication/Workers/BullMQ.ts +++ b/packages/server/core/src/communication/Workers/BullMQ.ts @@ -1,5 +1,5 @@ import { Worker as BMQWorker } from 'bullmq' -import { type Job, app } from '@magickml/server-core' +import { type Job, app } from 'server/core' import { Worker } from './Worker' export class BullMQWorker extends Worker { diff --git a/packages/server/core/src/communication/Workers/Worker.ts b/packages/server/core/src/communication/Workers/Worker.ts new file mode 100644 index 0000000000..723eb5d7d8 --- /dev/null +++ b/packages/server/core/src/communication/Workers/Worker.ts @@ -0,0 +1,6 @@ +export abstract class Worker { + constructor() {} + + // eslint-disable-next-line @typescript-eslint/no-unused-vars + initialize(queueName: string, callback: (job: any) => Promise): void {} +} diff --git a/packages/core/server/src/communication/Workers/index.ts b/packages/server/core/src/communication/Workers/index.ts similarity index 100% rename from packages/core/server/src/communication/Workers/index.ts rename to packages/server/core/src/communication/Workers/index.ts diff --git a/packages/core/server/src/communication/index.ts b/packages/server/core/src/communication/index.ts similarity index 100% rename from packages/core/server/src/communication/index.ts rename to packages/server/core/src/communication/index.ts diff --git a/packages/core/server/src/config/configuration.ts b/packages/server/core/src/config/configuration.ts similarity index 57% rename from packages/core/server/src/config/configuration.ts rename to packages/server/core/src/config/configuration.ts index 09af2ae8ae..ef07225705 100644 --- a/packages/core/server/src/config/configuration.ts +++ b/packages/server/core/src/config/configuration.ts @@ -1,13 +1,17 @@ -// DOCUMENTED +// DOCUMENTED /** * This module contains types and functions related to application configuration. * @packageDocumentation */ -import { Type, getValidator, defaultAppConfiguration } from '@feathersjs/typebox'; -import type { Static } from '@feathersjs/typebox'; +import { + Type, + getValidator, + defaultAppConfiguration, +} from '@feathersjs/typebox' +import type { Static } from '@feathersjs/typebox' -import { dataValidator } from './validators'; +import { dataValidator } from './validators' /** * The schema that describes the application configuration object. @@ -15,27 +19,24 @@ import { dataValidator } from './validators'; * All properties are optional. */ const configurationSchema = Type.Intersect([ - defaultAppConfiguration, - Type.Object({ - host: Type.String({maxLength: 255}), - port: Type.Number({minimum: 1, maximum: 65535}), - public: Type.String({format: 'uri'}), - }), -]); + defaultAppConfiguration, + Type.Object({ + host: Type.String({ maxLength: 255 }), + port: Type.Number({ minimum: 1, maximum: 65535 }), + public: Type.String({ format: 'uri' }), + }), +]) -/** +/** * The static version of the `configurationSchema` type, used as the return type of `getAppConfiguration`. */ -export type ApplicationConfiguration = Static; +export type ApplicationConfiguration = Static /** * A function that returns a validator that can validate objects against the `configurationSchema`. * @returns The validator function. */ -const configurationValidator = getValidator( - configurationSchema, - dataValidator -); +const configurationValidator = getValidator(configurationSchema, dataValidator) // Export both the schema and validator -export { configurationSchema, configurationValidator }; \ No newline at end of file +export { configurationSchema, configurationValidator } diff --git a/packages/core/server/src/config/types.ts b/packages/server/core/src/config/types.ts similarity index 71% rename from packages/core/server/src/config/types.ts rename to packages/server/core/src/config/types.ts index 599128efc7..fe76b24eae 100644 --- a/packages/core/server/src/config/types.ts +++ b/packages/server/core/src/config/types.ts @@ -1,28 +1,28 @@ -// DOCUMENTED +// DOCUMENTED // Import the required types from '@magickml/core' and rename them to avoid naming conflicts. import { Route as MagickRoute, Middleware as MagickMiddleware, Method as MagickMethod, Handler as MagickHandler, -} from "@magickml/core"; +} from 'shared/core' /** * Type alias for Middleware imported from '@magickml/core'. */ -export type Middleware = MagickMiddleware; +export type Middleware = MagickMiddleware /** * Type alias for Method imported from '@magickml/core'. */ -export type Method = MagickMethod; +export type Method = MagickMethod /** * Type alias for Handler imported from '@magickml/core'. */ -export type Handler = MagickHandler; +export type Handler = MagickHandler /** * Type alias for Route imported from '@magickml/core'. */ -export type Route = MagickRoute; +export type Route = MagickRoute diff --git a/packages/core/server/src/config/validators.ts b/packages/server/core/src/config/validators.ts similarity index 56% rename from packages/core/server/src/config/validators.ts rename to packages/server/core/src/config/validators.ts index c3bdd3529f..c60a32e62d 100644 --- a/packages/core/server/src/config/validators.ts +++ b/packages/server/core/src/config/validators.ts @@ -1,35 +1,35 @@ -// DOCUMENTED +// DOCUMENTED /** * This file provides a validation library for FeathersJS. * For more information about this file, visit the link https://dove.feathersjs.com/guides/cli/validators.html */ -import { Ajv, addFormats, FormatsPluginOptions } from '@feathersjs/schema'; +import { Ajv, addFormats, FormatsPluginOptions } from '@feathersjs/schema' const formats: FormatsPluginOptions = [ // List of supported JSON schema formats - 'date-time', // Format for a date-time value as defined by RFC 3339. - 'time', // Format for a time value as defined by RFC 3339. - 'date', // Format for a date value as defined by RFC 3339. - 'email', // A string that contains a valid email address. - 'hostname', // A string that contains a valid hostname, IPv4 address, or IPv6. - 'ipv4', // A string that contains a valid IPv4 address. - 'ipv6', // A string that contains a valid IPv6 address. - 'uri', // A valid URI, according to RFC3986. - 'uri-reference', // A string that contains a valid URI or a valid relative reference. - 'uuid', // Format for a UUID value. - 'uri-template', // A string that contains a valid URI Template according to RFC6570. - 'json-pointer', // A string that contains a valid JSON Pointer according to RFC6901. + 'date-time', // Format for a date-time value as defined by RFC 3339. + 'time', // Format for a time value as defined by RFC 3339. + 'date', // Format for a date value as defined by RFC 3339. + 'email', // A string that contains a valid email address. + 'hostname', // A string that contains a valid hostname, IPv4 address, or IPv6. + 'ipv4', // A string that contains a valid IPv4 address. + 'ipv6', // A string that contains a valid IPv6 address. + 'uri', // A valid URI, according to RFC3986. + 'uri-reference', // A string that contains a valid URI or a valid relative reference. + 'uuid', // Format for a UUID value. + 'uri-template', // A string that contains a valid URI Template according to RFC6570. + 'json-pointer', // A string that contains a valid JSON Pointer according to RFC6901. 'relative-json-pointer', // A string that contains a valid relative JSON Pointer according to draft 6 of the JSON Schema specification. - 'regex', // A valid Regular Expression. -]; + 'regex', // A valid Regular Expression. +] /** * Adds the supported JSON schema formats to the ajv instance for validating request data. * @param ajv - The instance of ajv library to add formats to. * @returns An ajv instance with the added formats. */ -export const dataValidator: Ajv = addFormats(new Ajv({}), formats); +export const dataValidator: Ajv = addFormats(new Ajv({}), formats) /** * Adds the supported JSON schema formats to the ajv instance for validating query parameters. @@ -42,4 +42,4 @@ export const queryValidator: Ajv = addFormats( removeAdditional: true, // Remove properties not in schema from validated data. }), formats -); \ No newline at end of file +) diff --git a/packages/core/server/src/customEmbeddings.ts b/packages/server/core/src/customEmbeddings.ts similarity index 98% rename from packages/core/server/src/customEmbeddings.ts rename to packages/server/core/src/customEmbeddings.ts index ebe473ae01..01938bb86c 100644 --- a/packages/core/server/src/customEmbeddings.ts +++ b/packages/server/core/src/customEmbeddings.ts @@ -1,4 +1,4 @@ -import { CompletionProvider, pluginManager, WorkerData } from '@magickml/core' +import { CompletionProvider, pluginManager, WorkerData } from 'shared/core' import { Embeddings } from 'langchain/embeddings/base' diff --git a/packages/core/server/src/dbClient.ts b/packages/server/core/src/dbClient.ts similarity index 100% rename from packages/core/server/src/dbClient.ts rename to packages/server/core/src/dbClient.ts diff --git a/packages/core/server/src/declarations.ts b/packages/server/core/src/declarations.ts similarity index 95% rename from packages/core/server/src/declarations.ts rename to packages/server/core/src/declarations.ts index c46204fe4c..fa32233dcf 100644 --- a/packages/core/server/src/declarations.ts +++ b/packages/server/core/src/declarations.ts @@ -6,7 +6,7 @@ import { } from '@feathersjs/feathers' import { Application as FeathersApplication } from '@feathersjs/koa' import { ApplicationConfiguration } from './config/configuration' -import { UserSpellManager } from '@magickml/core' +import { UserSpellManager } from 'shared/core' export type { NextFunction } diff --git a/packages/core/server/src/helpers/getSpell.ts b/packages/server/core/src/helpers/getSpell.ts similarity index 100% rename from packages/core/server/src/helpers/getSpell.ts rename to packages/server/core/src/helpers/getSpell.ts diff --git a/packages/core/server/src/hooks/authenticateApiKey.ts b/packages/server/core/src/hooks/authenticateApiKey.ts similarity index 100% rename from packages/core/server/src/hooks/authenticateApiKey.ts rename to packages/server/core/src/hooks/authenticateApiKey.ts diff --git a/packages/core/server/src/hooks/index.ts b/packages/server/core/src/hooks/index.ts similarity index 83% rename from packages/core/server/src/hooks/index.ts rename to packages/server/core/src/hooks/index.ts index 6ec366451c..b759ff2f4e 100644 --- a/packages/core/server/src/hooks/index.ts +++ b/packages/server/core/src/hooks/index.ts @@ -1,4 +1,4 @@ -// DOCUMENTED +// DOCUMENTED /** * @description Middleware function to catch and log errors * @param context - Feathers HookContext object @@ -7,7 +7,10 @@ */ import type { HookContext, NextFunction } from '../declarations' -export const logError = async (context: HookContext, next: NextFunction): Promise => { +export const logError = async ( + context: HookContext, + next: NextFunction +): Promise => { try { await next() } catch (error: any) { @@ -22,4 +25,4 @@ export const logError = async (context: HookContext, next: NextFunction): Promis // Re-throw error to be handled by error handler throw error } -} \ No newline at end of file +} diff --git a/packages/core/server/src/hooks/spellmanagerHooks.ts b/packages/server/core/src/hooks/spellmanagerHooks.ts similarity index 97% rename from packages/core/server/src/hooks/spellmanagerHooks.ts rename to packages/server/core/src/hooks/spellmanagerHooks.ts index efb116a8f8..40c8861f34 100644 --- a/packages/core/server/src/hooks/spellmanagerHooks.ts +++ b/packages/server/core/src/hooks/spellmanagerHooks.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import { SpellInterface } from '@magickml/core' +import { SpellInterface } from 'shared/core' import { HookContext } from '../declarations' import { getSpell } from '../helpers/getSpell' @@ -56,7 +56,7 @@ export const updateSpellInManager = async (context: HookContext) => { (id as string).length > 36 ? (id as string).slice(0, 36) : (id as string) if (!spellManager) return - + const spellRunner = spellManager.getReadySpellRunner(decodedId) if (!spellRunner) return diff --git a/packages/core/server/src/index.ts b/packages/server/core/src/index.ts similarity index 100% rename from packages/core/server/src/index.ts rename to packages/server/core/src/index.ts diff --git a/packages/core/server/src/metering/index.ts b/packages/server/core/src/metering/index.ts similarity index 73% rename from packages/core/server/src/metering/index.ts rename to packages/server/core/src/metering/index.ts index 2a29b47cca..0e1cced230 100644 --- a/packages/core/server/src/metering/index.ts +++ b/packages/server/core/src/metering/index.ts @@ -3,11 +3,7 @@ import { MeteringEvent, MeteringEventData, } from './meteringClient' -import { - trackOpenAIUsage, - trackCogUsage, - trackGoogleAIUsage, -} from './meters' +import { trackOpenAIUsage, trackCogUsage, trackGoogleAIUsage } from './meters' export { sendMeteringEvent, diff --git a/packages/core/server/src/metering/meteringClient.ts b/packages/server/core/src/metering/meteringClient.ts similarity index 97% rename from packages/core/server/src/metering/meteringClient.ts rename to packages/server/core/src/metering/meteringClient.ts index 5ce44cf717..bbcfd597ee 100644 --- a/packages/core/server/src/metering/meteringClient.ts +++ b/packages/server/core/src/metering/meteringClient.ts @@ -5,7 +5,7 @@ import { OPENMETER_TOKEN, OPENMETER_SOURCE, } from 'shared/config' -import { getLogger } from '@magickml/core' +import { getLogger } from 'shared/core' import { v4 as uuidv4 } from 'uuid' /** diff --git a/packages/core/server/src/metering/meters.ts b/packages/server/core/src/metering/meters.ts similarity index 100% rename from packages/core/server/src/metering/meters.ts rename to packages/server/core/src/metering/meters.ts diff --git a/packages/core/server/src/servers/fileServer.ts b/packages/server/core/src/servers/fileServer.ts similarity index 100% rename from packages/core/server/src/servers/fileServer.ts rename to packages/server/core/src/servers/fileServer.ts diff --git a/packages/core/server/src/servers/googleSpeechToText.ts b/packages/server/core/src/servers/googleSpeechToText.ts similarity index 100% rename from packages/core/server/src/servers/googleSpeechToText.ts rename to packages/server/core/src/servers/googleSpeechToText.ts diff --git a/packages/core/server/src/servers/googleTextToSpeech.ts b/packages/server/core/src/servers/googleTextToSpeech.ts similarity index 96% rename from packages/core/server/src/servers/googleTextToSpeech.ts rename to packages/server/core/src/servers/googleTextToSpeech.ts index 26af991f70..78a9d598bd 100644 --- a/packages/core/server/src/servers/googleTextToSpeech.ts +++ b/packages/server/core/src/servers/googleTextToSpeech.ts @@ -1,4 +1,4 @@ -// DOCUMENTED +// DOCUMENTED /** * Initializes a TextToSpeechClient client from the Google Cloud text-to-speech library. */ @@ -53,20 +53,20 @@ export async function tts( return new Promise((resolve, reject) => { fn(...args, (err, result) => { if (err) { - reject(err); + reject(err) } else { - resolve(result); + resolve(result) } - }); - }); - }; - } + }) + }) + } + } // Synthesize speech and write to a file const [response] = await client.synthesizeSpeech(ttsRequest) const writeFile = promisify(fs.writeFile) await writeFile(outputFile, response.audioContent as string, 'binary') - + return outputFile } @@ -85,4 +85,4 @@ function makeid(length: number) { result += characters.charAt(Math.floor(Math.random() * charactersLength)) } return result -} \ No newline at end of file +} diff --git a/packages/core/server/src/servers/tiktalknet.ts b/packages/server/core/src/servers/tiktalknet.ts similarity index 100% rename from packages/core/server/src/servers/tiktalknet.ts rename to packages/server/core/src/servers/tiktalknet.ts diff --git a/packages/core/server/src/services/Upload.class.ts b/packages/server/core/src/services/Upload.class.ts similarity index 100% rename from packages/core/server/src/services/Upload.class.ts rename to packages/server/core/src/services/Upload.class.ts diff --git a/packages/core/server/src/services/agentImage/agentImage.class.ts b/packages/server/core/src/services/agentImage/agentImage.class.ts similarity index 100% rename from packages/core/server/src/services/agentImage/agentImage.class.ts rename to packages/server/core/src/services/agentImage/agentImage.class.ts diff --git a/packages/core/server/src/services/agentImage/agentImage.ts b/packages/server/core/src/services/agentImage/agentImage.ts similarity index 100% rename from packages/core/server/src/services/agentImage/agentImage.ts rename to packages/server/core/src/services/agentImage/agentImage.ts diff --git a/packages/core/server/src/services/agents/agents.class.ts b/packages/server/core/src/services/agents/agents.class.ts similarity index 99% rename from packages/core/server/src/services/agents/agents.class.ts rename to packages/server/core/src/services/agents/agents.class.ts index 45da75d250..745d89ebe7 100644 --- a/packages/core/server/src/services/agents/agents.class.ts +++ b/packages/server/core/src/services/agents/agents.class.ts @@ -3,7 +3,7 @@ import type { Params } from '@feathersjs/feathers' import { KnexService } from '@feathersjs/knex' import type { KnexAdapterParams, KnexAdapterOptions } from '@feathersjs/knex' -import { app } from '@magickml/server-core' +import { app } from 'server/core' import md5 from 'md5' import type { Application } from '../../declarations' import type { Agent, AgentData, AgentPatch, AgentQuery } from './agents.schema' diff --git a/packages/core/server/src/services/agents/agents.schema.ts b/packages/server/core/src/services/agents/agents.schema.ts similarity index 98% rename from packages/core/server/src/services/agents/agents.schema.ts rename to packages/server/core/src/services/agents/agents.schema.ts index 80f3abcef2..2c48e23cda 100644 --- a/packages/core/server/src/services/agents/agents.schema.ts +++ b/packages/server/core/src/services/agents/agents.schema.ts @@ -11,7 +11,7 @@ import type { Static } from '@feathersjs/typebox' import type { HookContext } from '../../declarations' import { dataValidator, queryValidator } from '../../config/validators' -import { agentSchema } from '@magickml/core' +import { agentSchema } from 'shared/core' /** * Agent type diff --git a/packages/core/server/src/services/agents/agents.ts b/packages/server/core/src/services/agents/agents.ts similarity index 100% rename from packages/core/server/src/services/agents/agents.ts rename to packages/server/core/src/services/agents/agents.ts diff --git a/packages/core/server/src/services/documents/documents.class.ts b/packages/server/core/src/services/documents/documents.class.ts similarity index 100% rename from packages/core/server/src/services/documents/documents.class.ts rename to packages/server/core/src/services/documents/documents.class.ts diff --git a/packages/core/server/src/services/documents/documents.schema.ts b/packages/server/core/src/services/documents/documents.schema.ts similarity index 97% rename from packages/core/server/src/services/documents/documents.schema.ts rename to packages/server/core/src/services/documents/documents.schema.ts index 57d834407f..62a0b253ea 100644 --- a/packages/core/server/src/services/documents/documents.schema.ts +++ b/packages/server/core/src/services/documents/documents.schema.ts @@ -12,7 +12,7 @@ import type { Static } from '@feathersjs/typebox' // Imports custom module types for working with engineered documents import type { HookContext } from '../../declarations' import { dataValidator, queryValidator } from '../../config/validators' -import { documentSchema } from '@magickml/core' +import { documentSchema } from 'shared/core' // Definitions for base document schema resolution export const documentResolver = resolve({}) diff --git a/packages/core/server/src/services/documents/documents.ts b/packages/server/core/src/services/documents/documents.ts similarity index 100% rename from packages/core/server/src/services/documents/documents.ts rename to packages/server/core/src/services/documents/documents.ts diff --git a/packages/core/server/src/services/events/events.class.ts b/packages/server/core/src/services/events/events.class.ts similarity index 99% rename from packages/core/server/src/services/events/events.class.ts rename to packages/server/core/src/services/events/events.class.ts index 5fd1fd4b98..a2941bbd15 100644 --- a/packages/core/server/src/services/events/events.class.ts +++ b/packages/server/core/src/services/events/events.class.ts @@ -91,8 +91,6 @@ export class EventService< const res = await query - - return { events: res as unknown as { data: Array } } } } diff --git a/packages/core/server/src/services/events/events.schema.ts b/packages/server/core/src/services/events/events.schema.ts similarity index 100% rename from packages/core/server/src/services/events/events.schema.ts rename to packages/server/core/src/services/events/events.schema.ts diff --git a/packages/core/server/src/services/events/events.ts b/packages/server/core/src/services/events/events.ts similarity index 100% rename from packages/core/server/src/services/events/events.ts rename to packages/server/core/src/services/events/events.ts diff --git a/packages/core/server/src/services/index.ts b/packages/server/core/src/services/index.ts similarity index 96% rename from packages/core/server/src/services/index.ts rename to packages/server/core/src/services/index.ts index 40213f8055..488b937c46 100644 --- a/packages/core/server/src/services/index.ts +++ b/packages/server/core/src/services/index.ts @@ -10,7 +10,7 @@ import { agentImage } from './agentImage/agentImage' // For more information about this file see https://dove.feathersjs.com/guides/cli/application.html#configure-functions import type { Application } from '../declarations' -import { pluginManager } from '@magickml/core' +import { pluginManager } from 'shared/core' /** * Configures and registers services for the application. diff --git a/packages/core/server/src/services/projects/projects.class.ts b/packages/server/core/src/services/projects/projects.class.ts similarity index 100% rename from packages/core/server/src/services/projects/projects.class.ts rename to packages/server/core/src/services/projects/projects.class.ts diff --git a/packages/core/server/src/services/projects/projects.ts b/packages/server/core/src/services/projects/projects.ts similarity index 100% rename from packages/core/server/src/services/projects/projects.ts rename to packages/server/core/src/services/projects/projects.ts diff --git a/packages/core/server/src/services/requests/requests.class.ts b/packages/server/core/src/services/requests/requests.class.ts similarity index 100% rename from packages/core/server/src/services/requests/requests.class.ts rename to packages/server/core/src/services/requests/requests.class.ts diff --git a/packages/core/server/src/services/requests/requests.schema.ts b/packages/server/core/src/services/requests/requests.schema.ts similarity index 100% rename from packages/core/server/src/services/requests/requests.schema.ts rename to packages/server/core/src/services/requests/requests.schema.ts diff --git a/packages/core/server/src/services/requests/requests.ts b/packages/server/core/src/services/requests/requests.ts similarity index 100% rename from packages/core/server/src/services/requests/requests.ts rename to packages/server/core/src/services/requests/requests.ts diff --git a/packages/core/server/src/services/spells/spells.class.ts b/packages/server/core/src/services/spells/spells.class.ts similarity index 97% rename from packages/core/server/src/services/spells/spells.class.ts rename to packages/server/core/src/services/spells/spells.class.ts index b3faa22a3c..12e5c7f832 100644 --- a/packages/core/server/src/services/spells/spells.class.ts +++ b/packages/server/core/src/services/spells/spells.class.ts @@ -10,7 +10,7 @@ import type { Application } from '../../declarations' import type { Params } from '@feathersjs/feathers' import type { KnexAdapterParams, KnexAdapterOptions } from '@feathersjs/knex' import type { SpellData, SpellPatch, SpellQuery } from './spells.schema' -import { SpellInterface } from '@magickml/core' +import { SpellInterface } from 'shared/core' import { app } from '../../app' /** diff --git a/packages/core/server/src/services/spells/spells.schema.ts b/packages/server/core/src/services/spells/spells.schema.ts similarity index 97% rename from packages/core/server/src/services/spells/spells.schema.ts rename to packages/server/core/src/services/spells/spells.schema.ts index 873ef3f146..9d8043eabb 100644 --- a/packages/core/server/src/services/spells/spells.schema.ts +++ b/packages/server/core/src/services/spells/spells.schema.ts @@ -14,7 +14,7 @@ import type { HookContext } from '../../declarations' export const spellResolver = resolve({}) export const spellExternalResolver = resolve({}) -import { SpellInterface, spellSchema } from '@magickml/core' +import { SpellInterface, spellSchema } from 'shared/core' // Schema for creating new entries, removing additional fields // Define the properties for the new schema const spellDataSchemaProperties = { diff --git a/packages/core/server/src/services/spells/spells.ts b/packages/server/core/src/services/spells/spells.ts similarity index 100% rename from packages/core/server/src/services/spells/spells.ts rename to packages/server/core/src/services/spells/spells.ts diff --git a/packages/core/server/src/services/tasks/tasks.class.ts b/packages/server/core/src/services/tasks/tasks.class.ts similarity index 97% rename from packages/core/server/src/services/tasks/tasks.class.ts rename to packages/server/core/src/services/tasks/tasks.class.ts index 1062e01837..6550121031 100644 --- a/packages/core/server/src/services/tasks/tasks.class.ts +++ b/packages/server/core/src/services/tasks/tasks.class.ts @@ -19,9 +19,7 @@ export type TaskParams = KnexAdapterParams */ export class TaskService< ServiceParams extends Params = TaskParams -> extends KnexService { - -} +> extends KnexService {} /** * Returns options for KnexAdapter @@ -30,6 +28,6 @@ export const getOptions = (app: Application): KnexAdapterOptions => { return { paginate: app.get('paginate'), Model: app.get('dbClient'), - name: 'tasks' + name: 'tasks', } -} \ No newline at end of file +} diff --git a/packages/core/server/src/services/tasks/tasks.schema.ts b/packages/server/core/src/services/tasks/tasks.schema.ts similarity index 97% rename from packages/core/server/src/services/tasks/tasks.schema.ts rename to packages/server/core/src/services/tasks/tasks.schema.ts index 3d5bc1ea97..086c0d80fa 100644 --- a/packages/core/server/src/services/tasks/tasks.schema.ts +++ b/packages/server/core/src/services/tasks/tasks.schema.ts @@ -17,9 +17,7 @@ import { dataValidator, queryValidator } from '../../config/validators' // import the event schema since it will be embedded in the task schema import { eventSchemaPrototype } from '../events/events.schema' -const taskEventSchema = Type.Object( - eventSchemaPrototype -) +const taskEventSchema = Type.Object(eventSchemaPrototype) // Define the taskSchema export const taskSchema = Type.Object( diff --git a/packages/core/server/src/services/tasks/tasks.ts b/packages/server/core/src/services/tasks/tasks.ts similarity index 100% rename from packages/core/server/src/services/tasks/tasks.ts rename to packages/server/core/src/services/tasks/tasks.ts diff --git a/packages/core/server/src/services/utils.ts b/packages/server/core/src/services/utils.ts similarity index 63% rename from packages/core/server/src/services/utils.ts rename to packages/server/core/src/services/utils.ts index e591005ba8..ba7225a41e 100644 --- a/packages/core/server/src/services/utils.ts +++ b/packages/server/core/src/services/utils.ts @@ -1,6 +1,6 @@ -// DOCUMENTED -import { resolve } from '@feathersjs/schema'; -import type { HookContext } from '../declarations'; +// DOCUMENTED +import { resolve } from '@feathersjs/schema' +import type { HookContext } from '../declarations' /** * Create a resolver for JSON fields. @@ -9,23 +9,24 @@ import type { HookContext } from '../declarations'; */ export const jsonResolver = (jsonFields: string[]) => { // Initialize an object to store JSON mutations - const jsonMutations: Record any> = {}; + const jsonMutations: Record any> = {} // Iterate through each JSON field jsonFields.forEach(jsonField => { // Assign a function to handle the JSON mutation for each field jsonMutations[jsonField] = (value: any) => { // Early return if value is null/undefined - if (!value) return value; + if (!value) return value // Only parse if a string is passed as the value - if (typeof value === 'string') return JSON.parse(value as unknown as string); + if (typeof value === 'string') + return JSON.parse(value as unknown as string) // If the value is already JSON, just return it - return value; - }; - }); + return value + } + }) // Return the resolver with the JSON mutations - return resolve(jsonMutations); -}; \ No newline at end of file + return resolve(jsonMutations) +} diff --git a/packages/core/server/src/sockets/channels.ts b/packages/server/core/src/sockets/channels.ts similarity index 100% rename from packages/core/server/src/sockets/channels.ts rename to packages/server/core/src/sockets/channels.ts diff --git a/packages/core/server/src/sockets/sockets.ts b/packages/server/core/src/sockets/sockets.ts similarity index 98% rename from packages/core/server/src/sockets/sockets.ts rename to packages/server/core/src/sockets/sockets.ts index 460040d3e8..ae1be8055a 100644 --- a/packages/core/server/src/sockets/sockets.ts +++ b/packages/server/core/src/sockets/sockets.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import { SpellManager } from '@magickml/core' +import { SpellManager } from 'shared/core' /** * Handle socket connections for the application. diff --git a/packages/core/server/src/vectordb.ts b/packages/server/core/src/vectordb.ts similarity index 98% rename from packages/core/server/src/vectordb.ts rename to packages/server/core/src/vectordb.ts index 660f88c8b7..d328bd8f88 100644 --- a/packages/core/server/src/vectordb.ts +++ b/packages/server/core/src/vectordb.ts @@ -9,7 +9,8 @@ The original library can be found at https://github.com/hwchase17/langchainjs. import { Document } from 'langchain/document' import { Embeddings } from 'langchain/embeddings/base' import { SupabaseVectorStore } from 'langchain/vectorstores/supabase' -import { expandVector } from '@magickml/core' +import { expandVector } from 'shared/core' +import { v4 as uuidv4 } from 'uuid' import { EmbeddingArgs } from './customEmbeddings' export type ExtendedEmbeddings = Embeddings & { diff --git a/packages/core/server/tsconfig.json b/packages/server/core/tsconfig.json similarity index 100% rename from packages/core/server/tsconfig.json rename to packages/server/core/tsconfig.json diff --git a/packages/core/server/tsconfig.lib.json b/packages/server/core/tsconfig.lib.json similarity index 100% rename from packages/core/server/tsconfig.lib.json rename to packages/server/core/tsconfig.lib.json diff --git a/packages/core/server/tsconfig.spec.json b/packages/server/core/tsconfig.spec.json similarity index 100% rename from packages/core/server/tsconfig.spec.json rename to packages/server/core/tsconfig.spec.json diff --git a/packages/core/shared/.eslintrc.json b/packages/shared/core/.eslintrc.json similarity index 94% rename from packages/core/shared/.eslintrc.json rename to packages/shared/core/.eslintrc.json index 9597d66d71..ec5feb427c 100644 --- a/packages/core/shared/.eslintrc.json +++ b/packages/shared/core/.eslintrc.json @@ -4,8 +4,7 @@ "overrides": [ { "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], - "rules": { - } + "rules": {} }, { "files": ["*.ts", "*.tsx"], diff --git a/packages/core/shared/.gitignore b/packages/shared/core/.gitignore similarity index 100% rename from packages/core/shared/.gitignore rename to packages/shared/core/.gitignore diff --git a/packages/core/shared/.gitkeep b/packages/shared/core/.gitkeep similarity index 100% rename from packages/core/shared/.gitkeep rename to packages/shared/core/.gitkeep diff --git a/packages/core/shared/jest.config.ts b/packages/shared/core/jest.config.ts similarity index 93% rename from packages/core/shared/jest.config.ts rename to packages/shared/core/jest.config.ts index 5105664551..f5854ac597 100644 --- a/packages/core/shared/jest.config.ts +++ b/packages/shared/core/jest.config.ts @@ -20,7 +20,7 @@ export default { }, moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], collectCoverage: true, - coverageDirectory: '../../coverage/packages/core/shared', + coverageDirectory: '../../coverage/packages/shared/core', collectCoverageFrom: ['/src/**/*.ts*'], coveragePathIgnorePatterns: ['/node_modules/', './import-meta-env'], setupFilesAfterEnv: ['/jest.setup.ts'], diff --git a/packages/core/shared/jest.setup.ts b/packages/shared/core/jest.setup.ts similarity index 52% rename from packages/core/shared/jest.setup.ts rename to packages/shared/core/jest.setup.ts index 85243cd9a2..429aeae75a 100644 --- a/packages/core/shared/jest.setup.ts +++ b/packages/shared/core/jest.setup.ts @@ -1,3 +1,3 @@ -// DOCUMENTED +// DOCUMENTED // Import the regenerator-runtime for async/await support -import 'regenerator-runtime/runtime'; \ No newline at end of file +import 'regenerator-runtime/runtime' diff --git a/packages/core/shared/package.json b/packages/shared/core/package.json similarity index 86% rename from packages/core/shared/package.json rename to packages/shared/core/package.json index 2f2442d861..db3aa734e6 100644 --- a/packages/core/shared/package.json +++ b/packages/shared/core/package.json @@ -1,5 +1,5 @@ { - "name": "@magickml/core", + "name": "shared/core", "version": "0.0.1", "main": "./index.js", "types": "./index.d.ts", diff --git a/packages/core/shared/project.json b/packages/shared/core/project.json similarity index 75% rename from packages/core/shared/project.json rename to packages/shared/core/project.json index 978f28eb5e..9bd98fed37 100644 --- a/packages/core/shared/project.json +++ b/packages/shared/core/project.json @@ -1,7 +1,7 @@ { - "name": "@magickml/core", + "name": "shared-core", "$schema": "../../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "packages/core/shared/src", + "sourceRoot": "packages/shared/core/src", "projectType": "library", "implicitDependencies": [], "tags": [], @@ -10,16 +10,16 @@ "executor": "@nx/linter:eslint", "outputs": ["{options.outputFile}"], "options": { - "lintFilePatterns": ["packages/core/shared/**/*.{ts,tsx,js,jsx}"] + "lintFilePatterns": ["packages/shared/core/**/*.{ts,tsx,js,jsx}"] } }, "build": { "executor": "@nx/vite:build", "outputs": ["{options.outputPath}"], "defaultConfiguration": "production", - "configFile": "packages/core/shared/vite.config.ts", + "configFile": "packages/shared/core/vite.config.ts", "options": { - "outputPath": "dist/packages/core/shared" + "outputPath": "dist/packages/shared/core" }, "configurations": { "development": { @@ -34,7 +34,7 @@ "executor": "@nx/jest:jest", "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], "options": { - "jestConfig": "packages/core/shared/jest.config.ts", + "jestConfig": "packages/shared/core/jest.config.ts", "passWithNoTests": true }, "configurations": { diff --git a/packages/core/shared/src/communication/agentEventTypes.ts b/packages/shared/core/src/communication/agentEventTypes.ts similarity index 100% rename from packages/core/shared/src/communication/agentEventTypes.ts rename to packages/shared/core/src/communication/agentEventTypes.ts diff --git a/packages/core/shared/src/communication/agentJobTypes.ts b/packages/shared/core/src/communication/agentJobTypes.ts similarity index 100% rename from packages/core/shared/src/communication/agentJobTypes.ts rename to packages/shared/core/src/communication/agentJobTypes.ts diff --git a/packages/core/shared/src/communication/index.ts b/packages/shared/core/src/communication/index.ts similarity index 100% rename from packages/core/shared/src/communication/index.ts rename to packages/shared/core/src/communication/index.ts diff --git a/packages/core/shared/src/cost-calculator.ts b/packages/shared/core/src/cost-calculator.ts similarity index 100% rename from packages/core/shared/src/cost-calculator.ts rename to packages/shared/core/src/cost-calculator.ts diff --git a/packages/core/shared/src/data/layouts/defaultLayout.json b/packages/shared/core/src/data/layouts/defaultLayout.json similarity index 100% rename from packages/core/shared/src/data/layouts/defaultLayout.json rename to packages/shared/core/src/data/layouts/defaultLayout.json diff --git a/packages/core/shared/src/data/layouts/fullScreenLayout.json b/packages/shared/core/src/data/layouts/fullScreenLayout.json similarity index 100% rename from packages/core/shared/src/data/layouts/fullScreenLayout.json rename to packages/shared/core/src/data/layouts/fullScreenLayout.json diff --git a/packages/core/shared/src/data/layouts/promptEngineeringLayout.json b/packages/shared/core/src/data/layouts/promptEngineeringLayout.json similarity index 100% rename from packages/core/shared/src/data/layouts/promptEngineeringLayout.json rename to packages/shared/core/src/data/layouts/promptEngineeringLayout.json diff --git a/packages/core/shared/src/data/layouts/troubleshootingLayout.json b/packages/shared/core/src/data/layouts/troubleshootingLayout.json similarity index 100% rename from packages/core/shared/src/data/layouts/troubleshootingLayout.json rename to packages/shared/core/src/data/layouts/troubleshootingLayout.json diff --git a/packages/core/shared/src/dataControls/ArrayControl.ts b/packages/shared/core/src/dataControls/ArrayControl.ts similarity index 100% rename from packages/core/shared/src/dataControls/ArrayControl.ts rename to packages/shared/core/src/dataControls/ArrayControl.ts diff --git a/packages/core/shared/src/dataControls/BooleanControl.ts b/packages/shared/core/src/dataControls/BooleanControl.ts similarity index 100% rename from packages/core/shared/src/dataControls/BooleanControl.ts rename to packages/shared/core/src/dataControls/BooleanControl.ts diff --git a/packages/core/shared/src/dataControls/CodeControl.ts b/packages/shared/core/src/dataControls/CodeControl.ts similarity index 100% rename from packages/core/shared/src/dataControls/CodeControl.ts rename to packages/shared/core/src/dataControls/CodeControl.ts diff --git a/packages/shared/core/src/dataControls/CustomDropdown.tsx b/packages/shared/core/src/dataControls/CustomDropdown.tsx new file mode 100644 index 0000000000..4a0c327c4d --- /dev/null +++ b/packages/shared/core/src/dataControls/CustomDropdown.tsx @@ -0,0 +1,65 @@ +// DOCUMENTED +/** + * A dropdown component that can be customized with a title and options. + * @param {object} props - The props object contains a title string and an array of options. + * @param {string} props.title - The title of the dropdown. + * @param {string[]} props.data - The options to be displayed in the dropdown. + */ +export default function CustomDropdown(props: { + title: string + data: string[] +}): React.ReactElement { + return ( +
+
+
+ {props.title} +
+
+
    + {props.data.map((option, index) => ( +
  • + {option} +
  • + ))} +
+
+
+
+ ) +} + +/* + We disable @typescript-eslint/no-unused-vars because `props` is actually used in this Component +*/ diff --git a/packages/core/shared/src/dataControls/DropdownControl.ts b/packages/shared/core/src/dataControls/DropdownControl.ts similarity index 94% rename from packages/core/shared/src/dataControls/DropdownControl.ts rename to packages/shared/core/src/dataControls/DropdownControl.ts index 80a75bb74d..aa9dd289ec 100644 --- a/packages/core/shared/src/dataControls/DropdownControl.ts +++ b/packages/shared/core/src/dataControls/DropdownControl.ts @@ -1,15 +1,15 @@ -// DOCUMENTED -/** +// DOCUMENTED +/** * Represents a dropdown control that extends from DataControl. - * + * * @extends DataControl -*/ + */ import { DataControl } from '../plugins/inspectorPlugin' export class DropdownControl extends DataControl { /** * Creates an instance of DropdownControl. - * + * * @param {Object} options - An object containing various options for the dropdown control. * @param {string} options.name - The name of the dropdown control. * @param {string} options.dataKey - The datakey for the dropdown control. @@ -36,7 +36,7 @@ export class DropdownControl extends DataControl { icon?: string write?: boolean ignored?: string[] - tooltip?: string; + tooltip?: string }) { const options = { dataKey, @@ -49,9 +49,9 @@ export class DropdownControl extends DataControl { values, ignored, }, - tooltip: tooltip + tooltip: tooltip, } super(options) } -} \ No newline at end of file +} diff --git a/packages/core/shared/src/dataControls/EmptyControl.ts b/packages/shared/core/src/dataControls/EmptyControl.ts similarity index 100% rename from packages/core/shared/src/dataControls/EmptyControl.ts rename to packages/shared/core/src/dataControls/EmptyControl.ts diff --git a/packages/core/shared/src/dataControls/FewshotControl.ts b/packages/shared/core/src/dataControls/FewshotControl.ts similarity index 100% rename from packages/core/shared/src/dataControls/FewshotControl.ts rename to packages/shared/core/src/dataControls/FewshotControl.ts diff --git a/packages/core/shared/src/dataControls/InputControl.ts b/packages/shared/core/src/dataControls/InputControl.ts similarity index 83% rename from packages/core/shared/src/dataControls/InputControl.ts rename to packages/shared/core/src/dataControls/InputControl.ts index f25d4a4a70..c43fabba04 100644 --- a/packages/core/shared/src/dataControls/InputControl.ts +++ b/packages/shared/core/src/dataControls/InputControl.ts @@ -1,22 +1,22 @@ -// DOCUMENTED +// DOCUMENTED /** * A class that extends DataControl and represents an input control. - * + * * @extends DataControl */ -import { DataControl } from '../plugins/inspectorPlugin'; +import { DataControl } from '../plugins/inspectorPlugin' export class InputControl extends DataControl { /** * Creates an instance of InputControl. - * + * * @param {Object} inputOptions - The options to initialize InputControl with. * @param {string} inputOptions.dataKey - The key used to store and retrieve the value controlled by this input. * @param {string} inputOptions.name - The name or label associated with the input. * @param {string} [inputOptions.icon = 'hand'] - The name of the icon to display with the input. * @param {*} [inputOptions.defaultValue] - The default value for the input. * @param {string} [inputOptions.placeholder] - The placeholder text for the input. - * + * * @memberof InputControl */ constructor({ @@ -27,12 +27,12 @@ export class InputControl extends DataControl { defaultValue, placeholder, }: { - dataKey: string; - name: string; - icon?: string; - defaultValue?: unknown; - placeholder?: string; - tooltip?: string; + dataKey: string + name: string + icon?: string + defaultValue?: unknown + placeholder?: string + tooltip?: string }) { // Call super constructor with options and 'input' as the type of control super({ @@ -43,6 +43,6 @@ export class InputControl extends DataControl { icon: icon, placeholder: placeholder, tooltip: tooltip, - }); + }) } } diff --git a/packages/core/shared/src/dataControls/InputGenerator.ts b/packages/shared/core/src/dataControls/InputGenerator.ts similarity index 100% rename from packages/core/shared/src/dataControls/InputGenerator.ts rename to packages/shared/core/src/dataControls/InputGenerator.ts diff --git a/packages/core/shared/src/dataControls/ModelControl.ts b/packages/shared/core/src/dataControls/ModelControl.ts similarity index 79% rename from packages/core/shared/src/dataControls/ModelControl.ts rename to packages/shared/core/src/dataControls/ModelControl.ts index 6203b3142d..0c62466b03 100644 --- a/packages/core/shared/src/dataControls/ModelControl.ts +++ b/packages/shared/core/src/dataControls/ModelControl.ts @@ -1,9 +1,9 @@ -// DOCUMENTED +// DOCUMENTED /** * Represents a control used for selecting a model and its corresponding data. * Inherits from the DataControl class. */ -import { DataControl } from '../plugins/inspectorPlugin'; +import { DataControl } from '../plugins/inspectorPlugin' export class ModelControl extends DataControl { /** @@ -22,12 +22,12 @@ export class ModelControl extends DataControl { write = true, tooltip = '', }: { - name: string; - dataKey: string; - defaultValue: string; - icon?: string; - write?: boolean; - tooltip?: string; + name: string + dataKey: string + defaultValue: string + icon?: string + write?: boolean + tooltip?: string }) { const options = { dataKey, @@ -39,8 +39,8 @@ export class ModelControl extends DataControl { defaultValue, }, tooltip: tooltip, - }; + } - super(options); + super(options) } -} \ No newline at end of file +} diff --git a/packages/core/shared/src/dataControls/MultiSocketGenerator.ts b/packages/shared/core/src/dataControls/MultiSocketGenerator.ts similarity index 75% rename from packages/core/shared/src/dataControls/MultiSocketGenerator.ts rename to packages/shared/core/src/dataControls/MultiSocketGenerator.ts index 0aa9b84a50..5d6f71b407 100644 --- a/packages/core/shared/src/dataControls/MultiSocketGenerator.ts +++ b/packages/shared/core/src/dataControls/MultiSocketGenerator.ts @@ -1,5 +1,5 @@ -// DOCUMENTED -import { DataControl } from '../plugins/inspectorPlugin'; +// DOCUMENTED +import { DataControl } from '../plugins/inspectorPlugin' /** * MultiSocketGeneratorControl is a DataControl that allows you to socket groups @@ -9,7 +9,7 @@ export class MultiSocketGeneratorControl extends DataControl { /** * Type of connection. */ - connectionType: string; + connectionType: string /** * Creates an instance of MultiSocketGeneratorControl. @@ -30,15 +30,15 @@ export class MultiSocketGeneratorControl extends DataControl { name: nameInput, tooltip = '', }: { - socketTypes: string[]; - taskTypes: string[]; - ignored?: { name: string }[]; - icon?: string; - connectionType: 'input' | 'output'; - name: string; - tooltip?: string; + socketTypes: string[] + taskTypes: string[] + ignored?: { name: string }[] + icon?: string + connectionType: 'input' | 'output' + name: string + tooltip?: string }) { - const name = nameInput || `${socketTypes.join('|')} ${connectionType}s`; + const name = nameInput || `${socketTypes.join('|')} ${connectionType}s` const options = { dataKey: connectionType + 's', @@ -52,10 +52,10 @@ export class MultiSocketGeneratorControl extends DataControl { connectionType, }, tooltip: tooltip, - }; + } - super(options); + super(options) - this.connectionType = connectionType; + this.connectionType = connectionType } -} \ No newline at end of file +} diff --git a/packages/core/shared/src/dataControls/NumberControl.ts b/packages/shared/core/src/dataControls/NumberControl.ts similarity index 100% rename from packages/core/shared/src/dataControls/NumberControl.ts rename to packages/shared/core/src/dataControls/NumberControl.ts diff --git a/packages/core/shared/src/dataControls/OutputGenerator.ts b/packages/shared/core/src/dataControls/OutputGenerator.ts similarity index 100% rename from packages/core/shared/src/dataControls/OutputGenerator.ts rename to packages/shared/core/src/dataControls/OutputGenerator.ts diff --git a/packages/core/shared/src/dataControls/PlaytestControl.ts b/packages/shared/core/src/dataControls/PlaytestControl.ts similarity index 87% rename from packages/core/shared/src/dataControls/PlaytestControl.ts rename to packages/shared/core/src/dataControls/PlaytestControl.ts index 214350cbbb..35603a47d6 100644 --- a/packages/core/shared/src/dataControls/PlaytestControl.ts +++ b/packages/shared/core/src/dataControls/PlaytestControl.ts @@ -1,9 +1,9 @@ -// DOCUMENTED +// DOCUMENTED /** * Represents a subclass of DataControl that is specific to controlling playtest functionality. * @extends DataControl */ -import { DataControl } from '../plugins/inspectorPlugin'; +import { DataControl } from '../plugins/inspectorPlugin' export class PlaytestControl extends DataControl { /** @@ -23,7 +23,7 @@ export class PlaytestControl extends DataControl { label = 'Toggle', defaultValue = {}, ignored = [], - tooltip='' + tooltip = '', }) { const options = { dataKey, // shorthand object property assignment @@ -36,10 +36,9 @@ export class PlaytestControl extends DataControl { ignored, }, tooltip: tooltip, - }; - - super(options); // call super constructor + } + super(options) // call super constructor } /** @@ -47,6 +46,6 @@ export class PlaytestControl extends DataControl { * @param {any} playtestToggle - The current playtest toggle status. */ onData(playtestToggle) { - return; // No-op, as this method is incomplete + return // No-op, as this method is incomplete } -} \ No newline at end of file +} diff --git a/packages/core/shared/src/dataControls/SocketGenerator.ts b/packages/shared/core/src/dataControls/SocketGenerator.ts similarity index 68% rename from packages/core/shared/src/dataControls/SocketGenerator.ts rename to packages/shared/core/src/dataControls/SocketGenerator.ts index 1e591fe373..1f42670d14 100644 --- a/packages/core/shared/src/dataControls/SocketGenerator.ts +++ b/packages/shared/core/src/dataControls/SocketGenerator.ts @@ -1,21 +1,21 @@ -// DOCUMENTED +// DOCUMENTED /** * This class represents a SocketGeneratorControl, which extends DataControl * and generates a socket based on the input of the user. - * + * * @class SocketGeneratorControl * @extends DataControl */ -import { DataControl } from '../plugins/inspectorPlugin'; -import { SocketType } from '../sockets'; -import { IgnoredList, TaskType } from '../types'; +import { DataControl } from '../plugins/inspectorPlugin' +import { SocketType } from '../sockets' +import { IgnoredList, TaskType } from '../types' export class SocketGeneratorControl extends DataControl { - connectionType: string; + connectionType: string /** - * Create a new instance of SocketGeneratorControl. - * + * Create a new instance of SocketGeneratorControl. + * * @param {Object} options - The options needed to generate the socket control. * @param {SocketType} [options.socketType='anySocket'] - The socket type of the socket generated. * @param {TaskType} [options.taskType='output'] - The task type of the socket generated. @@ -33,13 +33,13 @@ export class SocketGeneratorControl extends DataControl { name: nameInput, tooltip = '', }: { - socketType?: SocketType, - taskType?: TaskType, - ignored?: IgnoredList, - icon?: string, - connectionType: 'input' | 'output', + socketType?: SocketType + taskType?: TaskType + ignored?: IgnoredList + icon?: string + connectionType: 'input' | 'output' name: string - tooltip?: string, + tooltip?: string }) { super({ dataKey: connectionType + 's', @@ -53,12 +53,17 @@ export class SocketGeneratorControl extends DataControl { connectionType, }, tooltip: tooltip, - }); + }) - if(!connectionType || !(connectionType === 'input' || connectionType === 'output')) { - throw new Error("connectionType of your generator must be defined and of the value 'input' or 'output'."); + if ( + !connectionType || + !(connectionType === 'input' || connectionType === 'output') + ) { + throw new Error( + "connectionType of your generator must be defined and of the value 'input' or 'output'." + ) } - this.connectionType = connectionType; + this.connectionType = connectionType } -} \ No newline at end of file +} diff --git a/packages/core/shared/src/dataControls/SpellControl.ts b/packages/shared/core/src/dataControls/SpellControl.ts similarity index 90% rename from packages/core/shared/src/dataControls/SpellControl.ts rename to packages/shared/core/src/dataControls/SpellControl.ts index ad2e61a49f..dc9bce8a94 100644 --- a/packages/core/shared/src/dataControls/SpellControl.ts +++ b/packages/shared/core/src/dataControls/SpellControl.ts @@ -1,12 +1,11 @@ -// DOCUMENTED +// DOCUMENTED /** * An extension of DataControl class that manages spell data. * @extends DataControl */ -import { DataControl } from '../plugins/inspectorPlugin'; +import { DataControl } from '../plugins/inspectorPlugin' export class SpellControl extends DataControl { - /** * Creates a new instance of SpellControl. * @param {Object} options - Options for SpellControl. @@ -31,6 +30,6 @@ export class SpellControl extends DataControl { icon: options.icon || 'sieve', tooltip: options.tooltip || '', } - super(optionsWithDefaults); + super(optionsWithDefaults) } -} \ No newline at end of file +} diff --git a/packages/core/shared/src/dataControls/SwitchControl.ts b/packages/shared/core/src/dataControls/SwitchControl.ts similarity index 98% rename from packages/core/shared/src/dataControls/SwitchControl.ts rename to packages/shared/core/src/dataControls/SwitchControl.ts index 7798e3fdc1..181a07b4a1 100644 --- a/packages/core/shared/src/dataControls/SwitchControl.ts +++ b/packages/shared/core/src/dataControls/SwitchControl.ts @@ -1,4 +1,4 @@ -// DOCUMENTED +// DOCUMENTED /** * Represents a switch control. @@ -8,7 +8,6 @@ import { DataControl } from '../plugins/inspectorPlugin' export class SwitchControl extends DataControl { - /** * Creates an instance of SwitchControl. * @param {{ @@ -61,4 +60,4 @@ export class SwitchControl extends DataControl { onData = () => { return } -} \ No newline at end of file +} diff --git a/packages/core/shared/src/dataControls/TextInputControl.tsx b/packages/shared/core/src/dataControls/TextInputControl.tsx similarity index 100% rename from packages/core/shared/src/dataControls/TextInputControl.tsx rename to packages/shared/core/src/dataControls/TextInputControl.tsx diff --git a/packages/core/shared/src/engine.ts b/packages/shared/core/src/engine.ts similarity index 99% rename from packages/core/shared/src/engine.ts rename to packages/shared/core/src/engine.ts index 0a4275986c..c5e6d9aef7 100644 --- a/packages/core/shared/src/engine.ts +++ b/packages/shared/core/src/engine.ts @@ -2,7 +2,7 @@ import Rete, { Node, Engine, NodeData, Plugin } from 'shared/rete' import io from 'socket.io' -import { getLogger } from '@magickml/core' +import { getLogger } from 'shared/core' import consolePlugin, { DebuggerArgs } from './plugins/consolePlugin' import ModulePlugin, { ModulePluginArgs } from './plugins/modulePlugin' import { ModuleManager } from './plugins/modulePlugin/module-manager' diff --git a/packages/core/shared/src/functions/ProcessPython.ts b/packages/shared/core/src/functions/ProcessPython.ts similarity index 100% rename from packages/core/shared/src/functions/ProcessPython.ts rename to packages/shared/core/src/functions/ProcessPython.ts diff --git a/packages/core/shared/src/functions/expandVector.ts b/packages/shared/core/src/functions/expandVector.ts similarity index 100% rename from packages/core/shared/src/functions/expandVector.ts rename to packages/shared/core/src/functions/expandVector.ts diff --git a/packages/core/shared/src/functions/index.ts b/packages/shared/core/src/functions/index.ts similarity index 100% rename from packages/core/shared/src/functions/index.ts rename to packages/shared/core/src/functions/index.ts diff --git a/packages/core/shared/src/functions/processCode.ts b/packages/shared/core/src/functions/processCode.ts similarity index 100% rename from packages/core/shared/src/functions/processCode.ts rename to packages/shared/core/src/functions/processCode.ts diff --git a/packages/core/shared/src/functions/saveRequest.ts b/packages/shared/core/src/functions/saveRequest.ts similarity index 100% rename from packages/core/shared/src/functions/saveRequest.ts rename to packages/shared/core/src/functions/saveRequest.ts diff --git a/packages/core/shared/src/functions/speechUtils.ts b/packages/shared/core/src/functions/speechUtils.ts similarity index 100% rename from packages/core/shared/src/functions/speechUtils.ts rename to packages/shared/core/src/functions/speechUtils.ts diff --git a/packages/core/shared/src/globals.ts b/packages/shared/core/src/globals.ts similarity index 82% rename from packages/core/shared/src/globals.ts rename to packages/shared/core/src/globals.ts index ab053130b7..e38e6ad0df 100644 --- a/packages/core/shared/src/globals.ts +++ b/packages/shared/core/src/globals.ts @@ -1,38 +1,38 @@ -// DOCUMENTED +// DOCUMENTED /** * Globals Manager is a singleton class that allows registration of global variables that can be accessed from anywhere in the codebase. - * + * * This is useful for things like the editor, which needs to be accessible from anywhere in the codebase. - * + * * TODO: This pattern is fine for now, but we should probably use a dependency injection through the interface or something. */ class GlobalsManager { - private globals: Map; + private globals: Map constructor() { - this.globals = new Map(); + this.globals = new Map() } /** * Register a new global variable with the given name and value. - * + * * @param name - The name of the global variable to be added. * @param value - The value of the global variable to be added. */ register(name: string, value: unknown): void { - this.globals.set(name, value); + this.globals.set(name, value) } /** * Get the value of a previously registered global variable. - * + * * @param name - The name of the global variable whose value is to be retrieved. * @returns The value of the requested global variable, or undefined if no such variable has been registered. */ get(name: string): unknown { - return this.globals.get(name); + return this.globals.get(name) } } // Export a singleton instance of the GlobalsManager class -export const globalsManager = new GlobalsManager(); \ No newline at end of file +export const globalsManager = new GlobalsManager() diff --git a/packages/core/shared/src/index.ts b/packages/shared/core/src/index.ts similarity index 100% rename from packages/core/shared/src/index.ts rename to packages/shared/core/src/index.ts diff --git a/packages/core/shared/src/logger/index.ts b/packages/shared/core/src/logger/index.ts similarity index 100% rename from packages/core/shared/src/logger/index.ts rename to packages/shared/core/src/logger/index.ts diff --git a/packages/core/shared/src/nodes/array/ArrayToJSON.ts b/packages/shared/core/src/nodes/array/ArrayToJSON.ts similarity index 100% rename from packages/core/shared/src/nodes/array/ArrayToJSON.ts rename to packages/shared/core/src/nodes/array/ArrayToJSON.ts diff --git a/packages/core/shared/src/nodes/array/ArrayVariable.ts b/packages/shared/core/src/nodes/array/ArrayVariable.ts similarity index 100% rename from packages/core/shared/src/nodes/array/ArrayVariable.ts rename to packages/shared/core/src/nodes/array/ArrayVariable.ts diff --git a/packages/core/shared/src/nodes/array/ExtractFromArray.ts b/packages/shared/core/src/nodes/array/ExtractFromArray.ts similarity index 100% rename from packages/core/shared/src/nodes/array/ExtractFromArray.ts rename to packages/shared/core/src/nodes/array/ExtractFromArray.ts diff --git a/packages/core/shared/src/nodes/array/GetValueFromArray.ts b/packages/shared/core/src/nodes/array/GetValueFromArray.ts similarity index 100% rename from packages/core/shared/src/nodes/array/GetValueFromArray.ts rename to packages/shared/core/src/nodes/array/GetValueFromArray.ts diff --git a/packages/core/shared/src/nodes/array/JSONToArray.ts b/packages/shared/core/src/nodes/array/JSONToArray.ts similarity index 100% rename from packages/core/shared/src/nodes/array/JSONToArray.ts rename to packages/shared/core/src/nodes/array/JSONToArray.ts diff --git a/packages/core/shared/src/nodes/array/JoinList.ts b/packages/shared/core/src/nodes/array/JoinList.ts similarity index 100% rename from packages/core/shared/src/nodes/array/JoinList.ts rename to packages/shared/core/src/nodes/array/JoinList.ts diff --git a/packages/core/shared/src/nodes/array/RemapArray.ts b/packages/shared/core/src/nodes/array/RemapArray.ts similarity index 100% rename from packages/core/shared/src/nodes/array/RemapArray.ts rename to packages/shared/core/src/nodes/array/RemapArray.ts diff --git a/packages/core/shared/src/nodes/audio/TextToSpeech.ts b/packages/shared/core/src/nodes/audio/TextToSpeech.ts similarity index 100% rename from packages/core/shared/src/nodes/audio/TextToSpeech.ts rename to packages/shared/core/src/nodes/audio/TextToSpeech.ts diff --git a/packages/core/shared/src/nodes/boolean/BooleanVariable.ts b/packages/shared/core/src/nodes/boolean/BooleanVariable.ts similarity index 100% rename from packages/core/shared/src/nodes/boolean/BooleanVariable.ts rename to packages/shared/core/src/nodes/boolean/BooleanVariable.ts diff --git a/packages/core/shared/src/nodes/boolean/IsVariableTrue.ts b/packages/shared/core/src/nodes/boolean/IsVariableTrue.ts similarity index 100% rename from packages/core/shared/src/nodes/boolean/IsVariableTrue.ts rename to packages/shared/core/src/nodes/boolean/IsVariableTrue.ts diff --git a/packages/core/shared/src/nodes/boolean/LogicalOperator.ts b/packages/shared/core/src/nodes/boolean/LogicalOperator.ts similarity index 100% rename from packages/core/shared/src/nodes/boolean/LogicalOperator.ts rename to packages/shared/core/src/nodes/boolean/LogicalOperator.ts diff --git a/packages/core/shared/src/nodes/code/Javascript.ts b/packages/shared/core/src/nodes/code/Javascript.ts similarity index 100% rename from packages/core/shared/src/nodes/code/Javascript.ts rename to packages/shared/core/src/nodes/code/Javascript.ts diff --git a/packages/core/shared/src/nodes/code/Python.ts b/packages/shared/core/src/nodes/code/Python.ts similarity index 100% rename from packages/core/shared/src/nodes/code/Python.ts rename to packages/shared/core/src/nodes/code/Python.ts diff --git a/packages/core/shared/src/nodes/database/Delete.ts b/packages/shared/core/src/nodes/database/Delete.ts similarity index 100% rename from packages/core/shared/src/nodes/database/Delete.ts rename to packages/shared/core/src/nodes/database/Delete.ts diff --git a/packages/core/shared/src/nodes/database/Insert.ts b/packages/shared/core/src/nodes/database/Insert.ts similarity index 100% rename from packages/core/shared/src/nodes/database/Insert.ts rename to packages/shared/core/src/nodes/database/Insert.ts diff --git a/packages/core/shared/src/nodes/database/Select.ts b/packages/shared/core/src/nodes/database/Select.ts similarity index 100% rename from packages/core/shared/src/nodes/database/Select.ts rename to packages/shared/core/src/nodes/database/Select.ts diff --git a/packages/core/shared/src/nodes/database/Update.ts b/packages/shared/core/src/nodes/database/Update.ts similarity index 100% rename from packages/core/shared/src/nodes/database/Update.ts rename to packages/shared/core/src/nodes/database/Update.ts diff --git a/packages/core/shared/src/nodes/database/Upsert.ts b/packages/shared/core/src/nodes/database/Upsert.ts similarity index 100% rename from packages/core/shared/src/nodes/database/Upsert.ts rename to packages/shared/core/src/nodes/database/Upsert.ts diff --git a/packages/core/shared/src/nodes/document/DocumentToContent.ts b/packages/shared/core/src/nodes/document/DocumentToContent.ts similarity index 100% rename from packages/core/shared/src/nodes/document/DocumentToContent.ts rename to packages/shared/core/src/nodes/document/DocumentToContent.ts diff --git a/packages/core/shared/src/nodes/document/GetDocuments.ts b/packages/shared/core/src/nodes/document/GetDocuments.ts similarity index 100% rename from packages/core/shared/src/nodes/document/GetDocuments.ts rename to packages/shared/core/src/nodes/document/GetDocuments.ts diff --git a/packages/core/shared/src/nodes/document/StoreDocument.ts b/packages/shared/core/src/nodes/document/StoreDocument.ts similarity index 100% rename from packages/core/shared/src/nodes/document/StoreDocument.ts rename to packages/shared/core/src/nodes/document/StoreDocument.ts diff --git a/packages/core/shared/src/nodes/embedding/CosineSimilarity.ts b/packages/shared/core/src/nodes/embedding/CosineSimilarity.ts similarity index 100% rename from packages/core/shared/src/nodes/embedding/CosineSimilarity.ts rename to packages/shared/core/src/nodes/embedding/CosineSimilarity.ts diff --git a/packages/core/shared/src/nodes/embedding/CreateTextEmbedding.ts b/packages/shared/core/src/nodes/embedding/CreateTextEmbedding.ts similarity index 100% rename from packages/core/shared/src/nodes/embedding/CreateTextEmbedding.ts rename to packages/shared/core/src/nodes/embedding/CreateTextEmbedding.ts diff --git a/packages/core/shared/src/nodes/embedding/ExtractRelationship.ts b/packages/shared/core/src/nodes/embedding/ExtractRelationship.ts similarity index 100% rename from packages/core/shared/src/nodes/embedding/ExtractRelationship.ts rename to packages/shared/core/src/nodes/embedding/ExtractRelationship.ts diff --git a/packages/core/shared/src/nodes/embedding/FindTextEmbedding.ts b/packages/shared/core/src/nodes/embedding/FindTextEmbedding.ts similarity index 100% rename from packages/core/shared/src/nodes/embedding/FindTextEmbedding.ts rename to packages/shared/core/src/nodes/embedding/FindTextEmbedding.ts diff --git a/packages/core/shared/src/nodes/events/EventDelete.ts b/packages/shared/core/src/nodes/events/EventDelete.ts similarity index 100% rename from packages/core/shared/src/nodes/events/EventDelete.ts rename to packages/shared/core/src/nodes/events/EventDelete.ts diff --git a/packages/core/shared/src/nodes/events/EventDestructure.ts b/packages/shared/core/src/nodes/events/EventDestructure.ts similarity index 100% rename from packages/core/shared/src/nodes/events/EventDestructure.ts rename to packages/shared/core/src/nodes/events/EventDestructure.ts diff --git a/packages/core/shared/src/nodes/events/EventRecall.ts b/packages/shared/core/src/nodes/events/EventRecall.ts similarity index 100% rename from packages/core/shared/src/nodes/events/EventRecall.ts rename to packages/shared/core/src/nodes/events/EventRecall.ts diff --git a/packages/core/shared/src/nodes/events/EventRestructure.ts b/packages/shared/core/src/nodes/events/EventRestructure.ts similarity index 100% rename from packages/core/shared/src/nodes/events/EventRestructure.ts rename to packages/shared/core/src/nodes/events/EventRestructure.ts diff --git a/packages/core/shared/src/nodes/events/EventStore.ts b/packages/shared/core/src/nodes/events/EventStore.ts similarity index 100% rename from packages/core/shared/src/nodes/events/EventStore.ts rename to packages/shared/core/src/nodes/events/EventStore.ts diff --git a/packages/core/shared/src/nodes/events/EventsToConversation.ts b/packages/shared/core/src/nodes/events/EventsToConversation.ts similarity index 100% rename from packages/core/shared/src/nodes/events/EventsToConversation.ts rename to packages/shared/core/src/nodes/events/EventsToConversation.ts diff --git a/packages/core/shared/src/nodes/flow/BooleanGate.ts b/packages/shared/core/src/nodes/flow/BooleanGate.ts similarity index 100% rename from packages/core/shared/src/nodes/flow/BooleanGate.ts rename to packages/shared/core/src/nodes/flow/BooleanGate.ts diff --git a/packages/core/shared/src/nodes/flow/CommandParser.ts b/packages/shared/core/src/nodes/flow/CommandParser.ts similarity index 100% rename from packages/core/shared/src/nodes/flow/CommandParser.ts rename to packages/shared/core/src/nodes/flow/CommandParser.ts diff --git a/packages/core/shared/src/nodes/flow/ExclusiveGate.ts b/packages/shared/core/src/nodes/flow/ExclusiveGate.ts similarity index 100% rename from packages/core/shared/src/nodes/flow/ExclusiveGate.ts rename to packages/shared/core/src/nodes/flow/ExclusiveGate.ts diff --git a/packages/core/shared/src/nodes/flow/IsNullOrUndefined.ts b/packages/shared/core/src/nodes/flow/IsNullOrUndefined.ts similarity index 100% rename from packages/core/shared/src/nodes/flow/IsNullOrUndefined.ts rename to packages/shared/core/src/nodes/flow/IsNullOrUndefined.ts diff --git a/packages/core/shared/src/nodes/flow/OrGate.ts b/packages/shared/core/src/nodes/flow/OrGate.ts similarity index 100% rename from packages/core/shared/src/nodes/flow/OrGate.ts rename to packages/shared/core/src/nodes/flow/OrGate.ts diff --git a/packages/core/shared/src/nodes/flow/RandomGate.ts b/packages/shared/core/src/nodes/flow/RandomGate.ts similarity index 100% rename from packages/core/shared/src/nodes/flow/RandomGate.ts rename to packages/shared/core/src/nodes/flow/RandomGate.ts diff --git a/packages/core/shared/src/nodes/flow/SwitchGate.ts b/packages/shared/core/src/nodes/flow/SwitchGate.ts similarity index 100% rename from packages/core/shared/src/nodes/flow/SwitchGate.ts rename to packages/shared/core/src/nodes/flow/SwitchGate.ts diff --git a/packages/core/shared/src/nodes/flow/WaitForAll.ts b/packages/shared/core/src/nodes/flow/WaitForAll.ts similarity index 100% rename from packages/core/shared/src/nodes/flow/WaitForAll.ts rename to packages/shared/core/src/nodes/flow/WaitForAll.ts diff --git a/packages/core/shared/src/nodes/index.ts b/packages/shared/core/src/nodes/index.ts similarity index 100% rename from packages/core/shared/src/nodes/index.ts rename to packages/shared/core/src/nodes/index.ts diff --git a/packages/core/shared/src/nodes/io/Input.ts b/packages/shared/core/src/nodes/io/Input.ts similarity index 100% rename from packages/core/shared/src/nodes/io/Input.ts rename to packages/shared/core/src/nodes/io/Input.ts diff --git a/packages/core/shared/src/nodes/io/JupyterNotebook.ts b/packages/shared/core/src/nodes/io/JupyterNotebook.ts similarity index 100% rename from packages/core/shared/src/nodes/io/JupyterNotebook.ts rename to packages/shared/core/src/nodes/io/JupyterNotebook.ts diff --git a/packages/core/shared/src/nodes/io/Output.ts b/packages/shared/core/src/nodes/io/Output.ts similarity index 100% rename from packages/core/shared/src/nodes/io/Output.ts rename to packages/shared/core/src/nodes/io/Output.ts diff --git a/packages/core/shared/src/nodes/io/Request.ts b/packages/shared/core/src/nodes/io/Request.ts similarity index 100% rename from packages/core/shared/src/nodes/io/Request.ts rename to packages/shared/core/src/nodes/io/Request.ts diff --git a/packages/core/shared/src/nodes/io/Respond.ts b/packages/shared/core/src/nodes/io/Respond.ts similarity index 100% rename from packages/core/shared/src/nodes/io/Respond.ts rename to packages/shared/core/src/nodes/io/Respond.ts diff --git a/packages/core/shared/src/nodes/io/Skill.ts b/packages/shared/core/src/nodes/io/Skill.ts similarity index 100% rename from packages/core/shared/src/nodes/io/Skill.ts rename to packages/shared/core/src/nodes/io/Skill.ts diff --git a/packages/core/shared/src/nodes/io/SocketInput.ts b/packages/shared/core/src/nodes/io/SocketInput.ts similarity index 98% rename from packages/core/shared/src/nodes/io/SocketInput.ts rename to packages/shared/core/src/nodes/io/SocketInput.ts index ac73614d7c..e3716cf546 100644 --- a/packages/core/shared/src/nodes/io/SocketInput.ts +++ b/packages/shared/core/src/nodes/io/SocketInput.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { v4 as uuidv4 } from 'uuid' import { MagickComponent } from '../../engine' diff --git a/packages/core/shared/src/nodes/io/SocketOutput.ts b/packages/shared/core/src/nodes/io/SocketOutput.ts similarity index 98% rename from packages/core/shared/src/nodes/io/SocketOutput.ts rename to packages/shared/core/src/nodes/io/SocketOutput.ts index 531fcbf63f..6a83232977 100644 --- a/packages/core/shared/src/nodes/io/SocketOutput.ts +++ b/packages/shared/core/src/nodes/io/SocketOutput.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import Rete from '@magickml/rete' +import Rete from 'shared/rete' import { v4 as uuidv4 } from 'uuid' import { MagickComponent } from '../../engine' diff --git a/packages/core/shared/src/nodes/io/Spell.ts b/packages/shared/core/src/nodes/io/Spell.ts similarity index 100% rename from packages/core/shared/src/nodes/io/Spell.ts rename to packages/shared/core/src/nodes/io/Spell.ts diff --git a/packages/core/shared/src/nodes/io/SpellByName.ts b/packages/shared/core/src/nodes/io/SpellByName.ts similarity index 100% rename from packages/core/shared/src/nodes/io/SpellByName.ts rename to packages/shared/core/src/nodes/io/SpellByName.ts diff --git a/packages/core/shared/src/nodes/magick/runSpell.ts b/packages/shared/core/src/nodes/magick/runSpell.ts similarity index 100% rename from packages/core/shared/src/nodes/magick/runSpell.ts rename to packages/shared/core/src/nodes/magick/runSpell.ts diff --git a/packages/core/shared/src/nodes/number/Add.ts b/packages/shared/core/src/nodes/number/Add.ts similarity index 100% rename from packages/core/shared/src/nodes/number/Add.ts rename to packages/shared/core/src/nodes/number/Add.ts diff --git a/packages/core/shared/src/nodes/number/Divide.ts b/packages/shared/core/src/nodes/number/Divide.ts similarity index 100% rename from packages/core/shared/src/nodes/number/Divide.ts rename to packages/shared/core/src/nodes/number/Divide.ts diff --git a/packages/core/shared/src/nodes/number/Equal.ts b/packages/shared/core/src/nodes/number/Equal.ts similarity index 100% rename from packages/core/shared/src/nodes/number/Equal.ts rename to packages/shared/core/src/nodes/number/Equal.ts diff --git a/packages/core/shared/src/nodes/number/GreaterThan.ts b/packages/shared/core/src/nodes/number/GreaterThan.ts similarity index 100% rename from packages/core/shared/src/nodes/number/GreaterThan.ts rename to packages/shared/core/src/nodes/number/GreaterThan.ts diff --git a/packages/core/shared/src/nodes/number/GreaterThanOrEqual.ts b/packages/shared/core/src/nodes/number/GreaterThanOrEqual.ts similarity index 100% rename from packages/core/shared/src/nodes/number/GreaterThanOrEqual.ts rename to packages/shared/core/src/nodes/number/GreaterThanOrEqual.ts diff --git a/packages/core/shared/src/nodes/number/InRange.ts b/packages/shared/core/src/nodes/number/InRange.ts similarity index 100% rename from packages/core/shared/src/nodes/number/InRange.ts rename to packages/shared/core/src/nodes/number/InRange.ts diff --git a/packages/core/shared/src/nodes/number/IsANumber.ts b/packages/shared/core/src/nodes/number/IsANumber.ts similarity index 100% rename from packages/core/shared/src/nodes/number/IsANumber.ts rename to packages/shared/core/src/nodes/number/IsANumber.ts diff --git a/packages/core/shared/src/nodes/number/LessThan.ts b/packages/shared/core/src/nodes/number/LessThan.ts similarity index 100% rename from packages/core/shared/src/nodes/number/LessThan.ts rename to packages/shared/core/src/nodes/number/LessThan.ts diff --git a/packages/core/shared/src/nodes/number/LessThanOrEqual.ts b/packages/shared/core/src/nodes/number/LessThanOrEqual.ts similarity index 100% rename from packages/core/shared/src/nodes/number/LessThanOrEqual.ts rename to packages/shared/core/src/nodes/number/LessThanOrEqual.ts diff --git a/packages/core/shared/src/nodes/number/Multiply.ts b/packages/shared/core/src/nodes/number/Multiply.ts similarity index 100% rename from packages/core/shared/src/nodes/number/Multiply.ts rename to packages/shared/core/src/nodes/number/Multiply.ts diff --git a/packages/core/shared/src/nodes/number/NumberVariable.ts b/packages/shared/core/src/nodes/number/NumberVariable.ts similarity index 100% rename from packages/core/shared/src/nodes/number/NumberVariable.ts rename to packages/shared/core/src/nodes/number/NumberVariable.ts diff --git a/packages/core/shared/src/nodes/number/Subtract.ts b/packages/shared/core/src/nodes/number/Subtract.ts similarity index 100% rename from packages/core/shared/src/nodes/number/Subtract.ts rename to packages/shared/core/src/nodes/number/Subtract.ts diff --git a/packages/core/shared/src/nodes/object/ComposeObject.ts b/packages/shared/core/src/nodes/object/ComposeObject.ts similarity index 100% rename from packages/core/shared/src/nodes/object/ComposeObject.ts rename to packages/shared/core/src/nodes/object/ComposeObject.ts diff --git a/packages/core/shared/src/nodes/object/GetValuesFromObject.ts b/packages/shared/core/src/nodes/object/GetValuesFromObject.ts similarity index 100% rename from packages/core/shared/src/nodes/object/GetValuesFromObject.ts rename to packages/shared/core/src/nodes/object/GetValuesFromObject.ts diff --git a/packages/core/shared/src/nodes/object/JSONToObject.ts b/packages/shared/core/src/nodes/object/JSONToObject.ts similarity index 100% rename from packages/core/shared/src/nodes/object/JSONToObject.ts rename to packages/shared/core/src/nodes/object/JSONToObject.ts diff --git a/packages/core/shared/src/nodes/object/MergeObjects.ts b/packages/shared/core/src/nodes/object/MergeObjects.ts similarity index 100% rename from packages/core/shared/src/nodes/object/MergeObjects.ts rename to packages/shared/core/src/nodes/object/MergeObjects.ts diff --git a/packages/core/shared/src/nodes/object/ObjectToJSON.ts b/packages/shared/core/src/nodes/object/ObjectToJSON.ts similarity index 100% rename from packages/core/shared/src/nodes/object/ObjectToJSON.ts rename to packages/shared/core/src/nodes/object/ObjectToJSON.ts diff --git a/packages/core/shared/src/nodes/text/CombineText.ts b/packages/shared/core/src/nodes/text/CombineText.ts similarity index 100% rename from packages/core/shared/src/nodes/text/CombineText.ts rename to packages/shared/core/src/nodes/text/CombineText.ts diff --git a/packages/core/shared/src/nodes/text/ComplexStringMatcher.ts b/packages/shared/core/src/nodes/text/ComplexStringMatcher.ts similarity index 100% rename from packages/core/shared/src/nodes/text/ComplexStringMatcher.ts rename to packages/shared/core/src/nodes/text/ComplexStringMatcher.ts diff --git a/packages/core/shared/src/nodes/text/EvaluateText.ts b/packages/shared/core/src/nodes/text/EvaluateText.ts similarity index 100% rename from packages/core/shared/src/nodes/text/EvaluateText.ts rename to packages/shared/core/src/nodes/text/EvaluateText.ts diff --git a/packages/core/shared/src/nodes/text/GenerateText.ts b/packages/shared/core/src/nodes/text/GenerateText.ts similarity index 100% rename from packages/core/shared/src/nodes/text/GenerateText.ts rename to packages/shared/core/src/nodes/text/GenerateText.ts diff --git a/packages/core/shared/src/nodes/text/GenerateUUID.ts b/packages/shared/core/src/nodes/text/GenerateUUID.ts similarity index 100% rename from packages/core/shared/src/nodes/text/GenerateUUID.ts rename to packages/shared/core/src/nodes/text/GenerateUUID.ts diff --git a/packages/core/shared/src/nodes/text/GetLength.ts b/packages/shared/core/src/nodes/text/GetLength.ts similarity index 100% rename from packages/core/shared/src/nodes/text/GetLength.ts rename to packages/shared/core/src/nodes/text/GetLength.ts diff --git a/packages/core/shared/src/nodes/text/ProfanityFilter.ts b/packages/shared/core/src/nodes/text/ProfanityFilter.ts similarity index 100% rename from packages/core/shared/src/nodes/text/ProfanityFilter.ts rename to packages/shared/core/src/nodes/text/ProfanityFilter.ts diff --git a/packages/core/shared/src/nodes/text/RegularExpression.ts b/packages/shared/core/src/nodes/text/RegularExpression.ts similarity index 100% rename from packages/core/shared/src/nodes/text/RegularExpression.ts rename to packages/shared/core/src/nodes/text/RegularExpression.ts diff --git a/packages/core/shared/src/nodes/text/ReplaceText.ts b/packages/shared/core/src/nodes/text/ReplaceText.ts similarity index 100% rename from packages/core/shared/src/nodes/text/ReplaceText.ts rename to packages/shared/core/src/nodes/text/ReplaceText.ts diff --git a/packages/core/shared/src/nodes/text/SplitBySentence.ts b/packages/shared/core/src/nodes/text/SplitBySentence.ts similarity index 100% rename from packages/core/shared/src/nodes/text/SplitBySentence.ts rename to packages/shared/core/src/nodes/text/SplitBySentence.ts diff --git a/packages/core/shared/src/nodes/text/StringVariable.ts b/packages/shared/core/src/nodes/text/StringVariable.ts similarity index 100% rename from packages/core/shared/src/nodes/text/StringVariable.ts rename to packages/shared/core/src/nodes/text/StringVariable.ts diff --git a/packages/core/shared/src/nodes/text/TextTemplate.ts b/packages/shared/core/src/nodes/text/TextTemplate.ts similarity index 100% rename from packages/core/shared/src/nodes/text/TextTemplate.ts rename to packages/shared/core/src/nodes/text/TextTemplate.ts diff --git a/packages/core/shared/src/nodes/text/TextVariable.ts b/packages/shared/core/src/nodes/text/TextVariable.ts similarity index 100% rename from packages/core/shared/src/nodes/text/TextVariable.ts rename to packages/shared/core/src/nodes/text/TextVariable.ts diff --git a/packages/core/shared/src/nodes/text/Trim.ts b/packages/shared/core/src/nodes/text/Trim.ts similarity index 100% rename from packages/core/shared/src/nodes/text/Trim.ts rename to packages/shared/core/src/nodes/text/Trim.ts diff --git a/packages/core/shared/src/nodes/text/TypeChat.ts b/packages/shared/core/src/nodes/text/TypeChat.ts similarity index 100% rename from packages/core/shared/src/nodes/text/TypeChat.ts rename to packages/shared/core/src/nodes/text/TypeChat.ts diff --git a/packages/core/shared/src/nodes/utility/AlertMessage.ts b/packages/shared/core/src/nodes/utility/AlertMessage.ts similarity index 100% rename from packages/core/shared/src/nodes/utility/AlertMessage.ts rename to packages/shared/core/src/nodes/utility/AlertMessage.ts diff --git a/packages/core/shared/src/nodes/utility/Cast.ts b/packages/shared/core/src/nodes/utility/Cast.ts similarity index 100% rename from packages/core/shared/src/nodes/utility/Cast.ts rename to packages/shared/core/src/nodes/utility/Cast.ts diff --git a/packages/core/shared/src/nodes/utility/CurrentTime.ts b/packages/shared/core/src/nodes/utility/CurrentTime.ts similarity index 100% rename from packages/core/shared/src/nodes/utility/CurrentTime.ts rename to packages/shared/core/src/nodes/utility/CurrentTime.ts diff --git a/packages/core/shared/src/nodes/utility/Echo.ts b/packages/shared/core/src/nodes/utility/Echo.ts similarity index 100% rename from packages/core/shared/src/nodes/utility/Echo.ts rename to packages/shared/core/src/nodes/utility/Echo.ts diff --git a/packages/core/shared/src/nodes/utility/Error.ts b/packages/shared/core/src/nodes/utility/Error.ts similarity index 100% rename from packages/core/shared/src/nodes/utility/Error.ts rename to packages/shared/core/src/nodes/utility/Error.ts diff --git a/packages/core/shared/src/nodes/utility/Log.ts b/packages/shared/core/src/nodes/utility/Log.ts similarity index 100% rename from packages/core/shared/src/nodes/utility/Log.ts rename to packages/shared/core/src/nodes/utility/Log.ts diff --git a/packages/core/shared/src/plugin.ts b/packages/shared/core/src/plugin.ts similarity index 100% rename from packages/core/shared/src/plugin.ts rename to packages/shared/core/src/plugin.ts diff --git a/packages/core/shared/src/plugins/cachePlugin/RunLastArguments.tsx b/packages/shared/core/src/plugins/cachePlugin/RunLastArguments.tsx similarity index 100% rename from packages/core/shared/src/plugins/cachePlugin/RunLastArguments.tsx rename to packages/shared/core/src/plugins/cachePlugin/RunLastArguments.tsx diff --git a/packages/core/shared/src/plugins/cachePlugin/index.ts b/packages/shared/core/src/plugins/cachePlugin/index.ts similarity index 100% rename from packages/core/shared/src/plugins/cachePlugin/index.ts rename to packages/shared/core/src/plugins/cachePlugin/index.ts diff --git a/packages/core/shared/src/plugins/consolePlugin/MagickConsole.ts b/packages/shared/core/src/plugins/consolePlugin/MagickConsole.ts similarity index 100% rename from packages/core/shared/src/plugins/consolePlugin/MagickConsole.ts rename to packages/shared/core/src/plugins/consolePlugin/MagickConsole.ts diff --git a/packages/core/shared/src/plugins/consolePlugin/index.ts b/packages/shared/core/src/plugins/consolePlugin/index.ts similarity index 100% rename from packages/core/shared/src/plugins/consolePlugin/index.ts rename to packages/shared/core/src/plugins/consolePlugin/index.ts diff --git a/packages/core/shared/src/plugins/debuggerPlugin/index.ts b/packages/shared/core/src/plugins/debuggerPlugin/index.ts similarity index 100% rename from packages/core/shared/src/plugins/debuggerPlugin/index.ts rename to packages/shared/core/src/plugins/debuggerPlugin/index.ts diff --git a/packages/core/shared/src/plugins/emitPlugin/index.ts b/packages/shared/core/src/plugins/emitPlugin/index.ts similarity index 100% rename from packages/core/shared/src/plugins/emitPlugin/index.ts rename to packages/shared/core/src/plugins/emitPlugin/index.ts diff --git a/packages/core/shared/src/plugins/historyPlugin/action.ts b/packages/shared/core/src/plugins/historyPlugin/action.ts similarity index 92% rename from packages/core/shared/src/plugins/historyPlugin/action.ts rename to packages/shared/core/src/plugins/historyPlugin/action.ts index 06021b490a..d8b383dd2a 100644 --- a/packages/core/shared/src/plugins/historyPlugin/action.ts +++ b/packages/shared/core/src/plugins/historyPlugin/action.ts @@ -1,4 +1,4 @@ -// DOCUMENTED +// DOCUMENTED /** * Represents an abstract Action with undo and redo functionalities. */ @@ -7,9 +7,9 @@ export default abstract class Action { * Undoes the action. */ abstract undo(): void - + /** * Redoes the action. */ abstract redo(): void -} \ No newline at end of file +} diff --git a/packages/core/shared/src/plugins/historyPlugin/actions/connection.ts b/packages/shared/core/src/plugins/historyPlugin/actions/connection.ts similarity index 100% rename from packages/core/shared/src/plugins/historyPlugin/actions/connection.ts rename to packages/shared/core/src/plugins/historyPlugin/actions/connection.ts diff --git a/packages/core/shared/src/plugins/historyPlugin/actions/node.ts b/packages/shared/core/src/plugins/historyPlugin/actions/node.ts similarity index 100% rename from packages/core/shared/src/plugins/historyPlugin/actions/node.ts rename to packages/shared/core/src/plugins/historyPlugin/actions/node.ts diff --git a/packages/core/shared/src/plugins/historyPlugin/history.ts b/packages/shared/core/src/plugins/historyPlugin/history.ts similarity index 64% rename from packages/core/shared/src/plugins/historyPlugin/history.ts rename to packages/shared/core/src/plugins/historyPlugin/history.ts index a4d181355f..af848b8ddb 100644 --- a/packages/core/shared/src/plugins/historyPlugin/history.ts +++ b/packages/shared/core/src/plugins/historyPlugin/history.ts @@ -1,13 +1,13 @@ -// DOCUMENTED +// DOCUMENTED /** * Represents an action that can be added to a `History` instance. */ -import Action from "./action"; +import Action from './action' /** * Represents the type of history action that can be performed. */ -type HistoryAction = 'undo' | 'redo'; +type HistoryAction = 'undo' | 'redo' /** * Encapsulates a collection of actions that can be undone and redone. @@ -16,33 +16,33 @@ export default class History { /** * If the `History` instance is currently active. */ - active:boolean; + active: boolean /** * The actions that have been produced by the instance. */ - produced:Action[]; + produced: Action[] /** * The actions that have been reserved by the instance. */ - reserved:Action[]; + reserved: Action[] /** * Creates a new instance of the `History` class. */ constructor() { - this.active = false; - this.produced = []; - this.reserved = []; + this.active = false + this.produced = [] + this.reserved = [] } /** * Adds an action to this `History` instance. * @param action The action to be added to this instance. */ - add(action:Action) { - if (this.active) return; - this.produced.push(action); - this.reserved = []; + add(action: Action) { + if (this.active) return + this.produced.push(action) + this.reserved = [] } /** @@ -50,7 +50,7 @@ export default class History { * @returns The last action produced. */ get last() { - return this.produced[this.produced.length - 1]; + return this.produced[this.produced.length - 1] } /** @@ -59,36 +59,36 @@ export default class History { * @param to The collection of actions to move the action to. * @param type The type of history action to perform. */ - _do(from:Action[], to:Action[], type:HistoryAction) { - const action = from.pop(); - if (!action) return; + _do(from: Action[], to: Action[], type: HistoryAction) { + const action = from.pop() + if (!action) return - this.active = true; - action[type](); - to.push(action); - this.active = false; + this.active = true + action[type]() + to.push(action) + this.active = false } /** * Undoes the last action performed by this `History` instance. */ undo() { - this._do(this.produced, this.reserved, 'undo'); + this._do(this.produced, this.reserved, 'undo') } /** * Clears all actions from this `History` instance. */ clear() { - this.active = false; - this.produced = []; - this.reserved = []; + this.active = false + this.produced = [] + this.reserved = [] } /** * Redoes the last action undone by this `History` instance. */ redo() { - this._do(this.reserved, this.produced, 'redo'); + this._do(this.reserved, this.produced, 'redo') } -} \ No newline at end of file +} diff --git a/packages/shared/core/src/plugins/historyPlugin/index.ts b/packages/shared/core/src/plugins/historyPlugin/index.ts new file mode 100644 index 0000000000..036c0bf9fb --- /dev/null +++ b/packages/shared/core/src/plugins/historyPlugin/index.ts @@ -0,0 +1,88 @@ +// DOCUMENTED +import Act from './action' +import { + AddConnectionAction, + RemoveConnectionAction, +} from './actions/connection' +import { AddNodeAction, DragNodeAction, RemoveNodeAction } from './actions/node' +import History from './history' + +/** + * Tracks node events and adds corresponding actions to history + * @param {object} editor - The editor instance + * @param {History} history - The history instance + */ +function trackNodes(editor, history) { + editor.on('nodecreated', node => history.add(new AddNodeAction(editor, node))) + editor.on('noderemoved', node => + history.add(new RemoveNodeAction(editor, node)) + ) + editor.on('nodetranslated', ({ node, prev }) => { + if (history.last instanceof DragNodeAction && history.last.node === node) { + history.last.update(node) + } else { + history.add(new DragNodeAction(editor, node, prev)) + } + }) +} + +/** + * Tracks connection events and adds corresponding actions to history + * @param {object} editor - The editor instance + * @param {History} history - The history instance + */ +function trackConnections(editor, history) { + editor.on('connectioncreated', c => + history.add(new AddConnectionAction(editor, c)) + ) + editor.on('connectionremoved', c => + history.add(new RemoveConnectionAction(editor, c)) + ) +} + +/** + * Installs the history plugin on the editor + * @param {object} editor - The editor instance + * @param {{keyboard: boolean}} options - Configuration options for the plugin + */ +function install(editor, { keyboard = true }) { + editor.bind('undo') + editor.bind('redo') + editor.bind('addhistory') + + const history = new History() + + editor.on('undo', () => history.undo()) + editor.on('redo', () => history.redo()) + editor.on('addhistory', action => history.add(action)) + editor.on('clear', () => { + history.clear() + }) + + if (keyboard) { + document.addEventListener('keydown', e => { + if (!e.ctrlKey) return + switch (e.code) { + case 'KeyZ': + editor.trigger('undo') + break + case 'KeyY': + editor.trigger('redo') + break + default: + } + }) + } + + trackNodes(editor, history) + trackConnections(editor, history) +} + +export const Action = Act + +const defaultExport = { + name: 'history', + install, +} + +export default defaultExport diff --git a/packages/core/shared/src/plugins/inspectorPlugin/DataControl.ts b/packages/shared/core/src/plugins/inspectorPlugin/DataControl.ts similarity index 100% rename from packages/core/shared/src/plugins/inspectorPlugin/DataControl.ts rename to packages/shared/core/src/plugins/inspectorPlugin/DataControl.ts diff --git a/packages/core/shared/src/plugins/inspectorPlugin/Inspector.ts b/packages/shared/core/src/plugins/inspectorPlugin/Inspector.ts similarity index 100% rename from packages/core/shared/src/plugins/inspectorPlugin/Inspector.ts rename to packages/shared/core/src/plugins/inspectorPlugin/Inspector.ts diff --git a/packages/core/shared/src/plugins/inspectorPlugin/dataControls/InfoControl.tsx b/packages/shared/core/src/plugins/inspectorPlugin/dataControls/InfoControl.tsx similarity index 84% rename from packages/core/shared/src/plugins/inspectorPlugin/dataControls/InfoControl.tsx rename to packages/shared/core/src/plugins/inspectorPlugin/dataControls/InfoControl.tsx index ea4ef2b253..4e19cb3569 100644 --- a/packages/core/shared/src/plugins/inspectorPlugin/dataControls/InfoControl.tsx +++ b/packages/shared/core/src/plugins/inspectorPlugin/dataControls/InfoControl.tsx @@ -1,4 +1,4 @@ -// DOCUMENTED +// DOCUMENTED import { DataControl } from '../DataControl' /** @@ -6,14 +6,21 @@ import { DataControl } from '../DataControl' * This class is responsible for creating a control option that represents the info component. */ export class InfoControl extends DataControl { - /** * Constructor for creating an instance of InfoControl * @param dataKey - The key in the source data that this control options represents * @param name - The name of the control option * @param info - Additional information that will be displayed in the UI */ - constructor({ dataKey, name, info }: { dataKey: string, name: string, info: string }) { + constructor({ + dataKey, + name, + info, + }: { + dataKey: string + name: string + info: string + }) { const options = { dataKey: dataKey, name: name, @@ -25,4 +32,4 @@ export class InfoControl extends DataControl { } super(options) } -} \ No newline at end of file +} diff --git a/packages/core/shared/src/plugins/inspectorPlugin/index.ts b/packages/shared/core/src/plugins/inspectorPlugin/index.ts similarity index 59% rename from packages/core/shared/src/plugins/inspectorPlugin/index.ts rename to packages/shared/core/src/plugins/inspectorPlugin/index.ts index 9aa46766e7..befe7f821c 100644 --- a/packages/core/shared/src/plugins/inspectorPlugin/index.ts +++ b/packages/shared/core/src/plugins/inspectorPlugin/index.ts @@ -1,68 +1,68 @@ -// DOCUMENTED -import { MagickComponent } from '../../engine'; -import { IRunContextEditor, MagickNode } from '../../types'; -import { HandleDataArgs, Inspector } from './Inspector'; +// DOCUMENTED +import { MagickComponent } from '../../engine' +import { IRunContextEditor, MagickNode } from '../../types' +import { HandleDataArgs, Inspector } from './Inspector' /** * Install the inspector plugin to the editor * @param {IRunContextEditor} editor - The editor instance where the plugin will be installed */ function install(editor: IRunContextEditor): void { - const { onInspector, sendToInspector, clearTextEditor } = editor.context; + const { onInspector, sendToInspector, clearTextEditor } = editor.context // Register a new component editor.on('componentregister', (component: MagickComponent) => { - const builder = component.builder; + const builder = component.builder if (!component.info) return console.error( 'All components must contain an info property describing the component to the end user.' - ); + ) // Override the default builder with a custom one, invoking the original builder inside it component.builder = (node: MagickNode) => { // Initialize an Inspector instance to handle registering data controls, serialization, etc. - node.inspector = new Inspector({ component, editor, node }); + node.inspector = new Inspector({ component, editor, node }) // Set node properties - node.category = component.category; - node.displayName = component.displayName; - node.info = component.info; + node.category = component.category + node.displayName = component.displayName + node.info = component.info // Attach the default info control to the component to display in the inspector if (onInspector) { - node.subscription = onInspector(node, (data) => { - node.inspector.handleData(data as HandleDataArgs); - editor.trigger('nodecreated', node); - }); + node.subscription = onInspector(node, data => { + node.inspector.handleData(data as HandleDataArgs) + editor.trigger('nodecreated', node) + }) } // Call the original builder - builder.call(component, node); - }; - }); + builder.call(component, node) + } + }) - let currentNode: MagickNode | undefined; + let currentNode: MagickNode | undefined // Handle publishing and subscribing to the inspector editor.on('nodeselect', (node: MagickNode) => { // Do nothing if the selected node is the same as the current one - if (currentNode && node.id === currentNode.id) return; - if (!clearTextEditor || !sendToInspector) return; + if (currentNode && node.id === currentNode.id) return + if (!clearTextEditor || !sendToInspector) return // Update the current node and clear the text editor - currentNode = node; - clearTextEditor(); - sendToInspector(node.inspector.data()); - }); + currentNode = node + clearTextEditor() + sendToInspector(node.inspector.data()) + }) } -export { DataControl } from './DataControl'; +export { DataControl } from './DataControl' // Default export object const defaultExport = { name: 'inspector', install, -}; +} -export default defaultExport; \ No newline at end of file +export default defaultExport diff --git a/packages/core/shared/src/plugins/keyCodePlugin/index.ts b/packages/shared/core/src/plugins/keyCodePlugin/index.ts similarity index 99% rename from packages/core/shared/src/plugins/keyCodePlugin/index.ts rename to packages/shared/core/src/plugins/keyCodePlugin/index.ts index 3fd03a30d6..92ceeef0a2 100644 --- a/packages/core/shared/src/plugins/keyCodePlugin/index.ts +++ b/packages/shared/core/src/plugins/keyCodePlugin/index.ts @@ -1,4 +1,4 @@ -// DOCUMENTED +// DOCUMENTED /** * The `IRunContextEditor` interface specifies the shape of objects that represent a magick editor context. * @interface diff --git a/packages/core/shared/src/plugins/lifecyclePlugin/index.ts b/packages/shared/core/src/plugins/lifecyclePlugin/index.ts similarity index 100% rename from packages/core/shared/src/plugins/lifecyclePlugin/index.ts rename to packages/shared/core/src/plugins/lifecyclePlugin/index.ts diff --git a/packages/core/shared/src/plugins/lifecyclePlugin/interfaces.ts b/packages/shared/core/src/plugins/lifecyclePlugin/interfaces.ts similarity index 100% rename from packages/core/shared/src/plugins/lifecyclePlugin/interfaces.ts rename to packages/shared/core/src/plugins/lifecyclePlugin/interfaces.ts diff --git a/packages/core/shared/src/plugins/lifecyclePlugin/utils.ts b/packages/shared/core/src/plugins/lifecyclePlugin/utils.ts similarity index 100% rename from packages/core/shared/src/plugins/lifecyclePlugin/utils.ts rename to packages/shared/core/src/plugins/lifecyclePlugin/utils.ts diff --git a/packages/core/shared/src/plugins/modulePlugin/index.ts b/packages/shared/core/src/plugins/modulePlugin/index.ts similarity index 100% rename from packages/core/shared/src/plugins/modulePlugin/index.ts rename to packages/shared/core/src/plugins/modulePlugin/index.ts diff --git a/packages/core/shared/src/plugins/modulePlugin/module-manager.ts b/packages/shared/core/src/plugins/modulePlugin/module-manager.ts similarity index 100% rename from packages/core/shared/src/plugins/modulePlugin/module-manager.ts rename to packages/shared/core/src/plugins/modulePlugin/module-manager.ts diff --git a/packages/core/shared/src/plugins/modulePlugin/module.ts b/packages/shared/core/src/plugins/modulePlugin/module.ts similarity index 100% rename from packages/core/shared/src/plugins/modulePlugin/module.ts rename to packages/shared/core/src/plugins/modulePlugin/module.ts diff --git a/packages/core/shared/src/plugins/modulePlugin/utils.ts b/packages/shared/core/src/plugins/modulePlugin/utils.ts similarity index 100% rename from packages/core/shared/src/plugins/modulePlugin/utils.ts rename to packages/shared/core/src/plugins/modulePlugin/utils.ts diff --git a/packages/core/shared/src/plugins/multiCopyPlugin/index.ts b/packages/shared/core/src/plugins/multiCopyPlugin/index.ts similarity index 100% rename from packages/core/shared/src/plugins/multiCopyPlugin/index.ts rename to packages/shared/core/src/plugins/multiCopyPlugin/index.ts diff --git a/packages/core/shared/src/plugins/multiSocketGenerator/index.ts b/packages/shared/core/src/plugins/multiSocketGenerator/index.ts similarity index 100% rename from packages/core/shared/src/plugins/multiSocketGenerator/index.ts rename to packages/shared/core/src/plugins/multiSocketGenerator/index.ts diff --git a/packages/core/shared/src/plugins/nodeClickPlugin/index.ts b/packages/shared/core/src/plugins/nodeClickPlugin/index.ts similarity index 95% rename from packages/core/shared/src/plugins/nodeClickPlugin/index.ts rename to packages/shared/core/src/plugins/nodeClickPlugin/index.ts index fab1bbe677..07fc167810 100644 --- a/packages/core/shared/src/plugins/nodeClickPlugin/index.ts +++ b/packages/shared/core/src/plugins/nodeClickPlugin/index.ts @@ -5,7 +5,7 @@ function install(editor: IRunContextEditor) { // handle publishing and subscribing to inspector const nodeDataMap = {} - const detectDoubleClick = (node, callback: ()=>void) => { + const detectDoubleClick = (node, callback: () => void) => { if (!nodeDataMap[node.id]) { nodeDataMap[node.id] = { clickCount: 0, diff --git a/packages/core/shared/src/plugins/remotePlugin/index.ts b/packages/shared/core/src/plugins/remotePlugin/index.ts similarity index 100% rename from packages/core/shared/src/plugins/remotePlugin/index.ts rename to packages/shared/core/src/plugins/remotePlugin/index.ts diff --git a/packages/core/shared/src/plugins/selectionPlugin/index.ts b/packages/shared/core/src/plugins/selectionPlugin/index.ts similarity index 100% rename from packages/core/shared/src/plugins/selectionPlugin/index.ts rename to packages/shared/core/src/plugins/selectionPlugin/index.ts diff --git a/packages/core/shared/src/plugins/socketGenerator/index.ts b/packages/shared/core/src/plugins/socketGenerator/index.ts similarity index 100% rename from packages/core/shared/src/plugins/socketGenerator/index.ts rename to packages/shared/core/src/plugins/socketGenerator/index.ts diff --git a/packages/core/shared/src/plugins/socketOverridePlugin/index.ts b/packages/shared/core/src/plugins/socketOverridePlugin/index.ts similarity index 99% rename from packages/core/shared/src/plugins/socketOverridePlugin/index.ts rename to packages/shared/core/src/plugins/socketOverridePlugin/index.ts index c3cbeb2e65..5b1d54a05b 100644 --- a/packages/core/shared/src/plugins/socketOverridePlugin/index.ts +++ b/packages/shared/core/src/plugins/socketOverridePlugin/index.ts @@ -5,7 +5,7 @@ function install(editor: IRunContextEditor) { editor.on('componentregister', (component: MagickComponent) => { component.worker = (node, _inputs, _outputs, context) => { const { context: innerContext, socketOutput } = context as any - + const { sendToPlaytest } = innerContext // Might be a bit hacky to do it this way, but it works for now diff --git a/packages/core/shared/src/plugins/socketPlugin/index.ts b/packages/shared/core/src/plugins/socketPlugin/index.ts similarity index 100% rename from packages/core/shared/src/plugins/socketPlugin/index.ts rename to packages/shared/core/src/plugins/socketPlugin/index.ts diff --git a/packages/core/shared/src/plugins/taskPlugin/index.ts b/packages/shared/core/src/plugins/taskPlugin/index.ts similarity index 100% rename from packages/core/shared/src/plugins/taskPlugin/index.ts rename to packages/shared/core/src/plugins/taskPlugin/index.ts diff --git a/packages/core/shared/src/plugins/taskPlugin/task.ts b/packages/shared/core/src/plugins/taskPlugin/task.ts similarity index 100% rename from packages/core/shared/src/plugins/taskPlugin/task.ts rename to packages/shared/core/src/plugins/taskPlugin/task.ts diff --git a/packages/core/shared/src/plugins/taskPlugin2/index.ts b/packages/shared/core/src/plugins/taskPlugin2/index.ts similarity index 100% rename from packages/core/shared/src/plugins/taskPlugin2/index.ts rename to packages/shared/core/src/plugins/taskPlugin2/index.ts diff --git a/packages/core/shared/src/plugins/taskPlugin2/task.ts b/packages/shared/core/src/plugins/taskPlugin2/task.ts similarity index 100% rename from packages/core/shared/src/plugins/taskPlugin2/task.ts rename to packages/shared/core/src/plugins/taskPlugin2/task.ts diff --git a/packages/core/shared/src/schemas.ts b/packages/shared/core/src/schemas.ts similarity index 100% rename from packages/core/shared/src/schemas.ts rename to packages/shared/core/src/schemas.ts diff --git a/packages/core/shared/src/sockets.ts b/packages/shared/core/src/sockets.ts similarity index 100% rename from packages/core/shared/src/sockets.ts rename to packages/shared/core/src/sockets.ts diff --git a/packages/core/shared/src/spellManager/Spell.ts b/packages/shared/core/src/spellManager/Spell.ts similarity index 100% rename from packages/core/shared/src/spellManager/Spell.ts rename to packages/shared/core/src/spellManager/Spell.ts diff --git a/packages/core/shared/src/spellManager/SpellManager.ts b/packages/shared/core/src/spellManager/SpellManager.ts similarity index 99% rename from packages/core/shared/src/spellManager/SpellManager.ts rename to packages/shared/core/src/spellManager/SpellManager.ts index a730239956..2a805f1864 100644 --- a/packages/core/shared/src/spellManager/SpellManager.ts +++ b/packages/shared/core/src/spellManager/SpellManager.ts @@ -1,7 +1,7 @@ // import { Application } from '@magickml/server-core'; import { Application } from '@feathersjs/koa' import io from 'socket.io' -import { getLogger } from '@magickml/core' +import { getLogger } from 'shared/core' import { isEqual } from 'radash' import { MagickSpellInput, SpellInterface } from '../types' diff --git a/packages/core/shared/src/spellManager/SpellRunner.ts b/packages/shared/core/src/spellManager/SpellRunner.ts similarity index 99% rename from packages/core/shared/src/spellManager/SpellRunner.ts rename to packages/shared/core/src/spellManager/SpellRunner.ts index 1976893c69..dadee7879d 100644 --- a/packages/core/shared/src/spellManager/SpellRunner.ts +++ b/packages/shared/core/src/spellManager/SpellRunner.ts @@ -1,4 +1,4 @@ -import type { app as FeathersApp } from '@magickml/server-core' +import type { app as FeathersApp } from 'server/core' import pino from 'pino' import io from 'socket.io' import { extractNodes, initSharedEngine, MagickEngine } from '../engine' diff --git a/packages/core/shared/src/spellManager/configureManager.ts b/packages/shared/core/src/spellManager/configureManager.ts similarity index 67% rename from packages/core/shared/src/spellManager/configureManager.ts rename to packages/shared/core/src/spellManager/configureManager.ts index 64034e1ce2..bb27727bdc 100644 --- a/packages/core/shared/src/spellManager/configureManager.ts +++ b/packages/shared/core/src/spellManager/configureManager.ts @@ -1,8 +1,8 @@ -import { UserSpellManager } from "../types" +import { UserSpellManager } from '../types' const configureManager = () => { // we need to fix this typing here to extend from express application instead (or feathers application?) - return (app: {userSpellManagers?: UserSpellManager}) => { + return (app: { userSpellManagers?: UserSpellManager }) => { app.userSpellManagers = new Map() } } diff --git a/packages/core/shared/src/spellManager/graphHelpers.ts b/packages/shared/core/src/spellManager/graphHelpers.ts similarity index 100% rename from packages/core/shared/src/spellManager/graphHelpers.ts rename to packages/shared/core/src/spellManager/graphHelpers.ts diff --git a/packages/core/shared/src/spellManager/index.ts b/packages/shared/core/src/spellManager/index.ts similarity index 100% rename from packages/core/shared/src/spellManager/index.ts rename to packages/shared/core/src/spellManager/index.ts diff --git a/packages/core/shared/src/spellManager/runSpell.ts b/packages/shared/core/src/spellManager/runSpell.ts similarity index 100% rename from packages/core/shared/src/spellManager/runSpell.ts rename to packages/shared/core/src/spellManager/runSpell.ts diff --git a/packages/core/shared/src/state/api/api.ts b/packages/shared/core/src/state/api/api.ts similarity index 96% rename from packages/core/shared/src/state/api/api.ts rename to packages/shared/core/src/state/api/api.ts index b68bdb9ec2..65496e4138 100644 --- a/packages/core/shared/src/state/api/api.ts +++ b/packages/shared/core/src/state/api/api.ts @@ -1,65 +1,65 @@ -// DOCUMENTED -// Import necessary libraries and types from toolkit -import { - BaseQueryFn, - createApi, - FetchArgs, - fetchBaseQuery, - FetchBaseQueryError, -} from '@reduxjs/toolkit/query/react' -import { RootState } from '../store' - -/** - * Dynamic base query that can be used to create a Redux Toolkit Query API - * with a dynamic API url and token based on the current state. - * - * @param args - The URL or FetchArgs containing the request information. - * @param api - The Redux Toolkit Query API instance. - * @param extraOptions - Any extra options provided during the request. - * @returns A FetchBaseQueryError if apiUrl missing, otherwise the response of the request. - */ -const dynamicBaseQuery: BaseQueryFn< - string | FetchArgs, - unknown, - FetchBaseQueryError -> = async (args, api, extraOptions) => { - // Get state from Redux store - const state = api.getState() as RootState - // Extract apiUrl and token from state - const apiUrl = state.globalConfig.apiUrl - const token = state.globalConfig.token - - // Handle scenarios where apiUrl is not present gracefully - if (!apiUrl) { - return { - error: { - status: 400, - statusText: 'Bad Request', - data: 'No apiUrl present', - }, - } - } - - // Create rawBaseQuery with provided apiUrl and token (if exists) - const rawBaseQuery = fetchBaseQuery({ - baseUrl: apiUrl, - prepareHeaders: async headers => { - if (token) headers.set('authorization', `Bearer ${token}`) - return headers - }, - }) - - // Return rawBaseQuery result with provided args and extraOptions - return rawBaseQuery(args, api, extraOptions) -} - -/** - * Creates a root API with a dynamic base query, appropriate reducerPath, - * tagTypes, and empty endpoints. - */ -export const rootApi = createApi({ - reducerPath: 'api', // Set reducer path - baseQuery: dynamicBaseQuery, // Use dynamicBaseQuery as baseQuery - tagTypes: ['Spell', 'Spells', 'Version'], // Define tagTypes for invalidation - endpoints: () => ({}), // Provide an empty object for endpoints -}) \ No newline at end of file +// DOCUMENTED +// Import necessary libraries and types from toolkit +import { + BaseQueryFn, + createApi, + FetchArgs, + fetchBaseQuery, + FetchBaseQueryError, +} from '@reduxjs/toolkit/query/react' +import { RootState } from '../store' + +/** + * Dynamic base query that can be used to create a Redux Toolkit Query API + * with a dynamic API url and token based on the current state. + * + * @param args - The URL or FetchArgs containing the request information. + * @param api - The Redux Toolkit Query API instance. + * @param extraOptions - Any extra options provided during the request. + * @returns A FetchBaseQueryError if apiUrl missing, otherwise the response of the request. + */ +const dynamicBaseQuery: BaseQueryFn< + string | FetchArgs, + unknown, + FetchBaseQueryError +> = async (args, api, extraOptions) => { + // Get state from Redux store + const state = api.getState() as RootState + // Extract apiUrl and token from state + const apiUrl = state.globalConfig.apiUrl + const token = state.globalConfig.token + + // Handle scenarios where apiUrl is not present gracefully + if (!apiUrl) { + return { + error: { + status: 400, + statusText: 'Bad Request', + data: 'No apiUrl present', + }, + } + } + + // Create rawBaseQuery with provided apiUrl and token (if exists) + const rawBaseQuery = fetchBaseQuery({ + baseUrl: apiUrl, + prepareHeaders: async headers => { + if (token) headers.set('authorization', `Bearer ${token}`) + return headers + }, + }) + + // Return rawBaseQuery result with provided args and extraOptions + return rawBaseQuery(args, api, extraOptions) +} + +/** + * Creates a root API with a dynamic base query, appropriate reducerPath, + * tagTypes, and empty endpoints. + */ +export const rootApi = createApi({ + reducerPath: 'api', // Set reducer path + baseQuery: dynamicBaseQuery, // Use dynamicBaseQuery as baseQuery + tagTypes: ['Spell', 'Spells', 'Version'], // Define tagTypes for invalidation + endpoints: () => ({}), // Provide an empty object for endpoints +}) diff --git a/packages/core/shared/src/state/api/spells.ts b/packages/shared/core/src/state/api/spells.ts similarity index 99% rename from packages/core/shared/src/state/api/spells.ts rename to packages/shared/core/src/state/api/spells.ts index 3690c55dac..ad17fb2e5a 100644 --- a/packages/core/shared/src/state/api/spells.ts +++ b/packages/shared/core/src/state/api/spells.ts @@ -2,7 +2,7 @@ import { FetchBaseQueryError } from '@reduxjs/toolkit/query/react' import { QueryReturnValue } from '@reduxjs/toolkit/dist/query/baseQueryTypes' import { rootApi } from './api' -import { SpellInterface } from '@magickml/core' +import { SpellInterface } from 'shared/core' import md5 from 'md5' /** diff --git a/packages/core/shared/src/state/globalConfig.ts b/packages/shared/core/src/state/globalConfig.ts similarity index 88% rename from packages/core/shared/src/state/globalConfig.ts rename to packages/shared/core/src/state/globalConfig.ts index cdd9dd5edc..75e19d43c7 100644 --- a/packages/core/shared/src/state/globalConfig.ts +++ b/packages/shared/core/src/state/globalConfig.ts @@ -1,4 +1,4 @@ -// DOCUMENTED +// DOCUMENTED /** * Module that exports a Redux slice for the global config that carries the authentication, project id and API url information. * @module globalConfigSlice @@ -33,7 +33,10 @@ export const globalConfigSlice: Slice = createSlice({ * @param {PayloadAction} action - Config to set on the global state. * @return {void} */ - setConfig: (state: GlobalConfig, action: PayloadAction): void => { + setConfig: ( + state: GlobalConfig, + action: PayloadAction + ): void => { const { apiUrl, token, projectId } = action.payload state.apiUrl = apiUrl state.token = token @@ -51,4 +54,4 @@ export const { setConfig } = globalConfigSlice.actions /** * Export GlobalConfigSlice reducer. */ -export default globalConfigSlice.reducer \ No newline at end of file +export default globalConfigSlice.reducer diff --git a/packages/core/shared/src/state/hooks.ts b/packages/shared/core/src/state/hooks.ts similarity index 100% rename from packages/core/shared/src/state/hooks.ts rename to packages/shared/core/src/state/hooks.ts diff --git a/packages/core/shared/src/state/localState.ts b/packages/shared/core/src/state/localState.ts similarity index 91% rename from packages/core/shared/src/state/localState.ts rename to packages/shared/core/src/state/localState.ts index 2f5b670dfb..d5ecd95f62 100644 --- a/packages/core/shared/src/state/localState.ts +++ b/packages/shared/core/src/state/localState.ts @@ -1,4 +1,4 @@ -// DOCUMENTED +// DOCUMENTED import { createSlice, createDraftSafeSelector, @@ -53,9 +53,8 @@ export const { addLocalState, deleteLocalState, upsertLocalState } = */ export const selectStateBytabId = createDraftSafeSelector( [state => localSelectors.selectAll(state), (_, id) => id], - (states, id) => - Object.values(states).find(state => state.id === id) + (states, id) => Object.values(states).find(state => state.id === id) ) // export the default reducer -export default localStateSlice.reducer \ No newline at end of file +export default localStateSlice.reducer diff --git a/packages/core/shared/src/state/preferences.ts b/packages/shared/core/src/state/preferences.ts similarity index 100% rename from packages/core/shared/src/state/preferences.ts rename to packages/shared/core/src/state/preferences.ts diff --git a/packages/core/shared/src/state/store.ts b/packages/shared/core/src/state/store.ts similarity index 100% rename from packages/core/shared/src/state/store.ts rename to packages/shared/core/src/state/store.ts diff --git a/packages/core/shared/src/state/tabs.ts b/packages/shared/core/src/state/tabs.ts similarity index 100% rename from packages/core/shared/src/state/tabs.ts rename to packages/shared/core/src/state/tabs.ts diff --git a/packages/core/shared/src/types.ts b/packages/shared/core/src/types.ts similarity index 100% rename from packages/core/shared/src/types.ts rename to packages/shared/core/src/types.ts diff --git a/packages/core/shared/src/utils/SpellError.ts b/packages/shared/core/src/utils/SpellError.ts similarity index 99% rename from packages/core/shared/src/utils/SpellError.ts rename to packages/shared/core/src/utils/SpellError.ts index 1aadf7b0b5..fc6c39ecf1 100644 --- a/packages/core/shared/src/utils/SpellError.ts +++ b/packages/shared/core/src/utils/SpellError.ts @@ -1,4 +1,4 @@ -// DOCUMENTED +// DOCUMENTED /** * The possible custom error codes to be used in the application. */ @@ -63,4 +63,4 @@ export const mapStatusCode = (customErrorCode: CustomErrorCodes) => { default: return 500 } -} \ No newline at end of file +} diff --git a/packages/core/shared/src/utils/getSpell.ts b/packages/shared/core/src/utils/getSpell.ts similarity index 100% rename from packages/core/shared/src/utils/getSpell.ts rename to packages/shared/core/src/utils/getSpell.ts diff --git a/packages/shared/core/src/utils/index.ts b/packages/shared/core/src/utils/index.ts new file mode 100644 index 0000000000..7889a697e9 --- /dev/null +++ b/packages/shared/core/src/utils/index.ts @@ -0,0 +1,3 @@ +export * from './runSpell' +export * from './getSpell' +export * from './SpellError' diff --git a/packages/core/shared/src/utils/runSpell.ts b/packages/shared/core/src/utils/runSpell.ts similarity index 100% rename from packages/core/shared/src/utils/runSpell.ts rename to packages/shared/core/src/utils/runSpell.ts diff --git a/packages/core/shared/src/vite-env.d.ts b/packages/shared/core/src/vite-env.d.ts similarity index 100% rename from packages/core/shared/src/vite-env.d.ts rename to packages/shared/core/src/vite-env.d.ts diff --git a/packages/shared/core/test/jest-import-meta-env.ts b/packages/shared/core/test/jest-import-meta-env.ts new file mode 100644 index 0000000000..dcf768fdf9 --- /dev/null +++ b/packages/shared/core/test/jest-import-meta-env.ts @@ -0,0 +1,5 @@ +// DOCUMENTED +/** + * An empty importMetaEnv object. + */ +export const importMetaEnv = {} as any // Turn off ESLint rule for explicit any usage. diff --git a/packages/core/shared/test/nodes/index.test.ts b/packages/shared/core/test/nodes/index.test.ts similarity index 98% rename from packages/core/shared/test/nodes/index.test.ts rename to packages/shared/core/test/nodes/index.test.ts index 8cfdbbfcb3..9039f6fc4b 100644 --- a/packages/core/shared/test/nodes/index.test.ts +++ b/packages/shared/core/test/nodes/index.test.ts @@ -5,4 +5,4 @@ describe('Nodes', () => { const nodes = getNodes() expect(nodes.length).toBeGreaterThan(0) }) -}) \ No newline at end of file +}) diff --git a/packages/core/shared/test/nodes/utility/Echo.result.json b/packages/shared/core/test/nodes/utility/Echo.result.json similarity index 93% rename from packages/core/shared/test/nodes/utility/Echo.result.json rename to packages/shared/core/test/nodes/utility/Echo.result.json index af0ac82710..59636ef445 100644 --- a/packages/core/shared/test/nodes/utility/Echo.result.json +++ b/packages/shared/core/test/nodes/utility/Echo.result.json @@ -1,3 +1,3 @@ { "Output - Default": "test" -} \ No newline at end of file +} diff --git a/packages/shared/core/test/nodes/utility/Echo.spell.json b/packages/shared/core/test/nodes/utility/Echo.spell.json new file mode 100644 index 0000000000..e60307c738 --- /dev/null +++ b/packages/shared/core/test/nodes/utility/Echo.spell.json @@ -0,0 +1,235 @@ +{ + "id": "183dd904-3d9f-4275-979f-a0fede13559b", + "name": "Echo", + "projectId": "bb1b3d24-84e0-424e-b4f1-57603f307a89", + "hash": "d0a78e00349429107d0f9c8557fa2130", + "createdAt": "1679459565853", + "updatedAt": "1679460534365", + "graph": { + "id": "demo@0.1.0", + "nodes": { + "234": { + "id": 234, + "data": { + "success": false + }, + "inputs": { + "trigger": { + "connections": [ + { + "node": 519, + "output": "trigger", + "data": { + "hello": "hello" + } + } + ] + }, + "string": { + "connections": [ + { + "node": 519, + "output": "content", + "data": { + "hello": "hello" + } + } + ] + } + }, + "outputs": { + "trigger": { + "connections": [ + { + "node": 521, + "input": "trigger", + "data": { + "hello": "hello" + } + } + ] + }, + "output": { + "connections": [ + { + "node": 521, + "input": "input", + "data": { + "hello": "hello" + } + } + ] + } + }, + "position": [-125.16726300656339, -435.0319261111516], + "name": "Echo" + }, + "519": { + "id": 519, + "data": { + "socketKey": "39e93504-3dc1-4919-9080-7bf8a7f69cf0", + "success": false + }, + "inputs": { + "trigger": { + "connections": [ + { + "node": 520, + "output": "trigger", + "data": { + "hello": "hello" + } + } + ] + }, + "event": { + "connections": [ + { + "node": 520, + "output": "output", + "data": { + "hello": "hello" + } + } + ] + } + }, + "outputs": { + "trigger": { + "connections": [ + { + "node": 234, + "input": "trigger", + "data": { + "hello": "hello" + } + } + ] + }, + "agentId": { + "connections": [] + }, + "content": { + "connections": [ + { + "node": 234, + "input": "string", + "data": { + "hello": "hello" + } + } + ] + }, + "client": { + "connections": [] + }, + "channel": { + "connections": [] + }, + "channelType": { + "connections": [] + }, + "entities": { + "connections": [] + }, + "projectId": { + "connections": [] + }, + "observer": { + "connections": [] + }, + "sender": { + "connections": [] + } + }, + "position": [-431.6445158203237, -436.9747968225492], + "name": "Event Destructure" + }, + "520": { + "id": 520, + "data": { + "isInput": true, + "name": "Input - Default", + "useDefault": false, + "defaultValue": "Hello world", + "socketKey": "c6582114-e0fb-4c6c-baab-b48934e07c90", + "success": false + }, + "inputs": {}, + "outputs": { + "trigger": { + "connections": [ + { + "node": 519, + "input": "trigger", + "data": { + "hello": "hello" + } + } + ] + }, + "output": { + "connections": [ + { + "node": 519, + "input": "event", + "data": { + "hello": "hello" + } + } + ] + } + }, + "position": [-731.2978535902487, -434.48770700846876], + "name": "Input" + }, + "521": { + "id": 521, + "data": { + "isOutput": true, + "name": "Output - Default", + "socketKey": "f4d76f20-fee1-4ee3-a551-4b26ff7b81ec", + "success": false + }, + "inputs": { + "trigger": { + "connections": [ + { + "node": 234, + "output": "trigger", + "data": { + "hello": "hello" + } + } + ] + }, + "input": { + "connections": [ + { + "node": 234, + "output": "output", + "data": { + "hello": "hello" + } + } + ] + }, + "event": { + "connections": [] + } + }, + "outputs": { + "trigger": { + "connections": [] + }, + "output": { + "connections": [] + } + }, + "position": [177.2501870715851, -434.47957489745335], + "name": "Output" + } + }, + "comments": [] + } +} diff --git a/packages/core/shared/test/nodes/utility/Echo.test.ts b/packages/shared/core/test/nodes/utility/Echo.test.ts similarity index 99% rename from packages/core/shared/test/nodes/utility/Echo.test.ts rename to packages/shared/core/test/nodes/utility/Echo.test.ts index 463b34b807..416c50c73f 100644 --- a/packages/core/shared/test/nodes/utility/Echo.test.ts +++ b/packages/shared/core/test/nodes/utility/Echo.test.ts @@ -17,7 +17,7 @@ describe('Echo', () => { path.join(__dirname, 'Echo.result.json'), JSON.stringify(result, null, 2) ) - + expect(result['Output - Default'] || result['Output']).toBe(testString) }) }) diff --git a/packages/core/shared/test/nodes/utility/Template.spell.json b/packages/shared/core/test/nodes/utility/Template.spell.json similarity index 100% rename from packages/core/shared/test/nodes/utility/Template.spell.json rename to packages/shared/core/test/nodes/utility/Template.spell.json diff --git a/packages/core/shared/test/nodes/utility/Template.test.ts b/packages/shared/core/test/nodes/utility/Template.test.ts similarity index 98% rename from packages/core/shared/test/nodes/utility/Template.test.ts rename to packages/shared/core/test/nodes/utility/Template.test.ts index b577f6e8ac..d240c2dbac 100644 --- a/packages/core/shared/test/nodes/utility/Template.test.ts +++ b/packages/shared/core/test/nodes/utility/Template.test.ts @@ -9,7 +9,7 @@ describe('Template', () => { content: testString, }, }) - + expect(result['Output - Default'] || result['Output']).toBe(testString) }) }) diff --git a/packages/core/shared/test/utils/runSpell.ts b/packages/shared/core/test/utils/runSpell.ts similarity index 97% rename from packages/core/shared/test/utils/runSpell.ts rename to packages/shared/core/test/utils/runSpell.ts index d908f75436..2f0570ba36 100644 --- a/packages/core/shared/test/utils/runSpell.ts +++ b/packages/shared/core/test/utils/runSpell.ts @@ -1,7 +1,7 @@ // DOCUMENTED import { GraphData, SpellInterface } from '../../src/types' import { SpellRunner } from '../../src/spellManager' -import { app } from '@magickml/server-core' +import { app } from 'server/core' /** * Type definition for arguments passed to the runSpell function. diff --git a/packages/core/shared/test/utils/spellHandler.ts b/packages/shared/core/test/utils/spellHandler.ts similarity index 95% rename from packages/core/shared/test/utils/spellHandler.ts rename to packages/shared/core/test/utils/spellHandler.ts index 43ca3c72ef..91ff1b937d 100644 --- a/packages/core/shared/test/utils/spellHandler.ts +++ b/packages/shared/core/test/utils/spellHandler.ts @@ -1,5 +1,5 @@ // DOCUMENTED -import { app } from '@magickml/server-core' +import { app } from 'server/core' import { SpellRunner } from '../../src/spellManager' import { MagickSpellInput, SpellInterface } from '../../src/types' diff --git a/packages/core/shared/tsconfig.json b/packages/shared/core/tsconfig.json similarity index 100% rename from packages/core/shared/tsconfig.json rename to packages/shared/core/tsconfig.json diff --git a/packages/core/shared/tsconfig.lib.json b/packages/shared/core/tsconfig.lib.json similarity index 100% rename from packages/core/shared/tsconfig.lib.json rename to packages/shared/core/tsconfig.lib.json diff --git a/packages/core/shared/tsconfig.spec.json b/packages/shared/core/tsconfig.spec.json similarity index 100% rename from packages/core/shared/tsconfig.spec.json rename to packages/shared/core/tsconfig.spec.json diff --git a/packages/core/shared/vite.config.ts b/packages/shared/core/vite.config.ts similarity index 95% rename from packages/core/shared/vite.config.ts rename to packages/shared/core/vite.config.ts index 8469fb328a..ef0c71b51b 100644 --- a/packages/core/shared/vite.config.ts +++ b/packages/shared/core/vite.config.ts @@ -1,6 +1,6 @@ import { defineConfig } from 'vite' -import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; +import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin' import dts from 'vite-plugin-dts' import { join } from 'path' import react from '@vitejs/plugin-react' @@ -68,8 +68,8 @@ export default defineConfig({ formats: ['es', 'cjs'], }, rollupOptions: { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore plugins: [rollupNodePolyFill()], // External packages that should not be bundled into your library. external: ['react', 'react-dom', 'react/jsx-runtime'], diff --git a/tsconfig.base.json b/tsconfig.base.json index fab50cef9f..c1fd384a1c 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -27,7 +27,6 @@ "paths": { "@magickml/agent": ["apps/agent/src/index.ts"], "@magickml/client": ["apps/client/src/index.ts"], - "@magickml/core": ["packages/core/shared/src/index.ts"], "@magickml/docs": ["apps/docs/src/index.ts"], "@magickml/plugin-anthropic-client": [ "packages/plugins/anthropic/client/src/index.ts" @@ -183,7 +182,6 @@ "packages/plugins/twitter/server/src/index.ts" ], "@magickml/server": ["apps/server/src/index.ts"], - "@magickml/server-core": ["packages/core/server/src/index.ts"], "@magickml/types": ["packages/@types/src/index.ts"], "@magickml/ui": ["packages/ui/src/index.ts"], "@magickml/ui/components": ["packages/utils/components/src/index.ts"], @@ -204,8 +202,10 @@ "server/cloud-agent-worker": [ "packages/server/cloud-agent-worker/src/index.ts" ], + "server/core": ["packages/server/core/src/index.ts"], "server/redis-pubsub": ["packages/server/redis-pubsub/src/index.ts"], "shared/config": ["packages/shared/config/src/index.ts"], + "shared/core": ["packages/shared/core/src/index.ts"], "shared/rete": ["packages/shared/rete/src/index.ts"] } }, From 027216b0c9838af76da47ab2eea5cd899058017b Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 27 Sep 2023 11:58:03 -0700 Subject: [PATCH 125/349] Create empty providers package --- client/providers/.eslintrc.json | 25 +++++++++++ client/providers/README.md | 11 +++++ client/providers/package.json | 8 ++++ client/providers/project.json | 34 ++++++++++++++ client/providers/src/index.ts | 1 + client/providers/src/lib/providers.spec.ts | 7 +++ client/providers/src/lib/providers.ts | 3 ++ client/providers/tsconfig.json | 23 ++++++++++ client/providers/tsconfig.lib.json | 10 +++++ client/providers/tsconfig.spec.json | 19 ++++++++ client/providers/vite.config.ts | 52 ++++++++++++++++++++++ tsconfig.base.json | 1 + 12 files changed, 194 insertions(+) create mode 100644 client/providers/.eslintrc.json create mode 100644 client/providers/README.md create mode 100644 client/providers/package.json create mode 100644 client/providers/project.json create mode 100644 client/providers/src/index.ts create mode 100644 client/providers/src/lib/providers.spec.ts create mode 100644 client/providers/src/lib/providers.ts create mode 100644 client/providers/tsconfig.json create mode 100644 client/providers/tsconfig.lib.json create mode 100644 client/providers/tsconfig.spec.json create mode 100644 client/providers/vite.config.ts diff --git a/client/providers/.eslintrc.json b/client/providers/.eslintrc.json new file mode 100644 index 0000000000..adbe7ae2df --- /dev/null +++ b/client/providers/.eslintrc.json @@ -0,0 +1,25 @@ +{ + "extends": ["../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], + "rules": {} + }, + { + "files": ["*.ts", "*.tsx"], + "rules": {} + }, + { + "files": ["*.js", "*.jsx"], + "rules": {} + }, + { + "files": ["*.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": "error" + } + } + ] +} diff --git a/client/providers/README.md b/client/providers/README.md new file mode 100644 index 0000000000..b6d36458ca --- /dev/null +++ b/client/providers/README.md @@ -0,0 +1,11 @@ +# providers + +This library was generated with [Nx](https://nx.dev). + +## Building + +Run `nx build providers` to build the library. + +## Running unit tests + +Run `nx test providers` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/client/providers/package.json b/client/providers/package.json new file mode 100644 index 0000000000..6fdae1fce8 --- /dev/null +++ b/client/providers/package.json @@ -0,0 +1,8 @@ +{ + "name": "@magickml/providers", + "version": "0.0.1", + "dependencies": {}, + "main": "./index.js", + "module": "./index.mjs", + "typings": "./index.d.ts" +} diff --git a/client/providers/project.json b/client/providers/project.json new file mode 100644 index 0000000000..c3cc2b19c4 --- /dev/null +++ b/client/providers/project.json @@ -0,0 +1,34 @@ +{ + "name": "@magickml/providers", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "client/providers/src", + "projectType": "library", + "targets": { + "build": { + "executor": "@nx/vite:build", + "outputs": ["{options.outputPath}"], + "options": { + "outputPath": "dist/client/providers" + } + }, + "test": { + "executor": "@nx/vite:test", + "outputs": ["{options.reportsDirectory}"], + "options": { + "passWithNoTests": true, + "reportsDirectory": "../../coverage/client/providers" + } + }, + "lint": { + "executor": "@nx/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": [ + "client/providers/**/*.ts", + "client/providers/package.json" + ] + } + } + }, + "tags": [] +} diff --git a/client/providers/src/index.ts b/client/providers/src/index.ts new file mode 100644 index 0000000000..9bade26303 --- /dev/null +++ b/client/providers/src/index.ts @@ -0,0 +1 @@ +export * from './lib/providers' diff --git a/client/providers/src/lib/providers.spec.ts b/client/providers/src/lib/providers.spec.ts new file mode 100644 index 0000000000..4884d1118b --- /dev/null +++ b/client/providers/src/lib/providers.spec.ts @@ -0,0 +1,7 @@ +import { providers } from './providers' + +describe('providers', () => { + it('should work', () => { + expect(providers()).toEqual('providers') + }) +}) diff --git a/client/providers/src/lib/providers.ts b/client/providers/src/lib/providers.ts new file mode 100644 index 0000000000..4c2a800afe --- /dev/null +++ b/client/providers/src/lib/providers.ts @@ -0,0 +1,3 @@ +export function providers(): string { + return 'providers' +} diff --git a/client/providers/tsconfig.json b/client/providers/tsconfig.json new file mode 100644 index 0000000000..bdf594cdb1 --- /dev/null +++ b/client/providers/tsconfig.json @@ -0,0 +1,23 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "module": "commonjs", + "forceConsistentCasingInFileNames": true, + "strict": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "types": ["vitest"] + }, + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + } + ] +} diff --git a/client/providers/tsconfig.lib.json b/client/providers/tsconfig.lib.json new file mode 100644 index 0000000000..33eca2c2cd --- /dev/null +++ b/client/providers/tsconfig.lib.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "declaration": true, + "types": ["node"] + }, + "include": ["src/**/*.ts"], + "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"] +} diff --git a/client/providers/tsconfig.spec.json b/client/providers/tsconfig.spec.json new file mode 100644 index 0000000000..6d3be74271 --- /dev/null +++ b/client/providers/tsconfig.spec.json @@ -0,0 +1,19 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "types": ["vitest/globals", "vitest/importMeta", "vite/client", "node"] + }, + "include": [ + "vite.config.ts", + "src/**/*.test.ts", + "src/**/*.spec.ts", + "src/**/*.test.tsx", + "src/**/*.spec.tsx", + "src/**/*.test.js", + "src/**/*.spec.js", + "src/**/*.test.jsx", + "src/**/*.spec.jsx", + "src/**/*.d.ts" + ] +} diff --git a/client/providers/vite.config.ts b/client/providers/vite.config.ts new file mode 100644 index 0000000000..8670758738 --- /dev/null +++ b/client/providers/vite.config.ts @@ -0,0 +1,52 @@ +/// +import { defineConfig } from 'vite' + +import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin' +import dts from 'vite-plugin-dts' +import * as path from 'path' + +export default defineConfig({ + cacheDir: '../../node_modules/.vite/@magickml/providers', + + plugins: [ + dts({ + entryRoot: 'src', + tsConfigFilePath: path.join(__dirname, 'tsconfig.lib.json'), + skipDiagnostics: true, + }), + + nxViteTsPaths(), + ], + + // Uncomment this if you are using workers. + // worker: { + // plugins: [ nxViteTsPaths() ], + // }, + + // Configuration for building your library. + // See: https://vitejs.dev/guide/build.html#library-mode + build: { + lib: { + // Could also be a dictionary or array of multiple entry points. + entry: 'src/index.ts', + name: '@magickml/providers', + fileName: 'index', + // Change this to the formats you want to support. + // Don't forget to update your package.json as well. + formats: ['es', 'cjs'], + }, + rollupOptions: { + // External packages that should not be bundled into your library. + external: [], + }, + }, + + test: { + globals: true, + cache: { + dir: '../../node_modules/.vitest', + }, + environment: 'node', + include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], + }, +}) diff --git a/tsconfig.base.json b/tsconfig.base.json index c1fd384a1c..68243dea4b 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -181,6 +181,7 @@ "@magickml/plugin-twitter-server": [ "packages/plugins/twitter/server/src/index.ts" ], + "@magickml/providers": ["client/providers/src/index.ts"], "@magickml/server": ["apps/server/src/index.ts"], "@magickml/types": ["packages/@types/src/index.ts"], "@magickml/ui": ["packages/ui/src/index.ts"], From 5a74aa98a5347fc9ea362bc8b577d8724f3cf063 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 27 Sep 2023 11:59:46 -0700 Subject: [PATCH 126/349] Remove wrong providers path --- client/providers/.eslintrc.json | 25 ----------- client/providers/README.md | 11 ----- client/providers/package.json | 8 ---- client/providers/project.json | 34 -------------- client/providers/src/index.ts | 1 - client/providers/src/lib/providers.spec.ts | 7 --- client/providers/src/lib/providers.ts | 3 -- client/providers/tsconfig.json | 23 ---------- client/providers/tsconfig.lib.json | 10 ----- client/providers/tsconfig.spec.json | 19 -------- client/providers/vite.config.ts | 52 ---------------------- tsconfig.base.json | 1 - 12 files changed, 194 deletions(-) delete mode 100644 client/providers/.eslintrc.json delete mode 100644 client/providers/README.md delete mode 100644 client/providers/package.json delete mode 100644 client/providers/project.json delete mode 100644 client/providers/src/index.ts delete mode 100644 client/providers/src/lib/providers.spec.ts delete mode 100644 client/providers/src/lib/providers.ts delete mode 100644 client/providers/tsconfig.json delete mode 100644 client/providers/tsconfig.lib.json delete mode 100644 client/providers/tsconfig.spec.json delete mode 100644 client/providers/vite.config.ts diff --git a/client/providers/.eslintrc.json b/client/providers/.eslintrc.json deleted file mode 100644 index adbe7ae2df..0000000000 --- a/client/providers/.eslintrc.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "extends": ["../../.eslintrc.json"], - "ignorePatterns": ["!**/*"], - "overrides": [ - { - "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], - "rules": {} - }, - { - "files": ["*.ts", "*.tsx"], - "rules": {} - }, - { - "files": ["*.js", "*.jsx"], - "rules": {} - }, - { - "files": ["*.json"], - "parser": "jsonc-eslint-parser", - "rules": { - "@nx/dependency-checks": "error" - } - } - ] -} diff --git a/client/providers/README.md b/client/providers/README.md deleted file mode 100644 index b6d36458ca..0000000000 --- a/client/providers/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# providers - -This library was generated with [Nx](https://nx.dev). - -## Building - -Run `nx build providers` to build the library. - -## Running unit tests - -Run `nx test providers` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/client/providers/package.json b/client/providers/package.json deleted file mode 100644 index 6fdae1fce8..0000000000 --- a/client/providers/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "@magickml/providers", - "version": "0.0.1", - "dependencies": {}, - "main": "./index.js", - "module": "./index.mjs", - "typings": "./index.d.ts" -} diff --git a/client/providers/project.json b/client/providers/project.json deleted file mode 100644 index c3cc2b19c4..0000000000 --- a/client/providers/project.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "@magickml/providers", - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "client/providers/src", - "projectType": "library", - "targets": { - "build": { - "executor": "@nx/vite:build", - "outputs": ["{options.outputPath}"], - "options": { - "outputPath": "dist/client/providers" - } - }, - "test": { - "executor": "@nx/vite:test", - "outputs": ["{options.reportsDirectory}"], - "options": { - "passWithNoTests": true, - "reportsDirectory": "../../coverage/client/providers" - } - }, - "lint": { - "executor": "@nx/linter:eslint", - "outputs": ["{options.outputFile}"], - "options": { - "lintFilePatterns": [ - "client/providers/**/*.ts", - "client/providers/package.json" - ] - } - } - }, - "tags": [] -} diff --git a/client/providers/src/index.ts b/client/providers/src/index.ts deleted file mode 100644 index 9bade26303..0000000000 --- a/client/providers/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './lib/providers' diff --git a/client/providers/src/lib/providers.spec.ts b/client/providers/src/lib/providers.spec.ts deleted file mode 100644 index 4884d1118b..0000000000 --- a/client/providers/src/lib/providers.spec.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { providers } from './providers' - -describe('providers', () => { - it('should work', () => { - expect(providers()).toEqual('providers') - }) -}) diff --git a/client/providers/src/lib/providers.ts b/client/providers/src/lib/providers.ts deleted file mode 100644 index 4c2a800afe..0000000000 --- a/client/providers/src/lib/providers.ts +++ /dev/null @@ -1,3 +0,0 @@ -export function providers(): string { - return 'providers' -} diff --git a/client/providers/tsconfig.json b/client/providers/tsconfig.json deleted file mode 100644 index bdf594cdb1..0000000000 --- a/client/providers/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "module": "commonjs", - "forceConsistentCasingInFileNames": true, - "strict": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true, - "types": ["vitest"] - }, - "files": [], - "include": [], - "references": [ - { - "path": "./tsconfig.lib.json" - }, - { - "path": "./tsconfig.spec.json" - } - ] -} diff --git a/client/providers/tsconfig.lib.json b/client/providers/tsconfig.lib.json deleted file mode 100644 index 33eca2c2cd..0000000000 --- a/client/providers/tsconfig.lib.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../dist/out-tsc", - "declaration": true, - "types": ["node"] - }, - "include": ["src/**/*.ts"], - "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"] -} diff --git a/client/providers/tsconfig.spec.json b/client/providers/tsconfig.spec.json deleted file mode 100644 index 6d3be74271..0000000000 --- a/client/providers/tsconfig.spec.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../dist/out-tsc", - "types": ["vitest/globals", "vitest/importMeta", "vite/client", "node"] - }, - "include": [ - "vite.config.ts", - "src/**/*.test.ts", - "src/**/*.spec.ts", - "src/**/*.test.tsx", - "src/**/*.spec.tsx", - "src/**/*.test.js", - "src/**/*.spec.js", - "src/**/*.test.jsx", - "src/**/*.spec.jsx", - "src/**/*.d.ts" - ] -} diff --git a/client/providers/vite.config.ts b/client/providers/vite.config.ts deleted file mode 100644 index 8670758738..0000000000 --- a/client/providers/vite.config.ts +++ /dev/null @@ -1,52 +0,0 @@ -/// -import { defineConfig } from 'vite' - -import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin' -import dts from 'vite-plugin-dts' -import * as path from 'path' - -export default defineConfig({ - cacheDir: '../../node_modules/.vite/@magickml/providers', - - plugins: [ - dts({ - entryRoot: 'src', - tsConfigFilePath: path.join(__dirname, 'tsconfig.lib.json'), - skipDiagnostics: true, - }), - - nxViteTsPaths(), - ], - - // Uncomment this if you are using workers. - // worker: { - // plugins: [ nxViteTsPaths() ], - // }, - - // Configuration for building your library. - // See: https://vitejs.dev/guide/build.html#library-mode - build: { - lib: { - // Could also be a dictionary or array of multiple entry points. - entry: 'src/index.ts', - name: '@magickml/providers', - fileName: 'index', - // Change this to the formats you want to support. - // Don't forget to update your package.json as well. - formats: ['es', 'cjs'], - }, - rollupOptions: { - // External packages that should not be bundled into your library. - external: [], - }, - }, - - test: { - globals: true, - cache: { - dir: '../../node_modules/.vitest', - }, - environment: 'node', - include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], - }, -}) diff --git a/tsconfig.base.json b/tsconfig.base.json index 68243dea4b..c1fd384a1c 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -181,7 +181,6 @@ "@magickml/plugin-twitter-server": [ "packages/plugins/twitter/server/src/index.ts" ], - "@magickml/providers": ["client/providers/src/index.ts"], "@magickml/server": ["apps/server/src/index.ts"], "@magickml/types": ["packages/@types/src/index.ts"], "@magickml/ui": ["packages/ui/src/index.ts"], From 4ef3bae3bc90f0d18d86532a02347c6f28fa9584 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 27 Sep 2023 12:00:45 -0700 Subject: [PATCH 127/349] Properly generate providers package --- packages/client/providers/.eslintrc.json | 25 +++++++++ packages/client/providers/README.md | 11 ++++ packages/client/providers/package.json | 8 +++ packages/client/providers/project.json | 34 ++++++++++++ packages/client/providers/src/index.ts | 1 + .../providers/src/lib/providers.spec.ts | 7 +++ .../client/providers/src/lib/providers.ts | 3 ++ packages/client/providers/tsconfig.json | 23 ++++++++ packages/client/providers/tsconfig.lib.json | 10 ++++ packages/client/providers/tsconfig.spec.json | 19 +++++++ packages/client/providers/vite.config.ts | 52 +++++++++++++++++++ tsconfig.base.json | 1 + 12 files changed, 194 insertions(+) create mode 100644 packages/client/providers/.eslintrc.json create mode 100644 packages/client/providers/README.md create mode 100644 packages/client/providers/package.json create mode 100644 packages/client/providers/project.json create mode 100644 packages/client/providers/src/index.ts create mode 100644 packages/client/providers/src/lib/providers.spec.ts create mode 100644 packages/client/providers/src/lib/providers.ts create mode 100644 packages/client/providers/tsconfig.json create mode 100644 packages/client/providers/tsconfig.lib.json create mode 100644 packages/client/providers/tsconfig.spec.json create mode 100644 packages/client/providers/vite.config.ts diff --git a/packages/client/providers/.eslintrc.json b/packages/client/providers/.eslintrc.json new file mode 100644 index 0000000000..3230caf3d2 --- /dev/null +++ b/packages/client/providers/.eslintrc.json @@ -0,0 +1,25 @@ +{ + "extends": ["../../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], + "rules": {} + }, + { + "files": ["*.ts", "*.tsx"], + "rules": {} + }, + { + "files": ["*.js", "*.jsx"], + "rules": {} + }, + { + "files": ["*.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": "error" + } + } + ] +} diff --git a/packages/client/providers/README.md b/packages/client/providers/README.md new file mode 100644 index 0000000000..b6d36458ca --- /dev/null +++ b/packages/client/providers/README.md @@ -0,0 +1,11 @@ +# providers + +This library was generated with [Nx](https://nx.dev). + +## Building + +Run `nx build providers` to build the library. + +## Running unit tests + +Run `nx test providers` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/packages/client/providers/package.json b/packages/client/providers/package.json new file mode 100644 index 0000000000..6fdae1fce8 --- /dev/null +++ b/packages/client/providers/package.json @@ -0,0 +1,8 @@ +{ + "name": "@magickml/providers", + "version": "0.0.1", + "dependencies": {}, + "main": "./index.js", + "module": "./index.mjs", + "typings": "./index.d.ts" +} diff --git a/packages/client/providers/project.json b/packages/client/providers/project.json new file mode 100644 index 0000000000..b6a78364ba --- /dev/null +++ b/packages/client/providers/project.json @@ -0,0 +1,34 @@ +{ + "name": "@magickml/providers", + "$schema": "../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "packages/client/providers/src", + "projectType": "library", + "targets": { + "build": { + "executor": "@nx/vite:build", + "outputs": ["{options.outputPath}"], + "options": { + "outputPath": "dist/packages/client/providers" + } + }, + "test": { + "executor": "@nx/vite:test", + "outputs": ["{options.reportsDirectory}"], + "options": { + "passWithNoTests": true, + "reportsDirectory": "../../../coverage/packages/client/providers" + } + }, + "lint": { + "executor": "@nx/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": [ + "packages/client/providers/**/*.ts", + "packages/client/providers/package.json" + ] + } + } + }, + "tags": [] +} diff --git a/packages/client/providers/src/index.ts b/packages/client/providers/src/index.ts new file mode 100644 index 0000000000..9bade26303 --- /dev/null +++ b/packages/client/providers/src/index.ts @@ -0,0 +1 @@ +export * from './lib/providers' diff --git a/packages/client/providers/src/lib/providers.spec.ts b/packages/client/providers/src/lib/providers.spec.ts new file mode 100644 index 0000000000..4884d1118b --- /dev/null +++ b/packages/client/providers/src/lib/providers.spec.ts @@ -0,0 +1,7 @@ +import { providers } from './providers' + +describe('providers', () => { + it('should work', () => { + expect(providers()).toEqual('providers') + }) +}) diff --git a/packages/client/providers/src/lib/providers.ts b/packages/client/providers/src/lib/providers.ts new file mode 100644 index 0000000000..4c2a800afe --- /dev/null +++ b/packages/client/providers/src/lib/providers.ts @@ -0,0 +1,3 @@ +export function providers(): string { + return 'providers' +} diff --git a/packages/client/providers/tsconfig.json b/packages/client/providers/tsconfig.json new file mode 100644 index 0000000000..28e66cbe5e --- /dev/null +++ b/packages/client/providers/tsconfig.json @@ -0,0 +1,23 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "module": "commonjs", + "forceConsistentCasingInFileNames": true, + "strict": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "types": ["vitest"] + }, + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + } + ] +} diff --git a/packages/client/providers/tsconfig.lib.json b/packages/client/providers/tsconfig.lib.json new file mode 100644 index 0000000000..4befa7f099 --- /dev/null +++ b/packages/client/providers/tsconfig.lib.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../../dist/out-tsc", + "declaration": true, + "types": ["node"] + }, + "include": ["src/**/*.ts"], + "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"] +} diff --git a/packages/client/providers/tsconfig.spec.json b/packages/client/providers/tsconfig.spec.json new file mode 100644 index 0000000000..6d3be74271 --- /dev/null +++ b/packages/client/providers/tsconfig.spec.json @@ -0,0 +1,19 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "types": ["vitest/globals", "vitest/importMeta", "vite/client", "node"] + }, + "include": [ + "vite.config.ts", + "src/**/*.test.ts", + "src/**/*.spec.ts", + "src/**/*.test.tsx", + "src/**/*.spec.tsx", + "src/**/*.test.js", + "src/**/*.spec.js", + "src/**/*.test.jsx", + "src/**/*.spec.jsx", + "src/**/*.d.ts" + ] +} diff --git a/packages/client/providers/vite.config.ts b/packages/client/providers/vite.config.ts new file mode 100644 index 0000000000..058c1fe96a --- /dev/null +++ b/packages/client/providers/vite.config.ts @@ -0,0 +1,52 @@ +/// +import { defineConfig } from 'vite' + +import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin' +import dts from 'vite-plugin-dts' +import * as path from 'path' + +export default defineConfig({ + cacheDir: '../../../node_modules/.vite/@magickml/providers', + + plugins: [ + dts({ + entryRoot: 'src', + tsConfigFilePath: path.join(__dirname, 'tsconfig.lib.json'), + skipDiagnostics: true, + }), + + nxViteTsPaths(), + ], + + // Uncomment this if you are using workers. + // worker: { + // plugins: [ nxViteTsPaths() ], + // }, + + // Configuration for building your library. + // See: https://vitejs.dev/guide/build.html#library-mode + build: { + lib: { + // Could also be a dictionary or array of multiple entry points. + entry: 'src/index.ts', + name: '@magickml/providers', + fileName: 'index', + // Change this to the formats you want to support. + // Don't forget to update your package.json as well. + formats: ['es', 'cjs'], + }, + rollupOptions: { + // External packages that should not be bundled into your library. + external: [], + }, + }, + + test: { + globals: true, + cache: { + dir: '../../../node_modules/.vitest', + }, + environment: 'node', + include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], + }, +}) diff --git a/tsconfig.base.json b/tsconfig.base.json index c1fd384a1c..1994f418c9 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -181,6 +181,7 @@ "@magickml/plugin-twitter-server": [ "packages/plugins/twitter/server/src/index.ts" ], + "@magickml/providers": ["packages/client/providers/src/index.ts"], "@magickml/server": ["apps/server/src/index.ts"], "@magickml/types": ["packages/@types/src/index.ts"], "@magickml/ui": ["packages/ui/src/index.ts"], From 6f44437fc292d63591eeb654cd15d8efa2234cd6 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 27 Sep 2023 13:22:52 -0700 Subject: [PATCH 128/349] Fix references to client core providers being moved --- .../core/src/components/Drawer/AgentMenu.tsx | 18 +++---- .../core/src/components/Drawer/CustomNode.tsx | 7 ++- .../components/Drawer/Newsidebar/index.tsx | 54 +++++++++---------- .../components/Drawer/OldSidebar/index.tsx | 2 +- .../core/src/components/Drawer/index.tsx | 2 +- packages/client/core/src/contexts/index.ts | 2 - packages/client/core/src/index.ts | 2 - packages/client/core/src/providers/index.tsx | 3 -- packages/client/core/tsconfig.json | 2 +- .../editor/src/DataControls/SpellSelect.tsx | 2 +- .../editor/src/contexts/AppProviders.tsx | 2 +- .../editor/src/contexts/EditorProvider.tsx | 5 +- .../editor/src/contexts/InspectorProvider.tsx | 10 ++-- .../src/contexts/MagickInterfaceProvider.tsx | 2 +- .../editor/src/contexts/TabProvider.tsx | 2 +- .../src/layouts/MainLayout/MainLayout.tsx | 3 +- packages/client/editor/src/main.tsx | 2 +- .../editor/src/plugins/areaPlugin/snap.ts | 2 +- .../editor/src/screens/Composer/index.tsx | 2 +- .../DocumentWindow/DocContentModal.tsx | 3 +- .../screens/DocumentWindow/DocumentTable.tsx | 3 +- .../src/screens/DocumentWindow/index.tsx | 3 +- .../src/screens/EventWindow/EventTable.tsx | 7 ++- .../editor/src/screens/EventWindow/index.tsx | 3 +- .../src/screens/HomeScreen/CreateNew.tsx | 11 ++-- .../src/screens/HomeScreen/HomeScreen.tsx | 3 +- .../editor/src/screens/Magick/Magick.tsx | 19 +++---- .../screens/MagickV2/panels/fileDrawer.tsx | 3 +- .../screens/MagickV2/workspaces/composer.tsx | 2 +- .../screens/RequestWindow/RequestTable.tsx | 8 +-- .../src/screens/RequestWindow/index.tsx | 3 +- .../src/screens/agents/AgentManagerWindow.tsx | 31 ++++++----- .../agents/AgentWindow/AgentDetails.tsx | 9 ++-- .../src/screens/agents/AgentWindow/index.tsx | 2 +- .../editor/src/windows/DebugConsole/index.tsx | 15 +++--- .../editor/src/windows/PlaytestWindow.tsx | 10 ++-- packages/client/providers/src/index.ts | 6 ++- .../src/lib}/ConfigProvider.tsx | 0 .../src/lib}/FeathersProvider.tsx | 4 +- .../src/lib/ProjectWindowProvider.tsx} | 0 .../src/lib}/PubSubProvider.tsx | 0 .../src/lib}/TreeDataProvider.tsx | 13 ++--- .../src/lib}/data/sampleData.json | 0 .../providers/src/lib/providers.spec.ts | 7 --- .../client/providers/src/lib/providers.ts | 3 -- packages/client/providers/tsconfig.json | 1 + .../avatar/client/src/hooks/useSpellList.ts | 2 +- .../core/src/dataControls/PlaytestControl.ts | 2 +- 48 files changed, 139 insertions(+), 158 deletions(-) delete mode 100644 packages/client/core/src/contexts/index.ts delete mode 100644 packages/client/core/src/providers/index.tsx rename packages/client/{core/src/providers => providers/src/lib}/ConfigProvider.tsx (100%) rename packages/client/{core/src/providers => providers/src/lib}/FeathersProvider.tsx (97%) rename packages/client/{core/src/contexts/ProjectWindowContext.tsx => providers/src/lib/ProjectWindowProvider.tsx} (100%) rename packages/client/{core/src/providers => providers/src/lib}/PubSubProvider.tsx (100%) rename packages/client/{core/src/contexts => providers/src/lib}/TreeDataProvider.tsx (96%) rename packages/client/{core/src/contexts => providers/src/lib}/data/sampleData.json (100%) delete mode 100644 packages/client/providers/src/lib/providers.spec.ts delete mode 100644 packages/client/providers/src/lib/providers.ts diff --git a/packages/client/core/src/components/Drawer/AgentMenu.tsx b/packages/client/core/src/components/Drawer/AgentMenu.tsx index 15b104f86f..76a6377d66 100644 --- a/packages/client/core/src/components/Drawer/AgentMenu.tsx +++ b/packages/client/core/src/components/Drawer/AgentMenu.tsx @@ -16,13 +16,12 @@ import AddCircleIcon from '@mui/icons-material/AddCircle' import { IconBtn } from 'client/core' import { Close, Done } from '@mui/icons-material' import styles from './menu.module.css' -import { useConfig } from 'client/core' import { enqueueSnackbar } from 'notistack' import { useDispatch, useSelector } from 'react-redux' import { Modal } from 'client/core' import { DEFAULT_USER_TOKEN, STANDALONE, API_ROOT_URL } from 'shared/config' -import { useFeathers } from '../../providers/FeathersProvider' +import { useFeathers, useConfig } from '@magickml/providers' // todo fix this import import { useSpellList } from '../../../../../plugins/avatar/client/src/hooks/useSpellList' @@ -540,14 +539,12 @@ function AgentMenu({ data, resetData }) { background: 'none', outline: 'none', }, - color: `${ - selectedAgentData && + color: `${selectedAgentData && (selectedAgentData.default ? 'grey' : 'white') - }`, - cursor: `${ - selectedAgentData && + }`, + cursor: `${selectedAgentData && (selectedAgentData.default ? 'not-allowed' : 'pointer') - }`, + }`, }} onClick={e => { if (!selectedAgentData.default) { @@ -601,9 +598,8 @@ function AgentMenu({ data, resetData }) { open={openConfirm} onClose={handleClose} handleAction={onSubmit} - title={`Delete ${ - selectedAgentData ? selectedAgentData.name : '' - } agent`} + title={`Delete ${selectedAgentData ? selectedAgentData.name : '' + } agent`} submitText="Confirm" children="Do you want to delete this agent?" /> diff --git a/packages/client/core/src/components/Drawer/CustomNode.tsx b/packages/client/core/src/components/Drawer/CustomNode.tsx index 779df51e0f..0bcb4c177e 100644 --- a/packages/client/core/src/components/Drawer/CustomNode.tsx +++ b/packages/client/core/src/components/Drawer/CustomNode.tsx @@ -11,7 +11,7 @@ import Menu from '@mui/material/Menu' import MenuItem from '@mui/material/MenuItem' import DriveFileRenameOutlineTwoToneIcon from '@mui/icons-material/DriveFileRenameOutlineTwoTone' import DeleteOutlineTwoToneIcon from '@mui/icons-material/DeleteOutlineTwoTone' -import { useFeathers } from 'client/core' +import { useFeathers } from '@magickml/providers' import { Modal } from 'client/core' import { RootState, @@ -205,9 +205,8 @@ export const CustomNode: React.FC = props => { style={{ paddingInlineStart: indent }} >
{props.node.droppable && (
diff --git a/packages/client/core/src/components/Drawer/Newsidebar/index.tsx b/packages/client/core/src/components/Drawer/Newsidebar/index.tsx index fe4efe8e43..20f838ee8b 100644 --- a/packages/client/core/src/components/Drawer/Newsidebar/index.tsx +++ b/packages/client/core/src/components/Drawer/Newsidebar/index.tsx @@ -13,7 +13,7 @@ import ListItemText from '@mui/material/ListItemText' import { CSSObject, Theme, styled } from '@mui/material/styles' import { useEffect, useState } from 'react' import { useLocation, useNavigate } from 'react-router-dom' -import { useTreeData } from '../../../contexts/TreeDataProvider' +import { useTreeData } from '@magickml/providers' import { SetAPIKeys } from '../SetAPIKeys' import { Tooltip, Typography } from '@mui/material' import { drawerTooltipText } from '../tooltiptext' @@ -38,7 +38,7 @@ import FolderOpenOutlinedIcon from '@mui/icons-material/FolderOpenOutlined' import DescriptionOutlinedIcon from '@mui/icons-material/DescriptionOutlined' import StarBorderPurple500OutlinedIcon from '@mui/icons-material/StarBorderPurple500Outlined' import HistoryEduOutlinedIcon from '@mui/icons-material/HistoryEduOutlined' -import { useConfig } from 'client/core' +import { useConfig } from '@magickml/providers' import { DEFAULT_USER_TOKEN, STANDALONE, PRODUCTION } from 'shared/config' import { useDispatch, useSelector } from 'react-redux' @@ -317,33 +317,33 @@ export function NewSidebar(DrawerProps): JSX.Element { useEffect(() => { if (!config.apiUrl) return - ;(async () => { - const res = await fetch( - `${config.apiUrl}/agents?projectId=${config.projectId}`, - { - headers: STANDALONE - ? { Authorization: `Bearer ${DEFAULT_USER_TOKEN}` } - : { Authorization: `Bearer ${token}` }, + ; (async () => { + const res = await fetch( + `${config.apiUrl}/agents?projectId=${config.projectId}`, + { + headers: STANDALONE + ? { Authorization: `Bearer ${DEFAULT_USER_TOKEN}` } + : { Authorization: `Bearer ${token}` }, + } + ) + const json = await res.json() + // if data.length === 0 create new agent + if (json.data.length === 0) { + await createNew({ + name: 'Default Agent', + projectId: config.projectId, + enabled: false, + publicVariables: '{}', + secrets: '{}', + default: true, + }) + setData(json.data) + } else { + setData(json.data) } - ) - const json = await res.json() - // if data.length === 0 create new agent - if (json.data.length === 0) { - await createNew({ - name: 'Default Agent', - projectId: config.projectId, - enabled: false, - publicVariables: '{}', - secrets: '{}', - default: true, - }) - setData(json.data) - } else { - setData(json.data) - } - // setIsLoading(false) - })() + // setIsLoading(false) + })() }, [config?.apiUrl]) // Function to handle the click event on the hideMenu div diff --git a/packages/client/core/src/components/Drawer/OldSidebar/index.tsx b/packages/client/core/src/components/Drawer/OldSidebar/index.tsx index 0c955c61f0..9d564f1f65 100644 --- a/packages/client/core/src/components/Drawer/OldSidebar/index.tsx +++ b/packages/client/core/src/components/Drawer/OldSidebar/index.tsx @@ -19,7 +19,7 @@ import { useLocation, useNavigate } from 'react-router-dom' import { ProjectWindowProvider, useProjectWindow, -} from '../../../contexts/ProjectWindowContext' +} from '../../../../../providers/src/lib/ProjectWindowProvider' import ProjectWindow from '../ProjectWindow' import { SetAPIKeys } from '../SetAPIKeys' import MagickLogo from '../logo-full.png' diff --git a/packages/client/core/src/components/Drawer/index.tsx b/packages/client/core/src/components/Drawer/index.tsx index a375fb9d67..a55c8571a3 100644 --- a/packages/client/core/src/components/Drawer/index.tsx +++ b/packages/client/core/src/components/Drawer/index.tsx @@ -1,7 +1,7 @@ // DOCUMENTED import { useFeatureFlagEnabled } from 'posthog-js/react' import { FEATURE_FLAGS } from 'shared/config' -import { ProjectWindowProvider } from '../../contexts/ProjectWindowContext' +import { ProjectWindowProvider } from '../../../../providers/src/lib/ProjectWindowProvider' import { OldSidebar } from './OldSidebar' import { NewSidebar } from './Newsidebar' diff --git a/packages/client/core/src/contexts/index.ts b/packages/client/core/src/contexts/index.ts deleted file mode 100644 index 5fda6a8c45..0000000000 --- a/packages/client/core/src/contexts/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { ProjectWindowProvider, useProjectWindow } from './ProjectWindowContext' -export { TreeDataProvider, useTreeData } from './TreeDataProvider' diff --git a/packages/client/core/src/index.ts b/packages/client/core/src/index.ts index 2387c52660..f91d0019a1 100644 --- a/packages/client/core/src/index.ts +++ b/packages/client/core/src/index.ts @@ -8,8 +8,6 @@ import { ClientPluginManager, pluginManager } from 'shared/core' import defaultTemplates from './templates' export * from './components' -export * from './contexts' -export * from './providers' /** * Gets spell templates from plugin manager. diff --git a/packages/client/core/src/providers/index.tsx b/packages/client/core/src/providers/index.tsx deleted file mode 100644 index e043a5573c..0000000000 --- a/packages/client/core/src/providers/index.tsx +++ /dev/null @@ -1,3 +0,0 @@ -export * from './ConfigProvider' -export * from './PubSubProvider' -export * from './FeathersProvider' diff --git a/packages/client/core/tsconfig.json b/packages/client/core/tsconfig.json index f0251adc82..26db299761 100644 --- a/packages/client/core/tsconfig.json +++ b/packages/client/core/tsconfig.json @@ -19,5 +19,5 @@ "jsx": "react-jsx" }, "files": [], - "include": ["src"] + "include": ["src", "../providers/src/lib/ProjectWindowProvider.tsx"] } diff --git a/packages/client/editor/src/DataControls/SpellSelect.tsx b/packages/client/editor/src/DataControls/SpellSelect.tsx index 79a4efbf05..d31dfad835 100644 --- a/packages/client/editor/src/DataControls/SpellSelect.tsx +++ b/packages/client/editor/src/DataControls/SpellSelect.tsx @@ -6,7 +6,7 @@ import md5 from 'md5' import { useSnackbar } from 'notistack' import { useEffect } from 'react' -import { useConfig } from 'client/core' +import { useConfig } from '@magickml/providers' import { openTab, spellApi, useAppDispatch } from 'client/state' /** diff --git a/packages/client/editor/src/contexts/AppProviders.tsx b/packages/client/editor/src/contexts/AppProviders.tsx index c702430e15..655c8962d0 100644 --- a/packages/client/editor/src/contexts/AppProviders.tsx +++ b/packages/client/editor/src/contexts/AppProviders.tsx @@ -1,5 +1,5 @@ // DOCUMENTED -import { ConfigProvider, FeathersProvider, PubSubProvider } from 'client/core' +import { ConfigProvider, FeathersProvider, PubSubProvider } from '@magickml/providers' import { createTheme, ThemeProvider } from '@mui/material' import React from 'react' import ToastProvider from './ToastProvider' diff --git a/packages/client/editor/src/contexts/EditorProvider.tsx b/packages/client/editor/src/contexts/EditorProvider.tsx index 62dd0907c8..620269a4d7 100644 --- a/packages/client/editor/src/contexts/EditorProvider.tsx +++ b/packages/client/editor/src/contexts/EditorProvider.tsx @@ -1,5 +1,6 @@ // DOCUMENTED -import { LoadingScreen, useFeathers } from 'client/core' +import { LoadingScreen } from 'client/core' +import { useFeathers, useConfig, usePubSub } from '@magickml/providers' import { EditorContext, GraphData, @@ -13,9 +14,7 @@ import React, { useRef, useState, } from 'react' -import { useSelector } from 'react-redux' -import { useConfig, usePubSub } from 'client/core' import { MyNode } from '../components/Node/Node' import { initEditor } from '../editor' import { zoomAt } from '../plugins/areaPlugin/zoom-at' diff --git a/packages/client/editor/src/contexts/InspectorProvider.tsx b/packages/client/editor/src/contexts/InspectorProvider.tsx index b08da2db39..3112bbbc6b 100644 --- a/packages/client/editor/src/contexts/InspectorProvider.tsx +++ b/packages/client/editor/src/contexts/InspectorProvider.tsx @@ -1,5 +1,5 @@ // DOCUMENTED -import { usePubSub } from 'client/core' +import { usePubSub } from '@magickml/providers' import { InspectorData, SupportedLanguages } from 'shared/core' import { createContext, useContext, useEffect, useState } from 'react' @@ -8,10 +8,10 @@ import { createContext, useContext, useEffect, useState } from 'react' */ export type TextEditorData = { options?: - | Record - | (undefined & { - language?: SupportedLanguages - }) + | Record + | (undefined & { + language?: SupportedLanguages + }) data?: string control?: Record | undefined name?: string diff --git a/packages/client/editor/src/contexts/MagickInterfaceProvider.tsx b/packages/client/editor/src/contexts/MagickInterfaceProvider.tsx index 97da687217..12ef6ffec6 100644 --- a/packages/client/editor/src/contexts/MagickInterfaceProvider.tsx +++ b/packages/client/editor/src/contexts/MagickInterfaceProvider.tsx @@ -1,5 +1,5 @@ // DOCUMENTED -import { useConfig, usePubSub } from 'client/core' +import { useConfig, usePubSub } from '@magickml/providers' import { EditorContext, GetSpell, diff --git a/packages/client/editor/src/contexts/TabProvider.tsx b/packages/client/editor/src/contexts/TabProvider.tsx index 1c558e01a7..5cf3e9b491 100644 --- a/packages/client/editor/src/contexts/TabProvider.tsx +++ b/packages/client/editor/src/contexts/TabProvider.tsx @@ -6,7 +6,7 @@ import { IDockviewPanelProps, SerializedDockview, } from 'dockview' -import { usePubSub } from 'client/core' +import { usePubSub } from '@magickml/providers' import { getWorkspaceLayout } from 'client/layouts' type DockviewTheme = 'dockview-theme-abyss' diff --git a/packages/client/editor/src/layouts/MainLayout/MainLayout.tsx b/packages/client/editor/src/layouts/MainLayout/MainLayout.tsx index 10e506b6c3..ce4f3120b2 100644 --- a/packages/client/editor/src/layouts/MainLayout/MainLayout.tsx +++ b/packages/client/editor/src/layouts/MainLayout/MainLayout.tsx @@ -5,7 +5,8 @@ */ import { Outlet } from 'react-router-dom' import ModalProvider from '../../contexts/ModalProvider' -import { DrawerProvider, TreeDataProvider } from 'client/core' +import { DrawerProvider } from 'client/core' +import { TreeDataProvider } from '@magickml/providers' /** * Main layout component. diff --git a/packages/client/editor/src/main.tsx b/packages/client/editor/src/main.tsx index 0bcb23d9eb..fb4e9ed96d 100644 --- a/packages/client/editor/src/main.tsx +++ b/packages/client/editor/src/main.tsx @@ -18,7 +18,7 @@ import AppProviders from './contexts/AppProviders' import { LocalizationProvider } from '@mui/x-date-pickers' import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs' -import { AppConfig } from 'client/core' +import { AppConfig } from '@magickml/providers' import { MagickmlChatbox } from 'client/magickml-chatbox' import { createStore } from 'client/state' diff --git a/packages/client/editor/src/plugins/areaPlugin/snap.ts b/packages/client/editor/src/plugins/areaPlugin/snap.ts index e4dc0bcdeb..ea4cf3939f 100644 --- a/packages/client/editor/src/plugins/areaPlugin/snap.ts +++ b/packages/client/editor/src/plugins/areaPlugin/snap.ts @@ -1,4 +1,4 @@ -import { PubSub, events } from 'client/core' +import { PubSub, events } from '@magickml/providers' import { MagickEditor } from 'shared/core' export class SnapGrid { diff --git a/packages/client/editor/src/screens/Composer/index.tsx b/packages/client/editor/src/screens/Composer/index.tsx index 48d7d43c51..8979c86430 100644 --- a/packages/client/editor/src/screens/Composer/index.tsx +++ b/packages/client/editor/src/screens/Composer/index.tsx @@ -4,7 +4,7 @@ import { useSelector } from 'react-redux' import { SpellInterface } from 'shared/core' -import { useConfig, useFeathers, usePubSub } from 'client/core' +import { useConfig, useFeathers, usePubSub } from '@magickml/providers' import { useEditor } from '../../contexts/EditorProvider' import { Layout } from '../../contexts/LayoutProvider' import { debounce } from '../../utils/debounce' diff --git a/packages/client/editor/src/screens/DocumentWindow/DocContentModal.tsx b/packages/client/editor/src/screens/DocumentWindow/DocContentModal.tsx index 228cfc270c..4b0c6f4c87 100644 --- a/packages/client/editor/src/screens/DocumentWindow/DocContentModal.tsx +++ b/packages/client/editor/src/screens/DocumentWindow/DocContentModal.tsx @@ -1,4 +1,5 @@ -import { Modal, useTreeData } from 'client/core' +import { Modal } from 'client/core' +import { useTreeData } from '@magickml/providers' import { Typography } from '@mui/material' import styles from './index.module.scss' diff --git a/packages/client/editor/src/screens/DocumentWindow/DocumentTable.tsx b/packages/client/editor/src/screens/DocumentWindow/DocumentTable.tsx index c74629be59..c96769121d 100644 --- a/packages/client/editor/src/screens/DocumentWindow/DocumentTable.tsx +++ b/packages/client/editor/src/screens/DocumentWindow/DocumentTable.tsx @@ -14,7 +14,7 @@ import { Typography, } from '@mui/material' import { useSnackbar } from 'notistack' -import { useConfig } from 'client/core' +import { useConfig, useTreeData } from '@magickml/providers' import { useEffect, useMemo, useState } from 'react' import { CSVLink } from 'react-csv' import { FaFileCsv } from 'react-icons/fa' @@ -31,7 +31,6 @@ import { import { DocumentData, columns } from './document' import styles from './index.module.scss' import DocumentModal from './DocumentModal' -import { useTreeData } from '../../../../core/client/src/contexts/TreeDataProvider' import DocContentModal from './DocContentModal' /** * GlobalFilter component for applying search filter on the whole table. diff --git a/packages/client/editor/src/screens/DocumentWindow/index.tsx b/packages/client/editor/src/screens/DocumentWindow/index.tsx index 6c2a6d6ee3..49655567cf 100644 --- a/packages/client/editor/src/screens/DocumentWindow/index.tsx +++ b/packages/client/editor/src/screens/DocumentWindow/index.tsx @@ -2,7 +2,8 @@ import { API_ROOT_URL } from 'shared/config' import { useEffect, useState } from 'react' import { useSelector } from 'react-redux' -import { LoadingScreen, useConfig } from 'client/core' +import { LoadingScreen } from 'client/core' +import { useConfig } from '@magickml/providers' import DocumentTable from './DocumentTable' /** diff --git a/packages/client/editor/src/screens/EventWindow/EventTable.tsx b/packages/client/editor/src/screens/EventWindow/EventTable.tsx index b580b3c424..89c5117124 100644 --- a/packages/client/editor/src/screens/EventWindow/EventTable.tsx +++ b/packages/client/editor/src/screens/EventWindow/EventTable.tsx @@ -2,7 +2,7 @@ // Import statements kept as-is import { TableComponent } from 'client/core' import { API_ROOT_URL } from 'shared/config' -import { useFeathers } from 'client/core' +import { useFeathers } from '@magickml/providers' import { Delete, MoreHoriz, Refresh } from '@mui/icons-material' import { Button, @@ -330,9 +330,8 @@ function EventTable({ events, updateCallback }) {
{ const pubSub = usePubSub() const pluginComponents = [] - ;(pluginManager as ClientPluginManager) - .getGroupedClientRoutes() - .forEach(plugin => { - plugin.routes.map(route => { - pluginComponents.push({ - name: route.path.charAt(1).toUpperCase() + route.path.slice(2), - component: route.component, + ; (pluginManager as ClientPluginManager) + .getGroupedClientRoutes() + .forEach(plugin => { + plugin.routes.map(route => { + pluginComponents.push({ + name: route.path.charAt(1).toUpperCase() + route.path.slice(2), + component: route.component, + }) }) }) - }) // Subscribe to open tab events useEffect(() => { diff --git a/packages/client/editor/src/screens/MagickV2/panels/fileDrawer.tsx b/packages/client/editor/src/screens/MagickV2/panels/fileDrawer.tsx index 1bca021cfb..7bd355dcfd 100644 --- a/packages/client/editor/src/screens/MagickV2/panels/fileDrawer.tsx +++ b/packages/client/editor/src/screens/MagickV2/panels/fileDrawer.tsx @@ -1,4 +1,5 @@ -import { NewSidebar, TreeDataProvider, usePubSub } from 'client/core' +import { NewSidebar } from 'client/core' +import { TreeDataProvider, usePubSub } from '@magickml/providers' import { IGridviewPanelProps } from 'dockview' import { useEffect, useState } from 'react' import { useHotkeys } from 'react-hotkeys-hook' diff --git a/packages/client/editor/src/screens/MagickV2/workspaces/composer.tsx b/packages/client/editor/src/screens/MagickV2/workspaces/composer.tsx index 4e018e3f68..a4a968d85f 100644 --- a/packages/client/editor/src/screens/MagickV2/workspaces/composer.tsx +++ b/packages/client/editor/src/screens/MagickV2/workspaces/composer.tsx @@ -1,4 +1,4 @@ -import { useConfig, useFeathers, usePubSub } from 'client/core' +import { useConfig, useFeathers, usePubSub } from '@magickml/providers' import { DockviewApi, DockviewReact, diff --git a/packages/client/editor/src/screens/RequestWindow/RequestTable.tsx b/packages/client/editor/src/screens/RequestWindow/RequestTable.tsx index 6ec6333bc6..d7ab3f2bc9 100644 --- a/packages/client/editor/src/screens/RequestWindow/RequestTable.tsx +++ b/packages/client/editor/src/screens/RequestWindow/RequestTable.tsx @@ -22,7 +22,8 @@ import { import { useSelector } from 'react-redux' import styles from './index.module.scss' import { Delete, Refresh, MoreHoriz } from '@mui/icons-material' -import { TableComponent, useFeathers } from 'client/core' +import { TableComponent } from 'client/core' +import { useFeathers } from '@magickml/providers' import { DocumentData, columns } from './requests' import { useSnackbar } from 'notistack' @@ -356,9 +357,8 @@ function RequestTable({ requests, updateCallback }) {