-
Notifications
You must be signed in to change notification settings - Fork 12
Create bot runner package #3868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Preview deployments |
2ad413f to
2654e2a
Compare
2654e2a to
442f82c
Compare
* add bot registration endpoint * add script to register bot * add register bot commands * update generic bot runner * fix copilot recommendations * fix handling of bot runner with registrations. * fix tests + fix copilot recommendations * include accept header and content type for test * cleanup code * get type of full row * add method to fetchRequestFromContext * fix schema * lint * fix lint types and add test for runner * fix type * simplify usage of username rather than matrix_user_id * fix more lint * fix lint * more defensive programming * fix lint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request introduces a new bot-runner package that enables users to register bots that can listen to Matrix room events and enqueue work via the realm server queue. The PR is marked as "WIP" in the description.
Changes:
- Created new
@cardstack/bot-runnerpackage with Matrix event handlers and database integration - Added bot registration REST API endpoints to realm-server (
/_bot-registration,/_bot-registrations) - Created database migration and schema for
bot_registrationstable - Added register-bot and unregister-bot commands in the host package
- Integrated bot-runner user into AI assistant room creation flow
Reviewed changes
Copilot reviewed 28 out of 30 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/bot-runner/* | New package with main entry point, event handlers, tests, configuration, and documentation |
| packages/postgres/migrations/1769200000000_create-bot-registrations.js | Database migration creating bot_registrations table |
| packages/realm-server/handlers/handle-bot-registration.ts | Handlers for bot registration, listing, and unregistration endpoints |
| packages/realm-server/routes.ts | Route definitions for bot registration endpoints |
| packages/realm-server/middleware/index.ts | Added DELETE method to request body parsing |
| packages/realm-server/tests/server-endpoints/bot-registration-test.ts | Comprehensive test coverage for bot registration endpoints |
| packages/realm-server/scripts/register-bot.sh | Shell script for registering bots via API |
| packages/host/app/commands/register-bot.ts | Command for registering bots from host application |
| packages/host/app/commands/unregister-bot.ts | Command for unregistering bots from host application |
| packages/host/app/services/realm-server.ts | Service methods for bot registration API calls |
| packages/host/app/services/matrix-service.ts | Added botRunnerUserId getter |
| packages/host/app/commands/create-ai-assistant-room.ts | Temporarily invites bot-runner to AI assistant rooms (marked with TODO) |
| packages/host/tests/integration/commands/bot-registration-test.gts | Integration tests for bot registration commands |
| packages/runtime-common/constants.ts | Added botRunnerUsername constant |
| packages/matrix/package.json | Added script to register bot-runner Matrix user |
| packages/base/command.gts | Added RegisterBotInput, RegisterBotResult, and UnregisterBotInput card definitions |
| pnpm-lock.yaml | Dependency updates for new bot-runner package |
| .github/workflows/ci.yaml | Added bot-registration-test to CI workflow |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| }); | ||
| }; | ||
|
|
||
| exports.down = (pgm) => { |
Copilot
AI
Jan 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bot_registrations table is queried by username in the timeline handler (packages/bot-runner/lib/timeline-handler.ts:64-69), but there's no index on the username column. For better query performance, especially as the number of registrations grows, consider adding an index on the username column. Example: pgm.createIndex('bot_registrations', 'username');
| }); | |
| }; | |
| exports.down = (pgm) => { | |
| }); | |
| pgm.createIndex('bot_registrations', 'username'); | |
| }; | |
| exports.down = (pgm) => { | |
| pgm.dropIndex('bot_registrations', 'username'); |
packages/postgres/migrations/1769200000000_create-bot-registrations.js
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c525189cbf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Introduce bot-runner