- 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>
65 lines
1.6 KiB
Markdown
65 lines
1.6 KiB
Markdown
# 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
|