diff --git a/apps/agent/package.json b/apps/agent/package.json
index e16b6ce756..f74ff474f4 100644
--- a/apps/agent/package.json
+++ b/apps/agent/package.json
@@ -29,7 +29,7 @@
},
"dependencies": {
"knex": "^2.4.2",
- "@magickml/core": "file:../../dist/packages/shared/core",
+ "shared/core": "file:../../dist/packages/shared/core",
"@magickml/server-core": "file:../../dist/packages/server-core"
}
}
diff --git a/apps/docs/docs/developer-guides/Package Overview.md b/apps/docs/docs/developer-guides/Package Overview.md
index b47c5fbb75..2d35c5f240 100644
--- a/apps/docs/docs/developer-guides/Package Overview.md
+++ b/apps/docs/docs/developer-guides/Package Overview.md
@@ -8,37 +8,49 @@ sidebar_position: 1
# Package Overview
## Apps
+
### Client
+
@magickml/client (./apps/client)
Frontend application. Everything the user sees in Magick IDE is exposed through the client, although most of the code lives in client-core and editor packages, as well as engine. Thin, mostly contains build settings and entrypoint.
### Server
+
@magickml/server (./apps/server)
Backend server application. Depends on server-core and engine. Thin, mostly contains startup code and configuration for the server. Provides an API which the client talks to, and runs preview spells for clients.
### Agent
+
@magickml/agent (./apps/agent)
Backend agent application. Depends on server-core and engine. Thin, startups the AgentManager and manages agents from the database. Talks directly to the database, not to the server.
### Docs
+
@magickml/docs (./apps/docs)
Documentation server build on Docusaurus.
## Shared Packages
+
### Engine
-@magickml/core (./packages/core/shared)
-Core runtime code for Magick. Contains all of the spell and spell running code, common interfaces and nodes. Available for install via [npm](https://www.npmjs.com/package/@magickml/core)
+
+shared/core (./packages/core/shared)
+Core runtime code for Magick. Contains all of the spell and spell running code, common interfaces and nodes. Available for install via [npm](https://www.npmjs.com/package/shared/core)
## Front End Packages
+
### Client Core
+
@magickml/client-core (./packages/core/client)
Frontend UI components and common code.
### Editor
+
@magickml/editor
Application code for the IDE, including windows, providers and state. Used in the client. Exports the entire Magick editor as components which can be imported whole or individually for custom routing (for example, in a Next.js frontend). Available for install via [npm](https://www.npmjs.com/package/@magickml/editor)
## Server Packages
+
### Server Core
+
@magickml/server-core (./packages/core/server)
-Contains all of the server code, imported by the server and agent apps.
\ No newline at end of file
+Contains all of the server code, imported by the server and agent apps.
diff --git a/package-lock.json b/package-lock.json
index a2018860a0..4c84d641dd 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -88,8 +88,8 @@
"date-fns": "^2.30.0",
"deep-equal": "2.2.1",
"diff-match-patch": "1.0.5",
- "discord.js": "14.11.0",
- "dockview": "^0.0.0-experimental-859723a8-20231004",
+ "discord.js": "^14.13.0",
+ "dockview": "^0.0.0-experimental-806ff2a9-20230927",
"docusaurus-plugin-typedoc": "0.19.2",
"dotenv-flow": "3.2.0",
"emoji-dictionary": "1.0.11",
diff --git a/package.json b/package.json
index 8a4347f538..ff22620662 100644
--- a/package.json
+++ b/package.json
@@ -19,18 +19,18 @@
"migrate": "nx run @magickml/server:migrate",
"lint": "npx nx run-many --all --target=lint --max-warnings=0",
"lint-fix": "npx nx run-many --all --target=lint --fix --max-warnings=0",
- "lint:engine": "npx nx lint @magickml/core --fix",
+ "lint:engine": "npx nx lint shared/core --fix",
"lint:editor": "npx nx lint @magickml/editor --fix",
"lint:server-core": "npx nx lint @magickml/server-core",
- "build": "npx nx lint @magickml/core && npx nx run-many --target=build --projects=@magickml/server,@magickml/cloud-agent-worker-app,@magickml/cloud-agent-manager-app",
+ "build": "npx nx lint shared/core && npx nx run-many --target=build --projects=@magickml/server,@magickml/cloud-agent-worker-app,@magickml/cloud-agent-manager-app",
"build-client": "npx nx build @magickml/client",
"heroku-prebuild": "npm i -g @nrwl/cli",
"build-server": "npx nx build @magickml/server",
"build-agent": "npx nx build @magickml/agent",
"build-docs": "npx nx build @magickml/docs",
- "build-engine": "npx nx build @magickml/core",
+ "build-engine": "npx nx build shared/core",
"test": "npx nx test",
- "test:core": "npx nx test @magickml/core",
+ "test:core": "npx nx test shared/core",
"nukefromorbit": "rimraf ./packages/**/node_modules && rimraf ./node_modules && rimraf ./apps/**/node_modules",
"remove": "npx nx generate @nx/workspace:remove",
"sortPackage": "npx sort-package-json",
diff --git a/packages/client/editor/src/components/Workspace.tsx b/packages/client/editor/src/components/Workspace.tsx
index 7feb8248c9..2680499419 100644
--- a/packages/client/editor/src/components/Workspace.tsx
+++ b/packages/client/editor/src/components/Workspace.tsx
@@ -94,6 +94,7 @@ const Workspace = ({ tab, pubSub }) => {
const props = {
tab,
node,
+ spellId: ''
}
const component = node.getComponent()
switch (component) {
@@ -117,7 +118,7 @@ const Workspace = ({ tab, pubSub }) => {
return (
<>
-
+
>
)
diff --git a/packages/client/editor/src/screens/DocumentWindow/DocumentTable.tsx b/packages/client/editor/src/screens/DocumentWindow/DocumentTable.tsx
index b23f4b1f57..65a98d1b61 100644
--- a/packages/client/editor/src/screens/DocumentWindow/DocumentTable.tsx
+++ b/packages/client/editor/src/screens/DocumentWindow/DocumentTable.tsx
@@ -123,7 +123,6 @@ function DocumentTable({ documents }) {
): DocumentData => {
return {
row,
- fileName,
content,
type,
projectId,
diff --git a/packages/client/feathers-redux-toolkit/tsconfig.json b/packages/client/feathers-redux-toolkit/tsconfig.json
index 28e66cbe5e..d7959e7d54 100644
--- a/packages/client/feathers-redux-toolkit/tsconfig.json
+++ b/packages/client/feathers-redux-toolkit/tsconfig.json
@@ -5,7 +5,7 @@
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
- "noPropertyAccessFromIndexSignature": true,
+ "noPropertyAccessFromIndexSignature": false,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"types": ["vitest"]
diff --git a/packages/core/server/src/services/spell-runner/spell-runner.class.ts b/packages/core/server/src/services/spell-runner/spell-runner.class.ts
index 4ec9f44950..c07251700e 100644
--- a/packages/core/server/src/services/spell-runner/spell-runner.class.ts
+++ b/packages/core/server/src/services/spell-runner/spell-runner.class.ts
@@ -1,5 +1,5 @@
// DOCUMENTED
-import { SpellInterface } from '@magickml/core'
+import { SpellInterface } from 'shared/core'
import otJson0 from 'ot-json0'
import { app } from '../../app'
import { Params } from '@feathersjs/feathers'
diff --git a/packages/plugins/anthropic/server/src/index.ts b/packages/plugins/anthropic/server/src/index.ts
index 1dc4066530..129afdc617 100644
--- a/packages/plugins/anthropic/server/src/index.ts
+++ b/packages/plugins/anthropic/server/src/index.ts
@@ -1,6 +1,6 @@
// UNDOCUMENTED
/**
- * A plugin for the @magickml/core that adds anthropic completion functionality
+ * A plugin for the shared/core that adds anthropic completion functionality
*
* @remarks
* The plugin uses handlers for text, chat and text embedding which are defined in the 'makeTextCompletion',
@@ -28,7 +28,7 @@ const completionHandlers = {
}
/**
- * A server plugin for the @magickml/core that adds anthropic completion functionality
+ * A server plugin for the shared/core that adds anthropic completion functionality
*/
const anthropicPlugin = new ServerPlugin({
name: 'anthropicPlugin',
diff --git a/packages/plugins/avatar/client/src/index.ts b/packages/plugins/avatar/client/src/index.ts
index 13229ab630..b26411b7f4 100644
--- a/packages/plugins/avatar/client/src/index.ts
+++ b/packages/plugins/avatar/client/src/index.ts
@@ -4,7 +4,7 @@ import App from './App'
/**
* This module provides an AvatarPlugin to be used
- * with the @magickml/core client-side library.
+ * with the shared/core client-side library.
* @module AvatarPlugin
*/
diff --git a/packages/plugins/database/server/src/index.ts b/packages/plugins/database/server/src/index.ts
index 350e0c13b3..224d44b98c 100644
--- a/packages/plugins/database/server/src/index.ts
+++ b/packages/plugins/database/server/src/index.ts
@@ -1,6 +1,6 @@
// DOCUMENTED
/**
- * A plugin for the @magickml/core that adds OpenAI completion functionality
+ * A plugin for the shared/core that adds OpenAI completion functionality
*
* @remarks
* The plugin uses handlers for text, chat and text embedding which are defined in the 'makeTextCompletion',
@@ -32,7 +32,7 @@ const completionHandlers = {
}
/**
- * A server plugin for the @magickml/core that adds OpenAI completion functionality
+ * A server plugin for the shared/core that adds OpenAI completion functionality
*/
const databasePlugin = new ServerPlugin({
name: 'databasePlugin',
diff --git a/packages/plugins/elevenlabs/server/src/index.ts b/packages/plugins/elevenlabs/server/src/index.ts
index 840e4d0202..8371cd838a 100644
--- a/packages/plugins/elevenlabs/server/src/index.ts
+++ b/packages/plugins/elevenlabs/server/src/index.ts
@@ -1,6 +1,6 @@
// DOCUMENTED
/**
- * A plugin for the @magickml/core that adds elevenlabs completion functionality
+ * A plugin for the shared/core that adds elevenlabs completion functionality
*
* @remarks
* The plugin uses handlers for text, chat and text embedding which are defined in the 'makeTextCompletion',
@@ -28,7 +28,7 @@ const completionHandlers = {
}
/**
- * A server plugin for the @magickml/core that adds elevenlabs completion functionality
+ * A server plugin for the shared/core that adds elevenlabs completion functionality
*/
const elevenlabsPlugin = new ServerPlugin({
name: 'elevenlabsPlugin',
diff --git a/packages/plugins/ethereum/shared/src/nodes/GetRecentTxsFromWallet.ts b/packages/plugins/ethereum/shared/src/nodes/GetRecentTxsFromWallet.ts
index 749906ac22..e496e8a861 100644
--- a/packages/plugins/ethereum/shared/src/nodes/GetRecentTxsFromWallet.ts
+++ b/packages/plugins/ethereum/shared/src/nodes/GetRecentTxsFromWallet.ts
@@ -34,7 +34,7 @@ type InputReturn =
* It belongs to the Ethereum family according to the specification in the constructor.
*
* @remarks
- * This component extends the MagickComponent class from the @magickml/core module and has an async worker method.
+ * This component extends the MagickComponent class from the shared/core module and has an async worker method.
*
* @returns a promise with a custom InputReturn type
*/
@@ -96,9 +96,9 @@ export class GetRecentTxsFromWallet extends MagickComponent<
* @remarks
* As shown before, the component expects a custom return of the InputReturn type.
*
- * @param node - Required by the worker and uses the WorkerData type from the @magickml/core module.
- * @param inputs - Required by the worker and uses the MagickWorkerInputs type from the @magickml/core module.
- * @param outputs - Required by the worker and uses the MagickWorkerOutputs type from the @magickml/core module.
+ * @param node - Required by the worker and uses the WorkerData type from the shared/core module.
+ * @param inputs - Required by the worker and uses the MagickWorkerInputs type from the shared/core module.
+ * @param outputs - Required by the worker and uses the MagickWorkerOutputs type from the shared/core module.
* @param data - A property of the worker method which defines the wallet address.
*
* @returns a promise with a custom InputReturn type
diff --git a/packages/plugins/googleai/server/src/functions/makeChatCompletion.ts b/packages/plugins/googleai/server/src/functions/makeChatCompletion.ts
index 6884330c57..fb5d3cd6b5 100644
--- a/packages/plugins/googleai/server/src/functions/makeChatCompletion.ts
+++ b/packages/plugins/googleai/server/src/functions/makeChatCompletion.ts
@@ -3,7 +3,7 @@ import { CompletionHandlerInputData, saveRequest } from 'shared/core'
import { GOOGLEAI_ENDPOINT } from '../constants'
import { trackGoogleAIUsage } from 'server/core'
import { wordCount } from './shared'
-import { DEFAULT_GOOGLEAI_API_KEY } from '@magickml/config'
+import { DEFAULT_GOOGLEAI_API_KEY } from 'shared/config'
type ChatMessage = {
author?: string
diff --git a/packages/plugins/googleai/server/src/functions/makeTextCompletion.ts b/packages/plugins/googleai/server/src/functions/makeTextCompletion.ts
index 7cb7b75ae3..a221951d6d 100644
--- a/packages/plugins/googleai/server/src/functions/makeTextCompletion.ts
+++ b/packages/plugins/googleai/server/src/functions/makeTextCompletion.ts
@@ -3,7 +3,7 @@ import { CompletionHandlerInputData, saveRequest } from 'shared/core'
import { GOOGLEAI_ENDPOINT } from '../constants'
import { trackGoogleAIUsage } from 'server/core'
import { wordCount } from './shared'
-import { DEFAULT_GOOGLEAI_API_KEY } from '@magickml/config'
+import { DEFAULT_GOOGLEAI_API_KEY } from 'shared/config'
/**
* Makes an API request to an AI text completion service.
diff --git a/packages/plugins/googleai/server/src/functions/makeTextEmbedding.ts b/packages/plugins/googleai/server/src/functions/makeTextEmbedding.ts
index 1e08313b4a..1bacf9c043 100644
--- a/packages/plugins/googleai/server/src/functions/makeTextEmbedding.ts
+++ b/packages/plugins/googleai/server/src/functions/makeTextEmbedding.ts
@@ -7,7 +7,7 @@ import {
import { GOOGLEAI_ENDPOINT } from '../constants'
import { trackGoogleAIUsage } from 'server/core'
import { wordCount } from './shared'
-import { DEFAULT_GOOGLEAI_API_KEY } from '@magickml/config'
+import { DEFAULT_GOOGLEAI_API_KEY } from 'shared/config'
/**
* A function that makes a request to create a text embedding using GoogleAI's
diff --git a/packages/plugins/googleai/server/src/index.ts b/packages/plugins/googleai/server/src/index.ts
index 3820399b5b..e10fb16e1a 100644
--- a/packages/plugins/googleai/server/src/index.ts
+++ b/packages/plugins/googleai/server/src/index.ts
@@ -1,6 +1,6 @@
// DOCUMENTED
/**
- * A plugin for the @magickml/core that adds GoogleAI completion functionality
+ * A plugin for the shared/core that adds GoogleAI completion functionality
*
* @remarks
* The plugin uses handlers for text, chat and text embedding which are defined in the 'makeTextCompletion',
@@ -34,7 +34,7 @@ const completionHandlers = {
}
/**
- * A server plugin for the @magickml/core that adds GoogleAI completion functionality
+ * A server plugin for the shared/core that adds GoogleAI completion functionality
*/
const GoogleAIPlugin = new ServerPlugin({
name: 'GoogleAIPlugin',
diff --git a/packages/plugins/localmodel/server/src/index.ts b/packages/plugins/localmodel/server/src/index.ts
index 28d1825031..0a33f03138 100644
--- a/packages/plugins/localmodel/server/src/index.ts
+++ b/packages/plugins/localmodel/server/src/index.ts
@@ -1,6 +1,6 @@
// DOCUMENTED
/**
- * A plugin for the @magickml/core that adds LocalModel completion functionality
+ * A plugin for the shared/core that adds LocalModel completion functionality
*
* @remarks
* The plugin uses handlers for text, chat and text embedding which are defined in the 'makeTextCompletion',
@@ -34,7 +34,7 @@ const completionHandlers = {
}
/**
- * A server plugin for the @magickml/core that adds local completion functionality
+ * A server plugin for the shared/core that adds local completion functionality
*/
const LocalModelPlugin = new ServerPlugin({
name: 'LocalModelPlugin',
diff --git a/packages/plugins/openai/server/src/index.ts b/packages/plugins/openai/server/src/index.ts
index 3902b84d2b..e7271b5c97 100644
--- a/packages/plugins/openai/server/src/index.ts
+++ b/packages/plugins/openai/server/src/index.ts
@@ -1,6 +1,6 @@
// DOCUMENTED
/**
- * A plugin for the @magickml/core that adds OpenAI completion functionality
+ * A plugin for the shared/core that adds OpenAI completion functionality
*
* @remarks
* The plugin uses handlers for text, chat and text embedding which are defined in the 'makeTextCompletion',
@@ -36,7 +36,7 @@ const completionHandlers = {
}
/**
- * A server plugin for the @magickml/core that adds OpenAI completion functionality
+ * A server plugin for the shared/core that adds OpenAI completion functionality
*/
const OpenAIPlugin = new ServerPlugin({
name: 'OpenAIPlugin',
diff --git a/packages/server/core/src/auth/cloudAuthentication.ts b/packages/server/core/src/auth/cloudAuthentication.ts
index 99bf4212a0..d61d1c4967 100644
--- a/packages/server/core/src/auth/cloudAuthentication.ts
+++ b/packages/server/core/src/auth/cloudAuthentication.ts
@@ -34,7 +34,7 @@ export class CloudJwtService extends AuthenticationService {
* @param params - The parameters required for authentication
* @returns payload with permissions if exists
*/
- async getPayload(authResult, params) {
+ override async getPayload(authResult, params) {
// Call original `getPayload` first
const payload = await super.getPayload(authResult, params)
const { user } = authResult
@@ -54,7 +54,7 @@ export class CloudJwtService extends AuthenticationService {
* @param secretOverride - Override the secret used for encryption
* @returns decrypted token payload
*/
- async verifyAccessToken(
+ override async verifyAccessToken(
token: string,
_optsOverride,
secretOverride?: string
@@ -86,7 +86,7 @@ export class CloudJwtService extends AuthenticationService {
* @param allowed - Allowed authentication strategies
* @returns Authentication result
*/
- async authenticate(
+ override async authenticate(
authentication: AuthenticationRequest,
params: AuthenticationParams,
...allowed: string[]
diff --git a/packages/server/core/src/communication/PubSub/Redis.ts b/packages/server/core/src/communication/PubSub/Redis.ts
index 1797d1cff2..1a24aa0725 100644
--- a/packages/server/core/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 '../../app';
+import { app } from '../../app'
export class RedisPubSubWrapper extends PubSub {
pubsub: RedisPubSub
@@ -11,15 +11,18 @@ export class RedisPubSubWrapper extends PubSub {
this.pubsub = app.get('pubsub')
}
- async publish(channel: string, message: string): Promise {
+ override async publish(channel: string, message: string): Promise {
return await this.pubsub.publish(channel, message)
}
- async subscribe(channel: string, callback: Function): Promise {
+ override async subscribe(channel: string, callback: Function): Promise {
return await this.pubsub.subscribe(channel, callback)
}
- async patternSubscribe(pattern: string, callback: Function): Promise {
+ override async patternSubscribe(
+ pattern: string,
+ callback: Function
+ ): Promise {
return await this.pubsub.patternSubscribe(pattern, callback)
}
}
diff --git a/packages/server/core/src/communication/Workers/BullMQ.ts b/packages/server/core/src/communication/Workers/BullMQ.ts
index 7619b8a7d7..6f99541bb3 100644
--- a/packages/server/core/src/communication/Workers/BullMQ.ts
+++ b/packages/server/core/src/communication/Workers/BullMQ.ts
@@ -9,7 +9,7 @@ export class BullMQWorker extends Worker {
super()
}
- initialize(
+ override initialize(
queueName: string,
callback: (job: Job) => Promise
): void {
diff --git a/packages/server/core/src/config/types.ts b/packages/server/core/src/config/types.ts
index fe76b24eae..7f653869cf 100644
--- a/packages/server/core/src/config/types.ts
+++ b/packages/server/core/src/config/types.ts
@@ -1,5 +1,5 @@
// DOCUMENTED
-// Import the required types from '@magickml/core' and rename them to avoid naming conflicts.
+// Import the required types from 'shared/core' and rename them to avoid naming conflicts.
import {
Route as MagickRoute,
Middleware as MagickMiddleware,
@@ -8,21 +8,21 @@ import {
} from 'shared/core'
/**
- * Type alias for Middleware imported from '@magickml/core'.
+ * Type alias for Middleware imported from 'shared/core'.
*/
export type Middleware = MagickMiddleware
/**
- * Type alias for Method imported from '@magickml/core'.
+ * Type alias for Method imported from 'shared/core'.
*/
export type Method = MagickMethod
/**
- * Type alias for Handler imported from '@magickml/core'.
+ * Type alias for Handler imported from 'shared/core'.
*/
export type Handler = MagickHandler
/**
- * Type alias for Route imported from '@magickml/core'.
+ * Type alias for Route imported from 'shared/core'.
*/
export type Route = MagickRoute
diff --git a/packages/server/core/src/lib/feathersPermissions.ts b/packages/server/core/src/lib/feathersPermissions.ts
new file mode 100644
index 0000000000..3103479ab9
--- /dev/null
+++ b/packages/server/core/src/lib/feathersPermissions.ts
@@ -0,0 +1,97 @@
+import { Forbidden } from '@feathersjs/errors'
+import { HookContext } from '@feathersjs/feathers'
+import get from 'lodash/get'
+import createDebug from 'debug'
+
+const debug = createDebug('feathers-permissions')
+
+type Options = {
+ entity?: string
+ field?: string
+ error?: boolean
+ permissions?: string[] | Function
+ roles?: string[] | Function
+}
+
+export function checkPermissions(options: Options = {}) {
+ const {
+ entity: entityName = 'user',
+ field = 'permissions',
+ error = true,
+ } = options
+ const permissions = options.permissions || options.roles
+
+ if (!Array.isArray(permissions) && typeof permissions !== 'function') {
+ throw new Error(
+ "'roles' option for feathers-permissions hook must be an array or a function"
+ )
+ }
+
+ return async (context: HookContext) => {
+ const { params, type, method } = context
+ const currentPermissions = await Promise.resolve(
+ typeof permissions === 'function' ? permissions(context) : permissions
+ )
+
+ if (type !== 'before') {
+ throw new Error(
+ "The feathers-permissions hook should only be used as a 'before' hook."
+ )
+ }
+
+ debug('Running checkPermissions hook with options:', {
+ entityName,
+ field,
+ roles: permissions,
+ })
+
+ const entity = context.params[entityName]
+
+ if (!entity) {
+ debug(
+ `hook.params.${entityName} does not exist. If you were expecting it to be defined check your hook order and your idField options in your auth config.`
+ )
+
+ if (params.provider) {
+ throw new Forbidden(
+ 'You do not have the correct permissions (invalid permission entity).'
+ )
+ }
+
+ return context
+ }
+
+ // Normalize permissions. They can either be a comma separated string or an array.
+ const value = get(entity, field, [])
+ const permissionList =
+ typeof value === 'string'
+ ? value.split(',').map(current => current.trim())
+ : value
+ const requiredPermissions = ['*', `*:${method}`]
+
+ currentPermissions.forEach(permission =>
+ requiredPermissions.push(
+ `${permission}`,
+ `${permission}:*`,
+ `${permission}:${method}`
+ )
+ )
+
+ debug('Required Permissions', requiredPermissions)
+
+ const permitted = permissionList.some(current =>
+ requiredPermissions.includes(current)
+ )
+
+ if (error !== false && !permitted) {
+ throw new Forbidden('You do not have the correct permissions.')
+ }
+
+ context.params = {
+ permitted,
+ ...params,
+ }
+
+ return context
+ }
+}
diff --git a/packages/server/core/src/services/agentImage/agentImage.class.ts b/packages/server/core/src/services/agentImage/agentImage.class.ts
index 22aa7470bc..6c5ea5408f 100644
--- a/packages/server/core/src/services/agentImage/agentImage.class.ts
+++ b/packages/server/core/src/services/agentImage/agentImage.class.ts
@@ -7,7 +7,7 @@ import {
AWS_BUCKET_ENDPOINT,
} from 'shared/config'
-import { getLogger } from '@magickml/core'
+import { getLogger } from 'shared/core'
type AgentImageData = {
image: string
diff --git a/packages/server/core/src/services/agents/agents.class.ts b/packages/server/core/src/services/agents/agents.class.ts
index 9e54bd7ab4..a791d733ea 100644
--- a/packages/server/core/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 '../../app';
+import { app } from '../../app'
import md5 from 'md5'
import type { Application } from '../../declarations'
import type { Agent, AgentData, AgentPatch, AgentQuery } from './agents.schema'
@@ -111,7 +111,7 @@ export class AgentService<
return true
}
- async create(
+ override async create(
data: AgentData | AgentData[] | any
): Promise {
// ADDING REST API KEY TO AGENT's DATA
diff --git a/packages/server/core/src/services/documents/documents.class.ts b/packages/server/core/src/services/documents/documents.class.ts
index 660b50f5aa..6a035396c1 100644
--- a/packages/server/core/src/services/documents/documents.class.ts
+++ b/packages/server/core/src/services/documents/documents.class.ts
@@ -94,7 +94,7 @@ export class DocumentService<
* @param id {string} The document ID to remove
* @return {Promise} The removed document
*/
- async remove(id: any, params): Promise {
+ override async remove(id: any, params): Promise {
const db = app.get('dbClient')
if (!id && params.projectId) {
@@ -118,7 +118,7 @@ export class DocumentService<
* @param params {ServiceParams} Optional parameters for the find operation
* @return {Promise} The found documents
*/
- async find(params?: ServiceParams): Promise {
+ override async find(params?: ServiceParams): Promise {
const db = app.get('dbClient')
if (
(params && params?.query?.embedding) ||
diff --git a/packages/server/core/src/vectordb.ts b/packages/server/core/src/vectordb.ts
index a61eb60ac9..a44a56d611 100644
--- a/packages/server/core/src/vectordb.ts
+++ b/packages/server/core/src/vectordb.ts
@@ -39,7 +39,10 @@ export class PostgresVectorStoreCustom extends SupabaseVectorStore {
* @param {any[]} [vector=''] - Precomputed vector (optional)
* @returns {Promise}
*/
- async addDocuments(documents: Document[], vector: any = ''): Promise {
+ override async addDocuments(
+ documents: Document[],
+ vector: any = ''
+ ): Promise {
const texts = documents.map(({ pageContent }) => pageContent)
if (vector != '') {
return this.addVectors(vector, documents)
@@ -56,7 +59,10 @@ export class PostgresVectorStoreCustom extends SupabaseVectorStore {
* @param {Document[]} documents - Array of documents
* @returns {Promise}
*/
- async addVectors(vectors: number[][], documents: Document[]): Promise {
+ override async addVectors(
+ vectors: number[][],
+ documents: Document[]
+ ): Promise {
const res = await this.client(this.tableName).insert(documents)
if (res.error) {
throw new Error(
diff --git a/packages/shared/core/src/dataControls/SwitchControl.ts b/packages/shared/core/src/dataControls/SwitchControl.ts
index 181a07b4a1..29a9f1f294 100644
--- a/packages/shared/core/src/dataControls/SwitchControl.ts
+++ b/packages/shared/core/src/dataControls/SwitchControl.ts
@@ -57,7 +57,7 @@ export class SwitchControl extends DataControl {
* The event handler for data.
* @memberof SwitchControl
*/
- onData = () => {
+ override onData = () => {
return
}
}
diff --git a/packages/shared/core/src/engine.ts b/packages/shared/core/src/engine.ts
index 131a2af60b..8cb0b84b49 100644
--- a/packages/shared/core/src/engine.ts
+++ b/packages/shared/core/src/engine.ts
@@ -163,7 +163,7 @@ export abstract class MagickComponent<
_task: Task
cache: UnknownData
editor: MagickEditor | null = null
- data: unknown = {}
+ override data: unknown = {}
category: string
info: string
display?: boolean
@@ -177,7 +177,7 @@ export abstract class MagickComponent<
contextMenuName: string | undefined
workspaceType: 'spell' | null | undefined
displayName: string | undefined
- engine: MagickEngine | null = null
+ override engine: MagickEngine | null = null
logger = getLogger()
constructor(name: string, task: TaskOptions, category: string, info: string) {
diff --git a/packages/shared/core/src/plugins/cachePlugin/RunLastArguments.tsx b/packages/shared/core/src/plugins/cachePlugin/RunLastArguments.tsx
index 87d80c1adc..115bb6b527 100644
--- a/packages/shared/core/src/plugins/cachePlugin/RunLastArguments.tsx
+++ b/packages/shared/core/src/plugins/cachePlugin/RunLastArguments.tsx
@@ -59,7 +59,7 @@ export class RunButtonControl extends Control {
* Returns the parent node object.
* @returns {Node} - The parent node instance.
*/
- getNode() {
+ override getNode() {
return this.parent as any
}
}
diff --git a/packages/shared/core/src/plugins/modulePlugin/module-manager.ts b/packages/shared/core/src/plugins/modulePlugin/module-manager.ts
index 994715891a..5a79f5275d 100644
--- a/packages/shared/core/src/plugins/modulePlugin/module-manager.ts
+++ b/packages/shared/core/src/plugins/modulePlugin/module-manager.ts
@@ -144,6 +144,7 @@ export class ModuleManager {
secrets: context.module.secrets,
publicVariables: context.module.publicVariables,
app: context.module.app,
+ sessionId: context.module.sessionId,
})
await engine?.process(data, null, Object.assign({}, context, { module }))
diff --git a/packages/shared/core/src/spellManager/runSpell.ts b/packages/shared/core/src/spellManager/runSpell.ts
deleted file mode 100644
index c71618fb0f..0000000000
--- a/packages/shared/core/src/spellManager/runSpell.ts
+++ /dev/null
@@ -1,129 +0,0 @@
-import { extractNodes, initSharedEngine, MagickEngine } from '../engine'
-import { getNodes } from '../nodes'
-import { Module } from '../plugins/modulePlugin/module'
-import {
- GraphData,
- MagickNode,
- ModuleComponent,
- SpellInterface,
- WorkerData,
-} from '../types'
-import { RunComponentArgs } from './SpellRunner'
-
-class RunSpell {
- engine: MagickEngine
- currentSpell!: SpellInterface
- module: Module
-
- constructor() {
- // Initialize the engine
- this.engine = initSharedEngine({
- name: 'demo@0.1.0',
- components: getNodes(),
- server: true,
- }) as MagickEngine
- // Set up the module to interface with the runtime processes
- this.module = new Module()
- }
-
- // getter method for all triggers ins of the loaded spell
- get triggerIns() {
- return this.engine.moduleManager.triggerIns
- }
-
- get context() {
- return {
- module: this.module,
- projectId: this.currentSpell.projectId,
- }
- }
-
- private _getComponent(componentName: string) {
- return this.engine.components.get(componentName)
- }
-
- private _formatOutputs(rawOutputs: Record) {
- const outputs = {} as Record
- const graph = this.currentSpell.graph
-
- Object.values(graph.nodes as MagickNode)
- .filter(node => {
- return node.name.includes('Output')
- })
- .forEach(node => {
- outputs[node.data.name as string] =
- rawOutputs[node.data.socketKey as string]
- })
-
- return outputs
- }
-
- /**
- * temporary method until we have a better way to target specific nodes
- * this is basically just using a "Default" trigger in
- * and does not support multipel triggers in to a spell yet
- */
- private _getFirstNodeTrigger() {
- const extractedNodes = extractNodes(
- this.currentSpell.graph.nodes,
- this.triggerIns
- )
- return extractedNodes[0]
- }
-
- private _resetTasks() {
- Object.values(this.engine.getTasks()).forEach(t => t.reset())
- }
-
- getOutputs() {
- const rawOutputs = {}
- this.module.write(rawOutputs)
- return this._formatOutputs(rawOutputs)
- }
-
- loadSpell(spell: SpellInterface) {
- this.currentSpell = spell
-
- // We process the graph for the new spell which will set up all the task workers
- this.engine.process(spell.graph as GraphData, null, this.context)
- }
-
- /**
- * Main spell runner. Processes inputs, gets the right component that starts the
- * running. Would be even better iof we just took a node identifier, got its
- * component, and ran the one triggered rather than this slightly hacky hard coded
- * method.
- */
- async runComponent({
- inputs,
- componentName,
- secrets,
- agent,
- publicVariables,
- app,
- }: RunComponentArgs) {
- // ensaure we run from a clean sloate
- this._resetTasks()
-
- // laod the inputs into module memory
- this.module.read({ inputs, secrets, publicVariables, app })
-
- const component = this._getComponent(componentName as string) as
- | ModuleComponent
- | undefined
-
- const triggeredNode = this._getFirstNodeTrigger() as WorkerData
-
- if (!component) {
- throw new Error(`Component ${componentName} not found`)
- }
-
- // this running is where the main "work" happens.
- // I do wonder whether we could make this even more elegant by having the node
- // 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, inputs, this.engine)
- }
-}
-
-export default RunSpell
diff --git a/packages/shared/core/src/utils/SpellError.ts b/packages/shared/core/src/utils/SpellError.ts
index fc6c39ecf1..ead0b6d444 100644
--- a/packages/shared/core/src/utils/SpellError.ts
+++ b/packages/shared/core/src/utils/SpellError.ts
@@ -19,7 +19,7 @@ export class SpellError extends Error {
/** The HTTP status code of the error */
public status: number
/** The error message */
- public message: string
+ public override message: string
/** Additional details about the error */
public details?: string
diff --git a/tsconfig.base.json b/tsconfig.base.json
index 13a5014809..5a2cdd48ca 100644
--- a/tsconfig.base.json
+++ b/tsconfig.base.json
@@ -17,6 +17,7 @@
"skipDefaultLibCheck": true,
"baseUrl": ".",
"esModuleInterop": true,
+ "noPropertyAccessFromIndexSignature": false,
"strict": false,
"typeRoots": [
"packages/@types",