Skip to content

Conversation

@wtfsayo
Copy link
Member

@wtfsayo wtfsayo commented Dec 4, 2025

Summary

This PR modernizes the standalone example files and improves the SQL plugin's directory handling by:

  1. Migrating examples from the deprecated MESSAGE_RECEIVED event system to the new messageService.handleMessage() API
  2. Adding automatic PGLite data directory creation in the SQL plugin with comprehensive tests

Changes

Examples ( & )

  • ✅ Replace deprecated MESSAGE_RECEIVED event with messageService.handleMessage() API
  • ✅ Set LOG_LEVEL to 'silent' for cleaner console output
  • ✅ Remove manual file system directory creation (now handled by SQL plugin)
  • ✅ Remove unused EventType and fs imports
  • ✅ Fix messageServerId to be properly converted to UUID in standalone-cli-chat.ts
  • ✅ Improve response handling with fallback to result.responseContent.text
  • ✅ Update inline documentation and comments

SQL Plugin

  • ✅ Add automatic directory creation in createDatabaseAdapter() (both index.ts and index.node.ts)
    • Creates directories for file paths only (not for memory://, idb://, or other special URIs)
    • Skips directory creation when using PostgreSQL
    • Uses mkdirSync(dataDir, { recursive: true }) to ensure parent directories are created
  • ✅ Add comprehensive unit tests in __tests__/unit/directory-creation.test.ts:
    • Tests directory creation for new file paths
    • Tests that existing directories don't cause errors
    • Tests that special URIs (memory://, idb://) don't trigger directory creation
    • Tests that PostgreSQL usage doesn't trigger directory creation

Testing

  • All existing tests pass
  • New unit tests added for directory creation logic
  • Manual testing of standalone.ts example
  • Manual testing of standalone-cli-chat.ts example

Type of Change

  • Bug fix (non-breaking change which fixes deprecation warnings)
  • Improvement (better directory handling and error prevention)
  • Test coverage improvement

Related Issues

  • Fixes deprecation warnings in example files
  • Improves developer experience by auto-creating required directories
  • Prevents runtime errors from missing PGLite data directories

Migration Guide

Users of the examples will now benefit from:

  • Cleaner, non-deprecated API usage
  • Automatic directory creation (no manual setup needed)
  • Better error messages and response handling

No breaking changes - fully backward compatible.


Note

Updates examples to use messageService.handleMessage and adds automatic PGLite directory creation in the SQL plugin with tests.

  • Examples:
    • Replace deprecated EventType.MESSAGE_RECEIVED with runtime.messageService.handleMessage() in examples/standalone.ts and examples/standalone-cli-chat.ts.
    • Set process.env.LOG_LEVEL = 'silent'; remove manual FS dir creation and unused imports.
    • Ensure messageServerId uses UUID in standalone-cli-chat.ts; improve response fallback handling.
  • SQL Plugin:
    • In packages/plugin-sql/src/index.ts and index.node.ts, auto-create PGLite data directory via mkdirSync(dataDir, { recursive: true }) when dataDir is a filesystem path.
    • Skip directory creation for memory://, idb://, and when postgresUrl is provided.
    • Add unit tests __tests__/unit/directory-creation.test.ts covering new directory-creation behavior.

Written by Cursor Bugbot for commit 3048a27. This will update automatically on new commits. Configure here.

- Replace deprecated MESSAGE_RECEIVED event with messageService.handleMessage()
- Remove unused EventType imports
- Add proper UUID conversion for messageServerId in standalone-cli-chat
- Improve response handling with fallback to result content
- Update both standalone.ts and standalone-cli-chat.ts examples
Refactors database adapter initialization to automatically create the PGLite data directory if it does not exist, unless a special URI (e.g., memory://, idb://) or PostgreSQL is used. Removes manual directory creation from example scripts and adds unit tests to verify directory creation behavior.
@wtfsayo wtfsayo changed the title fix(examples): migrate to messageService.handleMessage() API fix(examples,plugin-sql): migrate to messageService API and auto-create PGLite directories Dec 4, 2025
Added a runtime check to ensure messageService is initialized before handling messages. Also updated the content handler callback to explicitly return an empty array, clarifying its intent.
@elizaOS elizaOS deleted a comment from claude bot Dec 4, 2025
@elizaOS elizaOS deleted a comment from coderabbitai bot Dec 4, 2025
@elizaOS elizaOS deleted a comment from claude bot Dec 4, 2025
@elizaOS elizaOS deleted a comment from claude bot Dec 4, 2025
@wtfsayo wtfsayo changed the title fix(examples,plugin-sql): migrate to messageService API and auto-create PGLite directories fix(plugin-sql): migrate to messageService API and auto-create PGLite directories Dec 4, 2025
Changed the setupDatabase method in AgentInitializer to return an IDatabaseAdapter instead of void. This improves type safety and allows callers to use the database adapter directly.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 4, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/examples-use-message-service-api

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@elizaOS elizaOS deleted a comment from claude bot Dec 4, 2025
@wtfsayo wtfsayo merged commit e9fc1a9 into develop Dec 4, 2025
13 checks passed
@wtfsayo wtfsayo deleted the fix/examples-use-message-service-api branch December 4, 2025 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants