Skip to content

SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.

update build scripts

Forhad Hosainc0f639aed7c6
diff --git a/.vscode/launch.json b/.vscode/launch.json
index 4421e84c..664d395e 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -1,6 +1,6 @@
{
"version": "0.2.0",
- "configurations": [
+ "configurations": [
{
"type": "node",
"request": "launch",
@@ -25,41 +25,35 @@
"outFiles": ["${workspaceFolder}/packages/middleware/dist/**/*.js"],
"sourceMaps": true,
"env": {},
-
+
"outputCapture": "std"
},
- {
- "type": "node",
- "name": "Run standalone .ts script using node -r esbuild-register",
- "request": "launch",
- "skipFiles": ["<node_internals>/**"],
- "runtimeArgs": ["-r", "esbuild-register"],
- "program": "${file}",
- "sourceMaps": true,
- "cwd": "${workspaceFolder}",
- "console": "integratedTerminal",
- "internalConsoleOptions": "neverOpen"
- },
{
"name": "Launch Runtime Server",
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/packages/runtime/dist/index.cjs",
- "preLaunchTask": "runtime: build:dev",
+ "preLaunchTask": "runtime: build",
"skipFiles": ["<node_internals>/**"],
"sourceMaps": true,
"outFiles": ["${workspaceFolder}/packages/runtime/dist/**/*.js"],
- "cwd": "${workspaceFolder}/packages/runtime"
+ "cwd": "${workspaceFolder}/packages/runtime",
+ "env": {
+ "NODE_ENV": "development"
+ },
+ "console": "integratedTerminal"
},
{
- "name": "Launch Runtime Server (No Build)",
"type": "node",
+ "name": "Run standalone .ts script using node -r esbuild-register",
"request": "launch",
- "program": "${workspaceFolder}/packages/runtime/dist/index.cjs",
"skipFiles": ["<node_internals>/**"],
+ "runtimeArgs": ["-r", "esbuild-register"],
+ "program": "${file}",
"sourceMaps": true,
- "outFiles": ["${workspaceFolder}/packages/runtime/dist/**/*.js"],
- "cwd": "${workspaceFolder}/packages/runtime"
+ "cwd": "${workspaceFolder}",
+ "console": "integratedTerminal",
+ "internalConsoleOptions": "neverOpen"
}
]
}
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
index 89779046..ed44b927 100644
--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -45,12 +45,41 @@
"dependsOn": ["build-app-backend", "start-frontend-processes"]
},
{
- "label": "runtime: build:dev",
+ "label": "runtime: build",
"type": "npm",
- "script": "build:dev",
+ "script": "build",
"path": "packages/runtime/",
"group": "build",
- "problemMatcher": []
+ "problemMatcher": [],
+ "detail": "Build runtime server for production"
+ },
+ {
+ "label": "runtime: clean",
+ "type": "npm",
+ "script": "clean",
+ "path": "packages/runtime/",
+ "group": "build",
+ "problemMatcher": [],
+ "detail": "Clean runtime build directory"
+ },
+ {
+ "label": "runtime: watch",
+ "type": "npm",
+ "script": "watch",
+ "path": "packages/runtime/",
+ "group": "build",
+ "isBackground": true,
+ "problemMatcher": {
+ "pattern": {
+ "regexp": "^$"
+ },
+ "background": {
+ "activeOnStart": true,
+ "beginsPattern": "rollup",
+ "endsPattern": "waiting for changes"
+ }
+ },
+ "detail": "Build runtime and watch for changes"
}
]
}
diff --git a/packages/runtime/.eslintrc.json b/packages/runtime/.eslintrc.json
new file mode 100644
index 00000000..eec085fd
--- /dev/null
+++ b/packages/runtime/.eslintrc.json
@@ -0,0 +1,63 @@
+{
+ "env": {
+ "node": true,
+ "es2021": true,
+ "jest": true
+ },
+ "extends": ["airbnb-base", "prettier", "plugin:@typescript-eslint/recommended", "plugin:prettier/recommended"],
+ "globals": {
+ "NodeJS": true
+ },
+ "parser": "@typescript-eslint/parser",
+ "parserOptions": {
+ "ecmaVersion": 12,
+ "sourceType": "module"
+ },
+ "plugins": ["@typescript-eslint", "import"],
+
+ "rules": {
+ "import/prefer-default-export": "off",
+ "class-methods-use-this": "off",
+ "@typescript-eslint/no-non-null-assertion": "off",
+ "no-underscore-dangle": "off",
+ "import/no-relative-packages": "off",
+ "import/no-extraneous-dependencies": "off",
+ "consistent-return": "off",
+ "no-plusplus": "off",
+ "eqeqeq": "off",
+ "import/extensions": "off",
+ "import/no-unresolved": "off",
+ "lines-between-class-members": "off",
+ "no-continue": "off",
+ "no-use-before-define": "off",
+ "no-restricted-syntax": "off",
+ "no-unused-vars": "off",
+ "@typescript-eslint/ban-types": "off",
+ "no-await-in-loop": "off",
+ "no-else-return": "off",
+ "no-nested-ternary": "off",
+ "no-extra-boolean-cast": "off",
+ "@typescript-eslint/no-unused-vars": [
+ "warn", // or "error"
+ {
+ "argsIgnorePattern": "^_",
+ "varsIgnorePattern": "^_",
+ "caughtErrorsIgnorePattern": "^_"
+ }
+ ],
+ "@typescript-eslint/no-explicit-any": ["off"],
+ "import/order": ["off"],
+ "@typescript-eslint/ban-ts-comment": ["off"],
+ "prefer-destructuring": ["off"],
+ "no-shadow": ["off"]
+ },
+ "settings": {
+ "import/resolver": {
+ "node": {
+ "paths": ["src"],
+ "extensions": [".js", ".ts", ".d.ts", ".tsx"]
+ }
+ }
+ },
+ "ignorePatterns": ["*.d.ts"]
+}
diff --git a/packages/runtime/.lintstagedrc.json b/packages/runtime/.lintstagedrc.json
new file mode 100644
index 00000000..fe275acd
--- /dev/null
+++ b/packages/runtime/.lintstagedrc.json
@@ -0,0 +1,3 @@
+{
+ "*.ts": "eslint"
+}
diff --git a/packages/runtime/.prettierrc.json b/packages/runtime/.prettierrc.json
new file mode 100644
index 00000000..313081be
--- /dev/null
+++ b/packages/runtime/.prettierrc.json
@@ -0,0 +1,8 @@
+{
+ "printWidth": 150,
+ "singleQuote": true,
+ "trailingComma": "all",
+ "bracketSpacing": true,
+ "arrowParens": "avoid",
+ "endOfLine": "auto"
+}
diff --git a/packages/runtime/nodemon.json b/packages/runtime/nodemon.json
new file mode 100644
index 00000000..eeb59d6a
--- /dev/null
+++ b/packages/runtime/nodemon.json
@@ -0,0 +1,15 @@
+{
+ "watch": ["src", "package.json"],
+ "ext": "ts,js,json",
+ "ignore": [
+ "src/**/*.test.ts",
+ "src/**/*.spec.ts",
+ "tests/**/*",
+ "dist/**/*",
+ "node_modules/**/*"
+ ],
+ "exec": "npm run build:dev && npm run start:dev",
+ "env": {
+ "NODE_ENV": "development"
+ }
+}
diff --git a/packages/runtime/package.json b/packages/runtime/package.json
index 65b1e8de..1efb543c 100644
--- a/packages/runtime/package.json
+++ b/packages/runtime/package.json
@@ -2,16 +2,21 @@
"name": "runtime-server",
"version": "2.0.0",
"description": "SmythOS Runtime Server (Agent, Debugger, Embodiment)",
- "main": "rollup.config.js",
+ "main": "dist/index.cjs",
"type": "module",
"scripts": {
- "dev": "npm run build:dev && node ./dist/index.cjs",
- "build:dev": "cross-env NODE_OPTIONS='--max-old-space-size=4096' BUILD=dev FORMAT=cjs rollup -c ./rollup.config.js",
- "start": "node ./dist/index.cjs",
+ "dev": "nodemon",
+ "build": "cross-env NODE_ENV=production NODE_OPTIONS='--max-old-space-size=4096' rollup -c",
+ "start:prod": "cross-env NODE_ENV=production node ./dist/index.cjs",
"test": "cross-env TEST_ENV=true vitest --reporter verbose",
- "prepare:staging": "npm version patch --no-git-tag-version",
- "prepare:production": "npm version minor -f",
- "deploy:dev": "git tag -f dev-deploy && git push origin dev-deploy -f"
+ "clean": "rm -rf dist",
+ "lint": "eslint --ext .ts src/",
+ "lint-fix": "eslint --ext .ts src/ --fix",
+ "ts-error-scan": "tsc --noEmit",
+ "format": "prettier --write \"**/*.ts\"",
+ "prettier:format": "prettier --write **/*.{js,jsx,ts,tsx,json,css,md}",
+ "lint-staged": "lint-staged",
+ "bump": "pnpm version patch"
},
"author": "Alaa-eddine KADDOURI",
"devDependencies": {
@@ -23,7 +28,19 @@
"@types/node": "^22.9.0",
"@types/swagger-ui-express": "^4.1.7",
"@types/uuid": "^9.0.8",
+ "@typescript-eslint/eslint-plugin": "^5.59.0",
"cross-env": "^7.0.3",
+ "eslint": "^8.38.0",
+ "eslint-config-airbnb-base": "^15.0.0",
+ "eslint-config-prettier": "^8.8.0",
+ "eslint-config-standard-with-typescript": "^34.0.1",
+ "eslint-plugin-import": "^2.27.5",
+ "eslint-plugin-prettier": "^4.2.1",
+ "eslint-plugin-promise": "^6.1.1",
+ "knip": "^5.61.3",
+ "lint-staged": "^13.2.1",
+ "nodemon": "^3.0.2",
+ "prettier": "^2.8.7",
"pkg": "^5.8.1",
"rollup": "^2.79.2",
"rollup-plugin-copy": "^3.5.0",
diff --git a/packages/runtime/rollup.config.js b/packages/runtime/rollup.config.js
index 232c686b..535bbbd8 100644
--- a/packages/runtime/rollup.config.js
+++ b/packages/runtime/rollup.config.js
@@ -10,8 +10,8 @@ import { terser } from "rollup-plugin-terser";
import typescriptPaths from "rollup-plugin-typescript-paths";
import pkg from "./package.json";
-const isProduction = process.env.BUILD === "prod";
-const format = process.env.FORMAT || "es";
+const isProduction = process.env.NODE_ENV === "production";
+const isDevelopment = process.env.NODE_ENV === "development";
const banner = `/**
* ${pkg.name} v${pkg.version}
@@ -19,184 +19,58 @@ const banner = `/**
*/
`;
-const devCJSConfig = {
+// Base plugins for all configurations
+const basePlugins = [
+ resolve({
+ browser: false,
+ preferBuiltins: true,
+ mainFields: ["module", "main"],
+ extensions: [".js", ".ts", ".json"],
+ }),
+ commonjs(),
+ json(),
+ filenameReplacePlugin(),
+ typescriptPaths({
+ tsconfig: "./tsconfig.json",
+ preserveExtensions: true,
+ nonRelative: false,
+ }),
+ sourcemaps(),
+];
+
+// Development configuration
+const devConfig = {
input: "./src/index.ts",
output: {
- file: "./dist/index.cjs", // CommonJS output
- format: "cjs", // Specify the CommonJS format
+ file: "./dist/index.cjs",
+ format: "cjs",
sourcemap: true,
- inlineDynamicImports: true, // Inline all dynamic imports into one file
+ inlineDynamicImports: true,
banner,
},
plugins: [
- resolve({
- browser: false, // Allow bundling of modules from `node_modules`
- preferBuiltins: true, // Prefer Node.js built-in modules
- mainFields: ["module", "main"], // Ensure Node.js package resolution
- extensions: [".js", ".ts", ".json"], // Resolve these extensions
- }),
- commonjs(), // Convert CommonJS modules to ES6 for Rollup to bundle them
- json(),
- filenameReplacePlugin(),
- typescriptPaths({
- tsconfig: "./tsconfig.json",
- preserveExtensions: true,
- nonRelative: false,
- }),
+ ...basePlugins,
esbuild({
sourceMap: true,
minify: false,
treeShaking: false,
target: "node18",
}),
- sourcemaps(),
copy({
targets: [
{ src: "src/data/*", dest: "dist/data" },
{ src: "src/static/*", dest: "dist/static" },
- // swagger-ui-dist package
{
- src: "node_modules/swagger-ui-dist/*.{js,css,html,.js.map}",
+ src: "node_modules/swagger-ui-dist/*.{js,css,html,js.map}",
dest: "dist",
},
],
}),
],
};
-const devESBundleConfig = {
- input: "./src/index.ts",
- output: {
- format: "es",
- sourcemap: true,
-
- //Comment this line and uncomment the following lines if you need ES bundle
- //file: 'distributions/agent-builder/dist/agent-builder.dev.js',
- dir: "dist",
- inlineDynamicImports: true,
- entryFileNames: "index.bundle.js",
- banner,
- },
- plugins: [
- //Uncomment the following lines if you need ES Bundle
- resolve({
- browser: false,
- preferBuiltins: true,
- }),
- commonjs(),
- json(),
- filenameReplacePlugin(),
- typescriptPaths({
- tsconfig: "./tsconfig.json",
- preserveExtensions: true,
- nonRelative: false,
- }),
- esbuild({
- sourceMap: true,
- minify: false,
- treeShaking: false,
- }),
-
- // typescript({
- // tsconfig: './tsconfig.json',
- // clean: true,
- // include: ['src/**/*.ts', 'distributions/AWS/**/*.ts'],
- // exclude: ['node_modules'],
- // }),
-
- sourcemaps(),
-
- copy({
- targets: [
- { src: "src/data/*", dest: "dist/data" },
- /*{ src: 'src/static/*', dest: 'dist/static' },*/
- ],
- }),
- ],
-};
-
-const devESConfig = {
- input: "./src/index.ts",
- output: {
- format: "es",
- sourcemap: true,
-
- //Comment this line and uncomment the following lines if you need ES bundle
- file: "./dist/index.js",
- banner,
- },
- plugins: [
- json(),
- filenameReplacePlugin(),
- typescriptPaths({
- tsconfig: "./tsconfig.json",
- preserveExtensions: true,
- nonRelative: false,
- }),
- esbuild({
- sourceMap: true,
- minify: false,
- treeShaking: false,
- }),
-
- // typescript({
- // tsconfig: './tsconfig.json',
- // clean: true,
- // include: ['src/**/*.ts', 'distributions/AWS/**/*.ts'],
- // exclude: ['node_modules'],
- // }),
-
- sourcemaps(),
-
- copy({
- targets: [
- { src: "src/data/*", dest: "dist/data" },
- /*{ src: 'src/static/*', dest: 'dist/static' },*/
- ],
- }),
- ],
-};
-const prodESConfig = {
- input: "./src/index.ts",
- output: {
- file: "./dist/index.js",
- format: "es",
- sourcemap: true,
- banner,
- },
- plugins: [
- json(),
- typescriptPaths({
- tsconfig: "./tsconfig.json", // Ensure this points to your tsconfig file
- preserveExtensions: true,
- nonRelative: false,
- }),
- filenameReplacePlugin(),
- esbuild({
- sourceMap: true,
- minify: true,
- treeShaking: true,
- }),
- // typescript({
- // tsconfig: './tsconfig.json',
- // clean: true,
- // include: ['src/**/*.ts', 'distributions/AWS/**/*.ts'],
- // exclude: ['node_modules'],
- // }),
-
- sourcemaps(),
- terser(),
-
- copy({
- targets: [
- { src: "src/data/*", dest: "dist/data" },
- /*{ src: 'src/static/*', dest: 'dist/static' },*/
- ],
- }),
- ],
-};
-
-const prodCJSConfig = {
+// Production configuration
+const prodConfig = {
input: "./src/index.ts",
output: {
file: "./dist/index.cjs",
@@ -206,58 +80,32 @@ const prodCJSConfig = {
banner,
},
plugins: [
- resolve({
- browser: false, // Allow bundling of modules from `node_modules`
- preferBuiltins: true, // Prefer Node.js built-in modules
- mainFields: ["module", "main"], // Ensure Node.js package resolution
- extensions: [".js", ".ts", ".json"], // Resolve these extensions
- }),
- commonjs(), // Convert CommonJS modules to ES6 for Rollup to bundle them
- json(),
- typescriptPaths({
- tsconfig: "./tsconfig.json", // Ensure this points to your tsconfig file
- preserveExtensions: true,
- nonRelative: false,
- }),
- filenameReplacePlugin(),
+ ...basePlugins,
esbuild({
sourceMap: true,
minify: true,
treeShaking: true,
+ target: "node18",
+ }),
+ terser({
+ compress: {
+ drop_console: false, // Keep console logs for server apps
+ },
}),
- // typescript({
- // tsconfig: './tsconfig.json',
- // clean: true,
- // include: ['src/**/*.ts', 'distributions/AWS/**/*.ts'],
- // exclude: ['node_modules'],
- // }),
-
- sourcemaps(),
- terser(),
-
copy({
targets: [
{ src: "src/data/*", dest: "dist/data" },
- /*{ src: 'src/static/*', dest: 'dist/static' },*/
+ { src: "src/static/*", dest: "dist/static" },
+ {
+ src: "node_modules/swagger-ui-dist/*.{js,css,html,js.map}",
+ dest: "dist",
+ },
],
}),
],
};
-let devConfig = devESConfig;
-if (format === "cjs") {
- devConfig = devCJSConfig;
-}
-
-if (format === "esbundle") {
- devConfig = devESBundleConfig;
-}
-
-let config = isProduction
- ? format === "cjs"
- ? prodCJSConfig
- : prodESConfig
- : devConfig;
+const config = isProduction ? prodConfig : devConfig;
export default config;