@@ -64,14 +64,16 @@ let fallbackTickCount = 0;
6464
6565 async function loadCredentials(): Promise<Credentials | null> {
6666 try {
67- const file = Bun.file(config.credentialsFile);
68- if (await file.exists()) {
69- return (await file.json()) as Credentials;
70- }
71- } catch {
67+ return memory.getCredentials();
68+ } catch (error) {
69+ output.log(
70+ formatSystemMessage(
71+ `FATAL: Failed to load credentials: ${(error as Error).message}`,
72+ ),
73+ );
74+ shutdown();
7275 return null;
7376 }
74- return null;
7577 }
7678
7779 async function saveCredentials(
@@ -79,8 +81,7 @@ async function saveCredentials(
7981 token: string,
8082 personality: PersonalityType,
8183 ): Promise<void> {
82- const data: Credentials = { username, token, personality };
83- await Bun.write(config.credentialsFile, JSON.stringify(data, null, 2));
84+ memory.saveCredentials(username, token, personality);
8485 }
8586
8687 function updateOutput(): void {
@@ -430,7 +431,7 @@ client.on<ErrorPayload>("error", (data) => {
430431 );
431432 output.log(
432433 formatSystemMessage(
433- `Delete ${config.credentialsFile} and run again to create a new account.`,
434+ `Delete ${config.memoryPath} and run again to create a new account.`,
434435 ),
435436 );
436437 shutdown();
@@ -573,34 +574,9 @@ client.on("version_info", (data: Record<string, unknown>) => {
573574 gameState.credentials = await loadCredentials();
574575
575576 console.log(`Instance: ${config.instanceName}`);
576-console.log(`Credentials: ${config.credentialsFile}`);
577-console.log(`Memory DB: ${config.memoryPath}`);
577+console.log(`DB: ${config.memoryPath}`);
578578 output.log(formatSystemMessage(`Instance: ${config.instanceName}`));
579-output.log(formatSystemMessage(`Credentials: ${config.credentialsFile}`));
580-output.log(formatSystemMessage(`Memory DB: ${config.memoryPath}`));
581-
582-// Force re-registration if personality is missing
583-if (gameState.credentials && !gameState.credentials.personality) {
584- output.log(
585- formatSystemMessage(
586- "Credentials missing personality field - forcing re-registration",
587- ),
588- );
589- try {
590- await Bun.write(config.credentialsFile, "");
591- const file = Bun.file(config.credentialsFile);
592- if (await file.exists()) {
593- await file.remove?.();
594- }
595- } catch (error) {
596- output.log(
597- formatSystemMessage(
598- `Failed to delete credentials: ${(error as Error).message}`,
599- ),
600- );
601- }
602- gameState.credentials = null;
603-}
579+output.log(formatSystemMessage(`DB: ${config.memoryPath}`));
604580
605581 await client.connect();
606582 updateOutput();