@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.
- package/.turbo/turbo-build.log +12 -26
- package/dist/packages/autonomous/src/actions/emote.d.ts.map +1 -1
- package/dist/packages/autonomous/src/actions/restart.d.ts.map +1 -1
- package/dist/packages/autonomous/src/actions/restart.js +0 -1
- package/dist/packages/autonomous/src/actions/send-message.d.ts.map +1 -1
- package/dist/packages/autonomous/src/actions/switch-stream-source.d.ts.map +1 -1
- package/dist/packages/autonomous/src/api/agent-lifecycle-routes.d.ts.map +1 -1
- package/dist/packages/autonomous/src/api/agent-lifecycle-routes.js +1 -1
- package/dist/packages/autonomous/src/api/apps-routes.d.ts +1 -1
- package/dist/packages/autonomous/src/api/apps-routes.d.ts.map +1 -1
- package/dist/packages/autonomous/src/api/character-routes.js +1 -1
- package/dist/packages/autonomous/src/api/cloud-billing-routes.d.ts.map +1 -1
- package/dist/packages/autonomous/src/api/cloud-compat-routes.d.ts.map +1 -1
- package/dist/packages/autonomous/src/api/cloud-status-routes.d.ts +1 -1
- package/dist/packages/autonomous/src/api/cloud-status-routes.d.ts.map +1 -1
- package/dist/packages/autonomous/src/api/index.d.ts +16 -16
- package/dist/packages/autonomous/src/api/index.d.ts.map +1 -1
- package/dist/packages/autonomous/src/api/index.js +15 -15
- package/dist/packages/autonomous/src/api/knowledge-service-loader.d.ts.map +1 -1
- package/dist/packages/autonomous/src/api/memory-routes.d.ts.map +1 -1
- package/dist/packages/autonomous/src/api/memory-routes.js +1 -1
- package/dist/packages/autonomous/src/api/parse-action-block.d.ts +2 -2
- package/dist/packages/autonomous/src/api/parse-action-block.d.ts.map +1 -1
- package/dist/packages/autonomous/src/api/provider-switch-config.d.ts +1 -1
- package/dist/packages/autonomous/src/api/provider-switch-config.d.ts.map +1 -1
- package/dist/packages/autonomous/src/api/sandbox-routes.js +1 -1
- package/dist/packages/autonomous/src/api/server.d.ts.map +1 -1
- package/dist/packages/autonomous/src/api/server.js +75 -68
- package/dist/packages/autonomous/src/api/stream-routes.d.ts +1 -1
- package/dist/packages/autonomous/src/api/stream-routes.d.ts.map +1 -1
- package/dist/packages/autonomous/src/api/stream-routes.js +3 -2
- package/dist/packages/autonomous/src/api/training-routes.d.ts.map +1 -1
- package/dist/packages/autonomous/src/api/training-routes.js +1 -1
- package/dist/packages/autonomous/src/api/trigger-routes.d.ts.map +1 -1
- package/dist/packages/autonomous/src/api/trigger-routes.js +6 -2
- package/dist/packages/autonomous/src/api/wallet-evm-balance.d.ts.map +1 -1
- package/dist/packages/autonomous/src/api/wallet-evm-balance.js +2 -1
- package/dist/packages/autonomous/src/cli/index.d.ts.map +1 -1
- package/dist/packages/autonomous/src/config/index.d.ts +1 -1
- package/dist/packages/autonomous/src/config/index.d.ts.map +1 -1
- package/dist/packages/autonomous/src/config/index.js +1 -1
- package/dist/packages/autonomous/src/index.d.ts +1 -1
- package/dist/packages/autonomous/src/index.d.ts.map +1 -1
- package/dist/packages/autonomous/src/index.js +1 -1
- package/dist/packages/autonomous/src/providers/simple-mode.d.ts.map +1 -1
- package/dist/packages/autonomous/src/providers/simple-mode.js +0 -1
- package/dist/packages/autonomous/src/runtime/eliza.d.ts.map +1 -1
- package/dist/packages/autonomous/src/runtime/eliza.js +12 -25
- package/dist/packages/autonomous/src/runtime/milady-plugin.d.ts.map +1 -1
- package/dist/packages/autonomous/src/server/index.d.ts +2 -2
- package/dist/packages/autonomous/src/server/index.d.ts.map +1 -1
- package/dist/packages/autonomous/src/server/index.js +1 -1
- package/dist/packages/autonomous/src/services/agent-export.d.ts.map +1 -1
- package/dist/packages/autonomous/src/services/agent-export.js +53 -43
- package/dist/packages/autonomous/src/services/index.d.ts +4 -4
- package/dist/packages/autonomous/src/services/index.d.ts.map +1 -1
- package/dist/packages/autonomous/src/services/index.js +4 -4
- package/dist/packages/autonomous/src/services/whatsapp-pairing.d.ts.map +1 -1
- package/dist/packages/autonomous/src/services/whatsapp-pairing.js +1 -1
- package/dist/packages/autonomous/src/triggers/runtime.d.ts.map +1 -1
- package/dist/packages/autonomous/src/triggers/runtime.js +2 -0
- package/package.json +5 -5
- package/src/actions/emote.ts +4 -1
- package/src/actions/restart.ts +4 -1
- package/src/actions/send-message.ts +9 -1
- package/src/actions/switch-stream-source.ts +7 -1
- package/src/api/agent-lifecycle-routes.ts +1 -10
- package/src/api/apps-routes.ts +2 -5
- package/src/api/character-routes.ts +1 -1
- package/src/api/cloud-billing-routes.ts +3 -1
- package/src/api/cloud-compat-routes.ts +3 -1
- package/src/api/cloud-status-routes.ts +4 -3
- package/src/api/index.ts +29 -33
- package/src/api/knowledge-service-loader.ts +9 -3
- package/src/api/memory-routes.ts +4 -1
- package/src/api/parse-action-block.ts +2 -4
- package/src/api/provider-switch-config.ts +1 -1
- package/src/api/sandbox-routes.ts +2 -1
- package/src/api/server.ts +105 -104
- package/src/api/stream-routes.ts +14 -7
- package/src/api/training-routes.ts +4 -1
- package/src/api/trigger-routes.ts +10 -4
- package/src/api/wallet-evm-balance.ts +2 -1
- package/src/cli/index.ts +3 -1
- package/src/cloud/cloud-manager.test.ts +9 -9
- package/src/config/index.ts +1 -1
- package/src/index.ts +1 -1
- package/src/providers/simple-mode.ts +0 -1
- package/src/runtime/cloud-onboarding.ts +5 -3
- package/src/runtime/eliza.ts +20 -28
- package/src/runtime/milady-plugin.ts +1 -4
- package/src/server/index.ts +2 -6
- package/src/services/agent-export.ts +44 -33
- package/src/services/index.ts +4 -4
- package/src/services/whatsapp-pairing.ts +5 -2
- package/src/triggers/runtime.ts +17 -3
- package/test/api/agent-admin-routes.test.ts +15 -9
- package/test/api/agent-lifecycle-routes.test.ts +18 -9
- package/test/api/agent-transfer-routes.test.ts +18 -9
- package/test/api/apps-routes.test.ts +7 -9
- package/test/api/auth-routes.test.ts +7 -7
- package/test/api/bug-report-routes.test.ts +5 -5
- package/test/api/knowledge-routes.test.ts +4 -4
- package/test/api/memory-routes.test.ts +4 -4
- package/test/api/models-routes.test.ts +9 -7
- package/test/api/nfa-routes.test.ts +6 -6
- package/test/api/permissions-routes.test.ts +5 -5
- package/test/api/registry-routes.test.ts +6 -6
- package/test/api/signal-routes.test.ts +6 -6
- package/test/api/subscription-routes.test.ts +4 -4
- package/test/api/trigger-routes.test.ts +4 -4
- package/test/api/wallet-routes.observability.test.ts +1 -1
- package/test/api/wallet-routes.test.ts +1 -1
- package/test/diagnostics/integration-observability.test.ts +1 -1
- package/test/security/audit-log.test.ts +6 -8
- package/test/security/network-policy.test.ts +3 -3
- package/test/services/version-compat.test.ts +23 -19
- package/tsconfig.json +1 -5
package/src/runtime/eliza.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
|
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
|
|
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<
|
|
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<
|
|
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
|
|
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
|
|
2704
|
+
if (missing.length === 0) return deduped.map((e) => e.id as string);
|
|
2713
2705
|
|
|
2714
|
-
const
|
|
2715
|
-
if (
|
|
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
|
|
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
|
|
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
|
});
|
package/src/server/index.ts
CHANGED
|
@@ -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
|
|
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.
|
|
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.
|
|
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
|
|
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
|
|
408
|
+
const participantsResult = await db.getParticipantsForRooms([room.id]);
|
|
409
|
+
const participantIds = participantsResult[0]?.entityIds ?? [];
|
|
407
410
|
for (const entityId of participantIds) {
|
|
408
|
-
const
|
|
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.
|
|
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.
|
|
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
|
-
|
|
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({
|
|
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
|
|
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
|
|
585
|
-
if (!
|
|
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.
|
|
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.
|
|
654
|
+
await db.createRoomParticipants([newEntityId], newRoomId);
|
|
648
655
|
if (p.userState === "FOLLOWED" || p.userState === "MUTED") {
|
|
649
|
-
await db.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
956
|
+
const roomIds = await db.getRoomsForParticipants([agentId]);
|
|
948
957
|
const entityIdSet = new Set<string>();
|
|
949
|
-
|
|
950
|
-
const
|
|
951
|
-
for (const
|
|
952
|
-
|
|
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
|
package/src/services/index.ts
CHANGED
|
@@ -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 "./
|
|
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 {
|
|
71
|
-
|
|
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
|
|
package/src/triggers/runtime.ts
CHANGED
|
@@ -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
|
-
|
|
134
|
-
|
|
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,
|
|
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 & {
|
|
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
|
-
}
|
|
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,
|
|
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: {
|
|
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 = {
|
|
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({
|
|
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,
|
|
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
|
|
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
|
|
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
|
|
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
|
});
|