Skip to content

fix: system message encryption and message processing#30

Open
JohnEsleyer wants to merge 25 commits into
devfrom
fix/message-processing-and-deterministic-system
Open

fix: system message encryption and message processing#30
JohnEsleyer wants to merge 25 commits into
devfrom
fix/message-processing-and-deterministic-system

Conversation

@JohnEsleyer

Copy link
Copy Markdown
Owner

Summary

  • Fix system messages being encrypted (caused garbled output like "Nf]���")
  • Reject XML commands when takeover mode is off
  • Remove unnecessary double-encryption in response
  • Add isSeen column for unread message tracking
  • Add test files for <give> command testing

Changes

HermitShell (v0.7.0)

  • db.go: System messages now stored unencrypted; add isSeen column with MarkHistorySeen() and GetUnseenCount() helpers
  • server.go: XML commands rejected in non-takeover mode; cleaned up response handling

Test Files

  • Added dog.jpg, 720p.mp4 for <give> command testing

Testing

  • Build passes: go build ./...
  • Manual testing recommended to verify system messages display correctly

Ref: docs/message-processing.md

- System messages are no longer encrypted (fixes garbled output)
- XML commands are rejected when takeover mode is off
- Remove unnecessary double-encryption in response
- Add isSeen column for unread message tracking
- Add helper functions: MarkHistorySeen, GetUnseenCount
- Add test files: dog.jpg, 720p.mp4 for give command testing

Ref: docs/message-processing.md
- Return role in chat responses for proper client handling
- Add error handling for decryption failures (return 400 error)
- Log decryption errors in GetHistory with placeholder message
- Ref: docs/message-processing.md
- Add isRejected column to history table for tracking rejected XML commands
- Add AddHistoryWithRejection function to db.go
- Add HandleMarkMessagesSeen endpoint for marking messages as read
- Update HandleGetUnreadCount to return actual count from database
- Update GetHistory to include isRejected field

Ref: docs/message-processing.md
- Switch from GCM to CBC encryption for client compatibility
- System prompt now always uses global context.md (ignores agent-specific)
- Parser requires <message> tag - rejects responses without it
- Fixed duplicate messages in WebSocket broadcast
- Add timestamp to history for copy context feature
- Handle both enc: and cbc: encryption prefixes
Major improvements to calendar/scheduling system:

Parser:
- Add new <schedule minutes="N" hours="H" days="D"> tag for relative time scheduling
- Server calculates absolute datetime from current time + duration
- Supports any combination of minutes/hours/days

Scheduler (agent-aware mode):
- Move scheduler from main.go to Server for access to LLM
- Scheduler injects reminders as user messages to agent
- Agent processes reminder and responds naturally
- Fix duplicate injection with mutex locking
- Mark events executed before triggering agent (prevents race conditions)
- Change reminder format to [SCHEDULED_REMINDER] prefix

Context/prompt:
- Add detailed instructions for handling scheduled reminders
- Explicitly instruct agent NOT to re-schedule [SCHEDULED_REMINDER] messages
- Show correct vs wrong response examples

Other fixes:
- ensureRuntimeData now updates existing context.md if source is newer
- Add retry mechanism for missing <message> tag (1 retry with reminder)
- Typewriter animation uses fixed 5ms per character

Docs:
- Document new <schedule> tag with examples
- Update reminder scenarios to use relative time
… and scheduler improvements

- Add event_type field to calendar for action vs deliver scheduling
- action type: triggers LLM when fired (for tasks like 'write code in 1 hour')
- deliver type: sends pre-written content directly (no LLM call)
- Fix timezone handling: use GetSystemTime() for consistent scheduling
- Store raw LLM response in history for debugging, broadcast clean message to UI
- Add debug logging to scheduler for troubleshooting
- Update context.md with scheduling documentation
…an history

- Add broadcastMessageWithRole for flexible message role broadcasting
- Add broadcastReminderMessage for scheduled reminder styling
- Format system execution feedback as readable output instead of raw JSON
- Skip terminal execution results when building context (reduce noise)
- Store parsed message content in history (not raw XML)
- Reminder messages now use 'reminder' role for proper Flutter styling
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant