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 config to fix debug issue

Forhad Hosain7d6204998f84
diff --git a/.vscode/launch.json b/.vscode/launch.json
index 664d395e..eaf23d20 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -32,11 +32,11 @@
"name": "Launch Runtime Server",
"type": "node",
"request": "launch",
- "program": "${workspaceFolder}/packages/runtime/dist/index.cjs",
- "preLaunchTask": "runtime: build",
+ "program": "${workspaceFolder}/packages/runtime/dist/index.dev.cjs",
+ "preLaunchTask": "runtime: build:dev",
"skipFiles": ["<node_internals>/**"],
"sourceMaps": true,
- "outFiles": ["${workspaceFolder}/packages/runtime/dist/**/*.js"],
+ "outFiles": ["${workspaceFolder}/packages/runtime/dist/**/*.cjs"],
"cwd": "${workspaceFolder}/packages/runtime",
"env": {
"NODE_ENV": "development"
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
index ed44b927..10748cea 100644
--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -53,6 +53,17 @@
"problemMatcher": [],
"detail": "Build runtime server for production"
},
+ {
+ "label": "runtime: build:dev",
+ "type": "shell",
+ "command": "NODE_ENV=development FORMAT=cjs npx rollup -c",
+ "options": {
+ "cwd": "${workspaceFolder}/packages/runtime"
+ },
+ "group": "build",
+ "problemMatcher": [],
+ "detail": "Build runtime server for development with source maps"
+ },
{
"label": "runtime: clean",
"type": "npm",
diff --git a/packages/runtime/nodemon.json b/packages/runtime/nodemon.json
index eeb59d6a..09f7857f 100644
--- a/packages/runtime/nodemon.json
+++ b/packages/runtime/nodemon.json
@@ -1,15 +1,6 @@
{
"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"
- }
+ "ext": "ts",
+ "ignore": ["src/**/*.spec.ts"],
+ "exec": "npm run dev"
}
diff --git a/packages/runtime/package.json b/packages/runtime/package.json
index 1aa1246c..02f1c1f7 100644
--- a/packages/runtime/package.json
+++ b/packages/runtime/package.json
@@ -5,8 +5,8 @@
"main": "dist/index.cjs",
"type": "module",
"scripts": {
- "dev": "nodemon",
- "build": "cross-env NODE_ENV=production NODE_OPTIONS='--max-old-space-size=4096' rollup -c",
+ "dev": "cross-env NODE_ENV=development FORMAT=cjs rollup -c && node --enable-source-maps ./dist/index.dev.cjs",
+ "build": "cross-env NODE_ENV=production FORMAT=cjs 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",
"clean": "rm -rf dist",
@@ -45,10 +45,10 @@
"rollup-plugin-sourcemaps": "^0.6.3",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript-paths": "^1.5.0",
+ "supertest": "^6.3.3",
"typescript": "^5.0.0",
"vite-tsconfig-paths": "^5.1.2",
- "vitest": "^2.1.4",
- "supertest": "^6.3.3"
+ "vitest": "^2.1.4"
},
"dependencies": {
"@modelcontextprotocol/sdk": "^1.10.1",
@@ -65,6 +65,7 @@
"openai": "^4.72.0",
"openapi-to-postmanv2": "^4.24.0",
"pkce-challenge": "^5.0.0",
+ "source-map-support": "^0.5.21",
"swagger-ui-express": "^5.0.0",
"uuid": "^9.0.1"
},
diff --git a/packages/runtime/rollup.config.js b/packages/runtime/rollup.config.js
index 535bbbd8..f1cab766 100644
--- a/packages/runtime/rollup.config.js
+++ b/packages/runtime/rollup.config.js
@@ -1,17 +1,17 @@
-import commonjs from "@rollup/plugin-commonjs";
-import json from "@rollup/plugin-json";
-import resolve from "@rollup/plugin-node-resolve";
-import { createFilter } from "@rollup/pluginutils";
-import path from "path";
-import copy from "rollup-plugin-copy";
-import esbuild from "rollup-plugin-esbuild";
-import sourcemaps from "rollup-plugin-sourcemaps";
-import { terser } from "rollup-plugin-terser";
-import typescriptPaths from "rollup-plugin-typescript-paths";
-import pkg from "./package.json";
+import json from '@rollup/plugin-json';
+import { createFilter } from '@rollup/pluginutils';
+import path from 'path';
+import esbuild from 'rollup-plugin-esbuild';
+import sourcemaps from 'rollup-plugin-sourcemaps';
+import { terser } from 'rollup-plugin-terser';
+import typescriptPaths from 'rollup-plugin-typescript-paths';
+import commonjs from '@rollup/plugin-commonjs';
+import resolve from '@rollup/plugin-node-resolve';
+import pkg from './package.json';
+import copy from 'rollup-plugin-copy';
-const isProduction = process.env.NODE_ENV === "production";
-const isDevelopment = process.env.NODE_ENV === "development";
+const isProduction = process.env.NODE_ENV === 'production';
+const format = process.env.FORMAT || 'es';
const banner = `/**
* ${pkg.name} v${pkg.version}
@@ -19,101 +19,134 @@ const banner = `/**
*/
`;
-// 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",
+const devCJSConfig = {
+ input: './src/index.ts',
output: {
- file: "./dist/index.cjs",
- format: "cjs",
+ file: './dist/index.dev.cjs',
+ format: 'cjs',
sourcemap: true,
inlineDynamicImports: true,
banner,
},
plugins: [
- ...basePlugins,
+ resolve({
+ browser: false,
+ preferBuiltins: true,
+ mainFields: ['module', 'main'],
+ extensions: ['.js', '.ts', '.json'],
+ }),
+ commonjs(),
+ json(),
+ filenameReplacePlugin(),
+ typescriptPaths({
+ tsconfig: './tsconfig.json',
+ preserveExtensions: true,
+ nonRelative: false,
+ }),
+ esbuild({
+ sourceMap: true,
+ minify: false,
+ treeShaking: false,
+ target: 'node18',
+ }),
+ sourcemaps(),
+ copy({
+ targets: [
+ { src: 'src/data/*', dest: 'dist/data' },
+ { src: 'src/static/*', dest: 'dist/static' },
+ { src: 'node_modules/swagger-ui-dist/*.{js,css,html,.js.map}', dest: 'dist' },
+ ],
+ }),
+ ],
+};
+
+const devESConfig = {
+ input: './src/index.ts',
+ output: {
+ format: 'es',
+ sourcemap: true,
+ file: './dist/index.dev.js',
+ banner,
+ },
+ plugins: [
+ json(),
+ filenameReplacePlugin(),
+ typescriptPaths({
+ tsconfig: './tsconfig.json',
+ preserveExtensions: true,
+ nonRelative: false,
+ }),
esbuild({
sourceMap: true,
minify: false,
treeShaking: false,
- target: "node18",
+ target: 'node18',
}),
+ sourcemaps(),
copy({
targets: [
- { src: "src/data/*", dest: "dist/data" },
- { src: "src/static/*", dest: "dist/static" },
- {
- src: "node_modules/swagger-ui-dist/*.{js,css,html,js.map}",
- dest: "dist",
- },
+ { src: 'src/data/*', dest: 'dist/data' },
+ { src: 'src/static/*', dest: 'dist/static' },
],
}),
],
};
-// Production configuration
const prodConfig = {
- input: "./src/index.ts",
+ input: './src/index.ts',
output: {
- file: "./dist/index.cjs",
- format: "cjs",
+ file: './dist/index.cjs',
+ format: 'cjs',
sourcemap: true,
inlineDynamicImports: true,
banner,
},
plugins: [
- ...basePlugins,
+ resolve({
+ browser: false,
+ preferBuiltins: true,
+ mainFields: ['module', 'main'],
+ extensions: ['.js', '.ts', '.json'],
+ }),
+ commonjs(),
+ json(),
+ typescriptPaths({
+ tsconfig: './tsconfig.json',
+ preserveExtensions: true,
+ nonRelative: false,
+ }),
+ filenameReplacePlugin(),
esbuild({
sourceMap: true,
minify: true,
treeShaking: true,
- target: "node18",
- }),
- terser({
- compress: {
- drop_console: false, // Keep console logs for server apps
- },
+ target: 'node18',
}),
+ sourcemaps(),
+ terser(),
copy({
targets: [
- { src: "src/data/*", dest: "dist/data" },
- { src: "src/static/*", dest: "dist/static" },
- {
- src: "node_modules/swagger-ui-dist/*.{js,css,html,js.map}",
- dest: "dist",
- },
+ { src: 'src/data/*', dest: 'dist/data' },
+ { src: 'src/static/*', dest: 'dist/static' },
],
}),
],
};
+let devConfig = devESConfig;
+if (format === 'cjs') {
+ devConfig = devCJSConfig;
+}
+
const config = isProduction ? prodConfig : devConfig;
export default config;
function filenameReplacePlugin() {
- const filter = createFilter("**/*.ts", "node_modules/**");
+ const filter = createFilter('**/*.ts', 'node_modules/**');
return {
- name: "filename-replace",
+ name: 'filename-replace',
transform(code, id) {
if (!filter(id)) return null;
@@ -121,14 +154,11 @@ function filenameReplacePlugin() {
const normalizedId = path.normalize(id);
// Extract the part of the path after '/src' and remove the file extension
- const relativePath = path.relative(path.resolve("src"), normalizedId);
- const filenameWithoutExtension = relativePath.replace(
- path.extname(relativePath),
- ""
- );
+ const relativePath = path.relative(path.resolve('src'), normalizedId);
+ const filenameWithoutExtension = relativePath.replace(path.extname(relativePath), '');
// Replace backslashes with forward slashes if on Windows
- const unixStylePath = filenameWithoutExtension.replace(/\\/g, "/");
+ const unixStylePath = filenameWithoutExtension.replace(/\\/g, '/');
const modifiedCode = code.replace(/___FILENAME___/g, unixStylePath);
diff --git a/packages/runtime/src/index.ts b/packages/runtime/src/index.ts
index c3271831..fbf55e33 100644
--- a/packages/runtime/src/index.ts
+++ b/packages/runtime/src/index.ts
@@ -6,6 +6,7 @@ import express from 'express';
import session from 'express-session';
import { Server } from 'http';
import path from 'path';
+import 'source-map-support/register.js';
import url from 'url';
// Core imports