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

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,40 +42,13 @@ 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,
61
45
  elizaOSCloudPlugin: () => elizaOSCloudPlugin,
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
46
+ default: () => src_default
74
47
  });
75
48
  module.exports = __toCommonJS(exports_index_node);
76
49
 
77
50
  // src/index.ts
78
- var import_core15 = require("@elizaos/core");
51
+ var import_core10 = require("@elizaos/core");
79
52
 
80
53
  // src/init.ts
81
54
  var import_core2 = require("@elizaos/core");
@@ -83,7 +56,11 @@ var import_core2 = require("@elizaos/core");
83
56
  // src/utils/config.ts
84
57
  var import_core = require("@elizaos/core");
85
58
  function getSetting(runtime, key, defaultValue) {
86
- return runtime.getSetting(key) ?? process.env[key] ?? defaultValue;
59
+ const value = runtime.getSetting(key);
60
+ if (value !== undefined && value !== null) {
61
+ return String(value);
62
+ }
63
+ return process.env[key] ?? defaultValue;
87
64
  }
88
65
  function isBrowser() {
89
66
  return typeof globalThis !== "undefined" && typeof globalThis.document !== "undefined";
@@ -194,33 +171,36 @@ function createOpenAIClient(runtime) {
194
171
  // src/utils/events.ts
195
172
  var import_core3 = require("@elizaos/core");
196
173
  function emitModelUsageEvent(runtime, type, prompt, usage) {
174
+ const truncatedPrompt = typeof prompt === "string" ? prompt.length > 200 ? `${prompt.slice(0, 200)}…` : prompt : "";
175
+ const inputTokens = Number(usage.inputTokens || 0);
176
+ const outputTokens = Number(usage.outputTokens || 0);
177
+ const totalTokens = Number(usage.totalTokens != null ? usage.totalTokens : inputTokens + outputTokens);
197
178
  runtime.emitEvent(import_core3.EventType.MODEL_USED, {
198
- provider: "openai",
179
+ runtime,
180
+ source: "elizacloud",
181
+ provider: "elizacloud",
199
182
  type,
200
- prompt,
183
+ prompt: truncatedPrompt,
201
184
  tokens: {
202
- prompt: usage.inputTokens,
203
- completion: usage.outputTokens,
204
- total: usage.totalTokens
185
+ prompt: inputTokens,
186
+ completion: outputTokens,
187
+ total: totalTokens
205
188
  }
206
189
  });
207
190
  }
208
191
 
209
192
  // src/models/text.ts
210
- async function handleTextSmall(runtime, {
211
- prompt,
212
- stopSequences = [],
213
- maxTokens = 8192,
214
- temperature = 0.7,
215
- frequencyPenalty = 0.7,
216
- presencePenalty = 0.7
217
- }) {
193
+ function buildGenerateParams(runtime, modelType, params) {
194
+ const { prompt, stopSequences = [] } = params;
195
+ const temperature = params.temperature ?? 0.7;
196
+ const frequencyPenalty = params.frequencyPenalty ?? 0.7;
197
+ const presencePenalty = params.presencePenalty ?? 0.7;
198
+ const maxTokens = params.maxOutputTokens ?? params.maxTokens ?? 8192;
218
199
  const openai = createOpenAIClient(runtime);
219
- const modelName = getSmallModel(runtime);
200
+ const modelName = modelType === import_core4.ModelType.TEXT_SMALL ? getSmallModel(runtime) : getLargeModel(runtime);
201
+ const modelLabel = modelType === import_core4.ModelType.TEXT_SMALL ? "TEXT_SMALL" : "TEXT_LARGE";
220
202
  const experimentalTelemetry = getExperimentalTelemetry(runtime);
221
- import_core4.logger.log(`[ELIZAOS_CLOUD] Using TEXT_SMALL model: ${modelName}`);
222
- import_core4.logger.log(prompt);
223
- const { text: openaiResponse, usage } = await import_ai.generateText({
203
+ const generateParams = {
224
204
  model: openai.languageModel(modelName),
225
205
  prompt,
226
206
  system: runtime.character.system ?? undefined,
@@ -232,42 +212,50 @@ async function handleTextSmall(runtime, {
232
212
  experimental_telemetry: {
233
213
  isEnabled: experimentalTelemetry
234
214
  }
235
- });
236
- if (usage) {
237
- emitModelUsageEvent(runtime, import_core4.ModelType.TEXT_SMALL, prompt, usage);
238
- }
239
- return openaiResponse;
215
+ };
216
+ return { generateParams, modelName, modelLabel, prompt };
217
+ }
218
+ function handleStreamingGeneration(runtime, modelType, generateParams, prompt, modelLabel) {
219
+ import_core4.logger.debug(`[ELIZAOS_CLOUD] Streaming text with ${modelLabel} model`);
220
+ const streamResult = import_ai.streamText(generateParams);
221
+ return {
222
+ textStream: streamResult.textStream,
223
+ text: streamResult.text,
224
+ usage: streamResult.usage.then((usage) => {
225
+ if (usage) {
226
+ emitModelUsageEvent(runtime, modelType, prompt, usage);
227
+ const inputTokens = usage.inputTokens ?? 0;
228
+ const outputTokens = usage.outputTokens ?? 0;
229
+ return {
230
+ promptTokens: inputTokens,
231
+ completionTokens: outputTokens,
232
+ totalTokens: inputTokens + outputTokens
233
+ };
234
+ }
235
+ return;
236
+ }),
237
+ finishReason: streamResult.finishReason
238
+ };
240
239
  }
241
- async function handleTextLarge(runtime, {
242
- prompt,
243
- stopSequences = [],
244
- maxTokens = 8192,
245
- temperature = 0.7,
246
- frequencyPenalty = 0.7,
247
- presencePenalty = 0.7
248
- }) {
249
- const openai = createOpenAIClient(runtime);
250
- const modelName = getLargeModel(runtime);
251
- const experimentalTelemetry = getExperimentalTelemetry(runtime);
252
- import_core4.logger.log(`[ELIZAOS_CLOUD] Using TEXT_LARGE model: ${modelName}`);
240
+ async function generateTextWithModel(runtime, modelType, params) {
241
+ const { generateParams, modelName, modelLabel, prompt } = buildGenerateParams(runtime, modelType, params);
242
+ import_core4.logger.debug(`[ELIZAOS_CLOUD] Generating text with ${modelLabel} model: ${modelName}`);
243
+ if (params.stream) {
244
+ return handleStreamingGeneration(runtime, modelType, generateParams, prompt, modelLabel);
245
+ }
246
+ import_core4.logger.log(`[ELIZAOS_CLOUD] Using ${modelLabel} model: ${modelName}`);
253
247
  import_core4.logger.log(prompt);
254
- const { text: openaiResponse, usage } = await import_ai.generateText({
255
- model: openai.languageModel(modelName),
256
- prompt,
257
- system: runtime.character.system ?? undefined,
258
- temperature,
259
- maxOutputTokens: maxTokens,
260
- frequencyPenalty,
261
- presencePenalty,
262
- stopSequences,
263
- experimental_telemetry: {
264
- isEnabled: experimentalTelemetry
265
- }
266
- });
267
- if (usage) {
268
- emitModelUsageEvent(runtime, import_core4.ModelType.TEXT_LARGE, prompt, usage);
248
+ const response = await import_ai.generateText(generateParams);
249
+ if (response.usage) {
250
+ emitModelUsageEvent(runtime, modelType, prompt, response.usage);
269
251
  }
270
- return openaiResponse;
252
+ return response.text;
253
+ }
254
+ async function handleTextSmall(runtime, params) {
255
+ return generateTextWithModel(runtime, import_core4.ModelType.TEXT_SMALL, params);
256
+ }
257
+ async function handleTextLarge(runtime, params) {
258
+ return generateTextWithModel(runtime, import_core4.ModelType.TEXT_LARGE, params);
271
259
  }
272
260
  // src/models/object.ts
273
261
  var import_core6 = require("@elizaos/core");
@@ -292,31 +280,6 @@ function getJsonRepairFunction() {
292
280
  }
293
281
  };
294
282
  }
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
- }
320
283
  async function webStreamToNodeStream(webStream) {
321
284
  try {
322
285
  const { Readable } = await import("node:stream");
@@ -410,7 +373,19 @@ async function handleObjectLarge(runtime, params) {
410
373
  }
411
374
  // src/models/embeddings.ts
412
375
  var import_core7 = require("@elizaos/core");
413
- async function handleTextEmbedding(runtime, params) {
376
+ var MAX_BATCH_SIZE = 100;
377
+ function extractRateLimitInfo(response) {
378
+ return {
379
+ remainingRequests: parseInt(response.headers.get("x-ratelimit-remaining-requests") || "", 10) || undefined,
380
+ remainingTokens: parseInt(response.headers.get("x-ratelimit-remaining-tokens") || "", 10) || undefined,
381
+ limitRequests: parseInt(response.headers.get("x-ratelimit-limit-requests") || "", 10) || undefined,
382
+ limitTokens: parseInt(response.headers.get("x-ratelimit-limit-tokens") || "", 10) || undefined,
383
+ resetRequests: response.headers.get("x-ratelimit-reset-requests") || undefined,
384
+ resetTokens: response.headers.get("x-ratelimit-reset-tokens") || undefined,
385
+ retryAfter: parseInt(response.headers.get("retry-after") || "", 10) || undefined
386
+ };
387
+ }
388
+ function getEmbeddingConfig(runtime) {
414
389
  const embeddingModelName = getSetting(runtime, "ELIZAOS_CLOUD_EMBEDDING_MODEL", "text-embedding-3-small");
415
390
  const embeddingDimension = Number.parseInt(getSetting(runtime, "ELIZAOS_CLOUD_EMBEDDING_DIMENSIONS", "1536") || "1536", 10);
416
391
  if (!Object.values(import_core7.VECTOR_DIMS).includes(embeddingDimension)) {
@@ -418,11 +393,23 @@ async function handleTextEmbedding(runtime, params) {
418
393
  import_core7.logger.error(errorMsg);
419
394
  throw new Error(errorMsg);
420
395
  }
396
+ return { embeddingModelName, embeddingDimension };
397
+ }
398
+ function createErrorVector(dimension, marker) {
399
+ const vector = Array(dimension).fill(0);
400
+ vector[0] = marker;
401
+ return vector;
402
+ }
403
+ async function handleTextEmbedding(runtime, params) {
404
+ const { embeddingDimension } = getEmbeddingConfig(runtime);
421
405
  if (params === null) {
422
406
  import_core7.logger.debug("Creating test embedding for initialization");
423
- const testVector = Array(embeddingDimension).fill(0);
424
- testVector[0] = 0.1;
425
- return testVector;
407
+ return createErrorVector(embeddingDimension, 0.1);
408
+ }
409
+ const anyParams = params;
410
+ if (typeof anyParams === "object" && "texts" in anyParams && Array.isArray(anyParams.texts)) {
411
+ import_core7.logger.debug(`[Embeddings] Batch mode: ${anyParams.texts.length} texts`);
412
+ return await handleBatchTextEmbedding(runtime, anyParams.texts);
426
413
  }
427
414
  let text;
428
415
  if (typeof params === "string") {
@@ -431,65 +418,131 @@ async function handleTextEmbedding(runtime, params) {
431
418
  text = params.text;
432
419
  } else {
433
420
  import_core7.logger.warn("Invalid input format for embedding");
434
- const fallbackVector = Array(embeddingDimension).fill(0);
435
- fallbackVector[0] = 0.2;
436
- return fallbackVector;
421
+ return createErrorVector(embeddingDimension, 0.2);
437
422
  }
438
423
  if (!text.trim()) {
439
424
  import_core7.logger.warn("Empty text for embedding");
440
- const emptyVector = Array(embeddingDimension).fill(0);
441
- emptyVector[0] = 0.3;
442
- return emptyVector;
425
+ return createErrorVector(embeddingDimension, 0.3);
443
426
  }
427
+ const results = await handleBatchTextEmbedding(runtime, [text]);
428
+ return results[0];
429
+ }
430
+ async function handleBatchTextEmbedding(runtime, texts) {
431
+ const { embeddingModelName, embeddingDimension } = getEmbeddingConfig(runtime);
444
432
  const embeddingBaseURL = getEmbeddingBaseURL(runtime);
445
- try {
446
- const response = await fetch(`${embeddingBaseURL}/embeddings`, {
447
- method: "POST",
448
- headers: {
449
- ...getAuthHeader(runtime, true),
450
- "Content-Type": "application/json"
451
- },
452
- body: JSON.stringify({
453
- model: embeddingModelName,
454
- input: text
455
- })
456
- });
457
- if (!response.ok) {
458
- import_core7.logger.error(`ElizaOS Cloud API error: ${response.status} - ${response.statusText}`);
459
- const errorVector = Array(embeddingDimension).fill(0);
460
- errorVector[0] = 0.4;
461
- return errorVector;
462
- }
463
- const data = await response.json();
464
- if (!data?.data?.[0]?.embedding) {
465
- import_core7.logger.error("API returned invalid structure");
466
- const errorVector = Array(embeddingDimension).fill(0);
467
- errorVector[0] = 0.5;
468
- return errorVector;
433
+ if (!texts || texts.length === 0) {
434
+ import_core7.logger.warn("[BatchEmbeddings] Empty texts array");
435
+ return [];
436
+ }
437
+ const validTexts = [];
438
+ const results = new Array(texts.length);
439
+ for (let i = 0;i < texts.length; i++) {
440
+ const text = texts[i]?.trim();
441
+ if (text) {
442
+ validTexts.push({ text, originalIndex: i });
443
+ } else {
444
+ results[i] = createErrorVector(embeddingDimension, 0.3);
469
445
  }
470
- const embedding = data.data[0].embedding;
471
- if (data.usage) {
472
- const usage = {
473
- inputTokens: data.usage.prompt_tokens,
474
- outputTokens: 0,
475
- totalTokens: data.usage.total_tokens
476
- };
477
- emitModelUsageEvent(runtime, import_core7.ModelType.TEXT_EMBEDDING, text, usage);
446
+ }
447
+ if (validTexts.length === 0) {
448
+ import_core7.logger.warn("[BatchEmbeddings] All texts were empty");
449
+ return results;
450
+ }
451
+ for (let batchStart = 0;batchStart < validTexts.length; batchStart += MAX_BATCH_SIZE) {
452
+ const batchEnd = Math.min(batchStart + MAX_BATCH_SIZE, validTexts.length);
453
+ const batch = validTexts.slice(batchStart, batchEnd);
454
+ const batchTexts = batch.map((b) => b.text);
455
+ import_core7.logger.info(`[BatchEmbeddings] Processing batch ${Math.floor(batchStart / MAX_BATCH_SIZE) + 1}/${Math.ceil(validTexts.length / MAX_BATCH_SIZE)}: ${batch.length} texts`);
456
+ try {
457
+ const response = await fetch(`${embeddingBaseURL}/embeddings`, {
458
+ method: "POST",
459
+ headers: {
460
+ ...getAuthHeader(runtime, true),
461
+ "Content-Type": "application/json"
462
+ },
463
+ body: JSON.stringify({
464
+ model: embeddingModelName,
465
+ input: batchTexts
466
+ })
467
+ });
468
+ const rateLimitInfo = extractRateLimitInfo(response);
469
+ if (rateLimitInfo.remainingRequests !== undefined && rateLimitInfo.remainingRequests < 50) {
470
+ import_core7.logger.warn(`[BatchEmbeddings] Rate limit: ${rateLimitInfo.remainingRequests}/${rateLimitInfo.limitRequests} requests remaining`);
471
+ }
472
+ if (response.status === 429) {
473
+ const retryAfter = rateLimitInfo.retryAfter || 30;
474
+ import_core7.logger.warn(`[BatchEmbeddings] Rate limited, waiting ${retryAfter}s...`);
475
+ await new Promise((resolve) => setTimeout(resolve, retryAfter * 1000));
476
+ const retryResponse = await fetch(`${embeddingBaseURL}/embeddings`, {
477
+ method: "POST",
478
+ headers: {
479
+ ...getAuthHeader(runtime, true),
480
+ "Content-Type": "application/json"
481
+ },
482
+ body: JSON.stringify({
483
+ model: embeddingModelName,
484
+ input: batchTexts
485
+ })
486
+ });
487
+ if (!retryResponse.ok) {
488
+ import_core7.logger.error(`[BatchEmbeddings] Retry failed: ${retryResponse.status}`);
489
+ for (const item of batch) {
490
+ results[item.originalIndex] = createErrorVector(embeddingDimension, 0.4);
491
+ }
492
+ continue;
493
+ }
494
+ const retryData = await retryResponse.json();
495
+ if (retryData?.data) {
496
+ for (const item of retryData.data) {
497
+ const originalIndex = batch[item.index].originalIndex;
498
+ results[originalIndex] = item.embedding;
499
+ }
500
+ import_core7.logger.info(`[BatchEmbeddings] Retry successful for ${batch.length} embeddings`);
501
+ }
502
+ continue;
503
+ }
504
+ if (!response.ok) {
505
+ import_core7.logger.error(`[BatchEmbeddings] API error: ${response.status} - ${response.statusText}`);
506
+ for (const item of batch) {
507
+ results[item.originalIndex] = createErrorVector(embeddingDimension, 0.4);
508
+ }
509
+ continue;
510
+ }
511
+ const data = await response.json();
512
+ if (!data?.data || !Array.isArray(data.data)) {
513
+ import_core7.logger.error("[BatchEmbeddings] API returned invalid structure");
514
+ for (const item of batch) {
515
+ results[item.originalIndex] = createErrorVector(embeddingDimension, 0.5);
516
+ }
517
+ continue;
518
+ }
519
+ for (const item of data.data) {
520
+ const originalIndex = batch[item.index].originalIndex;
521
+ results[originalIndex] = item.embedding;
522
+ }
523
+ if (data.usage) {
524
+ const usage = {
525
+ inputTokens: data.usage.prompt_tokens,
526
+ outputTokens: 0,
527
+ totalTokens: data.usage.total_tokens
528
+ };
529
+ emitModelUsageEvent(runtime, import_core7.ModelType.TEXT_EMBEDDING, `batch:${batch.length}`, usage);
530
+ }
531
+ import_core7.logger.debug(`[BatchEmbeddings] Got ${batch.length} embeddings (${embeddingDimension}d), remaining: ${rateLimitInfo.remainingRequests ?? "unknown"}`);
532
+ } catch (error) {
533
+ const message = error instanceof Error ? error.message : String(error);
534
+ import_core7.logger.error(`[BatchEmbeddings] Error: ${message}`);
535
+ for (const item of batch) {
536
+ results[item.originalIndex] = createErrorVector(embeddingDimension, 0.6);
537
+ }
478
538
  }
479
- import_core7.logger.log(`Got valid embedding with length ${embedding.length}`);
480
- return embedding;
481
- } catch (error) {
482
- const message = error instanceof Error ? error.message : String(error);
483
- import_core7.logger.error(`Error generating embedding: ${message}`);
484
- const errorVector = Array(embeddingDimension).fill(0);
485
- errorVector[0] = 0.6;
486
- return errorVector;
487
539
  }
540
+ return results;
488
541
  }
489
542
  // src/models/image.ts
490
543
  var import_core8 = require("@elizaos/core");
491
544
  async function handleImageGeneration(runtime, params) {
492
- const numImages = params.n || 1;
545
+ const numImages = params.count || 1;
493
546
  const size = params.size || "1024x1024";
494
547
  const prompt = params.prompt;
495
548
  const modelName = getImageGenerationModel(runtime);
@@ -585,10 +638,6 @@ async function handleImageDescription(runtime, params) {
585
638
  description: "No response from API"
586
639
  };
587
640
  }
588
- const isCustomPrompt = typeof params === "object" && params.prompt && params.prompt !== "Please analyze this image and provide a title and detailed description.";
589
- if (isCustomPrompt) {
590
- return content;
591
- }
592
641
  const processedResult = parseImageDescriptionResponse(content);
593
642
  return processedResult;
594
643
  } catch (error) {
@@ -600,89 +649,8 @@ async function handleImageDescription(runtime, params) {
600
649
  };
601
650
  }
602
651
  }
603
- // src/models/transcription.ts
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
652
  // src/models/speech.ts
685
- var import_core10 = require("@elizaos/core");
653
+ var import_core9 = require("@elizaos/core");
686
654
  async function fetchTextToSpeech(runtime, options) {
687
655
  const defaultModel = getSetting(runtime, "ELIZAOS_CLOUD_TTS_MODEL", "gpt-4o-mini-tts");
688
656
  const defaultVoice = getSetting(runtime, "ELIZAOS_CLOUD_TTS_VOICE", "nova");
@@ -724,367 +692,10 @@ async function fetchTextToSpeech(runtime, options) {
724
692
  throw new Error(`Failed to fetch speech from ElizaOS Cloud TTS: ${message}`);
725
693
  }
726
694
  }
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;
1047
695
  // 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
- }
1085
696
  var elizaOSCloudPlugin = {
1086
697
  name: "elizaOSCloud",
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.",
698
+ description: "ElizaOS Cloud plugin - Multi-model AI generation with text, image, and video support",
1088
699
  config: {
1089
700
  ELIZAOS_CLOUD_API_KEY: process.env.ELIZAOS_CLOUD_API_KEY,
1090
701
  ELIZAOS_CLOUD_BASE_URL: process.env.ELIZAOS_CLOUD_BASE_URL,
@@ -1098,39 +709,20 @@ var elizaOSCloudPlugin = {
1098
709
  ELIZAOS_CLOUD_EMBEDDING_DIMENSIONS: process.env.ELIZAOS_CLOUD_EMBEDDING_DIMENSIONS,
1099
710
  ELIZAOS_CLOUD_IMAGE_DESCRIPTION_MODEL: process.env.ELIZAOS_CLOUD_IMAGE_DESCRIPTION_MODEL,
1100
711
  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,
1107
- ELIZAOS_CLOUD_EXPERIMENTAL_TELEMETRY: process.env.ELIZAOS_CLOUD_EXPERIMENTAL_TELEMETRY
712
+ ELIZAOS_CLOUD_EXPERIMENTAL_TELEMETRY: process.env.ELIZAOS_CLOUD_EXPERIMENTAL_TELEMETRY,
713
+ ELIZAOS_CLOUD_IMAGE_GENERATION_MODEL: process.env.ELIZAOS_CLOUD_IMAGE_GENERATION_MODEL
1108
714
  },
1109
- priority: -1,
1110
715
  async init(config, runtime) {
1111
716
  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
- }
1119
717
  },
1120
718
  models: {
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
719
+ [import_core10.ModelType.TEXT_EMBEDDING]: handleTextEmbedding,
720
+ [import_core10.ModelType.TEXT_SMALL]: handleTextSmall,
721
+ [import_core10.ModelType.TEXT_LARGE]: handleTextLarge,
722
+ [import_core10.ModelType.IMAGE]: handleImageGeneration,
723
+ [import_core10.ModelType.IMAGE_DESCRIPTION]: handleImageDescription,
724
+ [import_core10.ModelType.OBJECT_SMALL]: handleObjectSmall,
725
+ [import_core10.ModelType.OBJECT_LARGE]: handleObjectLarge
1134
726
  },
1135
727
  tests: [
1136
728
  {
@@ -1146,7 +738,7 @@ var elizaOSCloudPlugin = {
1146
738
  }
1147
739
  });
1148
740
  const data = await response.json();
1149
- import_core15.logger.log({ data: data?.data?.length ?? "N/A" }, "Models Available");
741
+ import_core10.logger.log({ data: data?.data?.length ?? "N/A" }, "Models Available");
1150
742
  if (!response.ok) {
1151
743
  throw new Error(`Failed to validate OpenAI API key: ${response.statusText}`);
1152
744
  }
@@ -1156,13 +748,13 @@ var elizaOSCloudPlugin = {
1156
748
  name: "ELIZAOS_CLOUD_test_text_embedding",
1157
749
  fn: async (runtime) => {
1158
750
  try {
1159
- const embedding = await runtime.useModel(import_core15.ModelType.TEXT_EMBEDDING, {
751
+ const embedding = await runtime.useModel(import_core10.ModelType.TEXT_EMBEDDING, {
1160
752
  text: "Hello, world!"
1161
753
  });
1162
- import_core15.logger.log({ embedding }, "embedding");
754
+ import_core10.logger.log({ embedding }, "embedding");
1163
755
  } catch (error) {
1164
756
  const message = error instanceof Error ? error.message : String(error);
1165
- import_core15.logger.error(`Error in test_text_embedding: ${message}`);
757
+ import_core10.logger.error(`Error in test_text_embedding: ${message}`);
1166
758
  throw error;
1167
759
  }
1168
760
  }
@@ -1171,16 +763,16 @@ var elizaOSCloudPlugin = {
1171
763
  name: "ELIZAOS_CLOUD_test_text_large",
1172
764
  fn: async (runtime) => {
1173
765
  try {
1174
- const text = await runtime.useModel(import_core15.ModelType.TEXT_LARGE, {
766
+ const text = await runtime.useModel(import_core10.ModelType.TEXT_LARGE, {
1175
767
  prompt: "What is the nature of reality in 10 words?"
1176
768
  });
1177
769
  if (text.length === 0) {
1178
770
  throw new Error("Failed to generate text");
1179
771
  }
1180
- import_core15.logger.log({ text }, "generated with test_text_large");
772
+ import_core10.logger.log({ text }, "generated with test_text_large");
1181
773
  } catch (error) {
1182
774
  const message = error instanceof Error ? error.message : String(error);
1183
- import_core15.logger.error(`Error in test_text_large: ${message}`);
775
+ import_core10.logger.error(`Error in test_text_large: ${message}`);
1184
776
  throw error;
1185
777
  }
1186
778
  }
@@ -1189,16 +781,16 @@ var elizaOSCloudPlugin = {
1189
781
  name: "ELIZAOS_CLOUD_test_text_small",
1190
782
  fn: async (runtime) => {
1191
783
  try {
1192
- const text = await runtime.useModel(import_core15.ModelType.TEXT_SMALL, {
784
+ const text = await runtime.useModel(import_core10.ModelType.TEXT_SMALL, {
1193
785
  prompt: "What is the nature of reality in 10 words?"
1194
786
  });
1195
787
  if (text.length === 0) {
1196
788
  throw new Error("Failed to generate text");
1197
789
  }
1198
- import_core15.logger.log({ text }, "generated with test_text_small");
790
+ import_core10.logger.log({ text }, "generated with test_text_small");
1199
791
  } catch (error) {
1200
792
  const message = error instanceof Error ? error.message : String(error);
1201
- import_core15.logger.error(`Error in test_text_small: ${message}`);
793
+ import_core10.logger.error(`Error in test_text_small: ${message}`);
1202
794
  throw error;
1203
795
  }
1204
796
  }
@@ -1206,17 +798,17 @@ var elizaOSCloudPlugin = {
1206
798
  {
1207
799
  name: "ELIZAOS_CLOUD_test_image_generation",
1208
800
  fn: async (runtime) => {
1209
- import_core15.logger.log("ELIZAOS_CLOUD_test_image_generation");
801
+ import_core10.logger.log("ELIZAOS_CLOUD_test_image_generation");
1210
802
  try {
1211
- const image = await runtime.useModel(import_core15.ModelType.IMAGE, {
803
+ const image = await runtime.useModel(import_core10.ModelType.IMAGE, {
1212
804
  prompt: "A beautiful sunset over a calm ocean",
1213
- n: 1,
805
+ count: 1,
1214
806
  size: "1024x1024"
1215
807
  });
1216
- import_core15.logger.log({ image }, "generated with test_image_generation");
808
+ import_core10.logger.log({ image }, "generated with test_image_generation");
1217
809
  } catch (error) {
1218
810
  const message = error instanceof Error ? error.message : String(error);
1219
- import_core15.logger.error(`Error in test_image_generation: ${message}`);
811
+ import_core10.logger.error(`Error in test_image_generation: ${message}`);
1220
812
  throw error;
1221
813
  }
1222
814
  }
@@ -1225,36 +817,36 @@ var elizaOSCloudPlugin = {
1225
817
  name: "image-description",
1226
818
  fn: async (runtime) => {
1227
819
  try {
1228
- import_core15.logger.log("ELIZAOS_CLOUD_test_image_description");
820
+ import_core10.logger.log("ELIZAOS_CLOUD_test_image_description");
1229
821
  try {
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");
822
+ 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");
1231
823
  if (result && typeof result === "object" && "title" in result && "description" in result) {
1232
- import_core15.logger.log({ result }, "Image description");
824
+ import_core10.logger.log({ result }, "Image description");
1233
825
  } else {
1234
- import_core15.logger.error("Invalid image description result format:", result);
826
+ import_core10.logger.error("Invalid image description result format:", result);
1235
827
  }
1236
828
  } catch (e) {
1237
829
  const message = e instanceof Error ? e.message : String(e);
1238
- import_core15.logger.error(`Error in image description test: ${message}`);
830
+ import_core10.logger.error(`Error in image description test: ${message}`);
1239
831
  }
1240
832
  } catch (e) {
1241
833
  const message = e instanceof Error ? e.message : String(e);
1242
- import_core15.logger.error(`Error in ELIZAOS_CLOUD_test_image_description: ${message}`);
834
+ import_core10.logger.error(`Error in ELIZAOS_CLOUD_test_image_description: ${message}`);
1243
835
  }
1244
836
  }
1245
837
  },
1246
838
  {
1247
839
  name: "ELIZAOS_CLOUD_test_transcription",
1248
840
  fn: async (runtime) => {
1249
- import_core15.logger.log("ELIZAOS_CLOUD_test_transcription");
841
+ import_core10.logger.log("ELIZAOS_CLOUD_test_transcription");
1250
842
  try {
1251
843
  const response = await fetch("https://upload.wikimedia.org/wikipedia/en/4/40/Chris_Benoit_Voice_Message.ogg");
1252
844
  const arrayBuffer = await response.arrayBuffer();
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");
845
+ const transcription = await runtime.useModel(import_core10.ModelType.TRANSCRIPTION, Buffer.from(new Uint8Array(arrayBuffer)));
846
+ import_core10.logger.log({ transcription }, "generated with test_transcription");
1255
847
  } catch (error) {
1256
848
  const message = error instanceof Error ? error.message : String(error);
1257
- import_core15.logger.error(`Error in test_transcription: ${message}`);
849
+ import_core10.logger.error(`Error in test_transcription: ${message}`);
1258
850
  throw error;
1259
851
  }
1260
852
  }
@@ -1263,23 +855,23 @@ var elizaOSCloudPlugin = {
1263
855
  name: "ELIZAOS_CLOUD_test_text_tokenizer_encode",
1264
856
  fn: async (runtime) => {
1265
857
  const prompt = "Hello tokenizer encode!";
1266
- const tokens = await runtime.useModel(import_core15.ModelType.TEXT_TOKENIZER_ENCODE, { prompt });
858
+ const tokens = await runtime.useModel(import_core10.ModelType.TEXT_TOKENIZER_ENCODE, { prompt, modelType: import_core10.ModelType.TEXT_SMALL });
1267
859
  if (!Array.isArray(tokens) || tokens.length === 0) {
1268
860
  throw new Error("Failed to tokenize text: expected non-empty array of tokens");
1269
861
  }
1270
- import_core15.logger.log({ tokens }, "Tokenized output");
862
+ import_core10.logger.log({ tokens }, "Tokenized output");
1271
863
  }
1272
864
  },
1273
865
  {
1274
866
  name: "ELIZAOS_CLOUD_test_text_tokenizer_decode",
1275
867
  fn: async (runtime) => {
1276
868
  const prompt = "Hello tokenizer decode!";
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 });
869
+ const tokens = await runtime.useModel(import_core10.ModelType.TEXT_TOKENIZER_ENCODE, { prompt, modelType: import_core10.ModelType.TEXT_SMALL });
870
+ const decodedText = await runtime.useModel(import_core10.ModelType.TEXT_TOKENIZER_DECODE, { tokens, modelType: import_core10.ModelType.TEXT_SMALL });
1279
871
  if (decodedText !== prompt) {
1280
872
  throw new Error(`Decoded text does not match original. Expected "${prompt}", got "${decodedText}"`);
1281
873
  }
1282
- import_core15.logger.log({ decodedText }, "Decoded text");
874
+ import_core10.logger.log({ decodedText }, "Decoded text");
1283
875
  }
1284
876
  },
1285
877
  {
@@ -1292,10 +884,10 @@ var elizaOSCloudPlugin = {
1292
884
  if (!response) {
1293
885
  throw new Error("Failed to generate speech");
1294
886
  }
1295
- import_core15.logger.log("Generated speech successfully");
887
+ import_core10.logger.log("Generated speech successfully");
1296
888
  } catch (error) {
1297
889
  const message = error instanceof Error ? error.message : String(error);
1298
- import_core15.logger.error(`Error in ELIZAOS_CLOUD_test_text_to_speech: ${message}`);
890
+ import_core10.logger.error(`Error in ELIZAOS_CLOUD_test_text_to_speech: ${message}`);
1299
891
  throw error;
1300
892
  }
1301
893
  }
@@ -1306,4 +898,4 @@ var elizaOSCloudPlugin = {
1306
898
  };
1307
899
  var src_default = elizaOSCloudPlugin;
1308
900
 
1309
- //# debugId=7F91E5A78C775CA264756E2164756E21
901
+ //# debugId=6F6BBDBF3B2AA6B264756E2164756E21