@elizaos/plugin-elizacloud 1.5.19 → 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");
@@ -106,6 +133,9 @@ function getLargeModel(runtime) {
106
133
  function getImageDescriptionModel(runtime) {
107
134
  return getSetting(runtime, "ELIZAOS_CLOUD_IMAGE_DESCRIPTION_MODEL", "gpt-4o-mini") ?? "gpt-4o-mini";
108
135
  }
136
+ function getImageGenerationModel(runtime) {
137
+ return getSetting(runtime, "ELIZAOS_CLOUD_IMAGE_GENERATION_MODEL", "openai/gpt-5-nano") ?? "openai/gpt-5-nano";
138
+ }
109
139
  function getExperimentalTelemetry(runtime) {
110
140
  const setting = getSetting(runtime, "ELIZAOS_CLOUD_EXPERIMENTAL_TELEMETRY", "false");
111
141
  const normalizedSetting = String(setting).toLowerCase();
@@ -262,6 +292,31 @@ function getJsonRepairFunction() {
262
292
  }
263
293
  };
264
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
+ }
265
320
  async function webStreamToNodeStream(webStream) {
266
321
  try {
267
322
  const { Readable } = await import("node:stream");
@@ -437,7 +492,7 @@ async function handleImageGeneration(runtime, params) {
437
492
  const numImages = params.n || 1;
438
493
  const size = params.size || "1024x1024";
439
494
  const prompt = params.prompt;
440
- const modelName = "google/gemini-2.5-flash-image-preview";
495
+ const modelName = getImageGenerationModel(runtime);
441
496
  import_core8.logger.log(`[ELIZAOS_CLOUD] Using IMAGE model: ${modelName}`);
442
497
  const baseURL = getBaseURL(runtime);
443
498
  const aspectRatioMap = {
@@ -545,8 +600,89 @@ async function handleImageDescription(runtime, params) {
545
600
  };
546
601
  }
547
602
  }
548
- // src/models/speech.ts
603
+ // src/models/transcription.ts
549
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");
550
686
  async function fetchTextToSpeech(runtime, options) {
551
687
  const defaultModel = getSetting(runtime, "ELIZAOS_CLOUD_TTS_MODEL", "gpt-4o-mini-tts");
552
688
  const defaultVoice = getSetting(runtime, "ELIZAOS_CLOUD_TTS_VOICE", "nova");
@@ -588,10 +724,367 @@ async function fetchTextToSpeech(runtime, options) {
588
724
  throw new Error(`Failed to fetch speech from ElizaOS Cloud TTS: ${message}`);
589
725
  }
590
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;
591
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
+ }
592
1085
  var elizaOSCloudPlugin = {
593
1086
  name: "elizaOSCloud",
594
- 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.",
595
1088
  config: {
596
1089
  ELIZAOS_CLOUD_API_KEY: process.env.ELIZAOS_CLOUD_API_KEY,
597
1090
  ELIZAOS_CLOUD_BASE_URL: process.env.ELIZAOS_CLOUD_BASE_URL,
@@ -605,19 +1098,39 @@ var elizaOSCloudPlugin = {
605
1098
  ELIZAOS_CLOUD_EMBEDDING_DIMENSIONS: process.env.ELIZAOS_CLOUD_EMBEDDING_DIMENSIONS,
606
1099
  ELIZAOS_CLOUD_IMAGE_DESCRIPTION_MODEL: process.env.ELIZAOS_CLOUD_IMAGE_DESCRIPTION_MODEL,
607
1100
  ELIZAOS_CLOUD_IMAGE_DESCRIPTION_MAX_TOKENS: process.env.ELIZAOS_CLOUD_IMAGE_DESCRIPTION_MAX_TOKENS,
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,
608
1107
  ELIZAOS_CLOUD_EXPERIMENTAL_TELEMETRY: process.env.ELIZAOS_CLOUD_EXPERIMENTAL_TELEMETRY
609
1108
  },
1109
+ priority: -1,
610
1110
  async init(config, runtime) {
611
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
+ }
612
1119
  },
613
1120
  models: {
614
- [import_core10.ModelType.TEXT_EMBEDDING]: handleTextEmbedding,
615
- [import_core10.ModelType.TEXT_SMALL]: handleTextSmall,
616
- [import_core10.ModelType.TEXT_LARGE]: handleTextLarge,
617
- [import_core10.ModelType.IMAGE]: handleImageGeneration,
618
- [import_core10.ModelType.IMAGE_DESCRIPTION]: handleImageDescription,
619
- [import_core10.ModelType.OBJECT_SMALL]: handleObjectSmall,
620
- [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
621
1134
  },
622
1135
  tests: [
623
1136
  {
@@ -633,7 +1146,7 @@ var elizaOSCloudPlugin = {
633
1146
  }
634
1147
  });
635
1148
  const data = await response.json();
636
- 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");
637
1150
  if (!response.ok) {
638
1151
  throw new Error(`Failed to validate OpenAI API key: ${response.statusText}`);
639
1152
  }
@@ -643,13 +1156,13 @@ var elizaOSCloudPlugin = {
643
1156
  name: "ELIZAOS_CLOUD_test_text_embedding",
644
1157
  fn: async (runtime) => {
645
1158
  try {
646
- const embedding = await runtime.useModel(import_core10.ModelType.TEXT_EMBEDDING, {
1159
+ const embedding = await runtime.useModel(import_core15.ModelType.TEXT_EMBEDDING, {
647
1160
  text: "Hello, world!"
648
1161
  });
649
- import_core10.logger.log({ embedding }, "embedding");
1162
+ import_core15.logger.log({ embedding }, "embedding");
650
1163
  } catch (error) {
651
1164
  const message = error instanceof Error ? error.message : String(error);
652
- import_core10.logger.error(`Error in test_text_embedding: ${message}`);
1165
+ import_core15.logger.error(`Error in test_text_embedding: ${message}`);
653
1166
  throw error;
654
1167
  }
655
1168
  }
@@ -658,16 +1171,16 @@ var elizaOSCloudPlugin = {
658
1171
  name: "ELIZAOS_CLOUD_test_text_large",
659
1172
  fn: async (runtime) => {
660
1173
  try {
661
- const text = await runtime.useModel(import_core10.ModelType.TEXT_LARGE, {
1174
+ const text = await runtime.useModel(import_core15.ModelType.TEXT_LARGE, {
662
1175
  prompt: "What is the nature of reality in 10 words?"
663
1176
  });
664
1177
  if (text.length === 0) {
665
1178
  throw new Error("Failed to generate text");
666
1179
  }
667
- import_core10.logger.log({ text }, "generated with test_text_large");
1180
+ import_core15.logger.log({ text }, "generated with test_text_large");
668
1181
  } catch (error) {
669
1182
  const message = error instanceof Error ? error.message : String(error);
670
- import_core10.logger.error(`Error in test_text_large: ${message}`);
1183
+ import_core15.logger.error(`Error in test_text_large: ${message}`);
671
1184
  throw error;
672
1185
  }
673
1186
  }
@@ -676,16 +1189,16 @@ var elizaOSCloudPlugin = {
676
1189
  name: "ELIZAOS_CLOUD_test_text_small",
677
1190
  fn: async (runtime) => {
678
1191
  try {
679
- const text = await runtime.useModel(import_core10.ModelType.TEXT_SMALL, {
1192
+ const text = await runtime.useModel(import_core15.ModelType.TEXT_SMALL, {
680
1193
  prompt: "What is the nature of reality in 10 words?"
681
1194
  });
682
1195
  if (text.length === 0) {
683
1196
  throw new Error("Failed to generate text");
684
1197
  }
685
- import_core10.logger.log({ text }, "generated with test_text_small");
1198
+ import_core15.logger.log({ text }, "generated with test_text_small");
686
1199
  } catch (error) {
687
1200
  const message = error instanceof Error ? error.message : String(error);
688
- import_core10.logger.error(`Error in test_text_small: ${message}`);
1201
+ import_core15.logger.error(`Error in test_text_small: ${message}`);
689
1202
  throw error;
690
1203
  }
691
1204
  }
@@ -693,17 +1206,17 @@ var elizaOSCloudPlugin = {
693
1206
  {
694
1207
  name: "ELIZAOS_CLOUD_test_image_generation",
695
1208
  fn: async (runtime) => {
696
- import_core10.logger.log("ELIZAOS_CLOUD_test_image_generation");
1209
+ import_core15.logger.log("ELIZAOS_CLOUD_test_image_generation");
697
1210
  try {
698
- const image = await runtime.useModel(import_core10.ModelType.IMAGE, {
1211
+ const image = await runtime.useModel(import_core15.ModelType.IMAGE, {
699
1212
  prompt: "A beautiful sunset over a calm ocean",
700
1213
  n: 1,
701
1214
  size: "1024x1024"
702
1215
  });
703
- import_core10.logger.log({ image }, "generated with test_image_generation");
1216
+ import_core15.logger.log({ image }, "generated with test_image_generation");
704
1217
  } catch (error) {
705
1218
  const message = error instanceof Error ? error.message : String(error);
706
- import_core10.logger.error(`Error in test_image_generation: ${message}`);
1219
+ import_core15.logger.error(`Error in test_image_generation: ${message}`);
707
1220
  throw error;
708
1221
  }
709
1222
  }
@@ -712,36 +1225,36 @@ var elizaOSCloudPlugin = {
712
1225
  name: "image-description",
713
1226
  fn: async (runtime) => {
714
1227
  try {
715
- import_core10.logger.log("ELIZAOS_CLOUD_test_image_description");
1228
+ import_core15.logger.log("ELIZAOS_CLOUD_test_image_description");
716
1229
  try {
717
- 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");
718
1231
  if (result && typeof result === "object" && "title" in result && "description" in result) {
719
- import_core10.logger.log({ result }, "Image description");
1232
+ import_core15.logger.log({ result }, "Image description");
720
1233
  } else {
721
- import_core10.logger.error("Invalid image description result format:", result);
1234
+ import_core15.logger.error("Invalid image description result format:", result);
722
1235
  }
723
1236
  } catch (e) {
724
1237
  const message = e instanceof Error ? e.message : String(e);
725
- import_core10.logger.error(`Error in image description test: ${message}`);
1238
+ import_core15.logger.error(`Error in image description test: ${message}`);
726
1239
  }
727
1240
  } catch (e) {
728
1241
  const message = e instanceof Error ? e.message : String(e);
729
- 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}`);
730
1243
  }
731
1244
  }
732
1245
  },
733
1246
  {
734
1247
  name: "ELIZAOS_CLOUD_test_transcription",
735
1248
  fn: async (runtime) => {
736
- import_core10.logger.log("ELIZAOS_CLOUD_test_transcription");
1249
+ import_core15.logger.log("ELIZAOS_CLOUD_test_transcription");
737
1250
  try {
738
1251
  const response = await fetch("https://upload.wikimedia.org/wikipedia/en/4/40/Chris_Benoit_Voice_Message.ogg");
739
1252
  const arrayBuffer = await response.arrayBuffer();
740
- const transcription = await runtime.useModel(import_core10.ModelType.TRANSCRIPTION, Buffer.from(new Uint8Array(arrayBuffer)));
741
- 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");
742
1255
  } catch (error) {
743
1256
  const message = error instanceof Error ? error.message : String(error);
744
- import_core10.logger.error(`Error in test_transcription: ${message}`);
1257
+ import_core15.logger.error(`Error in test_transcription: ${message}`);
745
1258
  throw error;
746
1259
  }
747
1260
  }
@@ -750,23 +1263,23 @@ var elizaOSCloudPlugin = {
750
1263
  name: "ELIZAOS_CLOUD_test_text_tokenizer_encode",
751
1264
  fn: async (runtime) => {
752
1265
  const prompt = "Hello tokenizer encode!";
753
- 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 });
754
1267
  if (!Array.isArray(tokens) || tokens.length === 0) {
755
1268
  throw new Error("Failed to tokenize text: expected non-empty array of tokens");
756
1269
  }
757
- import_core10.logger.log({ tokens }, "Tokenized output");
1270
+ import_core15.logger.log({ tokens }, "Tokenized output");
758
1271
  }
759
1272
  },
760
1273
  {
761
1274
  name: "ELIZAOS_CLOUD_test_text_tokenizer_decode",
762
1275
  fn: async (runtime) => {
763
1276
  const prompt = "Hello tokenizer decode!";
764
- const tokens = await runtime.useModel(import_core10.ModelType.TEXT_TOKENIZER_ENCODE, { prompt });
765
- 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 });
766
1279
  if (decodedText !== prompt) {
767
1280
  throw new Error(`Decoded text does not match original. Expected "${prompt}", got "${decodedText}"`);
768
1281
  }
769
- import_core10.logger.log({ decodedText }, "Decoded text");
1282
+ import_core15.logger.log({ decodedText }, "Decoded text");
770
1283
  }
771
1284
  },
772
1285
  {
@@ -779,10 +1292,10 @@ var elizaOSCloudPlugin = {
779
1292
  if (!response) {
780
1293
  throw new Error("Failed to generate speech");
781
1294
  }
782
- import_core10.logger.log("Generated speech successfully");
1295
+ import_core15.logger.log("Generated speech successfully");
783
1296
  } catch (error) {
784
1297
  const message = error instanceof Error ? error.message : String(error);
785
- 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}`);
786
1299
  throw error;
787
1300
  }
788
1301
  }
@@ -793,4 +1306,4 @@ var elizaOSCloudPlugin = {
793
1306
  };
794
1307
  var src_default = elizaOSCloudPlugin;
795
1308
 
796
- //# debugId=F60800BE26E0FDF264756E2164756E21
1309
+ //# debugId=7F91E5A78C775CA264756E2164756E21