@smythos/sre 1.5.35 → 1.5.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/Components/FileStore.class.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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";import*as fs from"fs";import fs__default,{existsSync,mkdirSync,writeFileSync,readFileSync,unlinkSync}from"fs";import*as 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{encode,encodeChat}from"gpt-tokenizer";import path from"path";import os from"os";import"process";import mime from"mime";import{Readable}from"stream";import xxhash from"xxhashjs";import{jsonrepair}from"jsonrepair";import yaml from"js-yaml";import{EventSource}from"eventsource";import*as 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,CreateFunctionCommand,InvokeCommand}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{GetBucketLifecycleConfigurationCommand,PutBucketLifecycleConfigurationCommand,S3Client,HeadObjectCommand,DeleteObjectCommand,GetObjectCommand,PutObjectCommand,PutObjectTaggingCommand,GetObjectTaggingCommand,CopyObjectCommand}from"@aws-sdk/client-s3";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{MilvusClient,DataType,ErrorCode}from"@zilliz/milvus2-sdk-node";import{GoogleGenerativeAI}from"@google/generative-ai";import{GoogleAIFileManager,FileState}from"@google/generative-ai/server";import{GoogleGenAI}from"@google/genai";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 chokidar 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";import*as readlineSync from"readline-sync";var version="1.5.
|
|
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";import*as fs from"fs";import fs__default,{existsSync,mkdirSync,writeFileSync,readFileSync,unlinkSync}from"fs";import*as 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{encode,encodeChat}from"gpt-tokenizer";import path from"path";import os from"os";import"process";import mime from"mime";import{Readable}from"stream";import xxhash from"xxhashjs";import{jsonrepair}from"jsonrepair";import yaml from"js-yaml";import{EventSource}from"eventsource";import*as 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,CreateFunctionCommand,InvokeCommand}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{GetBucketLifecycleConfigurationCommand,PutBucketLifecycleConfigurationCommand,S3Client,HeadObjectCommand,DeleteObjectCommand,GetObjectCommand,PutObjectCommand,PutObjectTaggingCommand,GetObjectTaggingCommand,CopyObjectCommand}from"@aws-sdk/client-s3";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{MilvusClient,DataType,ErrorCode}from"@zilliz/milvus2-sdk-node";import{GoogleGenerativeAI}from"@google/generative-ai";import{GoogleAIFileManager,FileState}from"@google/generative-ai/server";import{GoogleGenAI}from"@google/genai";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 chokidar 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";import*as readlineSync from"readline-sync";var version="1.5.36";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=10*1024*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
2
|
Respond ONLY with a valid, parsable JSON object. Follow these strict guidelines:
|
|
3
3
|
1. The response must begin with '{' and end with '}'.
|
|
4
4
|
2. Use double quotes for all keys and string values.
|
|
@@ -83,7 +83,7 @@ ${totalLength}
|
|
|
83
83
|
${_error}
|
|
84
84
|
`),{hash:void 0,_error,_debug:logger2.output}}}}class FHash extends Component{constructor(){super()}init(){}async process(input,config2,agent){await super.process(input,config2,agent);const logger2=this.createComponentLogger(agent,config2);try{const data=input.Data,algorithm=config2.data.algorithm,encoding=config2.data.encoding;logger2.debug(` Generating hash using ${algorithm} algorithm and ${encoding} encoding`);const hashAlgo=crypto$1.createHash(algorithm);hashAlgo.update(data);const Hash=hashAlgo.digest(encoding);return logger2.debug(` Generated hash: ${Hash}`),{Hash,_error:void 0,_debug:logger2.output}}catch(err){const _error=err?.response?.data||err?.message||err.toString();return logger2.error(` Error generating hash
|
|
85
85
|
${_error}
|
|
86
|
-
`),{hash:void 0,_error,_debug:logger2.output}}}}var __defProp$13=Object.defineProperty,__defNormalProp$13=(obj,key,value)=>key in obj?__defProp$13(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,__publicField$13=(obj,key,value)=>__defNormalProp$13(obj,key+"",value);class FileStore extends Component{constructor(){super(),__publicField$13(this,"configSchema",Joi.object({name:Joi.string().max(1e3).allow("").label("Name"),ttl:Joi.number().integer().label("TTL")}))}init(){}async process(input,config2,agent){await super.process(input,config2,agent);const logger2=this.createComponentLogger(agent,config2);try{logger2.debug("=== File Store Log ===");let Output={},_error,data=input.Data;const accessCandidate=AccessCandidate.agent(agent.id),binaryData=await BinaryInput.from(data,null,null,accessCandidate),fileData=await binaryData.getJsonData(accessCandidate),buffer=await binaryData.getBuffer(),customFileName=TemplateString(config2.data.name).parse(input).result,metadata={ContentType:fileData.mimetype},ttl=config2.data.ttl||86400,extension=fileData.url?.split(".").pop(),s3StorageConnector=ConnectorService.getStorageConnector("S3"),fileName=this.getFileName(customFileName,extension);try{const smythFSUrl=`smythfs://${agent.id}.agent/components_data/${fileName}`;SmythFS.Instance.write(smythFSUrl,buffer,null,metadata),Output={Url:await SmythFS.Instance.genResourceUrl(smythFSUrl,AccessCandidate.agent(agent.id))}}catch(error){logger2.error(`Error saving file
|
|
86
|
+
`),{hash:void 0,_error,_debug:logger2.output}}}}var __defProp$13=Object.defineProperty,__defNormalProp$13=(obj,key,value)=>key in obj?__defProp$13(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,__publicField$13=(obj,key,value)=>__defNormalProp$13(obj,key+"",value);class FileStore extends Component{constructor(){super(),__publicField$13(this,"configSchema",Joi.object({name:Joi.string().max(1e3).allow("").label("Name"),ttl:Joi.number().integer().label("TTL")}))}init(){}async process(input,config2,agent){await super.process(input,config2,agent);const logger2=this.createComponentLogger(agent,config2);try{logger2.debug("=== File Store Log ===");let Output={},_error,data=input.Data;const accessCandidate=AccessCandidate.agent(agent.id),binaryData=await BinaryInput.from(data,null,null,accessCandidate),fileData=await binaryData.getJsonData(accessCandidate),buffer=await binaryData.getBuffer(),customFileName=TemplateString(config2.data.name).parse(input).result,metadata={ContentType:fileData.mimetype},ttl=config2.data.ttl||86400,extension=fileData.url?.split(".").pop(),s3StorageConnector=ConnectorService.getStorageConnector("S3"),fileName=this.getFileName(customFileName,extension);try{const smythFSUrl=`smythfs://${agent.id}.agent/components_data/${fileName}`;await SmythFS.Instance.write(smythFSUrl,buffer,null,metadata,ttl),Output={Url:await SmythFS.Instance.genResourceUrl(smythFSUrl,AccessCandidate.agent(agent.id))}}catch(error){logger2.error(`Error saving file
|
|
87
87
|
${error}
|
|
88
88
|
`),_error=error?.response?.data||error?.message||error.toString(),Output=void 0}return{...Output,_error,_debug:logger2.output}}catch(err){const _error=err?.response?.data||err?.message||err.toString();return logger2.error(` Error saving file
|
|
89
89
|
${_error}
|