Skip to content

Add Hermit-managed thread length monitoring#6

Open
julianengel wants to merge 10 commits intoopenclaw:mainfrom
julianengel:length-track
Open

Add Hermit-managed thread length monitoring#6
julianengel wants to merge 10 commits intoopenclaw:mainfrom
julianengel:length-track

Conversation

@julianengel
Copy link

Summary

  • add Hermit-managed tracking and polling for long helper threads
  • keep the worker focused on tracked-thread persistence while Hermit owns thresholds, messaging, and Discord actions
  • register qualifying welcome threads in the worker before the welcome message is posted

What changed

  • added a Hermit poller that runs on startup when THREAD_LENGTH_CHECK_INTERVAL_HOURS is configured
  • fetches tracked threads from the worker, inspects live Discord thread state, and updates worker state after each pass
  • warns at more than 100 messages, warns again at more than 150 messages, and auto-closes at more than 200 messages
  • treats archived or locked threads as closed and stops reprocessing them
  • stores warning and close state in the worker tracked_threads record via warningLevel, closed, and lastMessageCount
  • added git-tracked warning/close message templates so the wording lives in source control
  • updated the worker-tracking registration in threadCreateWelcome so newly welcomed helper threads are tracked immediately
  • documented the new monitor configuration and tracked-thread state in the README

Structure

Hermit now owns the thread-length policy end to end:

  • scheduling
  • threshold evaluation
  • Discord inspection
  • warning and close messages
  • archive and lock actions

The Cloudflare worker remains a persistence layer for:

  • tracked thread registration
  • last checked time
  • solved flag
  • warning level
  • closed flag
  • latest observed message count

This keeps the behavior portable if tracked thread storage later moves away from Cloudflare D1.

Configuration

  • WORKER_EVENT_URL
  • WORKER_EVENT_SECRET
  • HELPER_THREAD_WELCOME_PARENT_ID
  • THREAD_LENGTH_CHECK_INTERVAL_HOURS

Validation

  • npx tsc --noEmit

- add new /helper root command with guild-only subcommands: warn-new-thread and close-thread

- implement warn-new-thread optional user mention support (matching prior /say new-thread mention behavior)

- implement close-thread thread-only guard, then post close message and archive/lock thread

- remove /say new-thread subcommand and route this workflow to /helper

- add shared command webhook utility posting to HELPER_COMMAND_WEBHOOK_URL

- include webhook payload fields: threadId, messageCount, time, command, invokedBy

- wire helper command registration in src/index.ts and extend env typings

- document HELPER_COMMAND_WEBHOOK_URL and helper command usage in README/.env.example

- fix TS typing issues uncovered during validation: interaction.user nullability, thread type guard, github option literal types

Validation: npx tsc --noEmit passes
- read HELPER_COMMAND_WEBHOOK_SECRET from env

- include x-helper-webhook-secret header on helper webhook POST when configured

- document new env var in README and .env.example

- extend ProcessEnv typing with HELPER_COMMAND_WEBHOOK_SECRET
- add ThreadCreate listener to post onboarding guidance for new helper threads

- target one configured helper parent channel via HELPER_THREAD_WELCOME_PARENT_ID

- set default in-file helper welcome template (overrideable via HELPER_THREAD_WELCOME_TEMPLATE)

- register listener in src/index.ts and update env/docs typing and examples
- add /helper close subcommand that posts close message then archives and locks thread

- keep /helper close-thread as compatibility alias using shared close flow

- update README command list
@julianengel
Copy link
Author

@thewilloftheshadow Should be good to go!

@julianengel
Copy link
Author

Since #5:

Migrated the old external logging functionality directly into Hermit and moved it onto the existing Bun + SQLite stack.

What changed:

  • copied the helper event and tracked-thread schema/migrations into Hermit via Drizzle
  • replaced the old remote worker/D1 write path with direct internal SQLite persistence
  • kept a local Bun HTTP server for read-only visibility (/, /api/events, /api/threads)
  • wired helper event logging and tracked-thread state updates to run entirely inside Hermit/Carbon
  • kept the thread-length monitor in Hermit, driven by THREAD_LENGTH_CHECK_INTERVAL_HOURS (via interval - maybe cron better)
  • cleaned up the README to document the full runtime, commands, env vars, DB tables, and operational behavior

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