Skip to content

[Bug]: SmythOS not running in NextJS #207

@LemrabottIsmail

Description

@LemrabottIsmail

🐛 What happened?

Bug: SmythOS not running in NextJS APP, causing the app to crash
Expected: SmythOS should run in Frontend, since its working fine in ExpressJS
Actual: Throws model not found error

Error log:
Module not found: Can't resolve 'child_process'

1 | import dotenv from"dotenv";import Joi from"joi";import"dotenv/config";import winston from"winston";import Transport from"winston-transport";import pLimit from"p-limit";import axios,{AxiosHeaders}from"axios";importas fs from"fs";import fs__default,{existsSync,mkdirSync,writeFileSync,readFileSync,unlinkSync}from"fs";importas FileType from"file-type";import{fileTypeFromBuffer}from"file-type";import{isBinaryFileSync}from"isbinaryfile";import EventEmitter$1,{EventEmitter}from"events";import crypto$1,{createHash,randomUUID}from"crypto";import path from"path";import os from"os";import"process";import mime from"mime";import{encodeChat,encode}from"gpt-tokenizer";import{Readable}from"stream";import xxhash from"xxhashjs";import{jsonrepair}from"jsonrepair";import yaml from"js-yaml";import{EventSource}from"eventsource";importas acorn from"acorn";import dayjs from"dayjs";import querystring from"querystring";import{HfInference}from"@huggingface/inference";import{Runware}from"@runware/sdk-js";import FormData from"form-data";import{SocksProxyAgent}from"socks-proxy-agent";import OAuth from"oauth-1.0a";import zl from"zip-lib";import{LambdaClient,GetFunctionCommand,UpdateFunctionCodeCommand,Runtime,InvokeCommand,UpdateFunctionConfigurationCommand,CreateFunctionCommand}from"@aws-sdk/client-lambda";import{IAMClient,GetRoleCommand,CreateRoleCommand}from"@aws-sdk/client-iam";import{Client}from"@modelcontextprotocol/sdk/client/index.js";import{SSEClientTransport}from"@modelcontextprotocol/sdk/client/sse.js";import{StreamableHTTPClientTransport}from"@modelcontextprotocol/sdk/client/streamableHttp.js";import{GetBucketLifecycleConfigurationCommand,PutBucketLifecycleConfigurationCommand,S3Client,HeadObjectCommand,DeleteObjectCommand,GetObjectCommand,PutObjectCommand,PutObjectTaggingCommand,GetObjectTaggingCommand,CopyObjectCommand}from"@aws-sdk/client-s3";import"ses";import imageSize from"image-size";import{execSync}from"child_process";import{Pinecone}from"@pinecone-database/pinecone";import OpenAI,{toFile,OpenAI as OpenAI$1}from"openai";import{GoogleGenAI}from"@google/genai";import{MilvusClient,DataType,ErrorCode}from"@zilliz/milvus2-sdk-node";import{GoogleGenerativeAI,FunctionCallingMode}from"@google/generative-ai";import{GoogleAIFileManager,FileState}from"@google/generative-ai/server";import Anthropic from"@anthropic-ai/sdk";import Groq from"groq-sdk";import{BedrockRuntimeClient,ConverseCommand,ConverseStreamCommand}from"@aws-sdk/client-bedrock-runtime";import{VertexAI}from"@google-cloud/vertexai";import{Ollama}from"ollama";importas chokidar from"chokidar";import chokidar__default from"chokidar";import fs$1 from"fs/promises";import IORedis from"ioredis";import mysql from"mysql2/promise";import{SecretsManagerClient,ListSecretsCommand,GetSecretValueCommand,PutSecretValueCommand,CreateSecretCommand,DeleteSecretCommand}from"@aws-sdk/client-secrets-manager";importas readlineSync from"readline-sync";var version="1.6.8",pkg={version};dotenv.config();const config={env:{LOG_LEVEL:process.env.LOG_LEVEL||"none",LOG_FILTER:process.env.LOG_FILTER||"",NODE_ENV:process.env?.NODE_ENV}},REQUEST_METHODS=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],REQUEST_CONTENT_TYPES={none:"none",urlEncodedFormData:"application/x-www-form-urlencoded",multipartFormData:"multipart/form-data",json:"application/json",text:"text/plain",xml:"application/xml",binary:"binary"};var EMBODIMENT_TYPES=(EMBODIMENT_TYPES2=>(EMBODIMENT_TYPES2.ChatBot="chatBot",EMBODIMENT_TYPES2.ChatGPT="chatGPT",EMBODIMENT_TYPES2))(EMBODIMENT_TYPES||{});const ERR_MSG_INVALID_IMAGE_SOURCE="Please provide a valid Image Source. Supported image sources are: HTTP(S) URL, Base64 string, Data URL, Output Image from other component(s).",ERR_MSG_INVALID_BINARY="Please provide a valid data that is either a Blob, SmythFileObject (Binary Output from any Component), ArrayBuffer, Buffer, Base64 string, Data URL, or HTTP(s) URL",ERR_MSG_MAX_DEPTH="The maximum depth has been exceeded for the provided array or object.",ERR_MSG_MAX_ARRAY_SIZE="The maximum array size has been exceeded for the provided array.",ERR_MSG_MAX_OBJECT_SIZE="The maximum object size has been exceeded for the provided object.",MAX_DEPTH=10,MAX_OBJECT_SIZE=1e3,MAX_ARRAY_SIZE=1e3,MAX_FILE_SIZE=101024*1024,MAX_FILE_COUNT=10,DEFAULT_MAX_TOKENS_FOR_LLM=2048,S3_DAILY_PURGE_LIFECYCLE_TAG="ExpirationPolicy=DeleteDaily",S3_WEEKLY_PURGE_LIFECYCLE_TAG="ExpirationPolicy=DeleteWeekly",S3_MONTHLY_PURGE_LIFECYCLE_TAG="ExpirationPolicy=DeleteMonthly",TOOL_USE_DEFAULT_MODEL="gpt-4o-mini",COMP_NAMES={apiCall:"APICall",code:"Code",llmPrompt:"PromptGenerator",visionLLM:"VisionLLM"},JSON_RESPONSE_INSTRUCTION=`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 | Respond ONLY with a valid, parsable JSON object. Follow these strict guidelines:
3 | 1. The response must begin with '{' and end with '}'.
4 | 2. Use double quotes for all keys and string values.

🔄 How to reproduce

  1. Create a simple NextJS app
  2. Import import { Agent } from "@smythos/sdk";
  3. try to inititialze agent:
  4. const agent = new Agent({
    name: "Book Assistant",
    model: "gpt-4o",
    behavior:
    "You are a helpful assistant that can answer questions about the books.",
    });
  5. Issue will appear

💻 Code sample

import { Agent } from "@smythos/sdk";

const agent = new Agent({
  name: "Book Assistant",
  model: "gpt-4o",
  behavior:
    "You are a helpful assistant that can answer questions about the books.",
});

🖥️ Environment

Node.js: v22.9.0
Smyth: "^1.2.2"
Windows version: 24H2
package: @smythos/sdk

✅ Checklist

  • Searched existing issues
  • Provided reproduction steps

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions