feat(api): add agent memory module (MS22-DB-002, MS22-API-002)
Some checks failed
ci/woodpecker/push/api Pipeline failed
Some checks failed
ci/woodpecker/push/api Pipeline failed
- Add AgentMemory model to schema.prisma with workspaceId/agentId/key/value and @@unique([workspaceId, agentId, key]) constraint - Add Workspace.agentMemories relation - Add migration 20260228000000_ms22_agent_memory - Add AgentMemoryModule with service, controller, DTOs, and unit tests - Endpoints: PUT/GET/GET/:key/DELETE on /api/agents/:agentId/memory/:key - Register AgentMemoryModule in app.module.ts - 10 unit tests passing (service + controller) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
64
docs/scratchpads/ms22-agent-memory.md
Normal file
64
docs/scratchpads/ms22-agent-memory.md
Normal file
@@ -0,0 +1,64 @@
|
||||
# MS22 Agent Memory Module
|
||||
|
||||
## Objective
|
||||
|
||||
Add per-agent key/value store: AgentMemory model + NestJS module with CRUD endpoints.
|
||||
|
||||
## Issues
|
||||
|
||||
- MS22-DB-002: Add AgentMemory schema model
|
||||
- MS22-API-002: Add agent-memory NestJS module
|
||||
|
||||
## Plan
|
||||
|
||||
1. AgentMemory model → schema.prisma (after AgentSession, line 736)
|
||||
2. Add `agentMemories AgentMemory[]` relation to Workspace model
|
||||
3. Create apps/api/src/agent-memory/ with service, controller, DTOs, specs
|
||||
4. Register in app.module.ts
|
||||
5. Migrate: `prisma migrate dev --name ms22_agent_memory`
|
||||
6. lint + build
|
||||
7. Commit
|
||||
|
||||
## Endpoints
|
||||
|
||||
- PUT /api/agents/:agentId/memory/:key (upsert)
|
||||
- GET /api/agents/:agentId/memory (list all)
|
||||
- GET /api/agents/:agentId/memory/:key (get one)
|
||||
- DELETE /api/agents/:agentId/memory/:key (remove)
|
||||
|
||||
## Auth
|
||||
|
||||
- @UseGuards(AuthGuard, WorkspaceGuard, PermissionGuard)
|
||||
- @Workspace() decorator for workspaceId
|
||||
- Permission.WORKSPACE_MEMBER for write ops
|
||||
- Permission.WORKSPACE_ANY for read ops
|
||||
|
||||
## Schema
|
||||
|
||||
```prisma
|
||||
model AgentMemory {
|
||||
id String @id @default(uuid()) @db.Uuid
|
||||
workspaceId String @map("workspace_id") @db.Uuid
|
||||
agentId String @map("agent_id")
|
||||
key String
|
||||
value Json
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz
|
||||
updatedAt DateTime @updatedAt @map("updated_at") @db.Timestamptz
|
||||
|
||||
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([workspaceId, agentId, key])
|
||||
@@index([workspaceId])
|
||||
@@index([agentId])
|
||||
@@map("agent_memories")
|
||||
}
|
||||
```
|
||||
|
||||
## Progress
|
||||
|
||||
- [ ] Schema
|
||||
- [ ] Module files
|
||||
- [ ] app.module.ts
|
||||
- [ ] Migration
|
||||
- [ ] lint/build
|
||||
- [ ] Commit
|
||||
Reference in New Issue
Block a user