mom: add working memory system and improve log querying

- Add MEMORY.md files for persistent working memory
  - Global memory: workspace/MEMORY.md (shared across channels)
  - Channel memory: workspace/<channel>/MEMORY.md (channel-specific)
  - Automatically loaded into system prompt on each request

- Enhance JSONL log format with ISO 8601 dates
  - Add 'date' field for easy grepping (e.g., grep '"date":"2025-11-26"')
  - Migrated existing logs to include date field

- Improve log query efficiency
  - Add jq query patterns to prevent context overflow
  - Emphasize limiting NUMBER of messages (10-50), not truncating text
  - Show full message text and attachments in queries
  - Handle null/empty attachments with (.attachments // [])

- Optimize system prompt
  - Add current date/time for date-aware operations
  - Format recent messages as TSV (43% token savings vs raw JSONL)
  - Add efficient query examples with both JSON and TSV output

- Enhanced security documentation
  - Add prompt injection risk warnings
  - Document credential exfiltration scenarios
  - Provide mitigation strategies
This commit is contained in:
Mario Zechner 2025-11-26 13:21:43 +01:00
parent a484330cd1
commit 4e01eca40e
5 changed files with 309 additions and 18 deletions

View file

@ -156,6 +156,7 @@ export class MomBot {
const { userName, displayName } = await this.getUserInfo(event.user);
await this.store.logMessage(event.channel, {
date: new Date(parseFloat(event.ts) * 1000).toISOString(),
ts: event.ts,
user: event.user,
userName,