@elizaos/plugin-elizacloud 2.0.0-alpha.5 → 2.0.0-alpha.537

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.
Files changed (77) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +185 -0
  3. package/dist/actions/check-credits.d.ts.map +1 -1
  4. package/dist/actions/confirmation.d.ts +7 -0
  5. package/dist/actions/confirmation.d.ts.map +1 -0
  6. package/dist/actions/freeze-agent.d.ts.map +1 -1
  7. package/dist/actions/provision-agent.d.ts.map +1 -1
  8. package/dist/actions/resume-agent.d.ts.map +1 -1
  9. package/dist/browser/index.browser.js +22 -19
  10. package/dist/browser/index.browser.js.map +37 -31
  11. package/dist/cjs/index.node.cjs +1298 -451
  12. package/dist/cjs/index.node.js.map +37 -31
  13. package/dist/cloud-providers/cloud-status.d.ts.map +1 -1
  14. package/dist/cloud-providers/container-health.d.ts.map +1 -1
  15. package/dist/cloud-providers/credit-balance.d.ts.map +1 -1
  16. package/dist/cloud-providers/model-registry.d.ts.map +1 -1
  17. package/dist/index.browser.d.ts +2 -1
  18. package/dist/index.browser.d.ts.map +1 -1
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.node.d.ts +2 -1
  21. package/dist/index.node.d.ts.map +1 -1
  22. package/dist/init.d.ts.map +1 -1
  23. package/dist/models/embeddings.d.ts.map +1 -1
  24. package/dist/models/image.d.ts.map +1 -1
  25. package/dist/models/index.d.ts +1 -1
  26. package/dist/models/index.d.ts.map +1 -1
  27. package/dist/models/object.d.ts.map +1 -1
  28. package/dist/models/research.d.ts.map +1 -1
  29. package/dist/models/speech.d.ts.map +1 -1
  30. package/dist/models/text.d.ts +5 -2
  31. package/dist/models/text.d.ts.map +1 -1
  32. package/dist/models/tokenization.d.ts.map +1 -1
  33. package/dist/models/transcription.d.ts.map +1 -1
  34. package/dist/node/index.node.js +1280 -428
  35. package/dist/node/index.node.js.map +37 -31
  36. package/dist/providers/openai.d.ts.map +1 -1
  37. package/dist/services/cloud-auth.d.ts +140 -4
  38. package/dist/services/cloud-auth.d.ts.map +1 -1
  39. package/dist/services/cloud-backup.d.ts.map +1 -1
  40. package/dist/services/cloud-bootstrap.d.ts +38 -0
  41. package/dist/services/cloud-bootstrap.d.ts.map +1 -0
  42. package/dist/services/cloud-bridge.d.ts +1 -1
  43. package/dist/services/cloud-bridge.d.ts.map +1 -1
  44. package/dist/services/cloud-container.d.ts.map +1 -1
  45. package/dist/services/cloud-managed-gateway-relay.d.ts +38 -0
  46. package/dist/services/cloud-managed-gateway-relay.d.ts.map +1 -0
  47. package/dist/services/cloud-model-registry.d.ts +0 -1
  48. package/dist/services/cloud-model-registry.d.ts.map +1 -1
  49. package/dist/types/cloud.d.ts +41 -19
  50. package/dist/types/cloud.d.ts.map +1 -1
  51. package/dist/types/index.d.ts +1 -1
  52. package/dist/types/index.d.ts.map +1 -1
  53. package/dist/utils/cloud-api.d.ts +2 -27
  54. package/dist/utils/cloud-api.d.ts.map +1 -1
  55. package/dist/utils/config.d.ts +6 -3
  56. package/dist/utils/config.d.ts.map +1 -1
  57. package/dist/utils/events.d.ts.map +1 -1
  58. package/dist/utils/forwarded-settings.d.ts +1 -1
  59. package/dist/utils/forwarded-settings.d.ts.map +1 -1
  60. package/dist/utils/helpers.d.ts.map +1 -1
  61. package/dist/utils/responses-output.d.ts +6 -0
  62. package/dist/utils/responses-output.d.ts.map +1 -0
  63. package/dist/utils/sdk-client.d.ts +5 -0
  64. package/dist/utils/sdk-client.d.ts.map +1 -0
  65. package/package.json +84 -16
  66. package/types/cloud.ts +54 -41
  67. package/types/index.ts +6 -0
  68. package/dist/actions/index.d.ts +0 -5
  69. package/dist/actions/index.d.ts.map +0 -1
  70. package/dist/build.d.ts +0 -3
  71. package/dist/build.d.ts.map +0 -1
  72. package/dist/cloud-providers/index.d.ts +0 -4
  73. package/dist/cloud-providers/index.d.ts.map +0 -1
  74. package/dist/generated/specs/specs.d.ts +0 -55
  75. package/dist/generated/specs/specs.d.ts.map +0 -1
  76. package/dist/services/index.d.ts +0 -5
  77. package/dist/services/index.d.ts.map +0 -1
@@ -1,41 +1,38 @@
1
- var __create = Object.create;
2
- var __getProtoOf = Object.getPrototypeOf;
3
1
  var __defProp = Object.defineProperty;
4
2
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __toESM = (mod, isNodeMode, target) => {
8
- target = mod != null ? __create(__getProtoOf(mod)) : {};
9
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
10
- for (let key of __getOwnPropNames(mod))
11
- if (!__hasOwnProp.call(to, key))
12
- __defProp(to, key, {
13
- get: () => mod[key],
14
- enumerable: true
15
- });
16
- return to;
17
- };
18
- var __moduleCache = /* @__PURE__ */ new WeakMap;
5
+ function __accessProp(key) {
6
+ return this[key];
7
+ }
19
8
  var __toCommonJS = (from) => {
20
- var entry = __moduleCache.get(from), desc;
9
+ var entry = (__moduleCache ??= new WeakMap).get(from), desc;
21
10
  if (entry)
22
11
  return entry;
23
12
  entry = __defProp({}, "__esModule", { value: true });
24
- if (from && typeof from === "object" || typeof from === "function")
25
- __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
26
- get: () => from[key],
27
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
28
- }));
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (var key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(entry, key))
16
+ __defProp(entry, key, {
17
+ get: __accessProp.bind(from, key),
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
29
21
  __moduleCache.set(from, entry);
30
22
  return entry;
31
23
  };
24
+ var __moduleCache;
25
+ var __returnValue = (v) => v;
26
+ function __exportSetter(name, newValue) {
27
+ this[name] = __returnValue.bind(null, newValue);
28
+ }
32
29
  var __export = (target, all) => {
33
30
  for (var name in all)
34
31
  __defProp(target, name, {
35
32
  get: all[name],
36
33
  enumerable: true,
37
34
  configurable: true,
38
- set: (newValue) => all[name] = () => newValue
35
+ set: __exportSetter.bind(all, name)
39
36
  });
40
37
  };
41
38
 
@@ -43,24 +40,20 @@ var __export = (target, all) => {
43
40
  var exports_index_node = {};
44
41
  __export(exports_index_node, {
45
42
  elizaOSCloudPlugin: () => elizaOSCloudPlugin,
46
- default: () => typescript_default
43
+ default: () => index_node_default
47
44
  });
48
45
  module.exports = __toCommonJS(exports_index_node);
49
46
 
50
47
  // index.ts
51
- var import_core19 = require("@elizaos/core");
48
+ var import_core20 = require("@elizaos/core");
52
49
 
53
50
  // actions/check-credits.ts
54
51
  var DAILY_COST_PER_CONTAINER = 0.67;
55
52
  var checkCloudCreditsAction = {
56
53
  name: "CHECK_CLOUD_CREDITS",
57
54
  description: "Check ElizaCloud credit balance, container costs, and estimated remaining runtime.",
58
- similes: [
59
- "check credits",
60
- "check balance",
61
- "how much credit",
62
- "cloud billing"
63
- ],
55
+ descriptionCompressed: "Check ElizaCloud credits, container costs, remaining runtime.",
56
+ similes: ["check credits", "check balance", "how much credit", "cloud billing"],
64
57
  tags: ["cloud", "billing"],
65
58
  parameters: [
66
59
  {
@@ -70,8 +63,29 @@ var checkCloudCreditsAction = {
70
63
  schema: { type: "boolean" }
71
64
  }
72
65
  ],
73
- async validate(runtime) {
74
- return !!runtime.getService("CLOUD_AUTH")?.isAuthenticated();
66
+ validate: async (runtime, message, state, options) => {
67
+ const __avTextRaw = typeof message?.content?.text === "string" ? message.content.text : "";
68
+ const __avText = __avTextRaw.toLowerCase();
69
+ const __avKeywords = ["check", "cloud", "credits"];
70
+ const __avKeywordOk = __avKeywords.length > 0 && __avKeywords.some((kw) => kw.length > 0 && __avText.includes(kw));
71
+ const __avRegex = /\b(?:check|cloud|credits)\b/i;
72
+ const __avRegexOk = Boolean(__avText.match(__avRegex));
73
+ const __avSource = String(message?.content?.source ?? "");
74
+ const __avExpectedSource = "";
75
+ const __avSourceOk = __avExpectedSource ? __avSource === __avExpectedSource : Boolean(__avSource || state || runtime?.agentId || runtime?.getService);
76
+ const __avOptions = options && typeof options === "object" ? options : {};
77
+ const __avInputOk = __avText.trim().length > 0 || Object.keys(__avOptions).length > 0 || Boolean(message?.content && typeof message.content === "object");
78
+ if (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {
79
+ return false;
80
+ }
81
+ const __avLegacyValidate = async (runtime2) => {
82
+ return !!runtime2.getService("CLOUD_AUTH")?.isAuthenticated();
83
+ };
84
+ try {
85
+ return Boolean(await __avLegacyValidate(runtime));
86
+ } catch {
87
+ return false;
88
+ }
75
89
  },
76
90
  async handler(runtime, message, _state, options, callback) {
77
91
  const auth = runtime.getService("CLOUD_AUTH");
@@ -113,22 +127,37 @@ var checkCloudCreditsAction = {
113
127
  }
114
128
  };
115
129
 
130
+ // actions/confirmation.ts
131
+ function mergedOptions(options) {
132
+ const direct = options ?? {};
133
+ const parameters = direct.parameters && typeof direct.parameters === "object" ? direct.parameters : {};
134
+ return { ...direct, ...parameters };
135
+ }
136
+ function isConfirmed(options) {
137
+ const raw = mergedOptions(options).confirmed;
138
+ return raw === true || raw === "true";
139
+ }
140
+ function confirmationRequired(preview, data) {
141
+ return {
142
+ success: false,
143
+ text: preview,
144
+ data: { requiresConfirmation: true, preview, ...data }
145
+ };
146
+ }
147
+
116
148
  // actions/freeze-agent.ts
117
149
  function getContainerId(message, options) {
118
- if (options?.containerId)
119
- return String(options.containerId);
150
+ const params = mergedOptions(options);
151
+ if (params.containerId)
152
+ return String(params.containerId);
120
153
  const meta = message.metadata?.actionParams;
121
154
  return meta?.containerId ? String(meta.containerId) : null;
122
155
  }
123
156
  var freezeCloudAgentAction = {
124
157
  name: "FREEZE_CLOUD_AGENT",
125
158
  description: "Freeze a cloud agent: snapshot state, disconnect bridge, stop container.",
126
- similes: [
127
- "freeze agent",
128
- "hibernate agent",
129
- "pause agent",
130
- "stop cloud agent"
131
- ],
159
+ descriptionCompressed: "Freeze cloud agent: snapshot, disconnect, stop container.",
160
+ similes: ["freeze agent", "hibernate agent", "pause agent", "stop cloud agent"],
132
161
  tags: ["cloud", "container", "backup"],
133
162
  parameters: [
134
163
  {
@@ -136,10 +165,37 @@ var freezeCloudAgentAction = {
136
165
  description: "ID of the container to freeze",
137
166
  required: true,
138
167
  schema: { type: "string" }
168
+ },
169
+ {
170
+ name: "confirmed",
171
+ description: "Must be true to freeze the cloud agent after preview.",
172
+ required: false,
173
+ schema: { type: "boolean", default: false }
139
174
  }
140
175
  ],
141
- async validate(runtime) {
142
- return !!runtime.getService("CLOUD_AUTH")?.isAuthenticated();
176
+ validate: async (runtime, message, state, options) => {
177
+ const __avTextRaw = typeof message?.content?.text === "string" ? message.content.text : "";
178
+ const __avText = __avTextRaw.toLowerCase();
179
+ const __avKeywords = ["freeze", "cloud"];
180
+ const __avKeywordOk = __avKeywords.length > 0 && __avKeywords.some((kw) => kw.length > 0 && __avText.includes(kw));
181
+ const __avRegex = /\b(?:freeze|cloud)\b/i;
182
+ const __avRegexOk = Boolean(__avText.match(__avRegex));
183
+ const __avSource = String(message?.content?.source ?? "");
184
+ const __avExpectedSource = "";
185
+ const __avSourceOk = __avExpectedSource ? __avSource === __avExpectedSource : Boolean(__avSource || state || runtime?.agentId || runtime?.getService);
186
+ const __avOptions = options && typeof options === "object" ? options : {};
187
+ const __avInputOk = __avText.trim().length > 0 || Object.keys(__avOptions).length > 0 || Boolean(message?.content && typeof message.content === "object");
188
+ if (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {
189
+ return false;
190
+ }
191
+ const __avLegacyValidate = async (runtime2) => {
192
+ return !!runtime2.getService("CLOUD_AUTH")?.isAuthenticated();
193
+ };
194
+ try {
195
+ return Boolean(await __avLegacyValidate(runtime));
196
+ } catch {
197
+ return false;
198
+ }
143
199
  },
144
200
  async handler(runtime, message, _state, options, callback) {
145
201
  const containers = runtime.getService("CLOUD_CONTAINER");
@@ -155,6 +211,20 @@ var freezeCloudAgentAction = {
155
211
  error: `Container not running (status: ${container.status})`
156
212
  };
157
213
  }
214
+ const preview = [
215
+ "Confirmation required before freezing Eliza Cloud agent:",
216
+ `Container: ${container.name}`,
217
+ `ID: ${containerId}`,
218
+ "Effects: create snapshot, disconnect bridge, stop container."
219
+ ].join(`
220
+ `);
221
+ if (!isConfirmed(options)) {
222
+ await callback?.({ text: preview, actions: ["FREEZE_CLOUD_AGENT"] });
223
+ return confirmationRequired(preview, {
224
+ containerId,
225
+ containerName: container.name
226
+ });
227
+ }
158
228
  const notify = async (text) => {
159
229
  if (callback)
160
230
  await callback({ text, actions: ["FREEZE_CLOUD_AGENT"] });
@@ -185,6 +255,7 @@ var freezeCloudAgentAction = {
185
255
  var import_core = require("@elizaos/core");
186
256
 
187
257
  // types/cloud.ts
258
+ var import_cloud_sdk = require("@elizaos/cloud-sdk");
188
259
  var DEFAULT_CLOUD_CONFIG = {
189
260
  enabled: false,
190
261
  baseUrl: "https://www.elizacloud.ai/api/v1",
@@ -208,36 +279,32 @@ var DEFAULT_CLOUD_CONFIG = {
208
279
  }
209
280
  };
210
281
 
211
- class CloudApiError extends Error {
212
- statusCode;
213
- errorBody;
214
- constructor(statusCode, body) {
215
- super(body.error);
216
- this.name = "CloudApiError";
217
- this.statusCode = statusCode;
218
- this.errorBody = body;
219
- }
220
- }
221
-
222
- class InsufficientCreditsError extends CloudApiError {
223
- requiredCredits;
224
- constructor(body) {
225
- super(402, body);
226
- this.name = "InsufficientCreditsError";
227
- this.requiredCredits = body.requiredCredits ?? 0;
228
- }
229
- }
230
-
231
282
  // utils/forwarded-settings.ts
232
283
  var FORWARDED_SETTINGS = [
233
284
  "OPENAI_API_KEY",
234
285
  "ANTHROPIC_API_KEY",
235
286
  "GROQ_API_KEY",
236
287
  "ELIZAOS_CLOUD_API_KEY",
288
+ "NANO_MODEL",
289
+ "MEDIUM_MODEL",
237
290
  "SMALL_MODEL",
238
291
  "LARGE_MODEL",
292
+ "MEGA_MODEL",
293
+ "RESPONSE_HANDLER_MODEL",
294
+ "ACTION_PLANNER_MODEL",
295
+ "SHOULD_RESPOND_MODEL",
296
+ "PLANNER_MODEL",
297
+ "RESPONSE_MODEL",
239
298
  "ELIZAOS_CLOUD_SMALL_MODEL",
240
- "ELIZAOS_CLOUD_LARGE_MODEL"
299
+ "ELIZAOS_CLOUD_NANO_MODEL",
300
+ "ELIZAOS_CLOUD_MEDIUM_MODEL",
301
+ "ELIZAOS_CLOUD_LARGE_MODEL",
302
+ "ELIZAOS_CLOUD_MEGA_MODEL",
303
+ "ELIZAOS_CLOUD_RESPONSE_HANDLER_MODEL",
304
+ "ELIZAOS_CLOUD_ACTION_PLANNER_MODEL",
305
+ "ELIZAOS_CLOUD_SHOULD_RESPOND_MODEL",
306
+ "ELIZAOS_CLOUD_PLANNER_MODEL",
307
+ "ELIZAOS_CLOUD_RESPONSE_MODEL"
241
308
  ];
242
309
  function collectEnvVars(runtime) {
243
310
  const vars = {};
@@ -251,8 +318,9 @@ function collectEnvVars(runtime) {
251
318
 
252
319
  // actions/provision-agent.ts
253
320
  function extractParams(message, options) {
254
- if (options && Object.keys(options).length > 0)
255
- return options;
321
+ const params = mergedOptions(options);
322
+ if (Object.keys(params).length > 0)
323
+ return params;
256
324
  const meta = message.metadata;
257
325
  if (meta?.actionParams)
258
326
  return meta.actionParams;
@@ -264,6 +332,7 @@ function extractParams(message, options) {
264
332
  var provisionCloudAgentAction = {
265
333
  name: "PROVISION_CLOUD_AGENT",
266
334
  description: "Deploy an ElizaOS agent to ElizaCloud. Provisions a container, waits for deployment, connects the bridge, and starts auto-backup.",
335
+ descriptionCompressed: "Deploy agent to ElizaCloud. Provisions container, connects bridge, starts backup.",
267
336
  similes: [
268
337
  "deploy agent to cloud",
269
338
  "launch cloud agent",
@@ -301,11 +370,38 @@ var provisionCloudAgentAction = {
301
370
  description: "Enable periodic auto-backup (default: true)",
302
371
  required: false,
303
372
  schema: { type: "boolean" }
373
+ },
374
+ {
375
+ name: "confirmed",
376
+ description: "Must be true to provision the cloud agent after preview.",
377
+ required: false,
378
+ schema: { type: "boolean", default: false }
304
379
  }
305
380
  ],
306
- async validate(runtime) {
307
- const auth = runtime.getService("CLOUD_AUTH");
308
- return !!auth?.isAuthenticated();
381
+ validate: async (runtime, message, state, options) => {
382
+ const __avTextRaw = typeof message?.content?.text === "string" ? message.content.text : "";
383
+ const __avText = __avTextRaw.toLowerCase();
384
+ const __avKeywords = ["provision", "cloud"];
385
+ const __avKeywordOk = __avKeywords.length > 0 && __avKeywords.some((kw) => kw.length > 0 && __avText.includes(kw));
386
+ const __avRegex = /\b(?:provision|cloud)\b/i;
387
+ const __avRegexOk = Boolean(__avText.match(__avRegex));
388
+ const __avSource = String(message?.content?.source ?? "");
389
+ const __avExpectedSource = "";
390
+ const __avSourceOk = __avExpectedSource ? __avSource === __avExpectedSource : Boolean(__avSource || state || runtime?.agentId || runtime?.getService);
391
+ const __avOptions = options && typeof options === "object" ? options : {};
392
+ const __avInputOk = __avText.trim().length > 0 || Object.keys(__avOptions).length > 0 || Boolean(message?.content && typeof message.content === "object");
393
+ if (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {
394
+ return false;
395
+ }
396
+ const __avLegacyValidate = async (runtime2) => {
397
+ const auth = runtime2.getService("CLOUD_AUTH");
398
+ return !!auth?.isAuthenticated();
399
+ };
400
+ try {
401
+ return Boolean(await __avLegacyValidate(runtime));
402
+ } catch {
403
+ return false;
404
+ }
309
405
  },
310
406
  async handler(runtime, message, _state, options, callback) {
311
407
  const auth = runtime.getService("CLOUD_AUTH");
@@ -325,6 +421,22 @@ var provisionCloudAgentAction = {
325
421
  error: "Missing required parameters: name and project_name"
326
422
  };
327
423
  }
424
+ const autoBackup = params.auto_backup !== false;
425
+ const preview = [
426
+ "Confirmation required before provisioning Eliza Cloud agent:",
427
+ `Name: ${String(params.name)}`,
428
+ `Project: ${String(params.project_name)}`,
429
+ `Auto-backup: ${autoBackup ? "enabled" : "disabled"}`
430
+ ].join(`
431
+ `);
432
+ if (!isConfirmed(options)) {
433
+ await callback?.({ text: preview, actions: ["PROVISION_CLOUD_AGENT"] });
434
+ return confirmationRequired(preview, {
435
+ name: String(params.name),
436
+ project_name: String(params.project_name),
437
+ auto_backup: autoBackup
438
+ });
439
+ }
328
440
  const notify = async (text) => {
329
441
  if (callback)
330
442
  await callback({ text, actions: ["PROVISION_CLOUD_AGENT"] });
@@ -355,7 +467,6 @@ var provisionCloudAgentAction = {
355
467
  await bridge.connect(id);
356
468
  import_core.logger.info(`[PROVISION] Bridge connected to ${id}`);
357
469
  }
358
- const autoBackup = params.auto_backup !== false;
359
470
  if (autoBackup && backup)
360
471
  backup.scheduleAutoBackup(id);
361
472
  await notify(`Agent "${params.name}" deployed.${autoBackup ? " Auto-backup enabled." : ""}`);
@@ -377,8 +488,9 @@ var provisionCloudAgentAction = {
377
488
 
378
489
  // actions/resume-agent.ts
379
490
  function extractParams2(message, options) {
380
- if (options && Object.keys(options).length > 0)
381
- return options;
491
+ const params = mergedOptions(options);
492
+ if (Object.keys(params).length > 0)
493
+ return params;
382
494
  const meta = message.metadata;
383
495
  return meta?.actionParams ?? {};
384
496
  }
@@ -395,12 +507,8 @@ async function findLatestProjectSnapshot(backup, containers, projectName) {
395
507
  var resumeCloudAgentAction = {
396
508
  name: "RESUME_CLOUD_AGENT",
397
509
  description: "Resume a frozen cloud agent from snapshot. Re-provisions, restores state, reconnects bridge.",
398
- similes: [
399
- "resume agent",
400
- "unfreeze agent",
401
- "restart cloud agent",
402
- "restore agent"
403
- ],
510
+ descriptionCompressed: "Resume frozen cloud agent from snapshot.",
511
+ similes: ["resume agent", "unfreeze agent", "restart cloud agent", "restore agent"],
404
512
  tags: ["cloud", "container", "restore"],
405
513
  parameters: [
406
514
  {
@@ -426,10 +534,37 @@ var resumeCloudAgentAction = {
426
534
  description: "Additional environment variables",
427
535
  required: false,
428
536
  schema: { type: "object" }
537
+ },
538
+ {
539
+ name: "confirmed",
540
+ description: "Must be true to resume the cloud agent after preview.",
541
+ required: false,
542
+ schema: { type: "boolean", default: false }
429
543
  }
430
544
  ],
431
- async validate(runtime) {
432
- return !!runtime.getService("CLOUD_AUTH")?.isAuthenticated();
545
+ validate: async (runtime, message, state, options) => {
546
+ const __avTextRaw = typeof message?.content?.text === "string" ? message.content.text : "";
547
+ const __avText = __avTextRaw.toLowerCase();
548
+ const __avKeywords = ["resume", "cloud"];
549
+ const __avKeywordOk = __avKeywords.length > 0 && __avKeywords.some((kw) => kw.length > 0 && __avText.includes(kw));
550
+ const __avRegex = /\b(?:resume|cloud)\b/i;
551
+ const __avRegexOk = Boolean(__avText.match(__avRegex));
552
+ const __avSource = String(message?.content?.source ?? "");
553
+ const __avExpectedSource = "";
554
+ const __avSourceOk = __avExpectedSource ? __avSource === __avExpectedSource : Boolean(__avSource || state || runtime?.agentId || runtime?.getService);
555
+ const __avOptions = options && typeof options === "object" ? options : {};
556
+ const __avInputOk = __avText.trim().length > 0 || Object.keys(__avOptions).length > 0 || Boolean(message?.content && typeof message.content === "object");
557
+ if (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {
558
+ return false;
559
+ }
560
+ const __avLegacyValidate = async (runtime2) => {
561
+ return !!runtime2.getService("CLOUD_AUTH")?.isAuthenticated();
562
+ };
563
+ try {
564
+ return Boolean(await __avLegacyValidate(runtime));
565
+ } catch {
566
+ return false;
567
+ }
433
568
  },
434
569
  async handler(runtime, message, _state, options, callback) {
435
570
  const containerSvc = runtime.getService("CLOUD_CONTAINER");
@@ -442,6 +577,22 @@ var resumeCloudAgentAction = {
442
577
  error: "Missing required parameters: name and project_name"
443
578
  };
444
579
  }
580
+ const explicitSnapshot = typeof params.snapshotId === "string" && params.snapshotId.length > 0 ? params.snapshotId : null;
581
+ const preview = [
582
+ "Confirmation required before resuming Eliza Cloud agent:",
583
+ `Name: ${String(params.name)}`,
584
+ `Project: ${String(params.project_name)}`,
585
+ `Snapshot: ${explicitSnapshot ?? "latest available"}`
586
+ ].join(`
587
+ `);
588
+ if (!isConfirmed(options)) {
589
+ await callback?.({ text: preview, actions: ["RESUME_CLOUD_AGENT"] });
590
+ return confirmationRequired(preview, {
591
+ name: String(params.name),
592
+ project_name: String(params.project_name),
593
+ snapshotId: explicitSnapshot
594
+ });
595
+ }
445
596
  const notify = async (text) => {
446
597
  if (callback)
447
598
  await callback({ text, actions: ["RESUME_CLOUD_AGENT"] });
@@ -468,7 +619,7 @@ var resumeCloudAgentAction = {
468
619
  const running = await containerSvc.waitForDeployment(id);
469
620
  let restoredId = null;
470
621
  if (backup) {
471
- const explicit = params.snapshotId;
622
+ const explicit = explicitSnapshot ?? undefined;
472
623
  if (explicit) {
473
624
  await backup.restoreSnapshot(id, explicit);
474
625
  restoredId = explicit;
@@ -502,6 +653,7 @@ var resumeCloudAgentAction = {
502
653
  var cloudStatusProvider = {
503
654
  name: "elizacloud_status",
504
655
  description: "ElizaCloud container and connection status",
656
+ descriptionCompressed: "ElizaCloud container/connection status.",
505
657
  dynamic: true,
506
658
  position: 90,
507
659
  async get(runtime, _message, _state) {
@@ -548,6 +700,7 @@ var cloudStatusProvider = {
548
700
  var containerHealthProvider = {
549
701
  name: "elizacloud_health",
550
702
  description: "ElizaCloud container health",
703
+ descriptionCompressed: "ElizaCloud container health.",
551
704
  dynamic: true,
552
705
  position: 92,
553
706
  private: true,
@@ -588,12 +741,13 @@ var containerHealthProvider = {
588
741
 
589
742
  // cloud-providers/credit-balance.ts
590
743
  var import_core2 = require("@elizaos/core");
591
- var TOP_UP_URL = "https://www.elizacloud.ai/dashboard/billing";
744
+ var TOP_UP_URL = "https://www.elizacloud.ai/dashboard/settings?tab=billing";
592
745
  var creditCaches = new WeakMap;
593
746
  var TTL = 60000;
594
747
  var creditBalanceProvider = {
595
748
  name: "elizacloud_credits",
596
749
  description: "ElizaCloud credit balance",
750
+ descriptionCompressed: "ElizaCloud credit balance.",
597
751
  dynamic: true,
598
752
  position: 91,
599
753
  async get(runtime, _message, _state) {
@@ -644,6 +798,7 @@ var runtimeCaches = new WeakMap;
644
798
  var modelRegistryProvider = {
645
799
  name: "elizacloud_models",
646
800
  description: "Available AI models from ElizaCloud grouped by provider",
801
+ descriptionCompressed: "Available AI models from ElizaCloud by provider.",
647
802
  dynamic: true,
648
803
  position: 92,
649
804
  async get(runtime, _message, _state) {
@@ -699,12 +854,6 @@ function isBrowser() {
699
854
  function isProxyMode(runtime) {
700
855
  return isBrowser() && !!getSetting(runtime, "ELIZAOS_CLOUD_BROWSER_BASE_URL");
701
856
  }
702
- function getAuthHeader(runtime, forEmbedding = false) {
703
- if (isBrowser())
704
- return {};
705
- const key = forEmbedding ? getEmbeddingApiKey(runtime) : getApiKey(runtime);
706
- return key ? { Authorization: `Bearer ${key}` } : {};
707
- }
708
857
  function getBaseURL(runtime) {
709
858
  const browserURL = getSetting(runtime, "ELIZAOS_CLOUD_BROWSER_BASE_URL");
710
859
  const baseURL = isBrowser() && browserURL ? browserURL : getSetting(runtime, "ELIZAOS_CLOUD_BASE_URL", "https://www.elizacloud.ai/api/v1");
@@ -732,23 +881,32 @@ function getEmbeddingApiKey(runtime) {
732
881
  return getApiKey(runtime);
733
882
  }
734
883
  function getSmallModel(runtime) {
735
- return getSetting(runtime, "ELIZAOS_CLOUD_SMALL_MODEL") ?? getSetting(runtime, "SMALL_MODEL", "openai/gpt-5-mini");
884
+ return getSetting(runtime, "ELIZAOS_CLOUD_SMALL_MODEL") ?? getSetting(runtime, "SMALL_MODEL", "openai/gpt-5.4-mini");
885
+ }
886
+ function getNanoModel(runtime) {
887
+ return getSetting(runtime, "ELIZAOS_CLOUD_NANO_MODEL") ?? getSetting(runtime, "NANO_MODEL") ?? getSmallModel(runtime);
888
+ }
889
+ function getMediumModel(runtime) {
890
+ return getSetting(runtime, "ELIZAOS_CLOUD_MEDIUM_MODEL") ?? getSetting(runtime, "MEDIUM_MODEL") ?? getSmallModel(runtime);
736
891
  }
737
892
  function getLargeModel(runtime) {
738
- return getSetting(runtime, "ELIZAOS_CLOUD_LARGE_MODEL") ?? getSetting(runtime, "LARGE_MODEL", "anthropic/claude-sonnet-4.5");
893
+ return getSetting(runtime, "ELIZAOS_CLOUD_LARGE_MODEL") ?? getSetting(runtime, "LARGE_MODEL", "anthropic/claude-sonnet-4.6");
894
+ }
895
+ function getMegaModel(runtime) {
896
+ return getSetting(runtime, "ELIZAOS_CLOUD_MEGA_MODEL") ?? getSetting(runtime, "MEGA_MODEL") ?? getLargeModel(runtime);
897
+ }
898
+ function getResponseHandlerModel(runtime) {
899
+ return getSetting(runtime, "ELIZAOS_CLOUD_RESPONSE_HANDLER_MODEL") ?? getSetting(runtime, "ELIZAOS_CLOUD_SHOULD_RESPOND_MODEL") ?? getSetting(runtime, "RESPONSE_HANDLER_MODEL") ?? getSetting(runtime, "SHOULD_RESPOND_MODEL") ?? getNanoModel(runtime);
900
+ }
901
+ function getActionPlannerModel(runtime) {
902
+ return getSetting(runtime, "ELIZAOS_CLOUD_ACTION_PLANNER_MODEL") ?? getSetting(runtime, "ELIZAOS_CLOUD_PLANNER_MODEL") ?? getSetting(runtime, "ACTION_PLANNER_MODEL") ?? getSetting(runtime, "PLANNER_MODEL") ?? getMediumModel(runtime);
739
903
  }
740
904
  function getImageDescriptionModel(runtime) {
741
- return getSetting(runtime, "ELIZAOS_CLOUD_IMAGE_DESCRIPTION_MODEL", "gpt-5-mini");
905
+ return getSetting(runtime, "ELIZAOS_CLOUD_IMAGE_DESCRIPTION_MODEL", "gpt-5.4-mini");
742
906
  }
743
907
  function getImageGenerationModel(runtime) {
744
908
  return getSetting(runtime, "ELIZAOS_CLOUD_IMAGE_GENERATION_MODEL", "google/gemini-2.5-flash-image") ?? "google/gemini-2.5-flash-image";
745
909
  }
746
- function getReasoningSmallModel(runtime) {
747
- return getSetting(runtime, "ELIZAOS_CLOUD_REASONING_SMALL_MODEL") ?? getSetting(runtime, "REASONING_SMALL_MODEL", "deepseek/deepseek-r1");
748
- }
749
- function getReasoningLargeModel(runtime) {
750
- return getSetting(runtime, "ELIZAOS_CLOUD_REASONING_LARGE_MODEL") ?? getSetting(runtime, "REASONING_LARGE_MODEL", "anthropic/claude-opus-4.5");
751
- }
752
910
  function getResearchModel(runtime) {
753
911
  return getSetting(runtime, "ELIZAOS_CLOUD_RESEARCH_MODEL") ?? getSetting(runtime, "RESEARCH_MODEL", "o3-deep-research");
754
912
  }
@@ -757,6 +915,33 @@ function getExperimentalTelemetry(runtime) {
757
915
  return String(setting).toLowerCase() === "true";
758
916
  }
759
917
 
918
+ // utils/sdk-client.ts
919
+ var import_cloud_sdk2 = require("@elizaos/cloud-sdk");
920
+ function trimTrailingSlash(value) {
921
+ return value.replace(/\/+$/, "");
922
+ }
923
+ function apiBaseToSiteBaseUrl(apiBaseUrl) {
924
+ const trimmed = trimTrailingSlash(apiBaseUrl);
925
+ return trimmed.endsWith("/api/v1") ? trimmed.slice(0, -"/api/v1".length) : trimmed;
926
+ }
927
+ function apiKeyForRuntime(runtime, embedding = false) {
928
+ if (isBrowser())
929
+ return;
930
+ return embedding ? getEmbeddingApiKey(runtime) : getApiKey(runtime);
931
+ }
932
+ function createCloudApiClient(runtime, embedding = false) {
933
+ const baseUrl = embedding ? getEmbeddingBaseURL(runtime) : getBaseURL(runtime);
934
+ return new import_cloud_sdk2.CloudApiClient(trimTrailingSlash(baseUrl), apiKeyForRuntime(runtime, embedding));
935
+ }
936
+ function createElizaCloudClient(runtime) {
937
+ const apiBaseUrl = trimTrailingSlash(getBaseURL(runtime));
938
+ return new import_cloud_sdk2.ElizaCloudClient({
939
+ apiBaseUrl,
940
+ baseUrl: apiBaseToSiteBaseUrl(apiBaseUrl),
941
+ apiKey: apiKeyForRuntime(runtime)
942
+ });
943
+ }
944
+
760
945
  // init.ts
761
946
  function initializeOpenAI(_config, runtime) {
762
947
  (async () => {
@@ -767,20 +952,11 @@ function initializeOpenAI(_config, runtime) {
767
952
  return;
768
953
  }
769
954
  try {
770
- const baseURL = getBaseURL(runtime);
771
- const response = await fetch(`${baseURL}/models`, {
772
- headers: { ...getAuthHeader(runtime) }
773
- });
774
- if (!response.ok) {
775
- import_core4.logger.warn(`ElizaOS Cloud API key validation failed: ${response.statusText}`);
776
- import_core4.logger.warn("ElizaOS Cloud functionality will be limited until a valid API key is provided");
777
- import_core4.logger.info("Get your API key from https://www.elizacloud.ai/dashboard/api-keys");
778
- } else {
779
- import_core4.logger.log("ElizaOS Cloud API key validated successfully");
780
- }
955
+ await createCloudApiClient(runtime).get("/models");
956
+ import_core4.logger.log("ElizaOS Cloud API key validated successfully");
781
957
  } catch (fetchError) {
782
958
  const message = fetchError instanceof Error ? fetchError.message : String(fetchError);
783
- import_core4.logger.warn(`Error validating ElizaOS Cloud API key: ${message}`);
959
+ import_core4.logger.warn(`ElizaOS Cloud API key validation failed: ${message}`);
784
960
  import_core4.logger.warn("ElizaOS Cloud functionality will be limited until a valid API key is provided");
785
961
  }
786
962
  } catch (error) {
@@ -800,7 +976,7 @@ function emitModelUsageEvent(runtime, type, _prompt, usage) {
800
976
  const inputTokens = Number(usage.inputTokens || 0);
801
977
  const outputTokens = Number(usage.outputTokens || 0);
802
978
  const totalTokens = Number(usage.totalTokens != null ? usage.totalTokens : inputTokens + outputTokens);
803
- runtime.emitEvent(import_core5.EventType.MODEL_USED, {
979
+ const payload = {
804
980
  runtime,
805
981
  source: "elizacloud",
806
982
  type,
@@ -809,7 +985,8 @@ function emitModelUsageEvent(runtime, type, _prompt, usage) {
809
985
  completion: outputTokens,
810
986
  total: totalTokens
811
987
  }
812
- });
988
+ };
989
+ runtime.emitEvent(import_core5.EventType.MODEL_USED, payload);
813
990
  }
814
991
 
815
992
  // models/embeddings.ts
@@ -864,7 +1041,7 @@ async function handleTextEmbedding(runtime, params) {
864
1041
  }
865
1042
  async function handleBatchTextEmbedding(runtime, texts) {
866
1043
  const { embeddingModelName, embeddingDimension } = getEmbeddingConfig(runtime);
867
- const embeddingBaseURL = getEmbeddingBaseURL(runtime);
1044
+ const client = createCloudApiClient(runtime, true);
868
1045
  if (!texts || texts.length === 0) {
869
1046
  import_core6.logger.warn("[BatchEmbeddings] Empty texts array");
870
1047
  return [];
@@ -889,16 +1066,11 @@ async function handleBatchTextEmbedding(runtime, texts) {
889
1066
  const batchTexts = batch.map((b) => b.text);
890
1067
  import_core6.logger.info(`[BatchEmbeddings] Processing batch ${Math.floor(batchStart / MAX_BATCH_SIZE) + 1}/${Math.ceil(validTexts.length / MAX_BATCH_SIZE)}: ${batch.length} texts`);
891
1068
  try {
892
- const response = await fetch(`${embeddingBaseURL}/embeddings`, {
893
- method: "POST",
894
- headers: {
895
- ...getAuthHeader(runtime, true),
896
- "Content-Type": "application/json"
897
- },
898
- body: JSON.stringify({
1069
+ const response = await client.requestRaw("POST", "/embeddings", {
1070
+ json: {
899
1071
  model: embeddingModelName,
900
1072
  input: batchTexts
901
- })
1073
+ }
902
1074
  });
903
1075
  const rateLimitInfo = extractRateLimitInfo(response);
904
1076
  if (rateLimitInfo.remainingRequests !== undefined && rateLimitInfo.remainingRequests < 50) {
@@ -908,16 +1080,11 @@ async function handleBatchTextEmbedding(runtime, texts) {
908
1080
  const retryAfter = rateLimitInfo.retryAfter || 30;
909
1081
  import_core6.logger.warn(`[BatchEmbeddings] Rate limited, waiting ${retryAfter}s...`);
910
1082
  await new Promise((resolve) => setTimeout(resolve, retryAfter * 1000));
911
- const retryResponse = await fetch(`${embeddingBaseURL}/embeddings`, {
912
- method: "POST",
913
- headers: {
914
- ...getAuthHeader(runtime, true),
915
- "Content-Type": "application/json"
916
- },
917
- body: JSON.stringify({
1083
+ const retryResponse = await client.requestRaw("POST", "/embeddings", {
1084
+ json: {
918
1085
  model: embeddingModelName,
919
1086
  input: batchTexts
920
- })
1087
+ }
921
1088
  });
922
1089
  if (!retryResponse.ok) {
923
1090
  import_core6.logger.error(`[BatchEmbeddings] Retry failed: ${retryResponse.status}`);
@@ -1037,7 +1204,6 @@ async function handleImageGeneration(runtime, params) {
1037
1204
  const prompt = params.prompt;
1038
1205
  const modelName = getImageGenerationModel(runtime);
1039
1206
  import_core8.logger.log(`[ELIZAOS_CLOUD] Using IMAGE model: ${modelName}`);
1040
- const baseURL = getBaseURL(runtime);
1041
1207
  const aspectRatioMap = {
1042
1208
  "1024x1024": "1:1",
1043
1209
  "1792x1024": "16:9",
@@ -1045,27 +1211,13 @@ async function handleImageGeneration(runtime, params) {
1045
1211
  };
1046
1212
  const aspectRatio = aspectRatioMap[size] || "1:1";
1047
1213
  try {
1048
- const requestUrl = `${baseURL}/generate-image`;
1049
1214
  const requestBody = {
1050
1215
  prompt,
1051
1216
  numImages,
1052
1217
  aspectRatio,
1053
1218
  model: modelName
1054
1219
  };
1055
- const response = await fetch(requestUrl, {
1056
- method: "POST",
1057
- headers: {
1058
- ...getAuthHeader(runtime),
1059
- "Content-Type": "application/json"
1060
- },
1061
- body: JSON.stringify(requestBody)
1062
- });
1063
- if (!response.ok) {
1064
- const errorText = await response.text();
1065
- throw new Error(`Failed to generate image: ${response.status} ${errorText}`);
1066
- }
1067
- const data = await response.json();
1068
- const typedData = data;
1220
+ const typedData = await createElizaCloudClient(runtime).generateImage(requestBody);
1069
1221
  const result = typedData.images.map((img) => ({
1070
1222
  url: img.url || img.image
1071
1223
  }));
@@ -1098,7 +1250,7 @@ async function handleImageDescription(runtime, params) {
1098
1250
  ]
1099
1251
  }
1100
1252
  ];
1101
- const baseURL = getBaseURL(runtime);
1253
+ const client = createElizaCloudClient(runtime);
1102
1254
  try {
1103
1255
  const requestBody = {
1104
1256
  model: modelName,
@@ -1107,13 +1259,8 @@ async function handleImageDescription(runtime, params) {
1107
1259
  };
1108
1260
  let response = null;
1109
1261
  for (let attempt = 0;attempt < 3; attempt++) {
1110
- response = await fetch(`${baseURL}/chat/completions`, {
1111
- method: "POST",
1112
- headers: {
1113
- "Content-Type": "application/json",
1114
- ...getAuthHeader(runtime)
1115
- },
1116
- body: JSON.stringify(requestBody)
1262
+ response = await client.routes.postApiV1ChatCompletionsRaw({
1263
+ json: requestBody
1117
1264
  });
1118
1265
  if (response.status === 429 && attempt < 2) {
1119
1266
  const wait = (attempt + 1) * 2000;
@@ -1123,10 +1270,10 @@ async function handleImageDescription(runtime, params) {
1123
1270
  }
1124
1271
  break;
1125
1272
  }
1126
- if (!response || !response.ok) {
1273
+ if (!response?.ok) {
1127
1274
  const status = response?.status ?? 0;
1128
1275
  if (status === 402) {
1129
- throw new Error("Eliza Cloud credits exhausted — top up at https://www.elizacloud.ai/dashboard/billing");
1276
+ throw new Error("Eliza Cloud credits exhausted — top up at https://www.elizacloud.ai/dashboard/settings?tab=billing");
1130
1277
  }
1131
1278
  throw new Error(`ElizaOS Cloud API error: ${status}`);
1132
1279
  }
@@ -1157,17 +1304,82 @@ async function handleImageDescription(runtime, params) {
1157
1304
  }
1158
1305
  // models/object.ts
1159
1306
  var import_core9 = require("@elizaos/core");
1160
- var import_ai2 = require("ai");
1161
1307
 
1162
- // providers/openai.ts
1163
- var import_openai = require("@ai-sdk/openai");
1164
- function createOpenAIClient(runtime) {
1165
- const baseURL = getBaseURL(runtime);
1166
- const apiKey = getApiKey(runtime) ?? (isProxyMode(runtime) ? "eliza-proxy" : undefined);
1167
- return import_openai.createOpenAI({
1168
- apiKey: apiKey ?? "",
1169
- baseURL
1170
- });
1308
+ // utils/responses-output.ts
1309
+ function asRecord(value) {
1310
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
1311
+ return null;
1312
+ }
1313
+ return value;
1314
+ }
1315
+ function normalizeContentItems(value) {
1316
+ if (Array.isArray(value))
1317
+ return value;
1318
+ if (typeof value === "string")
1319
+ return [{ type: "text", text: value }];
1320
+ return value && typeof value === "object" ? [value] : [];
1321
+ }
1322
+ function extractTextFromContentItem(value) {
1323
+ if (typeof value === "string") {
1324
+ return [value];
1325
+ }
1326
+ const record = asRecord(value);
1327
+ if (!record)
1328
+ return [];
1329
+ const text = typeof record.text === "string" ? record.text : typeof record.output_text === "string" ? record.output_text : typeof record.content === "string" ? record.content : "";
1330
+ const type = typeof record.type === "string" ? record.type : undefined;
1331
+ if (text && (!type || type === "output_text" || type === "text")) {
1332
+ return [text];
1333
+ }
1334
+ return [];
1335
+ }
1336
+ function extractTextFromOutputItem(value) {
1337
+ const record = asRecord(value);
1338
+ if (!record)
1339
+ return [];
1340
+ const directContent = normalizeContentItems(record.content);
1341
+ if (directContent.length > 0) {
1342
+ return directContent.flatMap(extractTextFromContentItem);
1343
+ }
1344
+ const nestedMessage = asRecord(record.message);
1345
+ if (nestedMessage) {
1346
+ return normalizeContentItems(nestedMessage.content).flatMap(extractTextFromContentItem);
1347
+ }
1348
+ const type = typeof record.type === "string" ? record.type : undefined;
1349
+ const text = typeof record.text === "string" ? record.text : typeof record.output_text === "string" ? record.output_text : "";
1350
+ if (text && (type === "output_text" || type === "text")) {
1351
+ return [text];
1352
+ }
1353
+ return [];
1354
+ }
1355
+ function extractTextFromChoice(value) {
1356
+ const record = asRecord(value);
1357
+ if (!record)
1358
+ return [];
1359
+ if (typeof record.text === "string" && record.text) {
1360
+ return [record.text];
1361
+ }
1362
+ const message = asRecord(record.message);
1363
+ if (!message) {
1364
+ return [];
1365
+ }
1366
+ return normalizeContentItems(message.content).flatMap(extractTextFromContentItem);
1367
+ }
1368
+ function extractResponsesOutputText(data) {
1369
+ const record = asRecord(data);
1370
+ if (!record)
1371
+ return "";
1372
+ const segments = [];
1373
+ if (typeof record.output_text === "string" && record.output_text) {
1374
+ segments.push(record.output_text);
1375
+ }
1376
+ if (Array.isArray(record.output)) {
1377
+ segments.push(...record.output.flatMap(extractTextFromOutputItem));
1378
+ }
1379
+ if (Array.isArray(record.choices)) {
1380
+ segments.push(...record.choices.flatMap(extractTextFromChoice));
1381
+ }
1382
+ return segments.join("");
1171
1383
  }
1172
1384
 
1173
1385
  // models/object.ts
@@ -1177,9 +1389,8 @@ var REASONING_MODEL_PATTERNS = [
1177
1389
  "o4",
1178
1390
  "deepseek-r1",
1179
1391
  "deepseek-reasoner",
1180
- "claude-opus-4.5",
1181
- "claude-opus-4",
1182
- "gpt-5-mini",
1392
+ "claude-opus-4.7",
1393
+ "claude-opus-4-7",
1183
1394
  "gpt-5"
1184
1395
  ];
1185
1396
  function isReasoningModel(modelName) {
@@ -1187,50 +1398,85 @@ function isReasoningModel(modelName) {
1187
1398
  return REASONING_MODEL_PATTERNS.some((pattern) => lower.includes(pattern));
1188
1399
  }
1189
1400
  async function generateObjectByModelType(runtime, params, modelType, getModelFn) {
1190
- const openai = createOpenAIClient(runtime);
1191
1401
  const modelName = getModelFn(runtime);
1192
1402
  import_core9.logger.log(`[ELIZAOS_CLOUD] Using ${modelType} model: ${modelName}`);
1193
1403
  const reasoning = isReasoningModel(modelName);
1194
- try {
1195
- const model = openai.chat(modelName);
1196
- const { object, usage } = await import_ai2.generateObject({
1197
- model,
1198
- output: "no-schema",
1199
- prompt: params.prompt,
1200
- ...reasoning ? {} : { temperature: params.temperature ?? 0 },
1201
- experimental_repairText: getJsonRepairFunction()
1404
+ const input = [];
1405
+ if (runtime.character.system) {
1406
+ input.push({
1407
+ role: "system",
1408
+ content: [{ type: "input_text", text: runtime.character.system }]
1202
1409
  });
1203
- if (usage) {
1204
- emitModelUsageEvent(runtime, modelType, params.prompt, usage);
1410
+ }
1411
+ input.push({
1412
+ role: "user",
1413
+ content: [{ type: "input_text", text: params.prompt }]
1414
+ });
1415
+ const requestBody = {
1416
+ model: modelName,
1417
+ input,
1418
+ max_output_tokens: params.maxTokens ?? 8192,
1419
+ text: { format: { type: "json_object" } }
1420
+ };
1421
+ if (!reasoning && typeof params.temperature === "number") {
1422
+ requestBody.temperature = params.temperature;
1423
+ }
1424
+ const response = await createCloudApiClient(runtime).requestRaw("POST", "/responses", {
1425
+ json: requestBody
1426
+ });
1427
+ const responseText = await response.text();
1428
+ let data = {};
1429
+ if (responseText) {
1430
+ try {
1431
+ data = JSON.parse(responseText);
1432
+ } catch (parseErr) {
1433
+ import_core9.logger.error(`[generateObject] Failed to parse Eliza Cloud JSON: ${parseErr instanceof Error ? parseErr.message : String(parseErr)}`);
1205
1434
  }
1206
- return object;
1435
+ }
1436
+ if (!response.ok) {
1437
+ const errorBody = typeof data === "object" && data ? data.error : undefined;
1438
+ const errorMessage = typeof errorBody?.message === "string" && errorBody.message.trim() ? errorBody.message.trim() : `elizaOS Cloud error ${response.status}`;
1439
+ const requestError = new Error(errorMessage);
1440
+ requestError.status = response.status;
1441
+ if (errorBody) {
1442
+ requestError.error = errorBody;
1443
+ }
1444
+ throw requestError;
1445
+ }
1446
+ if (data.usage) {
1447
+ emitModelUsageEvent(runtime, modelType, params.prompt, {
1448
+ inputTokens: data.usage.input_tokens ?? 0,
1449
+ outputTokens: data.usage.output_tokens ?? 0,
1450
+ totalTokens: data.usage.total_tokens ?? 0
1451
+ });
1452
+ }
1453
+ let jsonText = extractResponsesOutputText(data);
1454
+ if (!jsonText.trim()) {
1455
+ throw new Error("Object generation returned empty response");
1456
+ }
1457
+ jsonText = jsonText.replace(/^[\s]*```(?:json)?\s*\n?/i, "").replace(/\n?```\s*$/i, "").trim();
1458
+ try {
1459
+ return JSON.parse(jsonText);
1207
1460
  } catch (error) {
1208
- if (error instanceof import_ai2.JSONParseError) {
1209
- import_core9.logger.error(`[generateObject] Failed to parse JSON: ${error.message}`);
1210
- const repairFunction = getJsonRepairFunction();
1211
- const repairedJsonString = await repairFunction({
1212
- text: error.text,
1213
- error
1214
- });
1215
- if (repairedJsonString) {
1216
- try {
1217
- const repairedObject = JSON.parse(repairedJsonString);
1218
- import_core9.logger.info("[generateObject] Successfully repaired JSON.");
1219
- return repairedObject;
1220
- } catch (repairParseError) {
1221
- const message = repairParseError instanceof Error ? repairParseError.message : String(repairParseError);
1222
- import_core9.logger.error(`[generateObject] Failed to parse repaired JSON: ${message}`);
1223
- throw repairParseError;
1224
- }
1225
- } else {
1226
- import_core9.logger.error("[generateObject] JSON repair failed.");
1227
- throw error;
1461
+ const repairFunction = getJsonRepairFunction();
1462
+ const repairedJsonString = await repairFunction({
1463
+ text: jsonText,
1464
+ error
1465
+ });
1466
+ if (repairedJsonString) {
1467
+ try {
1468
+ const repairedObject = JSON.parse(repairedJsonString);
1469
+ import_core9.logger.info("[generateObject] Successfully repaired JSON.");
1470
+ return repairedObject;
1471
+ } catch (repairParseError) {
1472
+ const message2 = repairParseError instanceof Error ? repairParseError.message : String(repairParseError);
1473
+ import_core9.logger.error(`[generateObject] Failed to parse repaired JSON: ${message2}`);
1474
+ throw repairParseError;
1228
1475
  }
1229
- } else {
1230
- const message = error instanceof Error ? error.message : String(error);
1231
- import_core9.logger.error(`[generateObject] Error: ${message}`);
1232
- throw error;
1233
1476
  }
1477
+ const message = error instanceof Error ? error.message : String(error);
1478
+ import_core9.logger.error(`[generateObject] Failed to parse JSON: ${message}`);
1479
+ throw error;
1234
1480
  }
1235
1481
  }
1236
1482
  async function handleObjectSmall(runtime, params) {
@@ -1241,6 +1487,33 @@ async function handleObjectLarge(runtime, params) {
1241
1487
  }
1242
1488
  // models/research.ts
1243
1489
  var import_core10 = require("@elizaos/core");
1490
+ function normalizeInput(input) {
1491
+ if (typeof input !== "string") {
1492
+ return input;
1493
+ }
1494
+ return [
1495
+ {
1496
+ role: "user",
1497
+ content: [
1498
+ {
1499
+ type: "input_text",
1500
+ text: input
1501
+ }
1502
+ ]
1503
+ }
1504
+ ];
1505
+ }
1506
+ function buildResearchApiError(status, errorText) {
1507
+ try {
1508
+ const parsed = JSON.parse(errorText);
1509
+ const message = parsed.error?.message;
1510
+ const param = parsed.error?.param;
1511
+ if (param === "tools.0.type" && message?.includes('expected "function"')) {
1512
+ return new Error(`Research API error: ${status} Eliza Cloud /responses rejected deep-research tool types; the provider currently only accepts function tools on this route`);
1513
+ }
1514
+ } catch {}
1515
+ return new Error(`Research API error: ${status} ${errorText}`);
1516
+ }
1244
1517
  function parseAnnotations(raw) {
1245
1518
  return raw.filter((a) => a.url !== undefined).map((a) => ({
1246
1519
  url: a.url,
@@ -1317,11 +1590,10 @@ function parseOutputItems(raw) {
1317
1590
  async function handleResearch(runtime, params) {
1318
1591
  const modelName = params.model ?? getResearchModel(runtime);
1319
1592
  import_core10.logger.log(`[ELIZAOS_CLOUD] Using RESEARCH model: ${modelName}`);
1320
- const baseURL = getBaseURL(runtime);
1321
1593
  const tools = params.tools ?? [{ type: "web_search_preview" }];
1322
1594
  const requestBody = {
1323
1595
  model: modelName,
1324
- input: params.input,
1596
+ input: normalizeInput(params.input),
1325
1597
  tools
1326
1598
  };
1327
1599
  if (params.instructions) {
@@ -1336,17 +1608,12 @@ async function handleResearch(runtime, params) {
1336
1608
  if (params.reasoningSummary) {
1337
1609
  requestBody.reasoning = { summary: params.reasoningSummary };
1338
1610
  }
1339
- const response = await fetch(`${baseURL}/responses`, {
1340
- method: "POST",
1341
- headers: {
1342
- ...getAuthHeader(runtime),
1343
- "Content-Type": "application/json"
1344
- },
1345
- body: JSON.stringify(requestBody)
1611
+ const response = await createCloudApiClient(runtime).requestRaw("POST", "/responses", {
1612
+ json: requestBody
1346
1613
  });
1347
1614
  if (!response.ok) {
1348
1615
  const errorText = await response.text();
1349
- throw new Error(`Research API error: ${response.status} ${errorText}`);
1616
+ throw buildResearchApiError(response.status, errorText);
1350
1617
  }
1351
1618
  const data = await response.json();
1352
1619
  if (data.usage) {
@@ -1382,27 +1649,21 @@ var import_core11 = require("@elizaos/core");
1382
1649
  async function fetchTextToSpeech(runtime, options) {
1383
1650
  const defaultModel = getSetting(runtime, "ELIZAOS_CLOUD_TTS_MODEL", "gpt-5-mini-tts");
1384
1651
  const defaultVoice = getSetting(runtime, "ELIZAOS_CLOUD_TTS_VOICE", "nova");
1385
- const defaultInstructions = getSetting(runtime, "ELIZAOS_CLOUD_TTS_INSTRUCTIONS", "");
1386
- const baseURL = getBaseURL(runtime);
1387
1652
  const model = options.model || defaultModel;
1388
1653
  const voice = options.voice || defaultVoice;
1389
- const instructions = options.instructions ?? defaultInstructions;
1390
1654
  const format2 = options.format || "mp3";
1655
+ const modelId = model.startsWith("elevenlabs/") ? model.split("/").slice(1).join("/") : model.startsWith("eleven_") ? model : undefined;
1656
+ const voiceId = voice && voice !== "nova" ? voice : undefined;
1391
1657
  try {
1392
- const res = await fetch(`${baseURL}/audio/speech`, {
1393
- method: "POST",
1658
+ const res = await createElizaCloudClient(runtime).routes.postApiV1VoiceTts({
1394
1659
  headers: {
1395
- ...getAuthHeader(runtime),
1396
- "Content-Type": "application/json",
1397
1660
  ...format2 === "mp3" ? { Accept: "audio/mpeg" } : {}
1398
1661
  },
1399
- body: JSON.stringify({
1400
- model,
1401
- voice,
1402
- input: options.text,
1403
- format: format2,
1404
- ...instructions && { instructions }
1405
- })
1662
+ json: {
1663
+ text: options.text,
1664
+ ...voiceId ? { voiceId } : {},
1665
+ ...modelId ? { modelId } : {}
1666
+ }
1406
1667
  });
1407
1668
  if (!res.ok) {
1408
1669
  const err = await res.text();
@@ -1422,51 +1683,103 @@ async function fetchTextToSpeech(runtime, options) {
1422
1683
  }
1423
1684
  // models/text.ts
1424
1685
  var import_core12 = require("@elizaos/core");
1425
- var import_ai3 = require("ai");
1686
+
1687
+ // providers/openai.ts
1688
+ var import_openai = require("@ai-sdk/openai");
1689
+ function createOpenAIClient(runtime) {
1690
+ const baseURL = getBaseURL(runtime);
1691
+ const apiKey = getApiKey(runtime) ?? (isProxyMode(runtime) ? "eliza-proxy" : undefined);
1692
+ return import_openai.createOpenAI({
1693
+ apiKey: apiKey ?? "",
1694
+ baseURL
1695
+ });
1696
+ }
1697
+
1698
+ // models/text.ts
1699
+ var TEXT_NANO_MODEL_TYPE = import_core12.ModelType.TEXT_NANO ?? "TEXT_NANO";
1700
+ var TEXT_MEDIUM_MODEL_TYPE = import_core12.ModelType.TEXT_MEDIUM ?? "TEXT_MEDIUM";
1701
+ var TEXT_SMALL_MODEL_TYPE = import_core12.ModelType.TEXT_SMALL;
1702
+ var TEXT_LARGE_MODEL_TYPE = import_core12.ModelType.TEXT_LARGE;
1703
+ var TEXT_MEGA_MODEL_TYPE = import_core12.ModelType.TEXT_MEGA ?? "TEXT_MEGA";
1704
+ var RESPONSE_HANDLER_MODEL_TYPE = import_core12.ModelType.RESPONSE_HANDLER ?? "RESPONSE_HANDLER";
1705
+ var ACTION_PLANNER_MODEL_TYPE = import_core12.ModelType.ACTION_PLANNER ?? "ACTION_PLANNER";
1426
1706
  var REASONING_MODEL_PATTERNS2 = [
1427
1707
  "o1",
1428
1708
  "o3",
1429
1709
  "o4",
1430
1710
  "deepseek-r1",
1431
1711
  "deepseek-reasoner",
1432
- "claude-opus-4.5",
1433
- "claude-opus-4",
1434
- "gpt-5-mini",
1712
+ "claude-opus-4.7",
1713
+ "claude-opus-4-7",
1435
1714
  "gpt-5"
1436
1715
  ];
1716
+ var RESPONSES_ROUTED_PREFIXES = ["openai/", "anthropic/"];
1717
+ function buildUserContent(params) {
1718
+ const content = [{ type: "text", text: params.prompt }];
1719
+ for (const attachment of params.attachments ?? []) {
1720
+ content.push({
1721
+ type: "file",
1722
+ data: attachment.data,
1723
+ mediaType: attachment.mediaType,
1724
+ ...attachment.filename ? { filename: attachment.filename } : {}
1725
+ });
1726
+ }
1727
+ return content;
1728
+ }
1437
1729
  function isReasoningModel2(modelName) {
1438
1730
  const lower = modelName.toLowerCase();
1439
1731
  return REASONING_MODEL_PATTERNS2.some((pattern) => lower.includes(pattern));
1440
1732
  }
1733
+ function supportsStopSequences(modelName) {
1734
+ const lower = modelName.toLowerCase();
1735
+ return !RESPONSES_ROUTED_PREFIXES.some((prefix) => lower.startsWith(prefix));
1736
+ }
1737
+ function getPurposeForModelType(modelType) {
1738
+ switch (modelType) {
1739
+ case RESPONSE_HANDLER_MODEL_TYPE:
1740
+ return "should_respond";
1741
+ case ACTION_PLANNER_MODEL_TYPE:
1742
+ return "action_planner";
1743
+ default:
1744
+ return "response";
1745
+ }
1746
+ }
1441
1747
  function getModelNameForType(runtime, modelType) {
1442
1748
  switch (modelType) {
1443
- case import_core12.ModelType.TEXT_SMALL:
1749
+ case TEXT_NANO_MODEL_TYPE:
1750
+ return getNanoModel(runtime);
1751
+ case TEXT_MEDIUM_MODEL_TYPE:
1752
+ return getMediumModel(runtime);
1753
+ case TEXT_SMALL_MODEL_TYPE:
1444
1754
  return getSmallModel(runtime);
1445
- case import_core12.ModelType.TEXT_LARGE:
1755
+ case TEXT_LARGE_MODEL_TYPE:
1446
1756
  return getLargeModel(runtime);
1447
- case import_core12.ModelType.TEXT_REASONING_SMALL:
1448
- return getReasoningSmallModel(runtime);
1449
- case import_core12.ModelType.TEXT_REASONING_LARGE:
1450
- return getReasoningLargeModel(runtime);
1757
+ case TEXT_MEGA_MODEL_TYPE:
1758
+ return getMegaModel(runtime);
1759
+ case RESPONSE_HANDLER_MODEL_TYPE:
1760
+ return getResponseHandlerModel(runtime);
1761
+ case ACTION_PLANNER_MODEL_TYPE:
1762
+ return getActionPlannerModel(runtime);
1451
1763
  default:
1452
1764
  return getLargeModel(runtime);
1453
1765
  }
1454
1766
  }
1455
1767
  function buildGenerateParams(runtime, modelType, params) {
1456
- const { prompt, stopSequences = [] } = params;
1768
+ const paramsWithAttachments = params;
1769
+ const { prompt } = params;
1457
1770
  const maxTokens = params.maxTokens ?? 8192;
1458
1771
  const openai = createOpenAIClient(runtime);
1459
1772
  const modelName = getModelNameForType(runtime, modelType);
1460
1773
  const experimentalTelemetry = getExperimentalTelemetry(runtime);
1774
+ const userContent = (paramsWithAttachments.attachments?.length ?? 0) > 0 ? buildUserContent(paramsWithAttachments) : undefined;
1461
1775
  const model = openai.chat(modelName);
1462
- const reasoning = isReasoningModel2(modelName) || modelType === import_core12.ModelType.TEXT_REASONING_SMALL || modelType === import_core12.ModelType.TEXT_REASONING_LARGE;
1776
+ const reasoning = isReasoningModel2(modelName);
1777
+ const stopSequences = !reasoning && supportsStopSequences(modelName) && Array.isArray(params.stopSequences) && params.stopSequences.length > 0 ? params.stopSequences : undefined;
1463
1778
  const generateParams = {
1464
1779
  model,
1465
- prompt,
1780
+ ...userContent ? { messages: [{ role: "user", content: userContent }] } : { prompt },
1466
1781
  system: runtime.character.system ?? undefined,
1467
- ...reasoning ? {} : {
1468
- stopSequences
1469
- },
1782
+ ...stopSequences ? { stopSequences } : {},
1470
1783
  maxOutputTokens: maxTokens,
1471
1784
  experimental_telemetry: {
1472
1785
  isEnabled: experimentalTelemetry
@@ -1474,129 +1787,101 @@ function buildGenerateParams(runtime, modelType, params) {
1474
1787
  };
1475
1788
  return { generateParams, modelName, modelType, prompt };
1476
1789
  }
1477
- function handleStreamingGeneration(runtime, modelType, generateParams, prompt) {
1478
- import_core12.logger.debug(`[ELIZAOS_CLOUD] Streaming text with ${modelType} model`);
1479
- const streamResult = import_ai3.streamText(generateParams);
1480
- return {
1481
- textStream: streamResult.textStream,
1482
- text: Promise.resolve(streamResult.text),
1483
- usage: Promise.resolve(streamResult.usage).then((usage) => {
1484
- if (usage) {
1485
- emitModelUsageEvent(runtime, modelType, prompt, usage);
1486
- const inputTokens = usage.inputTokens ?? 0;
1487
- const outputTokens = usage.outputTokens ?? 0;
1488
- return {
1489
- promptTokens: inputTokens,
1490
- completionTokens: outputTokens,
1491
- totalTokens: inputTokens + outputTokens
1492
- };
1493
- }
1494
- return;
1495
- }),
1496
- finishReason: Promise.resolve(streamResult.finishReason)
1497
- };
1498
- }
1499
1790
  async function generateTextWithModel(runtime, modelType, params) {
1500
- const { generateParams, modelName, prompt } = buildGenerateParams(runtime, modelType, params);
1791
+ const { modelName, prompt } = buildGenerateParams(runtime, modelType, params);
1501
1792
  import_core12.logger.debug(`[ELIZAOS_CLOUD] Generating text with ${modelType} model: ${modelName}`);
1502
1793
  if (params.stream) {
1503
- return handleStreamingGeneration(runtime, modelType, generateParams, prompt);
1794
+ import_core12.logger.debug("[ELIZAOS_CLOUD] Streaming text disabled for responses compatibility; falling back to buffered response.");
1504
1795
  }
1505
1796
  import_core12.logger.log(`[ELIZAOS_CLOUD] Using ${modelType} model: ${modelName}`);
1506
1797
  import_core12.logger.log(prompt);
1507
- const response = await import_ai3.generateText(generateParams);
1508
- if (response.usage) {
1509
- emitModelUsageEvent(runtime, modelType, prompt, response.usage);
1798
+ const reasoning = isReasoningModel2(modelName);
1799
+ const input = [];
1800
+ if (runtime.character.system) {
1801
+ input.push({
1802
+ role: "system",
1803
+ content: [{ type: "input_text", text: runtime.character.system }]
1804
+ });
1805
+ }
1806
+ input.push({
1807
+ role: "user",
1808
+ content: [{ type: "input_text", text: prompt }]
1809
+ });
1810
+ const requestBody = {
1811
+ model: modelName,
1812
+ input,
1813
+ max_output_tokens: params.maxTokens ?? 8192
1814
+ };
1815
+ if (!reasoning && typeof params.temperature === "number") {
1816
+ requestBody.temperature = params.temperature;
1817
+ }
1818
+ const response = await createCloudApiClient(runtime).requestRaw("POST", "/responses", {
1819
+ headers: {
1820
+ "X-Eliza-Llm-Purpose": getPurposeForModelType(modelType),
1821
+ "X-Eliza-Model-Type": modelType
1822
+ },
1823
+ json: requestBody
1824
+ });
1825
+ const responseText = await response.text();
1826
+ let data = {};
1827
+ if (responseText) {
1828
+ try {
1829
+ data = JSON.parse(responseText);
1830
+ } catch (parseErr) {
1831
+ import_core12.logger.error(`[ELIZAOS_CLOUD] Failed to parse responses JSON: ${parseErr instanceof Error ? parseErr.message : String(parseErr)}`);
1832
+ }
1833
+ }
1834
+ if (!response.ok) {
1835
+ const errorBody = typeof data === "object" && data ? data.error : undefined;
1836
+ const errorMessage = typeof errorBody?.message === "string" && errorBody.message.trim() ? errorBody.message.trim() : `elizaOS Cloud error ${response.status}`;
1837
+ const requestError = new Error(errorMessage);
1838
+ requestError.status = response.status;
1839
+ if (errorBody) {
1840
+ requestError.error = errorBody;
1841
+ }
1842
+ throw requestError;
1843
+ }
1844
+ if (data.usage) {
1845
+ emitModelUsageEvent(runtime, modelType, prompt, {
1846
+ inputTokens: data.usage.input_tokens ?? 0,
1847
+ outputTokens: data.usage.output_tokens ?? 0,
1848
+ totalTokens: data.usage.total_tokens ?? 0
1849
+ });
1510
1850
  }
1511
- return response.text;
1851
+ const text = extractResponsesOutputText(data);
1852
+ if (!text.trim()) {
1853
+ throw new Error("elizaOS Cloud returned no text response");
1854
+ }
1855
+ return text;
1512
1856
  }
1513
1857
  async function handleTextSmall(runtime, params) {
1514
- return generateTextWithModel(runtime, import_core12.ModelType.TEXT_SMALL, params);
1858
+ return generateTextWithModel(runtime, TEXT_SMALL_MODEL_TYPE, params);
1859
+ }
1860
+ async function handleTextNano(runtime, params) {
1861
+ return generateTextWithModel(runtime, TEXT_NANO_MODEL_TYPE, params);
1862
+ }
1863
+ async function handleTextMedium(runtime, params) {
1864
+ return generateTextWithModel(runtime, TEXT_MEDIUM_MODEL_TYPE, params);
1515
1865
  }
1516
1866
  async function handleTextLarge(runtime, params) {
1517
- return generateTextWithModel(runtime, import_core12.ModelType.TEXT_LARGE, params);
1867
+ return generateTextWithModel(runtime, TEXT_LARGE_MODEL_TYPE, params);
1518
1868
  }
1519
- async function handleTextReasoningSmall(runtime, params) {
1520
- return generateTextWithModel(runtime, import_core12.ModelType.TEXT_REASONING_SMALL, params);
1869
+ async function handleTextMega(runtime, params) {
1870
+ return generateTextWithModel(runtime, TEXT_MEGA_MODEL_TYPE, params);
1521
1871
  }
1522
- async function handleTextReasoningLarge(runtime, params) {
1523
- return generateTextWithModel(runtime, import_core12.ModelType.TEXT_REASONING_LARGE, params);
1872
+ async function handleResponseHandler(runtime, params) {
1873
+ return generateTextWithModel(runtime, RESPONSE_HANDLER_MODEL_TYPE, params);
1874
+ }
1875
+ async function handleActionPlanner(runtime, params) {
1876
+ return generateTextWithModel(runtime, ACTION_PLANNER_MODEL_TYPE, params);
1524
1877
  }
1525
1878
  // services/cloud-auth.ts
1526
- var import_core14 = require("@elizaos/core");
1879
+ var import_core13 = require("@elizaos/core");
1880
+ var import_shared = require("@elizaos/shared");
1881
+ var import_jose = require("jose");
1527
1882
 
1528
1883
  // utils/cloud-api.ts
1529
- var import_core13 = require("@elizaos/core");
1530
- class CloudApiClient {
1531
- baseUrl;
1532
- apiKey;
1533
- constructor(baseUrl, apiKey) {
1534
- this.baseUrl = baseUrl.replace(/\/+$/, "");
1535
- this.apiKey = apiKey;
1536
- }
1537
- setApiKey(key) {
1538
- this.apiKey = key;
1539
- }
1540
- setBaseUrl(url) {
1541
- this.baseUrl = url.replace(/\/+$/, "");
1542
- }
1543
- getBaseUrl() {
1544
- return this.baseUrl;
1545
- }
1546
- getApiKey() {
1547
- return this.apiKey;
1548
- }
1549
- buildWsUrl(path) {
1550
- return `${this.baseUrl.replace(/^http/, "ws")}${path}`;
1551
- }
1552
- async get(path) {
1553
- return this.request("GET", path);
1554
- }
1555
- async post(path, body) {
1556
- return this.request("POST", path, body);
1557
- }
1558
- async delete(path) {
1559
- return this.request("DELETE", path);
1560
- }
1561
- async postUnauthenticated(path, body) {
1562
- return this.request("POST", path, body, true);
1563
- }
1564
- async request(method, path, body, skipAuth = false) {
1565
- const url = `${this.baseUrl}${path}`;
1566
- import_core13.logger.debug(`[CloudAPI] ${method} ${url}`);
1567
- const headers = {
1568
- "Content-Type": "application/json",
1569
- Accept: "application/json"
1570
- };
1571
- if (!skipAuth && this.apiKey) {
1572
- headers.Authorization = `Bearer ${this.apiKey}`;
1573
- }
1574
- const response = await fetch(url, {
1575
- method,
1576
- headers,
1577
- ...body ? { body: JSON.stringify(body) } : {}
1578
- });
1579
- return this.handleResponse(response);
1580
- }
1581
- async handleResponse(response) {
1582
- const contentType = response.headers.get("content-type") ?? "";
1583
- if (!contentType.includes("application/json")) {
1584
- if (!response.ok) {
1585
- throw new CloudApiError(response.status, {
1586
- success: false,
1587
- error: `HTTP ${response.status}: ${response.statusText}`
1588
- });
1589
- }
1590
- return { success: true };
1591
- }
1592
- const body = await response.json();
1593
- if (!response.ok) {
1594
- const err = body;
1595
- throw response.status === 402 ? new InsufficientCreditsError(err) : new CloudApiError(response.status, err);
1596
- }
1597
- return body;
1598
- }
1599
- }
1884
+ var import_cloud_sdk3 = require("@elizaos/cloud-sdk");
1600
1885
 
1601
1886
  // services/cloud-auth.ts
1602
1887
  async function deriveDeviceId() {
@@ -1623,15 +1908,14 @@ function detectPlatform() {
1623
1908
  };
1624
1909
  return map[process.platform] ?? "linux";
1625
1910
  }
1626
-
1627
- class CloudAuthService extends import_core14.Service {
1911
+ class CloudAuthService extends import_core13.Service {
1628
1912
  static serviceType = "CLOUD_AUTH";
1629
- capabilityDescription = "ElizaCloud device authentication and session management";
1913
+ capabilityDescription = "Eliza Cloud device authentication and SSO session helpers";
1630
1914
  client;
1631
1915
  credentials = null;
1632
1916
  constructor(runtime) {
1633
1917
  super(runtime);
1634
- this.client = new CloudApiClient(DEFAULT_CLOUD_CONFIG.baseUrl);
1918
+ this.client = new import_cloud_sdk3.CloudApiClient(DEFAULT_CLOUD_CONFIG.baseUrl);
1635
1919
  }
1636
1920
  static async start(runtime) {
1637
1921
  const service = new CloudAuthService(runtime);
@@ -1651,13 +1935,13 @@ class CloudAuthService extends import_core14.Service {
1651
1935
  this.credentials = {
1652
1936
  apiKey: key,
1653
1937
  userId: String(this.runtime.getSetting("ELIZAOS_CLOUD_USER_ID") ?? ""),
1654
- organizationId: String(this.runtime.getSetting("ELIZAOS_CLOUD_ORG_ID") ?? ""),
1938
+ organizationId: String(this.runtime.getSetting("ELIZAOS_CLOUD_ORG_ID") ?? this.runtime.getSetting("ELIZA_CLOUD_ORGANIZATION_ID") ?? ""),
1655
1939
  authenticatedAt: Date.now()
1656
1940
  };
1657
- import_core14.logger.info("[CloudAuth] Authenticated with saved API key");
1941
+ import_core13.logger.info("[CloudAuth] Authenticated with saved API key");
1658
1942
  this.validateApiKey(key).then((valid) => {
1659
1943
  if (!valid) {
1660
- import_core14.logger.warn("[CloudAuth] Saved API key could not be validated (cloud may be unreachable or key revoked) — model calls will use the key anyway");
1944
+ import_core13.logger.warn("[CloudAuth] Saved API key could not be validated (cloud may be unreachable or key revoked) — model calls will use the key anyway");
1661
1945
  }
1662
1946
  }).catch(() => {});
1663
1947
  return;
@@ -1668,23 +1952,21 @@ class CloudAuthService extends import_core14.Service {
1668
1952
  await this.authenticateWithDevice();
1669
1953
  } catch (err) {
1670
1954
  const msg = err instanceof Error ? err.message : String(err);
1671
- import_core14.logger.warn(`[CloudAuth] Device auth failed (cloud may be unreachable): ${msg}`);
1672
- import_core14.logger.info("[CloudAuth] Service will start unauthenticated — cloud features disabled until connectivity is restored");
1955
+ import_core13.logger.warn(`[CloudAuth] Device auth failed (cloud may be unreachable): ${msg}`);
1956
+ import_core13.logger.info("[CloudAuth] Service will start unauthenticated — cloud features disabled until connectivity is restored");
1673
1957
  }
1674
1958
  } else {
1675
- import_core14.logger.info("[CloudAuth] Cloud not enabled (set ELIZAOS_CLOUD_ENABLED=true)");
1959
+ import_core13.logger.info("[CloudAuth] Cloud not enabled (set ELIZAOS_CLOUD_ENABLED=true)");
1676
1960
  }
1677
1961
  }
1678
1962
  async validateApiKey(key) {
1679
1963
  try {
1680
- const resp = await fetch(`${this.client.getBaseUrl()}/models`, {
1681
- headers: { Authorization: `Bearer ${key}` },
1682
- signal: AbortSignal.timeout(1e4)
1683
- });
1684
- return resp.ok;
1964
+ const validationClient = new import_cloud_sdk3.CloudApiClient(this.client.getBaseUrl(), key);
1965
+ await validationClient.get("/models", { timeoutMs: 1e4 });
1966
+ return true;
1685
1967
  } catch (err) {
1686
1968
  const msg = err instanceof Error ? err.message : String(err);
1687
- import_core14.logger.warn(`[CloudAuth] Could not reach cloud API to validate key: ${msg}`);
1969
+ import_core13.logger.warn(`[CloudAuth] Could not reach cloud API to validate key: ${msg}`);
1688
1970
  return false;
1689
1971
  }
1690
1972
  }
@@ -1693,7 +1975,7 @@ class CloudAuthService extends import_core14.Service {
1693
1975
  const platform = detectPlatform();
1694
1976
  const appVersion = process.env.ELIZAOS_CLOUD_APP_VERSION ?? "2.0.0-alpha";
1695
1977
  const os = await import("node:os");
1696
- import_core14.logger.info(`[CloudAuth] Authenticating device (platform=${platform})`);
1978
+ import_core13.logger.info(`[CloudAuth] Authenticating device (platform=${platform})`);
1697
1979
  const response = await this.client.postUnauthenticated("/device-auth", {
1698
1980
  deviceId,
1699
1981
  platform,
@@ -1708,9 +1990,28 @@ class CloudAuthService extends import_core14.Service {
1708
1990
  };
1709
1991
  this.client.setApiKey(response.data.apiKey);
1710
1992
  const action = response.data.isNew ? "New account created" : "Authenticated";
1711
- import_core14.logger.info(`[CloudAuth] ${action} (credits: $${response.data.credits.toFixed(2)})`);
1993
+ import_core13.logger.info(`[CloudAuth] ${action} (credits: $${response.data.credits.toFixed(2)})`);
1712
1994
  return this.credentials;
1713
1995
  }
1996
+ authenticateWithApiKey(input) {
1997
+ const apiKey = input.apiKey.trim();
1998
+ if (!apiKey) {
1999
+ throw new Error("Eliza Cloud API key is required");
2000
+ }
2001
+ this.client.setApiKey(apiKey);
2002
+ this.credentials = {
2003
+ apiKey,
2004
+ userId: input.userId ?? "",
2005
+ organizationId: input.organizationId ?? "",
2006
+ authenticatedAt: Date.now()
2007
+ };
2008
+ import_core13.logger.info("[CloudAuth] Authenticated with API key");
2009
+ return this.credentials;
2010
+ }
2011
+ clearAuth() {
2012
+ this.credentials = null;
2013
+ this.client.setApiKey(undefined);
2014
+ }
1714
2015
  isAuthenticated() {
1715
2016
  return this.credentials !== null;
1716
2017
  }
@@ -1732,8 +2033,8 @@ class CloudAuthService extends import_core14.Service {
1732
2033
  }
1733
2034
 
1734
2035
  // services/cloud-backup.ts
1735
- var import_core15 = require("@elizaos/core");
1736
- class CloudBackupService extends import_core15.Service {
2036
+ var import_core14 = require("@elizaos/core");
2037
+ class CloudBackupService extends import_core14.Service {
1737
2038
  static serviceType = "CLOUD_BACKUP";
1738
2039
  capabilityDescription = "ElizaCloud agent state backup and restore";
1739
2040
  authService;
@@ -1750,21 +2051,21 @@ class CloudBackupService extends import_core15.Service {
1750
2051
  clearInterval(entry.timer);
1751
2052
  }
1752
2053
  this.autoBackups.clear();
1753
- import_core15.logger.info("[CloudBackup] Service stopped");
2054
+ import_core14.logger.info("[CloudBackup] Service stopped");
1754
2055
  }
1755
2056
  async initialize() {
1756
2057
  const auth = this.runtime.getService("CLOUD_AUTH");
1757
2058
  if (!auth) {
1758
- import_core15.logger.warn("[CloudBackup] CloudAuthService not available");
2059
+ import_core14.logger.debug("[CloudBackup] CloudAuthService not available");
1759
2060
  return;
1760
2061
  }
1761
2062
  this.authService = auth;
1762
- import_core15.logger.info("[CloudBackup] Service initialized");
2063
+ import_core14.logger.info("[CloudBackup] Service initialized");
1763
2064
  }
1764
2065
  async createSnapshot(containerId, snapshotType = "manual", metadata) {
1765
2066
  const client = this.authService.getClient();
1766
2067
  const response = await client.post(`/agent-state/${containerId}/snapshot`, { snapshotType, metadata });
1767
- import_core15.logger.info(`[CloudBackup] Created ${snapshotType} snapshot for container ${containerId} (id=${response.data.id}, size=${formatBytes(response.data.sizeBytes)})`);
2068
+ import_core14.logger.info(`[CloudBackup] Created ${snapshotType} snapshot for container ${containerId} (id=${response.data.id}, size=${formatBytes(response.data.sizeBytes)})`);
1768
2069
  const autoEntry = this.autoBackups.get(containerId);
1769
2070
  if (autoEntry) {
1770
2071
  autoEntry.lastBackupAt = Date.now();
@@ -1778,8 +2079,10 @@ class CloudBackupService extends import_core15.Service {
1778
2079
  }
1779
2080
  async restoreSnapshot(containerId, snapshotId) {
1780
2081
  const client = this.authService.getClient();
1781
- await client.post(`/agent-state/${containerId}/restore`, { snapshotId });
1782
- import_core15.logger.info(`[CloudBackup] Restored snapshot ${snapshotId} for container ${containerId}`);
2082
+ await client.post(`/agent-state/${containerId}/restore`, {
2083
+ snapshotId
2084
+ });
2085
+ import_core14.logger.info(`[CloudBackup] Restored snapshot ${snapshotId} for container ${containerId}`);
1783
2086
  }
1784
2087
  async getLatestSnapshot(containerId) {
1785
2088
  const snapshots = await this.listSnapshots(containerId);
@@ -1790,17 +2093,17 @@ class CloudBackupService extends import_core15.Service {
1790
2093
  }
1791
2094
  scheduleAutoBackup(containerId, intervalMs) {
1792
2095
  if (this.autoBackups.has(containerId)) {
1793
- import_core15.logger.debug(`[CloudBackup] Auto-backup already scheduled for ${containerId}`);
2096
+ import_core14.logger.debug(`[CloudBackup] Auto-backup already scheduled for ${containerId}`);
1794
2097
  return;
1795
2098
  }
1796
2099
  const interval = intervalMs ?? this.backupIntervalMs;
1797
2100
  const timer = setInterval(() => {
1798
- import_core15.logger.debug(`[CloudBackup] Running auto-backup for container ${containerId}`);
2101
+ import_core14.logger.debug(`[CloudBackup] Running auto-backup for container ${containerId}`);
1799
2102
  this.createSnapshot(containerId, "auto", {
1800
2103
  trigger: "scheduled",
1801
2104
  scheduledIntervalMs: interval
1802
2105
  }).then(() => this.pruneSnapshots(containerId)).catch((err) => {
1803
- import_core15.logger.error(`[CloudBackup] Auto-backup failed for ${containerId}: ${err.message}`);
2106
+ import_core14.logger.error(`[CloudBackup] Auto-backup failed for ${containerId}: ${err.message}`);
1804
2107
  });
1805
2108
  }, interval);
1806
2109
  this.autoBackups.set(containerId, {
@@ -1808,7 +2111,7 @@ class CloudBackupService extends import_core15.Service {
1808
2111
  timer,
1809
2112
  lastBackupAt: null
1810
2113
  });
1811
- import_core15.logger.info(`[CloudBackup] Scheduled auto-backup for ${containerId} every ${Math.round(interval / 60000)} minutes`);
2114
+ import_core14.logger.info(`[CloudBackup] Scheduled auto-backup for ${containerId} every ${Math.round(interval / 60000)} minutes`);
1812
2115
  }
1813
2116
  cancelAutoBackup(containerId) {
1814
2117
  const entry = this.autoBackups.get(containerId);
@@ -1816,10 +2119,10 @@ class CloudBackupService extends import_core15.Service {
1816
2119
  return;
1817
2120
  clearInterval(entry.timer);
1818
2121
  this.autoBackups.delete(containerId);
1819
- import_core15.logger.info(`[CloudBackup] Cancelled auto-backup for ${containerId}`);
2122
+ import_core14.logger.info(`[CloudBackup] Cancelled auto-backup for ${containerId}`);
1820
2123
  }
1821
2124
  async createPreEvictionSnapshot(containerId) {
1822
- import_core15.logger.info(`[CloudBackup] Creating pre-eviction snapshot for ${containerId}`);
2125
+ import_core14.logger.info(`[CloudBackup] Creating pre-eviction snapshot for ${containerId}`);
1823
2126
  return this.createSnapshot(containerId, "pre-eviction", {
1824
2127
  trigger: "billing-eviction",
1825
2128
  createdAt: new Date().toISOString()
@@ -1834,9 +2137,9 @@ class CloudBackupService extends import_core15.Service {
1834
2137
  const client = this.authService.getClient();
1835
2138
  for (const snapshot of excess) {
1836
2139
  await client.delete(`/agent-state/${containerId}/snapshots/${snapshot.id}`);
1837
- import_core15.logger.debug(`[CloudBackup] Pruned old auto snapshot ${snapshot.id} for ${containerId}`);
2140
+ import_core14.logger.debug(`[CloudBackup] Pruned old auto snapshot ${snapshot.id} for ${containerId}`);
1838
2141
  }
1839
- import_core15.logger.info(`[CloudBackup] Pruned ${excess.length} old auto snapshot(s) for ${containerId}`);
2142
+ import_core14.logger.info(`[CloudBackup] Pruned ${excess.length} old auto snapshot(s) for ${containerId}`);
1840
2143
  }
1841
2144
  isAutoBackupScheduled(containerId) {
1842
2145
  return this.autoBackups.has(containerId);
@@ -1855,6 +2158,68 @@ function formatBytes(bytes) {
1855
2158
  return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;
1856
2159
  }
1857
2160
 
2161
+ // services/cloud-bootstrap.ts
2162
+ var import_core15 = require("@elizaos/core");
2163
+ function readEnv() {
2164
+ if (typeof process === "undefined") {
2165
+ return {};
2166
+ }
2167
+ return process.env;
2168
+ }
2169
+ function readSetting(runtime, key) {
2170
+ if (runtime && typeof runtime.getSetting === "function") {
2171
+ const value = runtime.getSetting(key);
2172
+ if (typeof value === "string" && value.length > 0) {
2173
+ return value;
2174
+ }
2175
+ }
2176
+ const fromEnv = readEnv()[key];
2177
+ if (typeof fromEnv === "string" && fromEnv.length > 0) {
2178
+ return fromEnv;
2179
+ }
2180
+ return null;
2181
+ }
2182
+ function trimTrailingSlash2(input) {
2183
+ let end = input.length;
2184
+ while (end > 0 && input.charCodeAt(end - 1) === 47) {
2185
+ end -= 1;
2186
+ }
2187
+ return end === input.length ? input : input.slice(0, end);
2188
+ }
2189
+
2190
+ class CloudBootstrapServiceImpl extends import_core15.Service {
2191
+ static serviceType = "CLOUD_BOOTSTRAP";
2192
+ capabilityDescription = "Exposes Eliza Cloud bootstrap-token trust anchor (issuer, JWKS URL, revocation list URL, expected container id) to app-core";
2193
+ static async start(runtime) {
2194
+ const service = new CloudBootstrapServiceImpl(runtime);
2195
+ const issuer = readSetting(runtime, "ELIZA_CLOUD_ISSUER");
2196
+ const containerId = readSetting(runtime, "ELIZA_CLOUD_CONTAINER_ID");
2197
+ if (issuer) {
2198
+ import_core15.logger.info(`[CloudBootstrap] Trust anchor configured (issuer=${issuer}, containerId=${containerId ?? "<unset>"})`);
2199
+ } else {
2200
+ import_core15.logger.debug("[CloudBootstrap] ELIZA_CLOUD_ISSUER unset — bootstrap-token verification will reject until configured");
2201
+ }
2202
+ return service;
2203
+ }
2204
+ async stop() {}
2205
+ getExpectedIssuer() {
2206
+ const issuer = readSetting(this.runtime, "ELIZA_CLOUD_ISSUER");
2207
+ if (!issuer) {
2208
+ throw new Error("ELIZA_CLOUD_ISSUER is not configured — bootstrap-token verification cannot proceed");
2209
+ }
2210
+ return trimTrailingSlash2(issuer);
2211
+ }
2212
+ getJwksUrl() {
2213
+ return `${this.getExpectedIssuer()}/.well-known/jwks.json`;
2214
+ }
2215
+ getRevocationListUrl() {
2216
+ return `${this.getExpectedIssuer()}/.well-known/revocations.json`;
2217
+ }
2218
+ getExpectedContainerId() {
2219
+ return readSetting(this.runtime, "ELIZA_CLOUD_CONTAINER_ID");
2220
+ }
2221
+ }
2222
+
1858
2223
  // services/cloud-bridge.ts
1859
2224
  var import_core16 = require("@elizaos/core");
1860
2225
  var import_undici = require("undici");
@@ -1878,15 +2243,15 @@ class CloudBridgeService extends import_core16.Service {
1878
2243
  async initialize() {
1879
2244
  const auth = this.runtime.getService("CLOUD_AUTH");
1880
2245
  if (!auth) {
1881
- import_core16.logger.warn("[CloudBridge] CloudAuthService not available");
2246
+ import_core16.logger.debug("[CloudBridge] CloudAuthService not available");
1882
2247
  return;
1883
2248
  }
1884
2249
  this.authService = auth;
1885
2250
  import_core16.logger.info("[CloudBridge] Service initialized");
1886
2251
  }
1887
2252
  async connect(containerId) {
1888
- if (this.connections.has(containerId)) {
1889
- const existing = this.connections.get(containerId);
2253
+ const existing = this.connections.get(containerId);
2254
+ if (existing) {
1890
2255
  if (existing.state === "connected" || existing.state === "connecting") {
1891
2256
  import_core16.logger.debug(`[CloudBridge] Already connected/connecting to ${containerId}`);
1892
2257
  return;
@@ -2129,7 +2494,7 @@ class CloudContainerService extends import_core17.Service {
2129
2494
  async initialize() {
2130
2495
  const auth = this.runtime.getService("CLOUD_AUTH");
2131
2496
  if (!auth) {
2132
- import_core17.logger.warn("[CloudContainer] CloudAuthService not available, container operations will fail");
2497
+ import_core17.logger.debug("[CloudContainer] CloudAuthService not available, container operations will fail");
2133
2498
  return;
2134
2499
  }
2135
2500
  this.authService = auth;
@@ -2295,8 +2660,458 @@ class CloudContainerService extends import_core17.Service {
2295
2660
  }
2296
2661
  }
2297
2662
 
2298
- // services/cloud-model-registry.ts
2663
+ // services/cloud-managed-gateway-relay.ts
2299
2664
  var import_core18 = require("@elizaos/core");
2665
+ var POLL_TIMEOUT_MS = 25000;
2666
+ var REQUEST_TIMEOUT_MS = POLL_TIMEOUT_MS + 5000;
2667
+ var RETRY_DELAY_MS = 2000;
2668
+ var IDLE_DELAY_MS = 250;
2669
+ function sleep(ms) {
2670
+ return new Promise((resolve) => setTimeout(resolve, ms));
2671
+ }
2672
+ function isRecord(value) {
2673
+ return typeof value === "object" && value !== null && !Array.isArray(value);
2674
+ }
2675
+ function isUuidLike(value) {
2676
+ return /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value);
2677
+ }
2678
+ function asTrimmedString(value) {
2679
+ return typeof value === "string" && value.trim() ? value.trim() : undefined;
2680
+ }
2681
+ function resolveChannelType(value) {
2682
+ const candidate = asTrimmedString(value)?.toUpperCase();
2683
+ return candidate && candidate in import_core18.ChannelType ? import_core18.ChannelType[candidate] : import_core18.ChannelType.DM;
2684
+ }
2685
+ function isCloudProvisionedRuntime() {
2686
+ if (typeof process === "undefined") {
2687
+ return false;
2688
+ }
2689
+ return process.env.ELIZA_CLOUD_PROVISIONED === "1";
2690
+ }
2691
+ function isNodeHost() {
2692
+ return typeof process !== "undefined" && typeof process.versions?.node === "string";
2693
+ }
2694
+ function normalizeAttachments(value) {
2695
+ if (!Array.isArray(value)) {
2696
+ return;
2697
+ }
2698
+ const attachments = value.map((entry, index) => {
2699
+ if (!isRecord(entry)) {
2700
+ return null;
2701
+ }
2702
+ const url = asTrimmedString(entry.url);
2703
+ if (!url) {
2704
+ return null;
2705
+ }
2706
+ const type = asTrimmedString(entry.type)?.toLowerCase();
2707
+ return {
2708
+ id: asTrimmedString(entry.id) ?? `${index}:${url}`,
2709
+ url,
2710
+ source: asTrimmedString(entry.source),
2711
+ title: asTrimmedString(entry.title),
2712
+ description: asTrimmedString(entry.description),
2713
+ text: asTrimmedString(entry.text),
2714
+ contentType: type === "image" ? import_core18.ContentType.IMAGE : type === "video" ? import_core18.ContentType.VIDEO : type === "audio" ? import_core18.ContentType.AUDIO : type === "document" ? import_core18.ContentType.DOCUMENT : undefined
2715
+ };
2716
+ }).filter((entry) => entry !== null);
2717
+ return attachments.length > 0 ? attachments : undefined;
2718
+ }
2719
+ function toJsonRecord(value) {
2720
+ return isRecord(value) ? value : undefined;
2721
+ }
2722
+ function toJsonMetadataRecord(value) {
2723
+ if (!isRecord(value)) {
2724
+ return;
2725
+ }
2726
+ return JSON.parse(JSON.stringify(value));
2727
+ }
2728
+ function buildGatewayMessagePayload(runtime, rpc) {
2729
+ const params = toJsonRecord(rpc.params);
2730
+ const sender = toJsonRecord(params?.sender);
2731
+ const source = asTrimmedString(params?.source) ?? "eliza_cloud_gateway";
2732
+ const text = typeof params?.text === "string" ? params.text : "";
2733
+ const senderId = asTrimmedString(sender?.id) ?? `${source}:anonymous`;
2734
+ const senderUserName = asTrimmedString(sender?.username) ?? senderId;
2735
+ const senderName = asTrimmedString(sender?.displayName) ?? asTrimmedString(sender?.name) ?? senderUserName;
2736
+ const roomKey = asTrimmedString(params?.roomId) ?? `${source}:${senderId}:${String(rpc.id ?? Date.now())}:${runtime.agentId}`;
2737
+ if (!text.trim() && !normalizeAttachments(params?.attachments)?.length) {
2738
+ return null;
2739
+ }
2740
+ return {
2741
+ text: text.trim() || " ",
2742
+ roomKey,
2743
+ channelType: resolveChannelType(params?.channelType),
2744
+ source,
2745
+ senderId,
2746
+ senderUserName,
2747
+ senderName,
2748
+ attachments: normalizeAttachments(params?.attachments),
2749
+ senderMetadata: toJsonRecord(sender?.metadata),
2750
+ transportMetadata: toJsonRecord(params?.metadata)
2751
+ };
2752
+ }
2753
+ function buildWorldKey(source, metadata, roomKey) {
2754
+ const discord = toJsonRecord(metadata?.discord);
2755
+ const guildId = asTrimmedString(discord?.guildId);
2756
+ if (guildId) {
2757
+ return `gateway:${source}:guild:${guildId}`;
2758
+ }
2759
+ const threadId = asTrimmedString(metadata?.threadId);
2760
+ if (threadId) {
2761
+ return `gateway:${source}:thread:${threadId}`;
2762
+ }
2763
+ return `gateway:${source}:room:${roomKey}`;
2764
+ }
2765
+
2766
+ class SessionMissingError extends Error {
2767
+ constructor() {
2768
+ super("Gateway relay session missing");
2769
+ this.name = "SessionMissingError";
2770
+ }
2771
+ }
2772
+
2773
+ class CloudManagedGatewayRelayService extends import_core18.Service {
2774
+ static serviceType = "CLOUD_MANAGED_GATEWAY_RELAY";
2775
+ capabilityDescription = "Registers a local Eliza runtime with the cloud managed gateway and handles inbound relay traffic";
2776
+ authService = null;
2777
+ loopPromise = null;
2778
+ currentSessionId = null;
2779
+ stopping = false;
2780
+ activeAbortController = null;
2781
+ relayStatus = "idle";
2782
+ lastSeenAt = null;
2783
+ static async start(runtime) {
2784
+ const service = new CloudManagedGatewayRelayService(runtime);
2785
+ await service.initialize();
2786
+ return service;
2787
+ }
2788
+ async stop() {
2789
+ this.stopping = true;
2790
+ this.relayStatus = "stopped";
2791
+ this.activeAbortController?.abort();
2792
+ if (this.loopPromise) {
2793
+ await this.loopPromise.catch((error) => {
2794
+ import_core18.logger.debug(`[CloudManagedGatewayRelay] Ignoring relay loop shutdown error: ${error instanceof Error ? error.message : String(error)}`);
2795
+ });
2796
+ }
2797
+ const sessionId = this.currentSessionId;
2798
+ this.currentSessionId = null;
2799
+ if (sessionId) {
2800
+ await this.disconnectSession(sessionId);
2801
+ }
2802
+ }
2803
+ async initialize() {
2804
+ if (!isNodeHost()) {
2805
+ import_core18.logger.debug("[CloudManagedGatewayRelay] Skipping gateway relay outside Node.js runtime");
2806
+ this.relayStatus = "stopped";
2807
+ return;
2808
+ }
2809
+ if (isCloudProvisionedRuntime()) {
2810
+ import_core18.logger.debug("[CloudManagedGatewayRelay] Skipping local relay inside provisioned cloud runtime");
2811
+ this.relayStatus = "stopped";
2812
+ return;
2813
+ }
2814
+ if (!this.runtime.messageService) {
2815
+ import_core18.logger.debug("[CloudManagedGatewayRelay] Skipping gateway relay without message service");
2816
+ this.relayStatus = "idle";
2817
+ return;
2818
+ }
2819
+ const auth = this.runtime.getService("CLOUD_AUTH");
2820
+ if (!auth) {
2821
+ import_core18.logger.debug("[CloudManagedGatewayRelay] CloudAuthService not available");
2822
+ this.relayStatus = "idle";
2823
+ return;
2824
+ }
2825
+ this.authService = auth;
2826
+ if (!this.authService.isAuthenticated()) {
2827
+ import_core18.logger.debug("[CloudManagedGatewayRelay] Skipping gateway relay while cloud auth is inactive");
2828
+ this.relayStatus = "idle";
2829
+ return;
2830
+ }
2831
+ this.startRelayLoopIfReady();
2832
+ }
2833
+ getSessionInfo() {
2834
+ const auth = this.authService;
2835
+ const status = this.stopping || this.relayStatus === "stopped" ? "stopped" : auth?.isAuthenticated() === false ? "idle" : this.relayStatus;
2836
+ return {
2837
+ sessionId: this.currentSessionId,
2838
+ organizationId: auth?.getOrganizationId() ?? null,
2839
+ userId: auth?.getUserId() ?? null,
2840
+ agentName: this.getAgentName(),
2841
+ platform: "local-runtime",
2842
+ lastSeenAt: this.lastSeenAt,
2843
+ status
2844
+ };
2845
+ }
2846
+ startRelayLoopIfReady() {
2847
+ if (this.loopPromise && !this.stopping) {
2848
+ return true;
2849
+ }
2850
+ const auth = this.authService ?? this.runtime.getService("CLOUD_AUTH");
2851
+ if (!auth?.isAuthenticated() || !this.runtime.messageService) {
2852
+ this.relayStatus = "idle";
2853
+ return false;
2854
+ }
2855
+ this.authService = auth;
2856
+ this.stopping = false;
2857
+ this.relayStatus = "idle";
2858
+ this.loopPromise = this.runLoop();
2859
+ import_core18.logger.info("[CloudManagedGatewayRelay] Local gateway relay loop started");
2860
+ return true;
2861
+ }
2862
+ async runLoop() {
2863
+ while (!this.stopping) {
2864
+ try {
2865
+ if (!this.currentSessionId) {
2866
+ this.currentSessionId = await this.registerSession();
2867
+ this.relayStatus = "registered";
2868
+ this.lastSeenAt = new Date().toISOString();
2869
+ continue;
2870
+ }
2871
+ this.relayStatus = "polling";
2872
+ const request = await this.pollNextRequest(this.currentSessionId);
2873
+ this.lastSeenAt = new Date().toISOString();
2874
+ if (!request) {
2875
+ this.relayStatus = "registered";
2876
+ await sleep(IDLE_DELAY_MS);
2877
+ continue;
2878
+ }
2879
+ const response = await this.handleRequest(request.rpc);
2880
+ await this.submitResponse(this.currentSessionId, request.requestId, response);
2881
+ this.relayStatus = "registered";
2882
+ } catch (error) {
2883
+ if (this.stopping) {
2884
+ return;
2885
+ }
2886
+ if (error instanceof SessionMissingError) {
2887
+ this.currentSessionId = null;
2888
+ this.relayStatus = "idle";
2889
+ await sleep(IDLE_DELAY_MS);
2890
+ continue;
2891
+ }
2892
+ this.relayStatus = "error";
2893
+ import_core18.logger.warn(`[CloudManagedGatewayRelay] Relay loop error: ${error instanceof Error ? error.message : String(error)}`);
2894
+ await sleep(RETRY_DELAY_MS);
2895
+ }
2896
+ }
2897
+ }
2898
+ getAgentName() {
2899
+ return this.runtime.character?.name?.trim() || "Eliza";
2900
+ }
2901
+ getClient() {
2902
+ const client = this.authService?.getClient();
2903
+ if (!client) {
2904
+ throw new Error("Cloud API client is unavailable");
2905
+ }
2906
+ return client;
2907
+ }
2908
+ async requestJson(path, options) {
2909
+ const timeoutMs = options.timeoutMs ?? REQUEST_TIMEOUT_MS;
2910
+ const controller = new AbortController;
2911
+ const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
2912
+ this.activeAbortController = controller;
2913
+ try {
2914
+ const response = await this.getClient().requestRaw(options.method, path, {
2915
+ headers: {
2916
+ Accept: "application/json"
2917
+ },
2918
+ json: options.json,
2919
+ query: options.query,
2920
+ signal: controller.signal
2921
+ });
2922
+ const body = await response.json().catch(() => ({}));
2923
+ return { status: response.status, body };
2924
+ } finally {
2925
+ clearTimeout(timeoutId);
2926
+ if (this.activeAbortController === controller) {
2927
+ this.activeAbortController = null;
2928
+ }
2929
+ }
2930
+ }
2931
+ async registerSession() {
2932
+ const { status, body } = await this.requestJson("/eliza/gateway-relay/sessions", {
2933
+ method: "POST",
2934
+ json: {
2935
+ runtimeAgentId: this.runtime.agentId,
2936
+ agentName: this.getAgentName()
2937
+ }
2938
+ });
2939
+ if (status >= 400 || !body?.success || !body.data?.session?.id) {
2940
+ throw new Error(`Failed to register gateway relay session (status=${status})`);
2941
+ }
2942
+ import_core18.logger.info(`[CloudManagedGatewayRelay] Registered local runtime for managed gateway (${body.data.session.id})`);
2943
+ return body.data.session.id;
2944
+ }
2945
+ async disconnectSession(sessionId) {
2946
+ try {
2947
+ await this.requestJson(`/eliza/gateway-relay/sessions/${encodeURIComponent(sessionId)}`, {
2948
+ method: "DELETE",
2949
+ timeoutMs: 1e4
2950
+ });
2951
+ } catch (error) {
2952
+ import_core18.logger.debug(`[CloudManagedGatewayRelay] Failed to disconnect relay session ${sessionId}: ${error instanceof Error ? error.message : String(error)}`);
2953
+ }
2954
+ }
2955
+ async pollNextRequest(sessionId) {
2956
+ const { status, body } = await this.requestJson(`/eliza/gateway-relay/sessions/${encodeURIComponent(sessionId)}/next`, {
2957
+ method: "GET",
2958
+ query: { timeoutMs: POLL_TIMEOUT_MS },
2959
+ timeoutMs: POLL_TIMEOUT_MS + 5000
2960
+ });
2961
+ if (status === 404) {
2962
+ throw new SessionMissingError;
2963
+ }
2964
+ if (status >= 400 || !body?.success) {
2965
+ throw new Error(`Failed to poll gateway relay session ${sessionId} (status=${status})`);
2966
+ }
2967
+ return body.data?.request ?? null;
2968
+ }
2969
+ async submitResponse(sessionId, requestId, response) {
2970
+ const { status, body } = await this.requestJson(`/eliza/gateway-relay/sessions/${encodeURIComponent(sessionId)}/responses`, {
2971
+ method: "POST",
2972
+ json: { requestId, response }
2973
+ });
2974
+ if (status === 404) {
2975
+ throw new SessionMissingError;
2976
+ }
2977
+ if (status >= 400 || body?.success === false) {
2978
+ throw new Error(`Failed to submit gateway relay response (status=${status})`);
2979
+ }
2980
+ }
2981
+ async handleRequest(rpc) {
2982
+ switch (rpc.method) {
2983
+ case "heartbeat":
2984
+ return {
2985
+ jsonrpc: "2.0",
2986
+ id: rpc.id,
2987
+ result: { timestamp: Date.now() }
2988
+ };
2989
+ case "status.get":
2990
+ return {
2991
+ jsonrpc: "2.0",
2992
+ id: rpc.id,
2993
+ result: {
2994
+ status: "running",
2995
+ runtimeAgentId: this.runtime.agentId,
2996
+ agentName: this.getAgentName()
2997
+ }
2998
+ };
2999
+ case "message.send":
3000
+ return this.handleMessageSend(rpc);
3001
+ default:
3002
+ return {
3003
+ jsonrpc: "2.0",
3004
+ id: rpc.id,
3005
+ error: {
3006
+ code: -32601,
3007
+ message: `Unsupported relay method: ${rpc.method}`
3008
+ }
3009
+ };
3010
+ }
3011
+ }
3012
+ async handleMessageSend(rpc) {
3013
+ if (!this.runtime.messageService) {
3014
+ return {
3015
+ jsonrpc: "2.0",
3016
+ id: rpc.id,
3017
+ error: { code: -32603, message: "Message service is not available" }
3018
+ };
3019
+ }
3020
+ const payload = buildGatewayMessagePayload(this.runtime, rpc);
3021
+ if (!payload) {
3022
+ return {
3023
+ jsonrpc: "2.0",
3024
+ id: rpc.id,
3025
+ error: { code: -32602, message: "Invalid message relay payload" }
3026
+ };
3027
+ }
3028
+ const roomId = isUuidLike(payload.roomKey) ? payload.roomKey : import_core18.createUniqueUuid(this.runtime, payload.roomKey);
3029
+ const worldId = import_core18.createUniqueUuid(this.runtime, buildWorldKey(payload.source, payload.transportMetadata, payload.roomKey));
3030
+ const entityId = import_core18.createUniqueUuid(this.runtime, `${payload.source}:${payload.senderId}`);
3031
+ const messageServerId = import_core18.createUniqueUuid(this.runtime, `eliza-cloud-gateway:${payload.source}`);
3032
+ const messageId = import_core18.createUniqueUuid(this.runtime, `${payload.source}:${payload.roomKey}:${String(rpc.id ?? Date.now())}:inbound`);
3033
+ const transportMetadata = toJsonMetadataRecord(payload.transportMetadata);
3034
+ await this.runtime.ensureConnection({
3035
+ entityId,
3036
+ roomId,
3037
+ roomName: payload.roomKey,
3038
+ worldId,
3039
+ worldName: payload.source,
3040
+ userName: payload.senderUserName,
3041
+ name: payload.senderName,
3042
+ source: payload.source,
3043
+ channelId: payload.roomKey,
3044
+ type: payload.channelType,
3045
+ messageServerId,
3046
+ metadata: transportMetadata
3047
+ });
3048
+ const message = import_core18.createMessageMemory({
3049
+ id: messageId,
3050
+ entityId,
3051
+ agentId: this.runtime.agentId,
3052
+ roomId,
3053
+ content: {
3054
+ text: payload.text,
3055
+ source: payload.source,
3056
+ channelType: payload.channelType,
3057
+ ...payload.attachments ? { attachments: payload.attachments } : {}
3058
+ }
3059
+ });
3060
+ message.metadata = {
3061
+ ...message.metadata,
3062
+ entityName: payload.senderName,
3063
+ entityUserName: payload.senderUserName,
3064
+ ...payload.senderMetadata ? { gatewaySender: toJsonMetadataRecord(payload.senderMetadata) } : {},
3065
+ ...payload.transportMetadata ? { gatewayMetadata: transportMetadata } : {}
3066
+ };
3067
+ const callbackTexts = [];
3068
+ const callback = async (content) => {
3069
+ const responseText = typeof content.text === "string" ? content.text : "";
3070
+ if (responseText.trim()) {
3071
+ callbackTexts.push(responseText);
3072
+ }
3073
+ const responseMemory = import_core18.createMessageMemory({
3074
+ id: import_core18.createUniqueUuid(this.runtime, `${payload.source}:${payload.roomKey}:${String(rpc.id ?? Date.now())}:response:${callbackTexts.length}`),
3075
+ entityId: this.runtime.agentId,
3076
+ agentId: this.runtime.agentId,
3077
+ roomId,
3078
+ content: {
3079
+ ...content,
3080
+ text: responseText,
3081
+ source: payload.source,
3082
+ channelType: payload.channelType
3083
+ }
3084
+ });
3085
+ await this.runtime.createMemory(responseMemory, "messages");
3086
+ return [responseMemory];
3087
+ };
3088
+ try {
3089
+ const result = await this.runtime.messageService.handleMessage(this.runtime, message, callback);
3090
+ const replyText = callbackTexts[callbackTexts.length - 1] ?? (typeof result.responseContent?.text === "string" ? result.responseContent.text : undefined);
3091
+ return {
3092
+ jsonrpc: "2.0",
3093
+ id: rpc.id,
3094
+ result: {
3095
+ didRespond: result.didRespond,
3096
+ ...replyText ? { text: replyText } : {},
3097
+ runtimeAgentId: this.runtime.agentId
3098
+ }
3099
+ };
3100
+ } catch (error) {
3101
+ return {
3102
+ jsonrpc: "2.0",
3103
+ id: rpc.id,
3104
+ error: {
3105
+ code: -32603,
3106
+ message: error instanceof Error ? error.message : String(error)
3107
+ }
3108
+ };
3109
+ }
3110
+ }
3111
+ }
3112
+
3113
+ // services/cloud-model-registry.ts
3114
+ var import_core19 = require("@elizaos/core");
2300
3115
  var CACHE_TTL_MS = 30 * 60 * 1000;
2301
3116
  var PROVIDER_PREFIXES = [
2302
3117
  ["gpt-", "openai"],
@@ -2330,16 +3145,13 @@ function stripProvider(modelId) {
2330
3145
  return modelId;
2331
3146
  }
2332
3147
 
2333
- class CloudModelRegistryService extends import_core18.Service {
3148
+ class CloudModelRegistryService extends import_core19.Service {
2334
3149
  static serviceType = "CLOUD_MODEL_REGISTRY";
2335
3150
  capabilityDescription = "Discovers and caches available AI models from ElizaCloud";
2336
3151
  models = [];
2337
3152
  byProvider = {};
2338
3153
  lastFetchedAt = 0;
2339
3154
  fetchPromise = null;
2340
- constructor(runtime) {
2341
- super(runtime);
2342
- }
2343
3155
  static async start(runtime) {
2344
3156
  const service = new CloudModelRegistryService(runtime);
2345
3157
  await service.initialize();
@@ -2353,7 +3165,7 @@ class CloudModelRegistryService extends import_core18.Service {
2353
3165
  async initialize() {
2354
3166
  const auth = this.runtime.getService("CLOUD_AUTH");
2355
3167
  if (!auth?.isAuthenticated()) {
2356
- import_core18.logger.info("[CloudModelRegistry] Auth not available, will fetch models on first access");
3168
+ import_core19.logger.info("[CloudModelRegistry] Auth not available, will fetch models on first access");
2357
3169
  return;
2358
3170
  }
2359
3171
  await this.fetchModels();
@@ -2389,7 +3201,7 @@ class CloudModelRegistryService extends import_core18.Service {
2389
3201
  this.byProvider[model.provider].push(model);
2390
3202
  }
2391
3203
  this.lastFetchedAt = Date.now();
2392
- import_core18.logger.info(`[CloudModelRegistry] Loaded ${this.models.length} models from ${Object.keys(this.byProvider).length} providers`);
3204
+ import_core19.logger.info(`[CloudModelRegistry] Loaded ${this.models.length} models from ${Object.keys(this.byProvider).length} providers`);
2393
3205
  }
2394
3206
  validateConfiguredModels() {
2395
3207
  if (this.models.length === 0)
@@ -2397,23 +3209,42 @@ class CloudModelRegistryService extends import_core18.Service {
2397
3209
  const modelIds = new Set(this.models.map((m) => m.id));
2398
3210
  const nameSet = new Set(this.models.map((m) => m.name));
2399
3211
  const settingsToCheck = [
3212
+ { key: "ELIZAOS_CLOUD_NANO_MODEL", label: "nano model" },
3213
+ { key: "ELIZAOS_CLOUD_MEDIUM_MODEL", label: "medium model" },
2400
3214
  { key: "ELIZAOS_CLOUD_SMALL_MODEL", label: "small model" },
2401
3215
  { key: "ELIZAOS_CLOUD_LARGE_MODEL", label: "large model" },
2402
- { key: "ELIZAOS_CLOUD_REASONING_SMALL_MODEL", label: "reasoning small model" },
2403
- { key: "ELIZAOS_CLOUD_REASONING_LARGE_MODEL", label: "reasoning large model" },
3216
+ { key: "ELIZAOS_CLOUD_MEGA_MODEL", label: "mega model" },
3217
+ {
3218
+ key: "ELIZAOS_CLOUD_RESPONSE_HANDLER_MODEL",
3219
+ label: "response handler model"
3220
+ },
3221
+ {
3222
+ key: "ELIZAOS_CLOUD_ACTION_PLANNER_MODEL",
3223
+ label: "action planner model"
3224
+ },
3225
+ { key: "ELIZAOS_CLOUD_RESPONSE_MODEL", label: "response model" },
2404
3226
  { key: "ELIZAOS_CLOUD_RESEARCH_MODEL", label: "research model" },
2405
3227
  { key: "ELIZAOS_CLOUD_EMBEDDING_MODEL", label: "embedding model" },
2406
- { key: "ELIZAOS_CLOUD_IMAGE_DESCRIPTION_MODEL", label: "image description model" },
2407
- { key: "ELIZAOS_CLOUD_IMAGE_GENERATION_MODEL", label: "image generation model" },
3228
+ {
3229
+ key: "ELIZAOS_CLOUD_IMAGE_DESCRIPTION_MODEL",
3230
+ label: "image description model"
3231
+ },
3232
+ {
3233
+ key: "ELIZAOS_CLOUD_IMAGE_GENERATION_MODEL",
3234
+ label: "image generation model"
3235
+ },
2408
3236
  { key: "ELIZAOS_CLOUD_TTS_MODEL", label: "TTS model" },
2409
- { key: "ELIZAOS_CLOUD_TRANSCRIPTION_MODEL", label: "transcription model" }
3237
+ {
3238
+ key: "ELIZAOS_CLOUD_TRANSCRIPTION_MODEL",
3239
+ label: "transcription model"
3240
+ }
2410
3241
  ];
2411
3242
  for (const { key, label } of settingsToCheck) {
2412
3243
  const value = this.runtime.getSetting(key);
2413
3244
  if (value && typeof value === "string") {
2414
3245
  const found = modelIds.has(value) || nameSet.has(value);
2415
3246
  if (!found) {
2416
- import_core18.logger.warn(`[CloudModelRegistry] Configured ${label} "${value}" not found in available models. ` + "It may still work if the gateway supports it, but check your configuration.");
3247
+ import_core19.logger.warn(`[CloudModelRegistry] Configured ${label} "${value}" not found in available models. ` + "It may still work if the gateway supports it, but check your configuration.");
2417
3248
  }
2418
3249
  }
2419
3250
  }
@@ -2433,6 +3264,11 @@ class CloudModelRegistryService extends import_core18.Service {
2433
3264
  }
2434
3265
 
2435
3266
  // index.ts
3267
+ var TEXT_NANO_MODEL_TYPE2 = import_core20.ModelType.TEXT_NANO ?? "TEXT_NANO";
3268
+ var TEXT_MEDIUM_MODEL_TYPE2 = import_core20.ModelType.TEXT_MEDIUM ?? "TEXT_MEDIUM";
3269
+ var TEXT_MEGA_MODEL_TYPE2 = import_core20.ModelType.TEXT_MEGA ?? "TEXT_MEGA";
3270
+ var RESPONSE_HANDLER_MODEL_TYPE2 = import_core20.ModelType.RESPONSE_HANDLER ?? "RESPONSE_HANDLER";
3271
+ var ACTION_PLANNER_MODEL_TYPE2 = import_core20.ModelType.ACTION_PLANNER ?? "ACTION_PLANNER";
2436
3272
  function getProcessEnv() {
2437
3273
  if (typeof process === "undefined") {
2438
3274
  return {};
@@ -2447,14 +3283,26 @@ var elizaOSCloudPlugin = {
2447
3283
  ELIZAOS_CLOUD_API_KEY: env.ELIZAOS_CLOUD_API_KEY ?? null,
2448
3284
  ELIZAOS_CLOUD_BASE_URL: env.ELIZAOS_CLOUD_BASE_URL ?? null,
2449
3285
  ELIZAOS_CLOUD_ENABLED: env.ELIZAOS_CLOUD_ENABLED ?? null,
3286
+ ELIZAOS_CLOUD_NANO_MODEL: env.ELIZAOS_CLOUD_NANO_MODEL ?? null,
3287
+ ELIZAOS_CLOUD_MEDIUM_MODEL: env.ELIZAOS_CLOUD_MEDIUM_MODEL ?? null,
2450
3288
  ELIZAOS_CLOUD_SMALL_MODEL: env.ELIZAOS_CLOUD_SMALL_MODEL ?? null,
2451
3289
  ELIZAOS_CLOUD_LARGE_MODEL: env.ELIZAOS_CLOUD_LARGE_MODEL ?? null,
3290
+ ELIZAOS_CLOUD_MEGA_MODEL: env.ELIZAOS_CLOUD_MEGA_MODEL ?? null,
3291
+ ELIZAOS_CLOUD_RESPONSE_HANDLER_MODEL: env.ELIZAOS_CLOUD_RESPONSE_HANDLER_MODEL ?? null,
3292
+ ELIZAOS_CLOUD_SHOULD_RESPOND_MODEL: env.ELIZAOS_CLOUD_SHOULD_RESPOND_MODEL ?? null,
3293
+ ELIZAOS_CLOUD_ACTION_PLANNER_MODEL: env.ELIZAOS_CLOUD_ACTION_PLANNER_MODEL ?? null,
3294
+ ELIZAOS_CLOUD_PLANNER_MODEL: env.ELIZAOS_CLOUD_PLANNER_MODEL ?? null,
3295
+ ELIZAOS_CLOUD_RESPONSE_MODEL: env.ELIZAOS_CLOUD_RESPONSE_MODEL ?? null,
3296
+ NANO_MODEL: env.NANO_MODEL ?? null,
3297
+ MEDIUM_MODEL: env.MEDIUM_MODEL ?? null,
2452
3298
  SMALL_MODEL: env.SMALL_MODEL ?? null,
2453
3299
  LARGE_MODEL: env.LARGE_MODEL ?? null,
2454
- ELIZAOS_CLOUD_REASONING_SMALL_MODEL: env.ELIZAOS_CLOUD_REASONING_SMALL_MODEL ?? null,
2455
- ELIZAOS_CLOUD_REASONING_LARGE_MODEL: env.ELIZAOS_CLOUD_REASONING_LARGE_MODEL ?? null,
2456
- REASONING_SMALL_MODEL: env.REASONING_SMALL_MODEL ?? null,
2457
- REASONING_LARGE_MODEL: env.REASONING_LARGE_MODEL ?? null,
3300
+ MEGA_MODEL: env.MEGA_MODEL ?? null,
3301
+ RESPONSE_HANDLER_MODEL: env.RESPONSE_HANDLER_MODEL ?? null,
3302
+ SHOULD_RESPOND_MODEL: env.SHOULD_RESPOND_MODEL ?? null,
3303
+ ACTION_PLANNER_MODEL: env.ACTION_PLANNER_MODEL ?? null,
3304
+ PLANNER_MODEL: env.PLANNER_MODEL ?? null,
3305
+ RESPONSE_MODEL: env.RESPONSE_MODEL ?? null,
2458
3306
  ELIZAOS_CLOUD_RESEARCH_MODEL: env.ELIZAOS_CLOUD_RESEARCH_MODEL ?? null,
2459
3307
  RESEARCH_MODEL: env.RESEARCH_MODEL ?? null,
2460
3308
  ELIZAOS_CLOUD_EMBEDDING_MODEL: env.ELIZAOS_CLOUD_EMBEDDING_MODEL ?? null,
@@ -2473,6 +3321,8 @@ var elizaOSCloudPlugin = {
2473
3321
  },
2474
3322
  services: [
2475
3323
  CloudAuthService,
3324
+ CloudBootstrapServiceImpl,
3325
+ CloudManagedGatewayRelayService,
2476
3326
  CloudModelRegistryService,
2477
3327
  CloudContainerService,
2478
3328
  CloudBridgeService,
@@ -2491,16 +3341,19 @@ var elizaOSCloudPlugin = {
2491
3341
  modelRegistryProvider
2492
3342
  ],
2493
3343
  models: {
2494
- [import_core19.ModelType.TEXT_EMBEDDING]: handleTextEmbedding,
2495
- [import_core19.ModelType.TEXT_SMALL]: handleTextSmall,
2496
- [import_core19.ModelType.TEXT_LARGE]: handleTextLarge,
2497
- [import_core19.ModelType.TEXT_REASONING_SMALL]: handleTextReasoningSmall,
2498
- [import_core19.ModelType.TEXT_REASONING_LARGE]: handleTextReasoningLarge,
2499
- [import_core19.ModelType.RESEARCH]: handleResearch,
2500
- [import_core19.ModelType.IMAGE]: handleImageGeneration,
2501
- [import_core19.ModelType.IMAGE_DESCRIPTION]: handleImageDescription,
2502
- [import_core19.ModelType.OBJECT_SMALL]: handleObjectSmall,
2503
- [import_core19.ModelType.OBJECT_LARGE]: handleObjectLarge
3344
+ [import_core20.ModelType.TEXT_EMBEDDING]: handleTextEmbedding,
3345
+ [TEXT_NANO_MODEL_TYPE2]: handleTextNano,
3346
+ [TEXT_MEDIUM_MODEL_TYPE2]: handleTextMedium,
3347
+ [import_core20.ModelType.TEXT_SMALL]: handleTextSmall,
3348
+ [import_core20.ModelType.TEXT_LARGE]: handleTextLarge,
3349
+ [TEXT_MEGA_MODEL_TYPE2]: handleTextMega,
3350
+ [RESPONSE_HANDLER_MODEL_TYPE2]: handleResponseHandler,
3351
+ [ACTION_PLANNER_MODEL_TYPE2]: handleActionPlanner,
3352
+ [import_core20.ModelType.RESEARCH]: handleResearch,
3353
+ [import_core20.ModelType.IMAGE]: handleImageGeneration,
3354
+ [import_core20.ModelType.IMAGE_DESCRIPTION]: handleImageDescription,
3355
+ [import_core20.ModelType.OBJECT_SMALL]: handleObjectSmall,
3356
+ [import_core20.ModelType.OBJECT_LARGE]: handleObjectLarge
2504
3357
  },
2505
3358
  tests: [
2506
3359
  {
@@ -2509,118 +3362,109 @@ var elizaOSCloudPlugin = {
2509
3362
  {
2510
3363
  name: "ELIZAOS_CLOUD_test_url_and_api_key_validation",
2511
3364
  fn: async (runtime) => {
2512
- const baseURL = getBaseURL(runtime);
2513
- const response = await fetch(`${baseURL}/models`, {
2514
- headers: {
2515
- Authorization: `Bearer ${getApiKey(runtime)}`
2516
- }
2517
- });
2518
- const data = await response.json();
2519
- import_core19.logger.log({
2520
- data: data?.data?.length ?? "N/A"
3365
+ const data = await createCloudApiClient(runtime).get("/models");
3366
+ import_core20.logger.log({
3367
+ data: data.data?.length ?? "N/A"
2521
3368
  }, "Models Available");
2522
- if (!response.ok) {
2523
- throw new Error(`Failed to validate OpenAI API key: ${response.statusText}`);
2524
- }
2525
3369
  }
2526
3370
  },
2527
3371
  {
2528
3372
  name: "ELIZAOS_CLOUD_test_text_embedding",
2529
3373
  fn: async (runtime) => {
2530
- const embedding = await runtime.useModel(import_core19.ModelType.TEXT_EMBEDDING, {
3374
+ const embedding = await runtime.useModel(import_core20.ModelType.TEXT_EMBEDDING, {
2531
3375
  text: "Hello, world!"
2532
3376
  });
2533
- import_core19.logger.log({ embedding }, "embedding");
3377
+ import_core20.logger.log({ embedding }, "embedding");
2534
3378
  }
2535
3379
  },
2536
3380
  {
2537
3381
  name: "ELIZAOS_CLOUD_test_text_large",
2538
3382
  fn: async (runtime) => {
2539
- const text = await runtime.useModel(import_core19.ModelType.TEXT_LARGE, {
3383
+ const text = await runtime.useModel(import_core20.ModelType.TEXT_LARGE, {
2540
3384
  prompt: "What is the nature of reality in 10 words?"
2541
3385
  });
2542
3386
  if (text.length === 0) {
2543
3387
  throw new Error("Failed to generate text");
2544
3388
  }
2545
- import_core19.logger.log({ text }, "generated with test_text_large");
3389
+ import_core20.logger.log({ text }, "generated with test_text_large");
2546
3390
  }
2547
3391
  },
2548
3392
  {
2549
3393
  name: "ELIZAOS_CLOUD_test_text_small",
2550
3394
  fn: async (runtime) => {
2551
- const text = await runtime.useModel(import_core19.ModelType.TEXT_SMALL, {
3395
+ const text = await runtime.useModel(import_core20.ModelType.TEXT_SMALL, {
2552
3396
  prompt: "What is the nature of reality in 10 words?"
2553
3397
  });
2554
3398
  if (text.length === 0) {
2555
3399
  throw new Error("Failed to generate text");
2556
3400
  }
2557
- import_core19.logger.log({ text }, "generated with test_text_small");
3401
+ import_core20.logger.log({ text }, "generated with test_text_small");
2558
3402
  }
2559
3403
  },
2560
3404
  {
2561
3405
  name: "ELIZAOS_CLOUD_test_image_generation",
2562
3406
  fn: async (runtime) => {
2563
- import_core19.logger.log("ELIZAOS_CLOUD_test_image_generation");
2564
- const image = await runtime.useModel(import_core19.ModelType.IMAGE, {
3407
+ import_core20.logger.log("ELIZAOS_CLOUD_test_image_generation");
3408
+ const image = await runtime.useModel(import_core20.ModelType.IMAGE, {
2565
3409
  prompt: "A beautiful sunset over a calm ocean",
2566
3410
  count: 1,
2567
3411
  size: "1024x1024"
2568
3412
  });
2569
- import_core19.logger.log({ image }, "generated with test_image_generation");
3413
+ import_core20.logger.log({ image }, "generated with test_image_generation");
2570
3414
  }
2571
3415
  },
2572
3416
  {
2573
3417
  name: "image-description",
2574
3418
  fn: async (runtime) => {
2575
- import_core19.logger.log("ELIZAOS_CLOUD_test_image_description");
2576
- const result = await runtime.useModel(import_core19.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");
3419
+ import_core20.logger.log("ELIZAOS_CLOUD_test_image_description");
3420
+ const result = await runtime.useModel(import_core20.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");
2577
3421
  if (result && typeof result === "object" && "title" in result && "description" in result) {
2578
- import_core19.logger.log({ result }, "Image description");
3422
+ import_core20.logger.log({ result }, "Image description");
2579
3423
  } else {
2580
- import_core19.logger.error(`Invalid image description result format: ${JSON.stringify(result)}`);
3424
+ import_core20.logger.error(`Invalid image description result format: ${JSON.stringify(result)}`);
2581
3425
  }
2582
3426
  }
2583
3427
  },
2584
3428
  {
2585
3429
  name: "ELIZAOS_CLOUD_test_transcription",
2586
3430
  fn: async (runtime) => {
2587
- import_core19.logger.log("ELIZAOS_CLOUD_test_transcription");
3431
+ import_core20.logger.log("ELIZAOS_CLOUD_test_transcription");
2588
3432
  const response = await fetch("https://upload.wikimedia.org/wikipedia/en/4/40/Chris_Benoit_Voice_Message.ogg");
2589
3433
  const arrayBuffer = await response.arrayBuffer();
2590
- const transcription = await runtime.useModel(import_core19.ModelType.TRANSCRIPTION, Buffer.from(new Uint8Array(arrayBuffer)));
2591
- import_core19.logger.log({ transcription }, "generated with test_transcription");
3434
+ const transcription = await runtime.useModel(import_core20.ModelType.TRANSCRIPTION, Buffer.from(new Uint8Array(arrayBuffer)));
3435
+ import_core20.logger.log({ transcription }, "generated with test_transcription");
2592
3436
  }
2593
3437
  },
2594
3438
  {
2595
3439
  name: "ELIZAOS_CLOUD_test_text_tokenizer_encode",
2596
3440
  fn: async (runtime) => {
2597
3441
  const prompt = "Hello tokenizer encode!";
2598
- const tokens = await runtime.useModel(import_core19.ModelType.TEXT_TOKENIZER_ENCODE, {
3442
+ const tokens = await runtime.useModel(import_core20.ModelType.TEXT_TOKENIZER_ENCODE, {
2599
3443
  prompt,
2600
- modelType: import_core19.ModelType.TEXT_SMALL
3444
+ modelType: import_core20.ModelType.TEXT_SMALL
2601
3445
  });
2602
3446
  if (!Array.isArray(tokens) || tokens.length === 0) {
2603
3447
  throw new Error("Failed to tokenize text: expected non-empty array of tokens");
2604
3448
  }
2605
- import_core19.logger.log({ tokens }, "Tokenized output");
3449
+ import_core20.logger.log({ tokens }, "Tokenized output");
2606
3450
  }
2607
3451
  },
2608
3452
  {
2609
3453
  name: "ELIZAOS_CLOUD_test_text_tokenizer_decode",
2610
3454
  fn: async (runtime) => {
2611
3455
  const prompt = "Hello tokenizer decode!";
2612
- const tokens = await runtime.useModel(import_core19.ModelType.TEXT_TOKENIZER_ENCODE, {
3456
+ const tokens = await runtime.useModel(import_core20.ModelType.TEXT_TOKENIZER_ENCODE, {
2613
3457
  prompt,
2614
- modelType: import_core19.ModelType.TEXT_SMALL
3458
+ modelType: import_core20.ModelType.TEXT_SMALL
2615
3459
  });
2616
- const decodedText = await runtime.useModel(import_core19.ModelType.TEXT_TOKENIZER_DECODE, {
3460
+ const decodedText = await runtime.useModel(import_core20.ModelType.TEXT_TOKENIZER_DECODE, {
2617
3461
  tokens,
2618
- modelType: import_core19.ModelType.TEXT_SMALL
3462
+ modelType: import_core20.ModelType.TEXT_SMALL
2619
3463
  });
2620
3464
  if (decodedText !== prompt) {
2621
3465
  throw new Error(`Decoded text does not match original. Expected "${prompt}", got "${decodedText}"`);
2622
3466
  }
2623
- import_core19.logger.log({ decodedText }, "Decoded text");
3467
+ import_core20.logger.log({ decodedText }, "Decoded text");
2624
3468
  }
2625
3469
  },
2626
3470
  {
@@ -2632,13 +3476,16 @@ var elizaOSCloudPlugin = {
2632
3476
  if (!response) {
2633
3477
  throw new Error("Failed to generate speech");
2634
3478
  }
2635
- import_core19.logger.log("Generated speech successfully");
3479
+ import_core20.logger.log("Generated speech successfully");
2636
3480
  }
2637
3481
  }
2638
3482
  ]
2639
3483
  }
2640
3484
  ]
2641
3485
  };
2642
- var typescript_default = elizaOSCloudPlugin;
3486
+ var plugin_elizacloud_default = elizaOSCloudPlugin;
3487
+
3488
+ // index.node.ts
3489
+ var index_node_default = plugin_elizacloud_default;
2643
3490
 
2644
- //# debugId=54ED4B75D5D15C8364756E2164756E21
3491
+ //# debugId=5B1B04FCBB721DF464756E2164756E21