@elizaos/autonomous 2.0.0-alpha.13 → 2.0.0-alpha.14

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 (118) hide show
  1. package/.turbo/turbo-build.log +12 -26
  2. package/dist/packages/autonomous/src/actions/emote.d.ts.map +1 -1
  3. package/dist/packages/autonomous/src/actions/restart.d.ts.map +1 -1
  4. package/dist/packages/autonomous/src/actions/restart.js +0 -1
  5. package/dist/packages/autonomous/src/actions/send-message.d.ts.map +1 -1
  6. package/dist/packages/autonomous/src/actions/switch-stream-source.d.ts.map +1 -1
  7. package/dist/packages/autonomous/src/api/agent-lifecycle-routes.d.ts.map +1 -1
  8. package/dist/packages/autonomous/src/api/agent-lifecycle-routes.js +1 -1
  9. package/dist/packages/autonomous/src/api/apps-routes.d.ts +1 -1
  10. package/dist/packages/autonomous/src/api/apps-routes.d.ts.map +1 -1
  11. package/dist/packages/autonomous/src/api/character-routes.js +1 -1
  12. package/dist/packages/autonomous/src/api/cloud-billing-routes.d.ts.map +1 -1
  13. package/dist/packages/autonomous/src/api/cloud-compat-routes.d.ts.map +1 -1
  14. package/dist/packages/autonomous/src/api/cloud-status-routes.d.ts +1 -1
  15. package/dist/packages/autonomous/src/api/cloud-status-routes.d.ts.map +1 -1
  16. package/dist/packages/autonomous/src/api/index.d.ts +16 -16
  17. package/dist/packages/autonomous/src/api/index.d.ts.map +1 -1
  18. package/dist/packages/autonomous/src/api/index.js +15 -15
  19. package/dist/packages/autonomous/src/api/knowledge-service-loader.d.ts.map +1 -1
  20. package/dist/packages/autonomous/src/api/memory-routes.d.ts.map +1 -1
  21. package/dist/packages/autonomous/src/api/memory-routes.js +1 -1
  22. package/dist/packages/autonomous/src/api/parse-action-block.d.ts +2 -2
  23. package/dist/packages/autonomous/src/api/parse-action-block.d.ts.map +1 -1
  24. package/dist/packages/autonomous/src/api/provider-switch-config.d.ts +1 -1
  25. package/dist/packages/autonomous/src/api/provider-switch-config.d.ts.map +1 -1
  26. package/dist/packages/autonomous/src/api/sandbox-routes.js +1 -1
  27. package/dist/packages/autonomous/src/api/server.d.ts.map +1 -1
  28. package/dist/packages/autonomous/src/api/server.js +75 -68
  29. package/dist/packages/autonomous/src/api/stream-routes.d.ts +1 -1
  30. package/dist/packages/autonomous/src/api/stream-routes.d.ts.map +1 -1
  31. package/dist/packages/autonomous/src/api/stream-routes.js +3 -2
  32. package/dist/packages/autonomous/src/api/training-routes.d.ts.map +1 -1
  33. package/dist/packages/autonomous/src/api/training-routes.js +1 -1
  34. package/dist/packages/autonomous/src/api/trigger-routes.d.ts.map +1 -1
  35. package/dist/packages/autonomous/src/api/trigger-routes.js +6 -2
  36. package/dist/packages/autonomous/src/api/wallet-evm-balance.d.ts.map +1 -1
  37. package/dist/packages/autonomous/src/api/wallet-evm-balance.js +2 -1
  38. package/dist/packages/autonomous/src/cli/index.d.ts.map +1 -1
  39. package/dist/packages/autonomous/src/config/index.d.ts +1 -1
  40. package/dist/packages/autonomous/src/config/index.d.ts.map +1 -1
  41. package/dist/packages/autonomous/src/config/index.js +1 -1
  42. package/dist/packages/autonomous/src/index.d.ts +1 -1
  43. package/dist/packages/autonomous/src/index.d.ts.map +1 -1
  44. package/dist/packages/autonomous/src/index.js +1 -1
  45. package/dist/packages/autonomous/src/providers/simple-mode.d.ts.map +1 -1
  46. package/dist/packages/autonomous/src/providers/simple-mode.js +0 -1
  47. package/dist/packages/autonomous/src/runtime/eliza.d.ts.map +1 -1
  48. package/dist/packages/autonomous/src/runtime/eliza.js +12 -25
  49. package/dist/packages/autonomous/src/runtime/milady-plugin.d.ts.map +1 -1
  50. package/dist/packages/autonomous/src/server/index.d.ts +2 -2
  51. package/dist/packages/autonomous/src/server/index.d.ts.map +1 -1
  52. package/dist/packages/autonomous/src/server/index.js +1 -1
  53. package/dist/packages/autonomous/src/services/agent-export.d.ts.map +1 -1
  54. package/dist/packages/autonomous/src/services/agent-export.js +53 -43
  55. package/dist/packages/autonomous/src/services/index.d.ts +4 -4
  56. package/dist/packages/autonomous/src/services/index.d.ts.map +1 -1
  57. package/dist/packages/autonomous/src/services/index.js +4 -4
  58. package/dist/packages/autonomous/src/services/whatsapp-pairing.d.ts.map +1 -1
  59. package/dist/packages/autonomous/src/services/whatsapp-pairing.js +1 -1
  60. package/dist/packages/autonomous/src/triggers/runtime.d.ts.map +1 -1
  61. package/dist/packages/autonomous/src/triggers/runtime.js +2 -0
  62. package/package.json +5 -5
  63. package/src/actions/emote.ts +4 -1
  64. package/src/actions/restart.ts +4 -1
  65. package/src/actions/send-message.ts +9 -1
  66. package/src/actions/switch-stream-source.ts +7 -1
  67. package/src/api/agent-lifecycle-routes.ts +1 -10
  68. package/src/api/apps-routes.ts +2 -5
  69. package/src/api/character-routes.ts +1 -1
  70. package/src/api/cloud-billing-routes.ts +3 -1
  71. package/src/api/cloud-compat-routes.ts +3 -1
  72. package/src/api/cloud-status-routes.ts +4 -3
  73. package/src/api/index.ts +29 -33
  74. package/src/api/knowledge-service-loader.ts +9 -3
  75. package/src/api/memory-routes.ts +4 -1
  76. package/src/api/parse-action-block.ts +2 -4
  77. package/src/api/provider-switch-config.ts +1 -1
  78. package/src/api/sandbox-routes.ts +2 -1
  79. package/src/api/server.ts +105 -104
  80. package/src/api/stream-routes.ts +14 -7
  81. package/src/api/training-routes.ts +4 -1
  82. package/src/api/trigger-routes.ts +10 -4
  83. package/src/api/wallet-evm-balance.ts +2 -1
  84. package/src/cli/index.ts +3 -1
  85. package/src/cloud/cloud-manager.test.ts +9 -9
  86. package/src/config/index.ts +1 -1
  87. package/src/index.ts +1 -1
  88. package/src/providers/simple-mode.ts +0 -1
  89. package/src/runtime/cloud-onboarding.ts +5 -3
  90. package/src/runtime/eliza.ts +20 -28
  91. package/src/runtime/milady-plugin.ts +1 -4
  92. package/src/server/index.ts +2 -6
  93. package/src/services/agent-export.ts +44 -33
  94. package/src/services/index.ts +4 -4
  95. package/src/services/whatsapp-pairing.ts +5 -2
  96. package/src/triggers/runtime.ts +17 -3
  97. package/test/api/agent-admin-routes.test.ts +15 -9
  98. package/test/api/agent-lifecycle-routes.test.ts +18 -9
  99. package/test/api/agent-transfer-routes.test.ts +18 -9
  100. package/test/api/apps-routes.test.ts +7 -9
  101. package/test/api/auth-routes.test.ts +7 -7
  102. package/test/api/bug-report-routes.test.ts +5 -5
  103. package/test/api/knowledge-routes.test.ts +4 -4
  104. package/test/api/memory-routes.test.ts +4 -4
  105. package/test/api/models-routes.test.ts +9 -7
  106. package/test/api/nfa-routes.test.ts +6 -6
  107. package/test/api/permissions-routes.test.ts +5 -5
  108. package/test/api/registry-routes.test.ts +6 -6
  109. package/test/api/signal-routes.test.ts +6 -6
  110. package/test/api/subscription-routes.test.ts +4 -4
  111. package/test/api/trigger-routes.test.ts +4 -4
  112. package/test/api/wallet-routes.observability.test.ts +1 -1
  113. package/test/api/wallet-routes.test.ts +1 -1
  114. package/test/diagnostics/integration-observability.test.ts +1 -1
  115. package/test/security/audit-log.test.ts +6 -8
  116. package/test/security/network-policy.test.ts +3 -3
  117. package/test/services/version-compat.test.ts +23 -19
  118. package/tsconfig.json +1 -5
@@ -41,6 +41,8 @@ import {
41
41
  ChannelType,
42
42
  type Character,
43
43
  type Component,
44
+ type MessageExampleGroup,
45
+ type ServiceTypeName,
44
46
  createMessageMemory,
45
47
  type Entity,
46
48
  type LogEntry,
@@ -54,13 +56,6 @@ import {
54
56
  type UUID,
55
57
  } from "@elizaos/core";
56
58
  import * as pluginAgentOrchestrator from "@elizaos/plugin-agent-orchestrator";
57
- import * as pluginAgentSkills from "@elizaos/plugin-agent-skills";
58
- import * as pluginAnthropic from "@elizaos/plugin-anthropic";
59
- import * as pluginCron from "@elizaos/plugin-cron";
60
- import * as pluginElizacloud from "@elizaos/plugin-elizacloud";
61
- import * as pluginExperience from "@elizaos/plugin-experience";
62
- import * as pluginForm from "@elizaos/plugin-form";
63
- import * as pluginKnowledge from "@elizaos/plugin-knowledge";
64
59
  import * as pluginLocalEmbedding from "@elizaos/plugin-local-embedding";
65
60
  import * as pluginOllama from "@elizaos/plugin-ollama";
66
61
  import * as pluginOpenai from "@elizaos/plugin-openai";
@@ -125,24 +120,17 @@ const STATIC_ELIZA_PLUGINS: Record<string, unknown> = {
125
120
  "@elizaos/plugin-sql": pluginSql,
126
121
  "@elizaos/plugin-local-embedding": pluginLocalEmbedding,
127
122
  "@elizaos/plugin-secrets-manager": pluginSecretsManager,
128
- "@elizaos/plugin-form": pluginForm,
129
- "@elizaos/plugin-knowledge": pluginKnowledge,
130
123
  "@elizaos/plugin-rolodex": pluginRolodex,
131
124
  "@elizaos/plugin-trajectory-logger": pluginTrajectoryLogger,
132
125
  "@elizaos/plugin-agent-orchestrator": pluginAgentOrchestrator,
133
- "@elizaos/plugin-cron": pluginCron,
134
126
  "@elizaos/plugin-shell": pluginShell,
135
127
  "@elizaos/plugin-plugin-manager": pluginPluginManager,
136
- "@elizaos/plugin-agent-skills": pluginAgentSkills,
137
128
  "@elizaos/plugin-pdf": pluginPdf,
138
129
  "@elizaos/plugin-openai": pluginOpenai,
139
- "@elizaos/plugin-anthropic": pluginAnthropic,
140
130
  "@elizaos/plugin-ollama": pluginOllama,
141
- "@elizaos/plugin-elizacloud": pluginElizacloud,
142
131
  "@elizaos/plugin-trust": pluginTrust,
143
132
  "@elizaos/plugin-todo": pluginTodo,
144
133
  "@elizaos/plugin-personality": pluginPersonality,
145
- "@elizaos/plugin-experience": pluginExperience,
146
134
  };
147
135
 
148
136
  // NODE_PATH so dynamic plugin imports (e.g. @elizaos/plugin-agent-orchestrator) resolve.
@@ -2340,10 +2328,14 @@ async function initializeDatabaseAdapter(
2340
2328
  runtime: AgentRuntime,
2341
2329
  config: MiladyConfig,
2342
2330
  ): Promise<void> {
2343
- if (!runtime.adapter || (await runtime.adapter.isReady())) return;
2331
+ const adapterWithInit = runtime.adapter as unknown as {
2332
+ isReady(): Promise<boolean>;
2333
+ init(): Promise<void>;
2334
+ };
2335
+ if (!runtime.adapter || (await adapterWithInit.isReady())) return;
2344
2336
 
2345
2337
  try {
2346
- await runtime.adapter.init();
2338
+ await adapterWithInit.init();
2347
2339
  logger.info(
2348
2340
  "[milady] Database adapter initialized early (before plugin inits)",
2349
2341
  );
@@ -2373,7 +2365,7 @@ async function initializeDatabaseAdapter(
2373
2365
  process.env.PGLITE_DATA_DIR = pgliteDataDir;
2374
2366
  }
2375
2367
 
2376
- await runtime.adapter.init();
2368
+ await adapterWithInit.init();
2377
2369
  logger.info(
2378
2370
  recoveryAction === "retry-without-reset"
2379
2371
  ? "[milady] Database adapter recovered after clearing a stale PGLite lock"
@@ -2666,7 +2658,7 @@ export function installRuntimeMethodBindings(runtime: AgentRuntime): void {
2666
2658
  // to create the same entity in rapid succession; plugin-sql's batch insert is
2667
2659
  // non-idempotent and can fail entire writes on duplicate/conflicting rows.
2668
2660
  if (!runtimeWithBindings.__miladyEntityWriteDiagnosticsInstalled) {
2669
- type CreateEntitiesFn = (entities: Entity[]) => Promise<boolean>;
2661
+ type CreateEntitiesFn = (entities: Entity[]) => Promise<string[]>;
2670
2662
  type GetEntitiesByIdsFn = (entityIds: UUID[]) => Promise<Entity[]>;
2671
2663
  type EnsureEntityExistsFn = (entity: Entity) => Promise<boolean>;
2672
2664
  const runtimeWithEntityWrites = runtime as AgentRuntime & {
@@ -2680,14 +2672,14 @@ export function installRuntimeMethodBindings(runtime: AgentRuntime): void {
2680
2672
  runtimeWithEntityWrites.createEntities.bind(runtime);
2681
2673
  runtimeWithEntityWrites.createEntities = async (
2682
2674
  entities: Entity[],
2683
- ): Promise<boolean> => {
2675
+ ): Promise<string[]> => {
2684
2676
  return withEntityCreateMutex(runtimeWithBindings, async () => {
2685
2677
  const uniqueById = new Map<UUID, Entity>();
2686
2678
  for (const entity of entities) {
2687
2679
  if (entity?.id) uniqueById.set(entity.id as UUID, entity);
2688
2680
  }
2689
2681
  const deduped = Array.from(uniqueById.values());
2690
- if (deduped.length === 0) return true;
2682
+ if (deduped.length === 0) return [];
2691
2683
 
2692
2684
  let missing = deduped;
2693
2685
  if (typeof runtimeWithEntityWrites.getEntitiesByIds === "function") {
@@ -2709,10 +2701,10 @@ export function installRuntimeMethodBindings(runtime: AgentRuntime): void {
2709
2701
  );
2710
2702
  }
2711
2703
  }
2712
- if (missing.length === 0) return true;
2704
+ if (missing.length === 0) return deduped.map((e) => e.id as string);
2713
2705
 
2714
- const ok = await originalCreateEntities(missing);
2715
- if (ok) return true;
2706
+ const createdIds = await originalCreateEntities(missing);
2707
+ if (createdIds.length > 0) return createdIds;
2716
2708
 
2717
2709
  if (
2718
2710
  typeof runtimeWithEntityWrites.ensureEntityExists === "function"
@@ -2730,13 +2722,13 @@ export function installRuntimeMethodBindings(runtime: AgentRuntime): void {
2730
2722
  );
2731
2723
  }
2732
2724
  }
2733
- if (allRecovered) return true;
2725
+ if (allRecovered) return missing.map((e) => e.id as string);
2734
2726
  }
2735
2727
 
2736
2728
  logger.warn(
2737
2729
  `[milady] createEntities unresolved after guarded retries (requested=${entities.length}, deduped=${deduped.length}, missing=${missing.length})`,
2738
2730
  );
2739
- return false;
2731
+ return [];
2740
2732
  });
2741
2733
  };
2742
2734
  }
@@ -2998,7 +2990,7 @@ export function buildCharacterFromConfig(config: MiladyConfig): Character {
2998
2990
  ...(style ? { style } : {}),
2999
2991
  ...(adjectives ? { adjectives } : {}),
3000
2992
  ...(postExamples ? { postExamples } : {}),
3001
- ...(mappedExamples ? { messageExamples: mappedExamples } : {}),
2993
+ ...(mappedExamples ? { messageExamples: mappedExamples as MessageExampleGroup[] } : {}),
3002
2994
  secrets,
3003
2995
  });
3004
2996
  }
@@ -4080,7 +4072,7 @@ export async function startEliza(
4080
4072
  let runtime = new AgentRuntime({
4081
4073
  character,
4082
4074
  // advancedCapabilities: true,
4083
- actionPlanning: true,
4075
+ // actionPlanning: true, // Not supported in this version of AgentRuntime
4084
4076
  // advancedMemory: true, // Not supported in this version of AgentRuntime
4085
4077
  plugins: [miladyPlugin, ...pluginsForRuntime],
4086
4078
  ...(runtimeLogLevel ? { logLevel: runtimeLogLevel } : {}),
@@ -4219,7 +4211,7 @@ export async function startEliza(
4219
4211
  // so API + agent come online immediately.
4220
4212
  try {
4221
4213
  const skillServicePromise = runtime.getServiceLoadPromise(
4222
- "AGENT_SKILLS_SERVICE",
4214
+ "AGENT_SKILLS_SERVICE" as ServiceTypeName,
4223
4215
  );
4224
4216
  const timeout = new Promise<never>((_resolve, reject) => {
4225
4217
  setTimeout(() => {
@@ -123,10 +123,7 @@ export function createMiladyPlugin(config?: MiladyPluginConfig): Plugin {
123
123
  const lines = customActions.map((a) => {
124
124
  const params =
125
125
  a.parameters
126
- ?.map(
127
- (p) =>
128
- `${p.name}${(p as { required?: boolean }).required ? " (required)" : ""}`,
129
- )
126
+ ?.map((p) => `${p.name}${p.required ? " (required)" : ""}`)
130
127
  .join(", ") || "none";
131
128
  return `- **${a.name}**: ${a.description} [params: ${params}]`;
132
129
  });
@@ -1,6 +1,2 @@
1
- export {
2
- startApiServer,
3
- } from "../api/server";
4
- export type {
5
- captureEarlyLogs,
6
- } from "../api/server";
1
+ export type { captureEarlyLogs } from "../api/server";
2
+ export { startApiServer } from "../api/server";
@@ -352,7 +352,8 @@ async function extractAgentData(
352
352
  logger.info(`[agent-export] Extracting data for agent ${agentId}`);
353
353
 
354
354
  // 1. Agent record
355
- const agent = await db.getAgent(agentId);
355
+ const agents = await db.getAgentsByIds([agentId]);
356
+ const agent = agents[0];
356
357
  if (!agent) {
357
358
  throw new AgentExportError(`Agent ${agentId} not found in database.`);
358
359
  }
@@ -367,14 +368,14 @@ async function extractAgentData(
367
368
 
368
369
  for (const world of agentWorlds) {
369
370
  if (!world.id) continue;
370
- const worldRooms = await db.getRoomsByWorld(world.id);
371
+ const worldRooms = await db.getRoomsByWorlds([world.id]);
371
372
  for (const room of worldRooms) {
372
373
  if (room.id) roomMap.set(room.id, room);
373
374
  }
374
375
  }
375
376
 
376
377
  // Also get rooms the agent participates in directly
377
- const participantRoomIds = await db.getRoomsForParticipant(agentId);
378
+ const participantRoomIds = await db.getRoomsForParticipants([agentId]);
378
379
  if (participantRoomIds.length > 0) {
379
380
  const participantRooms = await db.getRoomsByIds(participantRoomIds);
380
381
  if (participantRooms) {
@@ -398,14 +399,19 @@ async function extractAgentData(
398
399
  for (const room of rooms) {
399
400
  if (!room.id) continue;
400
401
 
401
- const roomEntities = await db.getEntitiesForRoom(room.id, true);
402
+ const entitiesResult = await db.getEntitiesForRooms([room.id], true);
403
+ const roomEntities = entitiesResult[0]?.entities ?? [];
402
404
  for (const entity of roomEntities) {
403
405
  if (entity.id) entityMap.set(entity.id, entity);
404
406
  }
405
407
 
406
- const participantIds = await db.getParticipantsForRoom(room.id);
408
+ const participantsResult = await db.getParticipantsForRooms([room.id]);
409
+ const participantIds = participantsResult[0]?.entityIds ?? [];
407
410
  for (const entityId of participantIds) {
408
- const userState = await db.getParticipantUserState(room.id, entityId);
411
+ const userStates = await db.getParticipantUserStates([
412
+ { roomId: room.id, entityId },
413
+ ]);
414
+ const userState = userStates[0] ?? null;
409
415
  participantRecords.push({
410
416
  entityId,
411
417
  roomId: room.id,
@@ -430,10 +436,11 @@ async function extractAgentData(
430
436
  };
431
437
  for (const entity of entities) {
432
438
  if (!entity.id) continue;
433
- for (const c of await db.getComponents(entity.id)) addComponent(c);
439
+ for (const c of await db.getComponentsForEntities([entity.id]))
440
+ addComponent(c);
434
441
  for (const world of agentWorlds) {
435
442
  if (!world.id) continue;
436
- for (const c of await db.getComponents(entity.id, world.id))
443
+ for (const c of await db.getComponentsForEntities([entity.id], world.id))
437
444
  addComponent(c);
438
445
  }
439
446
  }
@@ -463,7 +470,7 @@ async function extractAgentData(
463
470
  if (!world.id) continue;
464
471
  for (const tableName of MEMORY_TABLES) {
465
472
  const worldMemories = await db.getMemoriesByWorldId({
466
- worldId: world.id,
473
+ worldIds: [world.id],
467
474
  count: Number.MAX_SAFE_INTEGER,
468
475
  tableName,
469
476
  });
@@ -479,13 +486,13 @@ async function extractAgentData(
479
486
  logger.info(`[agent-export] Found ${allMemories.length} memories`);
480
487
 
481
488
  // 7. Relationships
482
- const relationships = await db.getRelationships({ entityId: agentId });
489
+ const relationships = await db.getRelationships({ entityIds: [agentId] });
483
490
  logger.info(`[agent-export] Found ${relationships.length} relationships`);
484
491
 
485
492
  // 8. Tasks
486
493
  // The Task proto type does not declare agentId, but the DB schema stores
487
494
  // agent_id. Filter using a dynamic property access to handle both shapes.
488
- const allTasks = await db.getTasks({});
495
+ const allTasks = await db.getTasks({ agentIds: [agentId] });
489
496
  const agentTasks = allTasks.filter((t) => taskAgentId(t) === agentId);
490
497
  logger.info(`[agent-export] Found ${agentTasks.length} tasks`);
491
498
 
@@ -502,11 +509,11 @@ async function extractAgentData(
502
509
  let characterConfig: Record<string, unknown> | undefined;
503
510
  if (runtime.character) {
504
511
  // Clone and strip secrets/sensitive fields
505
- const { secrets, ...safeChar } = runtime.character as Record<
512
+ const { secrets, ...safeChar } = runtime.character;
513
+ characterConfig = Object.fromEntries(Object.entries(safeChar)) as Record<
506
514
  string,
507
515
  unknown
508
516
  >;
509
- characterConfig = safeChar;
510
517
  logger.info(
511
518
  `[agent-export] Captured runtime character config (${Object.keys(safeChar).length} fields)`,
512
519
  );
@@ -581,8 +588,8 @@ async function restoreAgentData(
581
588
  agentData.createdAt = Date.now();
582
589
  agentData.updatedAt = Date.now();
583
590
 
584
- const agentCreated = await db.createAgent(agentData);
585
- if (!agentCreated) {
591
+ const agentCreatedIds = await db.createAgents([agentData]);
592
+ if (!agentCreatedIds || agentCreatedIds.length === 0) {
586
593
  throw new AgentExportError("Failed to create agent in database.");
587
594
  }
588
595
  logger.info(
@@ -597,7 +604,7 @@ async function restoreAgentData(
597
604
  id: remap(world.id ?? "") as UUID,
598
605
  agentId: newAgentId as UUID,
599
606
  };
600
- await db.createWorld(newWorld);
607
+ await db.createWorlds([newWorld]);
601
608
  worldsImported++;
602
609
  }
603
610
  logger.info(`[agent-import] Imported ${worldsImported} worlds`);
@@ -644,9 +651,11 @@ async function restoreAgentData(
644
651
  for (const p of payload.participants) {
645
652
  const newEntityId = remap(p.entityId) as UUID;
646
653
  const newRoomId = remap(p.roomId) as UUID;
647
- await db.addParticipantsRoom([newEntityId], newRoomId);
654
+ await db.createRoomParticipants([newEntityId], newRoomId);
648
655
  if (p.userState === "FOLLOWED" || p.userState === "MUTED") {
649
- await db.setParticipantUserState(newRoomId, newEntityId, p.userState);
656
+ await db.updateParticipantUserStates([
657
+ { roomId: newRoomId, entityId: newEntityId, state: p.userState },
658
+ ]);
650
659
  }
651
660
  participantsImported++;
652
661
  }
@@ -666,7 +675,7 @@ async function restoreAgentData(
666
675
  ? { sourceEntityId: remap(comp.sourceEntityId) as UUID }
667
676
  : {}),
668
677
  };
669
- await db.createComponent(newComp);
678
+ await db.createComponents([newComp]);
670
679
  componentsImported++;
671
680
  }
672
681
  logger.info(`[agent-import] Imported ${componentsImported} components`);
@@ -685,7 +694,7 @@ async function restoreAgentData(
685
694
  // Embeddings are excluded — they will be regenerated
686
695
  embedding: undefined,
687
696
  };
688
- await db.createMemory(newMem, tableName);
697
+ await db.createMemories([{ memory: newMem, tableName }]);
689
698
  memoriesImported++;
690
699
  }
691
700
  logger.info(`[agent-import] Imported ${memoriesImported} memories`);
@@ -693,12 +702,12 @@ async function restoreAgentData(
693
702
  // 8. Create relationships
694
703
  let relationshipsImported = 0;
695
704
  for (const rel of payload.relationships) {
696
- await db.createRelationship({
705
+ await db.createRelationships([{
697
706
  sourceEntityId: remap(rel.sourceEntityId ?? "") as UUID,
698
707
  targetEntityId: remap(rel.targetEntityId ?? "") as UUID,
699
708
  tags: rel.tags,
700
709
  metadata: rel.metadata,
701
- });
710
+ }]);
702
711
  relationshipsImported++;
703
712
  }
704
713
  logger.info(`[agent-import] Imported ${relationshipsImported} relationships`);
@@ -717,7 +726,7 @@ async function restoreAgentData(
717
726
  worldId: task.worldId ? (remap(task.worldId) as UUID) : undefined,
718
727
  entityId: task.entityId ? (remap(task.entityId) as UUID) : undefined,
719
728
  } as Task;
720
- await db.createTask(newTask);
729
+ await db.createTasks([newTask]);
721
730
  tasksImported++;
722
731
  }
723
732
  logger.info(`[agent-import] Imported ${tasksImported} tasks`);
@@ -725,16 +734,16 @@ async function restoreAgentData(
725
734
  // 10. Create logs
726
735
  let logsImported = 0;
727
736
  for (const logEntry of payload.logs) {
728
- await db.log({
737
+ await db.createLogs([{
729
738
  body: logEntry.body,
730
- entityId: logEntry.entityId
739
+ entityId: (logEntry.entityId
731
740
  ? (remap(logEntry.entityId) as UUID)
732
- : logEntry.entityId,
741
+ : logEntry.entityId) as UUID,
733
742
  roomId: logEntry.roomId
734
743
  ? (remap(logEntry.roomId) as UUID)
735
744
  : (newAgentId as UUID),
736
745
  type: logEntry.type ?? "action",
737
- });
746
+ }]);
738
747
  logsImported++;
739
748
  }
740
749
  logger.info(`[agent-import] Imported ${logsImported} logs`);
@@ -944,16 +953,18 @@ export async function estimateExportSize(
944
953
  const allWorlds = await db.getAllWorlds();
945
954
  const agentWorlds = allWorlds.filter((w) => w.agentId === agentId);
946
955
 
947
- const roomIds = await db.getRoomsForParticipant(agentId);
956
+ const roomIds = await db.getRoomsForParticipants([agentId]);
948
957
  const entityIdSet = new Set<string>();
949
- for (const roomId of roomIds) {
950
- const roomEntities = await db.getEntitiesForRoom(roomId);
951
- for (const e of roomEntities) {
952
- if (e.id) entityIdSet.add(e.id);
958
+ if (roomIds.length > 0) {
959
+ const entitiesResult = await db.getEntitiesForRooms(roomIds as UUID[], true);
960
+ for (const result of entitiesResult) {
961
+ for (const e of result.entities) {
962
+ if (e.id) entityIdSet.add(e.id);
963
+ }
953
964
  }
954
965
  }
955
966
 
956
- const tasks = await db.getTasks({});
967
+ const tasks = await db.getTasks({ agentIds: [agentId] });
957
968
  const agentTasks = tasks.filter((t) => taskAgentId(t) === agentId);
958
969
 
959
970
  // Rough estimate: ~500 bytes per memory, ~200 bytes per entity, ~300 per room
@@ -2,16 +2,16 @@ export * from "./agent-export";
2
2
  export * from "./app-manager";
3
3
  export * from "./browser-capture";
4
4
  export * from "./fallback-training-service";
5
- export * from "./remote-signing-service";
5
+ export * from "./privy-wallets";
6
6
  export * from "./registry-client";
7
+ export * from "./remote-signing-service";
7
8
  export * from "./sandbox-engine";
8
9
  export * from "./sandbox-manager";
9
- export * from "./skill-catalog-client";
10
- export * from "./skill-marketplace";
11
10
  export * from "./self-updater";
12
11
  export * from "./signing-policy";
12
+ export * from "./skill-catalog-client";
13
+ export * from "./skill-marketplace";
13
14
  export * from "./stream-manager";
14
15
  export * from "./tts-stream-bridge";
15
16
  export * from "./update-checker";
16
- export * from "./privy-wallets";
17
17
  export * from "./version-compat";
@@ -67,8 +67,11 @@ export class WhatsAppPairingSession {
67
67
 
68
68
  const baileys = await import("@whiskeysockets/baileys");
69
69
  const makeWASocket = baileys.default;
70
- const { useMultiFileAuthState, fetchLatestBaileysVersion, DisconnectReason } =
71
- baileys;
70
+ const {
71
+ useMultiFileAuthState,
72
+ fetchLatestBaileysVersion,
73
+ DisconnectReason,
74
+ } = baileys;
72
75
  const QRCode = (await import("qrcode")).default;
73
76
  const { Boom } = await import("@hapi/boom");
74
77
 
@@ -1,5 +1,5 @@
1
1
  import crypto from "node:crypto";
2
- import type { IAgentRuntime, Task, UUID } from "@elizaos/core";
2
+ import type { IAgentRuntime, Service, Task, UUID } from "@elizaos/core";
3
3
  import { stringToUuid } from "@elizaos/core";
4
4
  import {
5
5
  buildTriggerMetadata,
@@ -128,10 +128,22 @@ export function getTriggerLimit(runtime?: IAgentRuntime): number {
128
128
  return DEFAULT_MAX_ACTIVE_TRIGGERS;
129
129
  }
130
130
 
131
+ type AutonomyServiceLike = {
132
+ injectAutonomousInstruction?: (payload: {
133
+ instructions: string;
134
+ source: string;
135
+ wakeMode: TriggerConfig["wakeMode"];
136
+ triggerId: UUID;
137
+ triggerTaskId: UUID;
138
+ taskId?: UUID;
139
+ roomId?: UUID;
140
+ }) => Promise<void> | void;
141
+ };
142
+
131
143
  function isAutonomyServiceAvailable(runtime: IAgentRuntime): boolean {
132
144
  const svc =
133
- (runtime.getService("autonomy") as Record<string, unknown> | null) ??
134
- (runtime.getService("AUTONOMY") as Record<string, unknown> | null);
145
+ runtime.getService<Service & AutonomyServiceLike>("autonomy") ??
146
+ runtime.getService<Service & AutonomyServiceLike>("AUTONOMY");
135
147
  return typeof svc?.injectAutonomousInstruction === "function";
136
148
  }
137
149
 
@@ -348,6 +360,7 @@ export function registerTriggerTaskWorker(runtime: IAgentRuntime): void {
348
360
  source: options.source === "manual" ? "manual" : "scheduler",
349
361
  force: options.force === true,
350
362
  });
363
+ return {};
351
364
  },
352
365
  });
353
366
  }
@@ -358,6 +371,7 @@ export async function listTriggerTasks(
358
371
  if (!triggersFeatureEnabled(runtime)) return [];
359
372
  return runtime.getTasks({
360
373
  tags: [...TRIGGER_TASK_TAGS],
374
+ agentIds: [runtime.agentId],
361
375
  });
362
376
  }
363
377
 
@@ -1,16 +1,19 @@
1
- import { describe, test, expect, vi } from "vitest";
1
+ import { describe, expect, test, vi } from "vitest";
2
+ import type { AgentAdminRouteContext } from "../../src/api/agent-admin-routes";
3
+ import { handleAgentAdminRoutes } from "../../src/api/agent-admin-routes";
2
4
  import {
3
- createMockIncomingMessage,
4
5
  createMockHttpResponse,
6
+ createMockIncomingMessage,
5
7
  } from "../../src/test-support/test-helpers";
6
- import { handleAgentAdminRoutes } from "../../src/api/agent-admin-routes";
7
- import type { AgentAdminRouteContext } from "../../src/api/agent-admin-routes";
8
8
 
9
9
  function buildCtx(
10
10
  method: string,
11
11
  pathname: string,
12
12
  overrides?: Partial<AgentAdminRouteContext>,
13
- ): AgentAdminRouteContext & { getStatus: () => number; getJson: () => unknown } {
13
+ ): AgentAdminRouteContext & {
14
+ getStatus: () => number;
15
+ getJson: () => unknown;
16
+ } {
14
17
  const { res, getStatus, getJson } = createMockHttpResponse();
15
18
  const req = createMockIncomingMessage({ method, url: pathname });
16
19
  const ctx = {
@@ -48,13 +51,13 @@ function buildCtx(
48
51
  stateDirExists: () => false,
49
52
  removeStateDir: vi.fn(),
50
53
  logWarn: vi.fn(),
54
+ getStatus,
55
+ getJson,
51
56
  ...overrides,
52
57
  } as AgentAdminRouteContext & {
53
58
  getStatus: () => number;
54
59
  getJson: () => unknown;
55
60
  };
56
- (ctx as any).getStatus = getStatus;
57
- (ctx as any).getJson = getJson;
58
61
  return ctx;
59
62
  }
60
63
 
@@ -96,11 +99,14 @@ describe("agent-admin-routes", () => {
96
99
  });
97
100
 
98
101
  test("returns success when onRestart returns a new runtime", async () => {
99
- const mockRuntime = {
102
+ const mockRuntime: Pick<
103
+ import("@elizaos/core").AgentRuntime,
104
+ "character" | "getSetting" | "modelProvider"
105
+ > = {
100
106
  character: { name: "NewAgent" },
101
107
  getSetting: () => undefined,
102
108
  modelProvider: "openai",
103
- } as any;
109
+ };
104
110
  const onRestart = vi.fn(async () => mockRuntime);
105
111
  const onRuntimeSwapped = vi.fn();
106
112
  const ctx = buildCtx("POST", "/api/agent/restart", {
@@ -1,13 +1,13 @@
1
- import { describe, test, expect, vi } from "vitest";
2
- import {
3
- createMockIncomingMessage,
4
- createMockHttpResponse,
5
- } from "../../src/test-support/test-helpers";
6
- import { handleAgentLifecycleRoutes } from "../../src/api/agent-lifecycle-routes";
1
+ import { describe, expect, test, vi } from "vitest";
7
2
  import type {
8
3
  AgentLifecycleRouteContext,
9
4
  AgentLifecycleRouteState,
10
5
  } from "../../src/api/agent-lifecycle-routes";
6
+ import { handleAgentLifecycleRoutes } from "../../src/api/agent-lifecycle-routes";
7
+ import {
8
+ createMockHttpResponse,
9
+ createMockIncomingMessage,
10
+ } from "../../src/test-support/test-helpers";
11
11
 
12
12
  function buildState(
13
13
  overrides?: Partial<AgentLifecycleRouteState>,
@@ -115,7 +115,9 @@ describe("agent-lifecycle-routes", () => {
115
115
 
116
116
  test("returns enabled true when runtime has autonomy", async () => {
117
117
  const state = buildState({
118
- runtime: { enableAutonomy: true } as any,
118
+ runtime: {
119
+ enableAutonomy: true,
120
+ } as Pick<import("@elizaos/core").AgentRuntime, "enableAutonomy">,
119
121
  });
120
122
  const ctx = buildCtx("GET", "/api/agent/autonomy", state);
121
123
  await handleAgentLifecycleRoutes(ctx);
@@ -126,7 +128,9 @@ describe("agent-lifecycle-routes", () => {
126
128
 
127
129
  describe("POST /api/agent/autonomy", () => {
128
130
  test("sets autonomy on runtime", async () => {
129
- const runtime = { enableAutonomy: false } as any;
131
+ const runtime = {
132
+ enableAutonomy: false,
133
+ } as Pick<import("@elizaos/core").AgentRuntime, "enableAutonomy">;
130
134
  const state = buildState({ runtime });
131
135
  const ctx = buildCtx("POST", "/api/agent/autonomy", state, {
132
136
  readJsonBody: vi.fn(async () => ({ enabled: true })),
@@ -136,7 +140,12 @@ describe("agent-lifecycle-routes", () => {
136
140
  });
137
141
 
138
142
  test("rejects non-boolean enabled", async () => {
139
- const state = buildState({ runtime: {} as any });
143
+ const state = buildState({
144
+ runtime: {} as Pick<
145
+ import("@elizaos/core").AgentRuntime,
146
+ "enableAutonomy"
147
+ >,
148
+ });
140
149
  const ctx = buildCtx("POST", "/api/agent/autonomy", state, {
141
150
  readJsonBody: vi.fn(async () => ({ enabled: "yes" })),
142
151
  });
@@ -1,10 +1,10 @@
1
- import { describe, test, expect, vi } from "vitest";
1
+ import { describe, expect, test, vi } from "vitest";
2
+ import type { AgentTransferRouteContext } from "../../src/api/agent-transfer-routes";
3
+ import { handleAgentTransferRoutes } from "../../src/api/agent-transfer-routes";
2
4
  import {
3
- createMockIncomingMessage,
4
5
  createMockHttpResponse,
6
+ createMockIncomingMessage,
5
7
  } from "../../src/test-support/test-helpers";
6
- import { handleAgentTransferRoutes } from "../../src/api/agent-transfer-routes";
7
- import type { AgentTransferRouteContext } from "../../src/api/agent-transfer-routes";
8
8
 
9
9
  function buildCtx(
10
10
  method: string,
@@ -38,12 +38,12 @@ function buildCtx(
38
38
  importAgent: vi.fn(async () => ({ ok: true })),
39
39
  isAgentExportError: () => false,
40
40
  ...overrides,
41
+ getStatus,
42
+ getJson,
41
43
  } as AgentTransferRouteContext & {
42
44
  getStatus: () => number;
43
45
  getJson: () => unknown;
44
46
  };
45
- (ctx as any).getStatus = getStatus;
46
- (ctx as any).getJson = getJson;
47
47
  return ctx;
48
48
  }
49
49
 
@@ -60,7 +60,10 @@ describe("agent-transfer-routes", () => {
60
60
  });
61
61
 
62
62
  test("returns 400 when password is missing", async () => {
63
- const mockRuntime = { character: { name: "Agent" } } as any;
63
+ const mockRuntime: Pick<
64
+ import("@elizaos/core").AgentRuntime,
65
+ "character"
66
+ > = { character: { name: "Agent" } };
64
67
  const ctx = buildCtx("POST", "/api/agent/export", {
65
68
  state: { runtime: mockRuntime },
66
69
  readJsonBody: vi.fn(async () => ({})),
@@ -73,7 +76,10 @@ describe("agent-transfer-routes", () => {
73
76
  });
74
77
 
75
78
  test("exports successfully with valid password", async () => {
76
- const mockRuntime = { character: { name: "Agent" } } as any;
79
+ const mockRuntime: Pick<
80
+ import("@elizaos/core").AgentRuntime,
81
+ "character"
82
+ > = { character: { name: "Agent" } };
77
83
  const ctx = buildCtx("POST", "/api/agent/export", {
78
84
  state: { runtime: mockRuntime },
79
85
  readJsonBody: vi.fn(async () => ({
@@ -99,7 +105,10 @@ describe("agent-transfer-routes", () => {
99
105
  });
100
106
 
101
107
  test("returns estimate when runtime is available", async () => {
102
- const mockRuntime = { character: { name: "Agent" } } as any;
108
+ const mockRuntime: Pick<
109
+ import("@elizaos/core").AgentRuntime,
110
+ "character"
111
+ > = { character: { name: "Agent" } };
103
112
  const ctx = buildCtx("GET", "/api/agent/export/estimate", {
104
113
  state: { runtime: mockRuntime },
105
114
  });