-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
feat: Add pagination support and account status management across database adapters (CONFLICTED) #3359
Closed
Closed
feat: Add pagination support and account status management across database adapters (CONFLICTED) #3359
Changes from 1 commit
Commits
Show all changes
71 commits
Select commit
Hold shift + click to select a range
60ce697
feat: Add pagination support and account status management across dat…
tercel fe4f85e
feat: Enhance manage API routes for account management
tercel 5413122
feat: Add JWT authentication and token-based access control
tercel 326c885
feat: Add client-side stop mechanism for Twitter client components
tercel ffb3980
feat: Add Swagger documentation and enhance API authentication for cl…
tercel 29a9f5f
feat: Enhance pagination and query support across database adapters
tercel f0a4358
feat: Add dotenv configuration for Swagger generation
tercel bf2cb9e
fix: Improve dotenv configuration for Swagger generation
tercel 740137b
fix: Simplify character object handling in account update route
tercel 8090baa
fix: Improve character ID generation and agent start process
tercel e18f658
fix: Improve error logging and formatting in logger
tercel caf6226
fix: Improve error handling and logging in manage API routes
tercel 7f9d743
fix: Refactor account update route with improved error handling and I…
tercel 050e066
fix: Improve account creation logic for unique username and ID genera…
tercel 743a092
fix: Improve plugin importing and character merging logic
tercel 601ce41
feat: Add plugin list endpoint to manage API
tercel 89dd57b
feat: Implement plugin discovery and loading mechanism
tercel 51897aa
feat: Enhance plugin and memory management in DirectClient
tercel 4ff8558
chore: Add PM2 ecosystem configuration file
tercel 859b9fc
feat: Add PostgreSQL setup and text search optimization
tercel adae76b
feat: Add agent restart script with dynamic service naming and port m…
tercel c70760e
fix: Remove default character initialization in agent startup
tercel 993f807
refactor: Update plugin discovery mechanism to use package.json depen…
tercel 57ab3c0
fix: Configure SSL for PostgreSQL database connection
tercel 10bfa13
fix: Improve agent restart script reliability and startup process
tercel f63dc5b
fix: Improve agent startup logging and account status management
tercel c271a34
refactor: Update 3D generation plugin export and import plugin mechanism
tercel 2951e6c
feat: Add package metadata to plugin imports and character saving
tercel 7f687ff
feat: Add client discovery and metadata retrieval mechanism
tercel 467f046
feat: Enhance plugin name extraction for consistent naming
tercel 67f3f79
feat: Dynamically set Swagger documentation host based on request
tercel 796f2ea
feat: Improve README file discovery with case-insensitive search
tercel c8fe9c8
feat: Add README files for multiple ElizaOS clients and plugins
tercel e06b6e8
docs: Add comprehensive README for Deva client package
tercel 2630f76
feat: Add README parsing for environment variables in clients and plu…
tercel 43a621c
docs: Standardize README environment variable formatting across clien…
tercel b52bf52
docs: Add comprehensive README for ElizaOS Core Package
tercel 54fb047
feat: Add log streaming endpoint with SSE and client management
tercel 433a231
refactor: Improve log streaming message format for SSE endpoint
tercel 19c43c0
feat: Add system metrics endpoint for monitoring process and system r…
tercel a5ee4c7
refactor: Optimize memory usage monitoring and logging
tercel 8480a83
refactor: Remove unnecessary console log in token verification middle…
tercel 54c9ed2
refactor: Enhance restart-agent.sh with flexible start/stop/restart a…
tercel 89e2f7a
fix: Improve log stream heartbeat and timeout timestamp handling
tercel 20a53c7
feat: Add disk space metrics to system metrics endpoint
tercel 9369a02
docs: Add descriptive comments for disk space metrics type
tercel 30d5559
chore: Update dependencies and version, adjust CPU usage calculation
tercel 1f7d352
feat: Enhance CPU usage metrics with system-wide and process-specific…
tercel 72c55e8
feat: Enhance provider configuration and API key management
tercel 0a1dc6a
feat: Add template generation endpoint with JSON parsing and response…
tercel 717731e
feat: Add character template generator configuration
tercel cdc7043
fix: Standardize API error responses with JSON format
tercel 484ed59
feat: Enhance character loading with tplgen agent and source tracking
tercel 6a93247
fix: Automatically activate or pause accounts based on agent status
tercel 11be4b3
feat: Add source tracking to tplgen character template
tercel c6cad48
feat: Add token retrieval for model provider in runtime configuration
tercel befa3e7
feat: Improve runtime model provider handling and JSON parsing flexib…
tercel 766f4bc
feat: Improve memory ID generation and response message metadata
tercel 8de4d8f
refactor: Improve memory ID generation with descriptive prefixes
tercel 692ce39
feat: Increase body parser size limits for large JSON payloads
tercel a212b0b
feat: Optimize CPU metrics tracking and calculation
tercel 4a6f16e
feat: Implement log buffering for SSE client connections
tercel 3f88f1c
refactor: remove parsing bool string
tercel 1ef1c09
refactor: Enhance action matching and character saving logic
tercel d33cb9f
feat: Add account update method for character activation
tercel d66df6b
refactor: Improve logging and error handling in Solana and Near plugins
tercel 0330aa0
feat: Add string escape character cleaning utility and improve parsing
tercel 677b3d7
refactor: Disable most plugin configurations by default
tercel 63c8416
refactor: Remove commented-out plugin configurations
tercel 74fac96
feat: Add conversation length and action control to character configu…
tercel 4eb8fd8
feat: Enhance logging for direct client and Solana token transfers
tercel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ | |
type Memory, | ||
type Relationship, | ||
type UUID, elizaLogger, | ||
type PaginationParams, | ||
type PaginationResult, | ||
} from "@elizaos/core"; | ||
import { v4 } from "uuid"; | ||
|
||
|
@@ -322,6 +324,11 @@ | |
} | ||
} | ||
|
||
async updateAccount(account: Account): Promise<void> { | ||
await this.ensureConnection(); | ||
await this.database.collection('accounts').updateOne({ id: account.id }, { $set: account }); | ||
} | ||
|
||
async getActorDetails(params: { roomId: UUID }): Promise<Actor[]> { | ||
await this.ensureConnection(); | ||
const actors = await this.database.collection('participants') | ||
|
@@ -1440,6 +1447,61 @@ | |
return []; | ||
} | ||
} | ||
async paginate(collectionName: string, params: PaginationParams): Promise<PaginationResult> { | ||
await this.ensureConnection(); | ||
|
||
const { | ||
page = 1, | ||
pageSize = 10, | ||
where = {}, | ||
order = { createdAt: -1 } // MongoDB uses 1 for ASC, -1 for DESC | ||
} = params; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add input validation for pagination parameters. Validate and sanitize page and pageSize parameters to prevent potential issues. const {
- page = 1,
- pageSize = 10,
+ page = Math.max(1, Math.floor(Number(page) || 1)),
+ pageSize = Math.min(100, Math.max(1, Math.floor(Number(pageSize) || 10))),
where = {},
order = { createdAt: -1 }
} = params;
+
+if (isNaN(page) || isNaN(pageSize)) {
+ throw new Error('Invalid pagination parameters');
+}
|
||
|
||
const skip = (page - 1) * pageSize; | ||
|
||
// Convert where conditions for MongoDB | ||
const whereQuery: any = {}; | ||
// biome-ignore lint/complexity/noForEach: <explanation> | ||
Object.entries(where).forEach(([key, value]) => { | ||
if (value === null || value === undefined) return; | ||
|
||
if (typeof value === 'object') { | ||
if (key === 'createdAt') { | ||
whereQuery[key] = {}; | ||
if (value.gte) whereQuery[key].$gte = new Date(value.gte); | ||
if (value.lte) whereQuery[key].$lte = new Date(value.lte); | ||
} else { | ||
whereQuery[key] = value; | ||
} | ||
} else { | ||
whereQuery[key] = value; | ||
} | ||
}); | ||
|
||
try { | ||
// Get total count | ||
const total = await this.database.collection(collectionName) | ||
.countDocuments(whereQuery); | ||
|
||
// Get paginated data | ||
const list = await this.database.collection(collectionName) | ||
.find(whereQuery) | ||
.sort(order) | ||
.skip(skip) | ||
.limit(pageSize) | ||
.toArray(); | ||
|
||
return { | ||
list, | ||
total, | ||
page, | ||
pageSize, | ||
totalPages: Math.ceil(total / pageSize), | ||
}; | ||
} catch (error) { | ||
elizaLogger.error(`Error in paginate for collection ${collectionName}:`, error); | ||
throw error; | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🛠️ Refactor suggestion
Add error handling for database initialization.
Consider handling initialization failures more gracefully.