@elizaos/plugin-elizacloud 1.5.20 → 1.7.0-alpha.0

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.
@@ -42,13 +42,40 @@ var __export = (target, all) => {
42
42
  // src/index.node.ts
43
43
  var exports_index_node = {};
44
44
  __export(exports_index_node, {
45
+ worldTable: () => worldTable,
46
+ taskTable: () => taskTable,
47
+ serverTable: () => serverTable,
48
+ serverAgentsTable: () => serverAgentsTable,
49
+ roomTable: () => roomTable,
50
+ relationshipTable: () => relationshipTable,
51
+ pluginSql: () => import_node3.default,
52
+ participantTable: () => participantTable,
53
+ messageTable: () => messageTable,
54
+ messageServerTable: () => messageServerTable,
55
+ messageServerAgentsTable: () => messageServerAgentsTable,
56
+ memoryTable: () => memoryTable,
57
+ logTable: () => logTable,
58
+ getCloudStorage: () => getCloudStorage,
59
+ entityTable: () => entityTable,
60
+ embeddingTable: () => embeddingTable,
45
61
  elizaOSCloudPlugin: () => elizaOSCloudPlugin,
46
- default: () => src_default
62
+ default: () => src_default,
63
+ createDirectDatabaseAdapter: () => createDirectDatabaseAdapter,
64
+ createDatabaseAdapter: () => createDatabaseAdapter,
65
+ createCloudStorageService: () => createCloudStorageService,
66
+ createCloudDatabaseAdapter: () => createCloudDatabaseAdapter,
67
+ componentTable: () => componentTable,
68
+ channelTable: () => channelTable,
69
+ channelParticipantsTable: () => channelParticipantsTable,
70
+ cacheTable: () => cacheTable,
71
+ agentTable: () => agentTable,
72
+ CloudStorageService: () => CloudStorageService,
73
+ CloudDatabaseAdapter: () => CloudDatabaseAdapter
47
74
  });
48
75
  module.exports = __toCommonJS(exports_index_node);
49
76
 
50
77
  // src/index.ts
51
- var import_core10 = require("@elizaos/core");
78
+ var import_core15 = require("@elizaos/core");
52
79
 
53
80
  // src/init.ts
54
81
  var import_core2 = require("@elizaos/core");
@@ -265,6 +292,31 @@ function getJsonRepairFunction() {
265
292
  }
266
293
  };
267
294
  }
295
+ function detectAudioMimeType(buffer) {
296
+ if (buffer.length < 12) {
297
+ return "application/octet-stream";
298
+ }
299
+ if (buffer[0] === 82 && buffer[1] === 73 && buffer[2] === 70 && buffer[3] === 70 && buffer[8] === 87 && buffer[9] === 65 && buffer[10] === 86 && buffer[11] === 69) {
300
+ return "audio/wav";
301
+ }
302
+ if (buffer[0] === 73 && buffer[1] === 68 && buffer[2] === 51 || buffer[0] === 255 && (buffer[1] & 224) === 224) {
303
+ return "audio/mpeg";
304
+ }
305
+ if (buffer[0] === 79 && buffer[1] === 103 && buffer[2] === 103 && buffer[3] === 83) {
306
+ return "audio/ogg";
307
+ }
308
+ if (buffer[0] === 102 && buffer[1] === 76 && buffer[2] === 97 && buffer[3] === 67) {
309
+ return "audio/flac";
310
+ }
311
+ if (buffer[4] === 102 && buffer[5] === 116 && buffer[6] === 121 && buffer[7] === 112) {
312
+ return "audio/mp4";
313
+ }
314
+ if (buffer[0] === 26 && buffer[1] === 69 && buffer[2] === 223 && buffer[3] === 163) {
315
+ return "audio/webm";
316
+ }
317
+ import_core5.logger.warn("Could not detect audio format from buffer, using generic binary type");
318
+ return "application/octet-stream";
319
+ }
268
320
  async function webStreamToNodeStream(webStream) {
269
321
  try {
270
322
  const { Readable } = await import("node:stream");
@@ -548,8 +600,89 @@ async function handleImageDescription(runtime, params) {
548
600
  };
549
601
  }
550
602
  }
551
- // src/models/speech.ts
603
+ // src/models/transcription.ts
552
604
  var import_core9 = require("@elizaos/core");
605
+ async function handleTranscription(runtime, input) {
606
+ let modelName = getSetting(runtime, "ELIZAOS_CLOUD_TRANSCRIPTION_MODEL", "gpt-4o-mini-transcribe");
607
+ import_core9.logger.log(`[ELIZAOS_CLOUD] Using TRANSCRIPTION model: ${modelName}`);
608
+ const baseURL = getBaseURL(runtime);
609
+ let blob;
610
+ let extraParams = null;
611
+ if (input instanceof Blob || input instanceof File) {
612
+ blob = input;
613
+ } else if (Buffer.isBuffer(input)) {
614
+ const detectedMimeType = detectAudioMimeType(input);
615
+ import_core9.logger.debug(`Auto-detected audio MIME type: ${detectedMimeType}`);
616
+ blob = new Blob([input], { type: detectedMimeType });
617
+ } else if (typeof input === "object" && input !== null && "audio" in input && input.audio != null) {
618
+ const params = input;
619
+ if (!(params.audio instanceof Blob) && !(params.audio instanceof File) && !Buffer.isBuffer(params.audio)) {
620
+ throw new Error("TRANSCRIPTION param 'audio' must be a Blob/File/Buffer.");
621
+ }
622
+ if (Buffer.isBuffer(params.audio)) {
623
+ let mimeType = params.mimeType;
624
+ if (!mimeType) {
625
+ mimeType = detectAudioMimeType(params.audio);
626
+ import_core9.logger.debug(`Auto-detected audio MIME type: ${mimeType}`);
627
+ } else {
628
+ import_core9.logger.debug(`Using provided MIME type: ${mimeType}`);
629
+ }
630
+ blob = new Blob([params.audio], { type: mimeType });
631
+ } else {
632
+ blob = params.audio;
633
+ }
634
+ extraParams = params;
635
+ if (typeof params.model === "string" && params.model) {
636
+ modelName = params.model;
637
+ }
638
+ } else {
639
+ throw new Error("TRANSCRIPTION expects a Blob/File/Buffer or an object { audio: Blob/File/Buffer, mimeType?, language?, response_format?, timestampGranularities?, prompt?, temperature?, model? }");
640
+ }
641
+ const mime = blob.type || "audio/webm";
642
+ const filename = blob.name || (mime.includes("mp3") || mime.includes("mpeg") ? "recording.mp3" : mime.includes("ogg") ? "recording.ogg" : mime.includes("wav") ? "recording.wav" : mime.includes("webm") ? "recording.webm" : "recording.bin");
643
+ const formData = new FormData;
644
+ formData.append("file", blob, filename);
645
+ formData.append("model", String(modelName));
646
+ if (extraParams) {
647
+ if (typeof extraParams.language === "string") {
648
+ formData.append("language", String(extraParams.language));
649
+ }
650
+ if (typeof extraParams.response_format === "string") {
651
+ formData.append("response_format", String(extraParams.response_format));
652
+ }
653
+ if (typeof extraParams.prompt === "string") {
654
+ formData.append("prompt", String(extraParams.prompt));
655
+ }
656
+ if (typeof extraParams.temperature === "number") {
657
+ formData.append("temperature", String(extraParams.temperature));
658
+ }
659
+ if (Array.isArray(extraParams.timestampGranularities)) {
660
+ for (const g of extraParams.timestampGranularities) {
661
+ formData.append("timestamp_granularities[]", String(g));
662
+ }
663
+ }
664
+ }
665
+ try {
666
+ const response = await fetch(`${baseURL}/audio/transcriptions`, {
667
+ method: "POST",
668
+ headers: {
669
+ ...getAuthHeader(runtime)
670
+ },
671
+ body: formData
672
+ });
673
+ if (!response.ok) {
674
+ throw new Error(`Failed to transcribe audio: ${response.status} ${response.statusText}`);
675
+ }
676
+ const data = await response.json();
677
+ return data.text || "";
678
+ } catch (error) {
679
+ const message = error instanceof Error ? error.message : String(error);
680
+ import_core9.logger.error(`TRANSCRIPTION error: ${message}`);
681
+ throw error;
682
+ }
683
+ }
684
+ // src/models/speech.ts
685
+ var import_core10 = require("@elizaos/core");
553
686
  async function fetchTextToSpeech(runtime, options) {
554
687
  const defaultModel = getSetting(runtime, "ELIZAOS_CLOUD_TTS_MODEL", "gpt-4o-mini-tts");
555
688
  const defaultVoice = getSetting(runtime, "ELIZAOS_CLOUD_TTS_VOICE", "nova");
@@ -591,10 +724,367 @@ async function fetchTextToSpeech(runtime, options) {
591
724
  throw new Error(`Failed to fetch speech from ElizaOS Cloud TTS: ${message}`);
592
725
  }
593
726
  }
727
+ async function handleTextToSpeech(runtime, input) {
728
+ const options = typeof input === "string" ? { text: input } : input;
729
+ const resolvedModel = options.model || getSetting(runtime, "ELIZAOS_CLOUD_TTS_MODEL", "gpt-4o-mini-tts");
730
+ import_core10.logger.log(`[ELIZAOS_CLOUD] Using TEXT_TO_SPEECH model: ${resolvedModel}`);
731
+ try {
732
+ const speechStream = await fetchTextToSpeech(runtime, options);
733
+ return speechStream;
734
+ } catch (error) {
735
+ const message = error instanceof Error ? error.message : String(error);
736
+ import_core10.logger.error(`Error in TEXT_TO_SPEECH: ${message}`);
737
+ throw error;
738
+ }
739
+ }
740
+ // src/models/tokenization.ts
741
+ var import_core11 = require("@elizaos/core");
742
+ var import_js_tiktoken = require("js-tiktoken");
743
+ async function tokenizeText(model, prompt) {
744
+ const modelName = model === import_core11.ModelType.TEXT_SMALL ? process.env.ELIZAOS_CLOUD_SMALL_MODEL ?? process.env.SMALL_MODEL ?? "gpt-5-nano" : process.env.LARGE_MODEL ?? "gpt-5-mini";
745
+ const tokens = import_js_tiktoken.encodingForModel(modelName).encode(prompt);
746
+ return tokens;
747
+ }
748
+ async function detokenizeText(model, tokens) {
749
+ const modelName = model === import_core11.ModelType.TEXT_SMALL ? process.env.ELIZAOS_CLOUD_SMALL_MODEL ?? process.env.SMALL_MODEL ?? "gpt-5-nano" : process.env.ELIZAOS_CLOUD_LARGE_MODEL ?? process.env.LARGE_MODEL ?? "gpt-5-mini";
750
+ return import_js_tiktoken.encodingForModel(modelName).decode(tokens);
751
+ }
752
+ async function handleTokenizerEncode(_runtime, { prompt, modelType = import_core11.ModelType.TEXT_LARGE }) {
753
+ return await tokenizeText(modelType ?? import_core11.ModelType.TEXT_LARGE, prompt);
754
+ }
755
+ async function handleTokenizerDecode(_runtime, { tokens, modelType = import_core11.ModelType.TEXT_LARGE }) {
756
+ return await detokenizeText(modelType ?? import_core11.ModelType.TEXT_LARGE, tokens);
757
+ }
758
+ // src/database/adapter.ts
759
+ var import_core12 = require("@elizaos/core");
760
+ var import_node = __toESM(require("@elizaos/plugin-sql/node"));
761
+ var DEFAULT_CLOUD_URL = "https://www.elizacloud.ai";
762
+ async function createCloudDatabaseAdapter(config) {
763
+ const baseUrl = config.baseUrl || DEFAULT_CLOUD_URL;
764
+ import_core12.logger.info({ src: "plugin:elizacloud", agentId: config.agentId }, "Provisioning cloud database");
765
+ const response = await provisionCloudDatabase(config.apiKey, baseUrl, config.agentId);
766
+ if (!response.success || !response.connectionUrl) {
767
+ import_core12.logger.error({
768
+ src: "plugin:elizacloud",
769
+ error: response.error,
770
+ agentId: config.agentId
771
+ }, "Failed to provision cloud database");
772
+ return null;
773
+ }
774
+ import_core12.logger.info({ src: "plugin:elizacloud", agentId: config.agentId }, "Cloud database provisioned successfully");
775
+ const adapter = import_node.default.createDatabaseAdapter({ postgresUrl: response.connectionUrl }, config.agentId);
776
+ import_core12.logger.info({ src: "plugin:elizacloud", agentId: config.agentId }, "Cloud database adapter created using PostgreSQL connection");
777
+ return adapter;
778
+ }
779
+ async function provisionCloudDatabase(apiKey, baseUrl, agentId) {
780
+ try {
781
+ const response = await fetch(`${baseUrl}/api/v1/database/provision`, {
782
+ method: "POST",
783
+ headers: {
784
+ Authorization: `Bearer ${apiKey}`,
785
+ "Content-Type": "application/json"
786
+ },
787
+ body: JSON.stringify({
788
+ agentId,
789
+ type: "postgresql"
790
+ })
791
+ });
792
+ if (!response.ok) {
793
+ const errorText = await response.text();
794
+ return {
795
+ success: false,
796
+ error: `Cloud database provisioning failed: ${response.status} ${errorText}`
797
+ };
798
+ }
799
+ const data = await response.json();
800
+ return {
801
+ success: true,
802
+ connectionUrl: data.connectionUrl,
803
+ expiresAt: data.expiresAt
804
+ };
805
+ } catch (error) {
806
+ const message = error instanceof Error ? error.message : String(error);
807
+ return {
808
+ success: false,
809
+ error: `Network error during database provisioning: ${message}`
810
+ };
811
+ }
812
+ }
813
+
814
+ class CloudDatabaseAdapter {
815
+ config;
816
+ adapter = null;
817
+ constructor(config) {
818
+ this.config = config;
819
+ }
820
+ async initialize() {
821
+ if (this.adapter) {
822
+ return this.adapter;
823
+ }
824
+ this.adapter = await createCloudDatabaseAdapter(this.config);
825
+ return this.adapter;
826
+ }
827
+ getAdapter() {
828
+ return this.adapter;
829
+ }
830
+ }
831
+
832
+ // src/storage/service.ts
833
+ var import_core13 = require("@elizaos/core");
834
+ var DEFAULT_CLOUD_URL2 = "https://www.elizacloud.ai";
835
+ var STORAGE_ENDPOINT = "/api/v1/storage/files";
836
+ function createCloudStorageService(config) {
837
+ return new CloudStorageService(config);
838
+ }
839
+
840
+ class CloudStorageService {
841
+ apiKey;
842
+ baseUrl;
843
+ constructor(config) {
844
+ this.apiKey = config.apiKey;
845
+ this.baseUrl = config.baseUrl || DEFAULT_CLOUD_URL2;
846
+ }
847
+ async upload(file, options = {}) {
848
+ try {
849
+ const formData = new FormData;
850
+ let blob;
851
+ if (Buffer.isBuffer(file)) {
852
+ blob = new Blob([file], {
853
+ type: options.contentType || "application/octet-stream"
854
+ });
855
+ } else {
856
+ blob = file;
857
+ }
858
+ const filename = options.filename || (file instanceof File ? file.name : "file") || "upload";
859
+ formData.append("file", blob, filename);
860
+ if (options.metadata) {
861
+ formData.append("metadata", JSON.stringify(options.metadata));
862
+ }
863
+ const response = await fetch(`${this.baseUrl}${STORAGE_ENDPOINT}`, {
864
+ method: "POST",
865
+ headers: {
866
+ Authorization: `Bearer ${this.apiKey}`
867
+ },
868
+ body: formData
869
+ });
870
+ if (!response.ok) {
871
+ const errorData = await response.json().catch(() => ({}));
872
+ if (response.status === 402) {
873
+ return {
874
+ success: false,
875
+ error: `Insufficient credits. Required: ${errorData.required || "unknown"}, Available: ${errorData.available || "unknown"}. Top up at ${errorData.topUpUrl || "/dashboard/billing"}`
876
+ };
877
+ }
878
+ return {
879
+ success: false,
880
+ error: `Upload failed: ${response.status} ${errorData.error || "Unknown error"}`
881
+ };
882
+ }
883
+ const data = await response.json();
884
+ import_core13.logger.info({ src: "plugin:elizacloud", cost: data.cost, remaining: data.creditsRemaining }, "Storage upload successful");
885
+ return {
886
+ success: true,
887
+ id: data.id,
888
+ url: data.url,
889
+ pathname: data.pathname,
890
+ contentType: data.contentType,
891
+ size: data.size,
892
+ cost: data.cost,
893
+ creditsRemaining: data.creditsRemaining
894
+ };
895
+ } catch (error) {
896
+ const message = error instanceof Error ? error.message : String(error);
897
+ import_core13.logger.error({ src: "plugin:elizacloud", error }, "Storage upload failed");
898
+ return {
899
+ success: false,
900
+ error: `Upload error: ${message}`
901
+ };
902
+ }
903
+ }
904
+ async download(id, url) {
905
+ if (url) {
906
+ try {
907
+ const response = await fetch(url);
908
+ if (!response.ok) {
909
+ import_core13.logger.error({ src: "plugin:elizacloud", status: response.status, url }, "Storage direct download failed");
910
+ return null;
911
+ }
912
+ const arrayBuffer = await response.arrayBuffer();
913
+ return Buffer.from(arrayBuffer);
914
+ } catch (error) {
915
+ import_core13.logger.error({ src: "plugin:elizacloud", error }, "Storage direct download error");
916
+ return null;
917
+ }
918
+ }
919
+ try {
920
+ const response = await fetch(`${this.baseUrl}${STORAGE_ENDPOINT}/${id}?download=true`, {
921
+ headers: {
922
+ Authorization: `Bearer ${this.apiKey}`
923
+ },
924
+ redirect: "follow"
925
+ });
926
+ if (!response.ok) {
927
+ import_core13.logger.error({ src: "plugin:elizacloud", status: response.status }, "Storage download failed");
928
+ return null;
929
+ }
930
+ const arrayBuffer = await response.arrayBuffer();
931
+ return Buffer.from(arrayBuffer);
932
+ } catch (error) {
933
+ import_core13.logger.error({ src: "plugin:elizacloud", error }, "Storage download error");
934
+ return null;
935
+ }
936
+ }
937
+ async list(options = {}) {
938
+ try {
939
+ const params = new URLSearchParams;
940
+ if (options.prefix)
941
+ params.set("prefix", options.prefix);
942
+ if (options.limit)
943
+ params.set("limit", String(options.limit));
944
+ if (options.cursor)
945
+ params.set("cursor", options.cursor);
946
+ const response = await fetch(`${this.baseUrl}${STORAGE_ENDPOINT}?${params.toString()}`, {
947
+ headers: {
948
+ Authorization: `Bearer ${this.apiKey}`
949
+ }
950
+ });
951
+ if (!response.ok) {
952
+ import_core13.logger.error({ src: "plugin:elizacloud", status: response.status }, "Storage list failed");
953
+ return { items: [], hasMore: false };
954
+ }
955
+ const data = await response.json();
956
+ return {
957
+ items: data.items || [],
958
+ cursor: data.cursor,
959
+ hasMore: data.hasMore || false
960
+ };
961
+ } catch (error) {
962
+ import_core13.logger.error({ src: "plugin:elizacloud", error }, "Storage list error");
963
+ return { items: [], hasMore: false };
964
+ }
965
+ }
966
+ async delete(id, url) {
967
+ if (!url) {
968
+ import_core13.logger.error({ src: "plugin:elizacloud" }, "Storage delete requires file URL");
969
+ return false;
970
+ }
971
+ try {
972
+ const params = new URLSearchParams({ url });
973
+ const response = await fetch(`${this.baseUrl}${STORAGE_ENDPOINT}/${id}?${params.toString()}`, {
974
+ method: "DELETE",
975
+ headers: {
976
+ Authorization: `Bearer ${this.apiKey}`
977
+ }
978
+ });
979
+ if (!response.ok) {
980
+ const errorData = await response.json().catch(() => ({}));
981
+ import_core13.logger.error({ src: "plugin:elizacloud", status: response.status, error: errorData.error }, "Storage delete failed");
982
+ return false;
983
+ }
984
+ return true;
985
+ } catch (error) {
986
+ import_core13.logger.error({ src: "plugin:elizacloud", error }, "Storage delete error");
987
+ return false;
988
+ }
989
+ }
990
+ async getStats() {
991
+ try {
992
+ const response = await fetch(`${this.baseUrl}${STORAGE_ENDPOINT}?stats=true`, {
993
+ headers: {
994
+ Authorization: `Bearer ${this.apiKey}`
995
+ }
996
+ });
997
+ if (!response.ok) {
998
+ return null;
999
+ }
1000
+ const data = await response.json();
1001
+ return {
1002
+ totalFiles: data.stats?.totalFiles || 0,
1003
+ totalSize: data.stats?.totalSize || 0,
1004
+ totalSizeGB: data.stats?.totalSizeGB || 0,
1005
+ pricing: data.pricing || {}
1006
+ };
1007
+ } catch (error) {
1008
+ import_core13.logger.error({ src: "plugin:elizacloud", error }, "Storage stats error");
1009
+ return null;
1010
+ }
1011
+ }
1012
+ }
1013
+ // src/database/direct-adapter.ts
1014
+ var import_core14 = require("@elizaos/core");
1015
+ var import_node2 = __toESM(require("@elizaos/plugin-sql/node"));
1016
+ function createDatabaseAdapter(config, agentId) {
1017
+ const adapter = import_node2.default.createDatabaseAdapter({ postgresUrl: config.postgresUrl }, agentId);
1018
+ import_core14.logger.info({ src: "plugin:elizacloud", agentId }, "Direct database adapter created");
1019
+ return adapter;
1020
+ }
1021
+ async function createDirectDatabaseAdapter(config, agentId) {
1022
+ return createDatabaseAdapter(config, agentId);
1023
+ }
1024
+ // src/database/schema.ts
1025
+ var import_node3 = __toESM(require("@elizaos/plugin-sql/node"));
1026
+ var {
1027
+ agentTable,
1028
+ roomTable,
1029
+ participantTable,
1030
+ memoryTable,
1031
+ embeddingTable,
1032
+ entityTable,
1033
+ relationshipTable,
1034
+ componentTable,
1035
+ taskTable,
1036
+ logTable,
1037
+ cacheTable,
1038
+ worldTable,
1039
+ serverTable,
1040
+ messageTable,
1041
+ messageServerTable,
1042
+ messageServerAgentsTable,
1043
+ channelTable,
1044
+ channelParticipantsTable
1045
+ } = import_node3.default.schema;
1046
+ var serverAgentsTable = serverTable;
594
1047
  // src/index.ts
1048
+ var cloudStorageInstance = null;
1049
+ function getCloudStorage() {
1050
+ return cloudStorageInstance;
1051
+ }
1052
+ async function initializeCloudDatabase(runtime) {
1053
+ const apiKey = getApiKey(runtime);
1054
+ const baseUrl = getBaseURL(runtime);
1055
+ if (!apiKey) {
1056
+ import_core15.logger.warn({ src: "plugin:elizacloud" }, "Cloud database enabled but no API key found - skipping database initialization");
1057
+ return;
1058
+ }
1059
+ import_core15.logger.info({ src: "plugin:elizacloud", agentId: runtime.agentId }, "Initializing cloud database");
1060
+ const adapter = await createCloudDatabaseAdapter({
1061
+ apiKey,
1062
+ baseUrl,
1063
+ agentId: runtime.agentId
1064
+ });
1065
+ if (adapter) {
1066
+ runtime.registerDatabaseAdapter(adapter);
1067
+ import_core15.logger.info({ src: "plugin:elizacloud", agentId: runtime.agentId }, "Cloud database adapter registered successfully");
1068
+ } else {
1069
+ import_core15.logger.error({ src: "plugin:elizacloud", agentId: runtime.agentId }, "Failed to initialize cloud database adapter");
1070
+ }
1071
+ }
1072
+ function initializeCloudStorage(runtime) {
1073
+ const apiKey = getApiKey(runtime);
1074
+ const baseUrl = getBaseURL(runtime);
1075
+ if (!apiKey) {
1076
+ import_core15.logger.warn({ src: "plugin:elizacloud" }, "No API key found - cloud storage will not be available");
1077
+ return;
1078
+ }
1079
+ cloudStorageInstance = new CloudStorageService({
1080
+ apiKey,
1081
+ baseUrl
1082
+ });
1083
+ import_core15.logger.info({ src: "plugin:elizacloud", agentId: runtime.agentId }, "Cloud storage service initialized");
1084
+ }
595
1085
  var elizaOSCloudPlugin = {
596
1086
  name: "elizaOSCloud",
597
- description: "ElizaOS Cloud plugin - Multi-model AI generation with text, image, and video support",
1087
+ description: "ElizaOS Cloud plugin - Complete AI, storage, and database solution. Provides multi-model inference (GPT-4, Claude, Gemini), embeddings, image generation, transcription, TTS, managed PostgreSQL database, and cloud file storage. A single plugin that replaces all other AI and database plugins.",
598
1088
  config: {
599
1089
  ELIZAOS_CLOUD_API_KEY: process.env.ELIZAOS_CLOUD_API_KEY,
600
1090
  ELIZAOS_CLOUD_BASE_URL: process.env.ELIZAOS_CLOUD_BASE_URL,
@@ -608,20 +1098,39 @@ var elizaOSCloudPlugin = {
608
1098
  ELIZAOS_CLOUD_EMBEDDING_DIMENSIONS: process.env.ELIZAOS_CLOUD_EMBEDDING_DIMENSIONS,
609
1099
  ELIZAOS_CLOUD_IMAGE_DESCRIPTION_MODEL: process.env.ELIZAOS_CLOUD_IMAGE_DESCRIPTION_MODEL,
610
1100
  ELIZAOS_CLOUD_IMAGE_DESCRIPTION_MAX_TOKENS: process.env.ELIZAOS_CLOUD_IMAGE_DESCRIPTION_MAX_TOKENS,
611
- ELIZAOS_CLOUD_EXPERIMENTAL_TELEMETRY: process.env.ELIZAOS_CLOUD_EXPERIMENTAL_TELEMETRY,
612
- ELIZAOS_CLOUD_IMAGE_GENERATION_MODEL: process.env.ELIZAOS_CLOUD_IMAGE_GENERATION_MODEL
1101
+ ELIZAOS_CLOUD_IMAGE_GENERATION_MODEL: process.env.ELIZAOS_CLOUD_IMAGE_GENERATION_MODEL,
1102
+ ELIZAOS_CLOUD_TTS_MODEL: process.env.ELIZAOS_CLOUD_TTS_MODEL,
1103
+ ELIZAOS_CLOUD_TTS_VOICE: process.env.ELIZAOS_CLOUD_TTS_VOICE,
1104
+ ELIZAOS_CLOUD_TRANSCRIPTION_MODEL: process.env.ELIZAOS_CLOUD_TRANSCRIPTION_MODEL,
1105
+ ELIZAOS_CLOUD_DATABASE: process.env.ELIZAOS_CLOUD_DATABASE,
1106
+ ELIZAOS_CLOUD_STORAGE: process.env.ELIZAOS_CLOUD_STORAGE,
1107
+ ELIZAOS_CLOUD_EXPERIMENTAL_TELEMETRY: process.env.ELIZAOS_CLOUD_EXPERIMENTAL_TELEMETRY
613
1108
  },
1109
+ priority: -1,
614
1110
  async init(config, runtime) {
615
1111
  initializeOpenAI(config, runtime);
1112
+ if (!isBrowser()) {
1113
+ initializeCloudStorage(runtime);
1114
+ }
1115
+ const cloudDatabaseEnabled = runtime.getSetting("ELIZAOS_CLOUD_DATABASE") === "true" || process.env.ELIZAOS_CLOUD_DATABASE === "true";
1116
+ if (cloudDatabaseEnabled && !isBrowser()) {
1117
+ await initializeCloudDatabase(runtime);
1118
+ }
616
1119
  },
617
1120
  models: {
618
- [import_core10.ModelType.TEXT_EMBEDDING]: handleTextEmbedding,
619
- [import_core10.ModelType.TEXT_SMALL]: handleTextSmall,
620
- [import_core10.ModelType.TEXT_LARGE]: handleTextLarge,
621
- [import_core10.ModelType.IMAGE]: handleImageGeneration,
622
- [import_core10.ModelType.IMAGE_DESCRIPTION]: handleImageDescription,
623
- [import_core10.ModelType.OBJECT_SMALL]: handleObjectSmall,
624
- [import_core10.ModelType.OBJECT_LARGE]: handleObjectLarge
1121
+ [import_core15.ModelType.TEXT_SMALL]: handleTextSmall,
1122
+ [import_core15.ModelType.TEXT_LARGE]: handleTextLarge,
1123
+ [import_core15.ModelType.TEXT_REASONING_SMALL]: handleTextSmall,
1124
+ [import_core15.ModelType.TEXT_REASONING_LARGE]: handleTextLarge,
1125
+ [import_core15.ModelType.OBJECT_SMALL]: handleObjectSmall,
1126
+ [import_core15.ModelType.OBJECT_LARGE]: handleObjectLarge,
1127
+ [import_core15.ModelType.TEXT_EMBEDDING]: handleTextEmbedding,
1128
+ [import_core15.ModelType.TEXT_TOKENIZER_ENCODE]: handleTokenizerEncode,
1129
+ [import_core15.ModelType.TEXT_TOKENIZER_DECODE]: handleTokenizerDecode,
1130
+ [import_core15.ModelType.IMAGE]: handleImageGeneration,
1131
+ [import_core15.ModelType.IMAGE_DESCRIPTION]: handleImageDescription,
1132
+ [import_core15.ModelType.TRANSCRIPTION]: handleTranscription,
1133
+ [import_core15.ModelType.TEXT_TO_SPEECH]: handleTextToSpeech
625
1134
  },
626
1135
  tests: [
627
1136
  {
@@ -637,7 +1146,7 @@ var elizaOSCloudPlugin = {
637
1146
  }
638
1147
  });
639
1148
  const data = await response.json();
640
- import_core10.logger.log({ data: data?.data?.length ?? "N/A" }, "Models Available");
1149
+ import_core15.logger.log({ data: data?.data?.length ?? "N/A" }, "Models Available");
641
1150
  if (!response.ok) {
642
1151
  throw new Error(`Failed to validate OpenAI API key: ${response.statusText}`);
643
1152
  }
@@ -647,13 +1156,13 @@ var elizaOSCloudPlugin = {
647
1156
  name: "ELIZAOS_CLOUD_test_text_embedding",
648
1157
  fn: async (runtime) => {
649
1158
  try {
650
- const embedding = await runtime.useModel(import_core10.ModelType.TEXT_EMBEDDING, {
1159
+ const embedding = await runtime.useModel(import_core15.ModelType.TEXT_EMBEDDING, {
651
1160
  text: "Hello, world!"
652
1161
  });
653
- import_core10.logger.log({ embedding }, "embedding");
1162
+ import_core15.logger.log({ embedding }, "embedding");
654
1163
  } catch (error) {
655
1164
  const message = error instanceof Error ? error.message : String(error);
656
- import_core10.logger.error(`Error in test_text_embedding: ${message}`);
1165
+ import_core15.logger.error(`Error in test_text_embedding: ${message}`);
657
1166
  throw error;
658
1167
  }
659
1168
  }
@@ -662,16 +1171,16 @@ var elizaOSCloudPlugin = {
662
1171
  name: "ELIZAOS_CLOUD_test_text_large",
663
1172
  fn: async (runtime) => {
664
1173
  try {
665
- const text = await runtime.useModel(import_core10.ModelType.TEXT_LARGE, {
1174
+ const text = await runtime.useModel(import_core15.ModelType.TEXT_LARGE, {
666
1175
  prompt: "What is the nature of reality in 10 words?"
667
1176
  });
668
1177
  if (text.length === 0) {
669
1178
  throw new Error("Failed to generate text");
670
1179
  }
671
- import_core10.logger.log({ text }, "generated with test_text_large");
1180
+ import_core15.logger.log({ text }, "generated with test_text_large");
672
1181
  } catch (error) {
673
1182
  const message = error instanceof Error ? error.message : String(error);
674
- import_core10.logger.error(`Error in test_text_large: ${message}`);
1183
+ import_core15.logger.error(`Error in test_text_large: ${message}`);
675
1184
  throw error;
676
1185
  }
677
1186
  }
@@ -680,16 +1189,16 @@ var elizaOSCloudPlugin = {
680
1189
  name: "ELIZAOS_CLOUD_test_text_small",
681
1190
  fn: async (runtime) => {
682
1191
  try {
683
- const text = await runtime.useModel(import_core10.ModelType.TEXT_SMALL, {
1192
+ const text = await runtime.useModel(import_core15.ModelType.TEXT_SMALL, {
684
1193
  prompt: "What is the nature of reality in 10 words?"
685
1194
  });
686
1195
  if (text.length === 0) {
687
1196
  throw new Error("Failed to generate text");
688
1197
  }
689
- import_core10.logger.log({ text }, "generated with test_text_small");
1198
+ import_core15.logger.log({ text }, "generated with test_text_small");
690
1199
  } catch (error) {
691
1200
  const message = error instanceof Error ? error.message : String(error);
692
- import_core10.logger.error(`Error in test_text_small: ${message}`);
1201
+ import_core15.logger.error(`Error in test_text_small: ${message}`);
693
1202
  throw error;
694
1203
  }
695
1204
  }
@@ -697,17 +1206,17 @@ var elizaOSCloudPlugin = {
697
1206
  {
698
1207
  name: "ELIZAOS_CLOUD_test_image_generation",
699
1208
  fn: async (runtime) => {
700
- import_core10.logger.log("ELIZAOS_CLOUD_test_image_generation");
1209
+ import_core15.logger.log("ELIZAOS_CLOUD_test_image_generation");
701
1210
  try {
702
- const image = await runtime.useModel(import_core10.ModelType.IMAGE, {
1211
+ const image = await runtime.useModel(import_core15.ModelType.IMAGE, {
703
1212
  prompt: "A beautiful sunset over a calm ocean",
704
1213
  n: 1,
705
1214
  size: "1024x1024"
706
1215
  });
707
- import_core10.logger.log({ image }, "generated with test_image_generation");
1216
+ import_core15.logger.log({ image }, "generated with test_image_generation");
708
1217
  } catch (error) {
709
1218
  const message = error instanceof Error ? error.message : String(error);
710
- import_core10.logger.error(`Error in test_image_generation: ${message}`);
1219
+ import_core15.logger.error(`Error in test_image_generation: ${message}`);
711
1220
  throw error;
712
1221
  }
713
1222
  }
@@ -716,36 +1225,36 @@ var elizaOSCloudPlugin = {
716
1225
  name: "image-description",
717
1226
  fn: async (runtime) => {
718
1227
  try {
719
- import_core10.logger.log("ELIZAOS_CLOUD_test_image_description");
1228
+ import_core15.logger.log("ELIZAOS_CLOUD_test_image_description");
720
1229
  try {
721
- const result = await runtime.useModel(import_core10.ModelType.IMAGE_DESCRIPTION, "https://upload.wikimedia.org/wikipedia/commons/thumb/1/1c/Vitalik_Buterin_TechCrunch_London_2015_%28cropped%29.jpg/537px-Vitalik_Buterin_TechCrunch_London_2015_%28cropped%29.jpg");
1230
+ const result = await runtime.useModel(import_core15.ModelType.IMAGE_DESCRIPTION, "https://upload.wikimedia.org/wikipedia/commons/thumb/1/1c/Vitalik_Buterin_TechCrunch_London_2015_%28cropped%29.jpg/537px-Vitalik_Buterin_TechCrunch_London_2015_%28cropped%29.jpg");
722
1231
  if (result && typeof result === "object" && "title" in result && "description" in result) {
723
- import_core10.logger.log({ result }, "Image description");
1232
+ import_core15.logger.log({ result }, "Image description");
724
1233
  } else {
725
- import_core10.logger.error("Invalid image description result format:", result);
1234
+ import_core15.logger.error("Invalid image description result format:", result);
726
1235
  }
727
1236
  } catch (e) {
728
1237
  const message = e instanceof Error ? e.message : String(e);
729
- import_core10.logger.error(`Error in image description test: ${message}`);
1238
+ import_core15.logger.error(`Error in image description test: ${message}`);
730
1239
  }
731
1240
  } catch (e) {
732
1241
  const message = e instanceof Error ? e.message : String(e);
733
- import_core10.logger.error(`Error in ELIZAOS_CLOUD_test_image_description: ${message}`);
1242
+ import_core15.logger.error(`Error in ELIZAOS_CLOUD_test_image_description: ${message}`);
734
1243
  }
735
1244
  }
736
1245
  },
737
1246
  {
738
1247
  name: "ELIZAOS_CLOUD_test_transcription",
739
1248
  fn: async (runtime) => {
740
- import_core10.logger.log("ELIZAOS_CLOUD_test_transcription");
1249
+ import_core15.logger.log("ELIZAOS_CLOUD_test_transcription");
741
1250
  try {
742
1251
  const response = await fetch("https://upload.wikimedia.org/wikipedia/en/4/40/Chris_Benoit_Voice_Message.ogg");
743
1252
  const arrayBuffer = await response.arrayBuffer();
744
- const transcription = await runtime.useModel(import_core10.ModelType.TRANSCRIPTION, Buffer.from(new Uint8Array(arrayBuffer)));
745
- import_core10.logger.log({ transcription }, "generated with test_transcription");
1253
+ const transcription = await runtime.useModel(import_core15.ModelType.TRANSCRIPTION, Buffer.from(new Uint8Array(arrayBuffer)));
1254
+ import_core15.logger.log({ transcription }, "generated with test_transcription");
746
1255
  } catch (error) {
747
1256
  const message = error instanceof Error ? error.message : String(error);
748
- import_core10.logger.error(`Error in test_transcription: ${message}`);
1257
+ import_core15.logger.error(`Error in test_transcription: ${message}`);
749
1258
  throw error;
750
1259
  }
751
1260
  }
@@ -754,23 +1263,23 @@ var elizaOSCloudPlugin = {
754
1263
  name: "ELIZAOS_CLOUD_test_text_tokenizer_encode",
755
1264
  fn: async (runtime) => {
756
1265
  const prompt = "Hello tokenizer encode!";
757
- const tokens = await runtime.useModel(import_core10.ModelType.TEXT_TOKENIZER_ENCODE, { prompt });
1266
+ const tokens = await runtime.useModel(import_core15.ModelType.TEXT_TOKENIZER_ENCODE, { prompt });
758
1267
  if (!Array.isArray(tokens) || tokens.length === 0) {
759
1268
  throw new Error("Failed to tokenize text: expected non-empty array of tokens");
760
1269
  }
761
- import_core10.logger.log({ tokens }, "Tokenized output");
1270
+ import_core15.logger.log({ tokens }, "Tokenized output");
762
1271
  }
763
1272
  },
764
1273
  {
765
1274
  name: "ELIZAOS_CLOUD_test_text_tokenizer_decode",
766
1275
  fn: async (runtime) => {
767
1276
  const prompt = "Hello tokenizer decode!";
768
- const tokens = await runtime.useModel(import_core10.ModelType.TEXT_TOKENIZER_ENCODE, { prompt });
769
- const decodedText = await runtime.useModel(import_core10.ModelType.TEXT_TOKENIZER_DECODE, { tokens });
1277
+ const tokens = await runtime.useModel(import_core15.ModelType.TEXT_TOKENIZER_ENCODE, { prompt });
1278
+ const decodedText = await runtime.useModel(import_core15.ModelType.TEXT_TOKENIZER_DECODE, { tokens });
770
1279
  if (decodedText !== prompt) {
771
1280
  throw new Error(`Decoded text does not match original. Expected "${prompt}", got "${decodedText}"`);
772
1281
  }
773
- import_core10.logger.log({ decodedText }, "Decoded text");
1282
+ import_core15.logger.log({ decodedText }, "Decoded text");
774
1283
  }
775
1284
  },
776
1285
  {
@@ -783,10 +1292,10 @@ var elizaOSCloudPlugin = {
783
1292
  if (!response) {
784
1293
  throw new Error("Failed to generate speech");
785
1294
  }
786
- import_core10.logger.log("Generated speech successfully");
1295
+ import_core15.logger.log("Generated speech successfully");
787
1296
  } catch (error) {
788
1297
  const message = error instanceof Error ? error.message : String(error);
789
- import_core10.logger.error(`Error in ELIZAOS_CLOUD_test_text_to_speech: ${message}`);
1298
+ import_core15.logger.error(`Error in ELIZAOS_CLOUD_test_text_to_speech: ${message}`);
790
1299
  throw error;
791
1300
  }
792
1301
  }
@@ -797,4 +1306,4 @@ var elizaOSCloudPlugin = {
797
1306
  };
798
1307
  var src_default = elizaOSCloudPlugin;
799
1308
 
800
- //# debugId=A9BD62A484AEFF9664756E2164756E21
1309
+ //# debugId=7F91E5A78C775CA264756E2164756E21