Skip to content

Commit 05272a1

Browse files
committed
fix the init
1 parent 5e5fcae commit 05272a1

File tree

5 files changed

+19
-5
lines changed

5 files changed

+19
-5
lines changed

packages/cli/src/server/index.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,13 @@ export class AgentServer {
5959
);
6060

6161
// Initialize the database
62-
this.database.init();
63-
64-
// Initialize server components - will handle agent disabling
65-
this.initializeServer(options);
62+
this.database.init().then(() => {
63+
logger.success("Database initialized successfully");
64+
this.initializeServer(options);
65+
}).catch((error) => {
66+
logger.error("Failed to initialize database:", error);
67+
throw error;
68+
});
6669
} catch (error) {
6770
logger.error("Failed to initialize AgentServer:", error);
6871
throw error;

packages/client/src/lib/info.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "version": "1.0.0-alpha.2" }
1+
{"version": "1.0.0-alpha.2"}

packages/core/src/database.ts

+6
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ export abstract class DatabaseAdapter<DB = unknown>
2727
*/
2828
db: DB;
2929

30+
/**
31+
* Initialize the database adapter.
32+
* @returns A Promise that resolves when initialization is complete.
33+
*/
34+
abstract init(): Promise<void>;
35+
3036
/**
3137
* Optional close method for the database adapter.
3238
* @returns A Promise that resolves when closing is complete.

packages/core/src/runtime.ts

+2
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ export class AgentRuntime implements IAgentRuntime {
221221
async initialize() {
222222
// First create the agent entity directly
223223
try {
224+
await this.getDatabaseAdapter().init();
225+
224226
await this.getDatabaseAdapter().ensureAgentExists(
225227
this.character as Partial<Agent>,
226228
);

packages/core/src/types.ts

+3
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,9 @@ export interface IDatabaseAdapter {
704704
/** Database instance */
705705
db: any;
706706

707+
/** Initialize database connection */
708+
init(): Promise<void>;
709+
707710
/** Close database connection */
708711
close(): Promise<void>;
709712

0 commit comments

Comments
 (0)