Skip to content
This repository was archived by the owner on Feb 21, 2026. It is now read-only.

feat: add Discord channel support#1

Merged
Peyton-Spencer merged 1 commit intomainfrom
feat/discord-channel
Feb 11, 2026
Merged

feat: add Discord channel support#1
Peyton-Spencer merged 1 commit intomainfrom
feat/discord-channel

Conversation

@Peyton-Spencer
Copy link
Copy Markdown

Summary

  • Add Discord bot (PeytonOmni) as a secondary channel running alongside WhatsApp
  • Refactor index.ts for multi-channel routing — processGroupMessages, scheduler, and IPC all use findChannel() + formatOutbound() instead of hardcoded WhatsApp calls
  • Remove hardcoded ${ASSISTANT_NAME}: prefix from IPC; formatting now handled by formatOutbound() per-channel
  • Expand getAvailableGroups() to include dc: and tg: prefixed JIDs
  • Seed CLAUDE.md with secondary-channel instructions when Discord groups are registered
  • Move groups/*/CLAUDE.md to gitignored runtime files with tracked .template seeds (repo no longer dirty after agent edits its memory)
  • Update /setup skill to copy templates on first run

Test plan

  • bun run typecheck passes
  • bun run dev — bot comes online in Discord and WhatsApp still connects
  • Register a Discord channel as a group from WhatsApp, verify group folder + CLAUDE.md created
  • @mention bot in Discord, verify response
  • Send DM to bot, verify it responds without needing @mention

🤖 Generated with Claude Code

Add Discord bot (PeytonOmni) as a secondary channel alongside WhatsApp.
Refactor index.ts for multi-channel routing, move CLAUDE.md files to
gitignored runtime files with tracked .template seeds.

- Add discord.js dependency and DiscordChannel implementation
- Multi-channel routing in processGroupMessages, scheduler, and IPC
- Remove hardcoded assistant name prefix from IPC (use formatOutbound)
- Expand getAvailableGroups to include dc: and tg: JIDs
- Seed CLAUDE.md for Discord groups on registration
- Move groups/*/CLAUDE.md to .template, update .gitignore
- Update /setup skill to copy templates on first run

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Peyton-Spencer Peyton-Spencer merged commit fb9dc12 into main Feb 11, 2026
1 of 2 checks passed
Peyton-Spencer pushed a commit that referenced this pull request Feb 14, 2026
Implements three critical stability fixes identified in the audit:

1. **Unhandled Promise Rejection Handler (CRITICAL)**
   - Add process.on('unhandledRejection') to prevent crashes
   - Logs rejections instead of exiting to maintain service uptime
   - Prevents complete service outage from uncaught promise errors

2. **WhatsApp Event Listener Memory Leak (CRITICAL)**
   - Store event handlers and remove them before reconnection
   - Prevents exponential handler accumulation on reconnects
   - Fixes memory leak leading to eventual OOM crashes

3. **Group Folder Path Traversal (MEDIUM)**
   - Validate folder names with regex (alphanumeric + _ -)
   - Verify resolved paths stay within groups directory
   - Prevents malicious group registration from writing to arbitrary paths

Impact:
- Prevents process crashes from unhandled rejections
- Fixes production memory leak in WhatsApp channel
- Hardens security against path traversal attacks

Related:
- Audit report: nanoclaw-stability-audit-2026-02-14.md
- Issues #1, #4, #16 from stability audit

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Peyton-Spencer added a commit that referenced this pull request Feb 14, 2026
* fix: stability quick wins from 2026-02-14 audit

Implements three critical stability fixes identified in the audit:

1. **Unhandled Promise Rejection Handler (CRITICAL)**
   - Add process.on('unhandledRejection') to prevent crashes
   - Logs rejections instead of exiting to maintain service uptime
   - Prevents complete service outage from uncaught promise errors

2. **WhatsApp Event Listener Memory Leak (CRITICAL)**
   - Store event handlers and remove them before reconnection
   - Prevents exponential handler accumulation on reconnects
   - Fixes memory leak leading to eventual OOM crashes

3. **Group Folder Path Traversal (MEDIUM)**
   - Validate folder names with regex (alphanumeric + _ -)
   - Verify resolved paths stay within groups directory
   - Prevents malicious group registration from writing to arbitrary paths

Impact:
- Prevents process crashes from unhandled rejections
- Fixes production memory leak in WhatsApp channel
- Hardens security against path traversal attacks

Related:
- Audit report: nanoclaw-stability-audit-2026-02-14.md
- Issues #1, #4, #16 from stability audit

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* fix: add transaction support to deleteTask and SQL injection safety comment

Database improvements from stability audit:

1. **Transaction Support for deleteTask (MEDIUM)**
   - Wrap DELETE operations in explicit transaction
   - Ensures both child and parent deletions succeed atomically
   - Prevents partial deletion leaving orphaned task_run_logs

2. **SQL Injection Safety Documentation (HIGH)**
   - Add security comment to updateTask explaining safety assumptions
   - Document that field names are hardcoded (not user-controlled)
   - Warn future maintainers about SQL injection risks if logic changes

Impact:
- Prevents database corruption from partial task deletions
- Documents security assumptions for future code reviewers
- Hardens codebase against accidental SQL injection introduction

Related:
- Audit report: nanoclaw-stability-audit-2026-02-14.md
- Issues #3, #12 from stability audit

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

---------

Co-authored-by: NanoClaw Agent <nanoclaw@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Peyton-Spencer added a commit that referenced this pull request Feb 16, 2026
…crashes

Adopted from upstream PR qwibitai#243 by pottertech (Skip Potter):
qwibitai#243

Fixes issue qwibitai#221 - Unhandled promise rejections crash the entire process

Changes:
1. Add module-level unhandledRejection handler (prevents process crashes)
2. Add module-level uncaughtException handler (graceful shutdown)
3. Move error handler registration from main() to module level
4. Wrap streaming output callback in try/catch (prevents rejection propagation)
5. Connect shutdown function for error handlers to call

Impact:
- Prevents process crashes from unhandled rejections
- Enables graceful shutdown on uncaught exceptions
- Improves error recovery in streaming callbacks
- Maintains service availability during agent errors

Overlap with our Stability Audit (2026-02-14):
- Our audit identified this as Issue #1 (CRITICAL)
- Upstream PR qwibitai#243 provides production-tested implementation
- This PR supersedes local fixes from audit

Risk: LOW
- Defensive programming only
- No behavior changes to core logic
- Proven in upstream testing

Co-authored-by: Skip Potter <skippotter@Skips-MacBook-Air.local>
Co-authored-by: Brodie Foxworth <brodie.foxworth@pottersquill.com>
Peyton-Spencer added a commit that referenced this pull request Feb 16, 2026
…crashes (#107)

Adopted from upstream PR qwibitai#243 by pottertech (Skip Potter):
qwibitai#243

Fixes issue qwibitai#221 - Unhandled promise rejections crash the entire process

Changes:
1. Add module-level unhandledRejection handler (prevents process crashes)
2. Add module-level uncaughtException handler (graceful shutdown)
3. Move error handler registration from main() to module level
4. Wrap streaming output callback in try/catch (prevents rejection propagation)
5. Connect shutdown function for error handlers to call

Impact:
- Prevents process crashes from unhandled rejections
- Enables graceful shutdown on uncaught exceptions
- Improves error recovery in streaming callbacks
- Maintains service availability during agent errors

Overlap with our Stability Audit (2026-02-14):
- Our audit identified this as Issue #1 (CRITICAL)
- Upstream PR qwibitai#243 provides production-tested implementation
- This PR supersedes local fixes from audit

Risk: LOW
- Defensive programming only
- No behavior changes to core logic
- Proven in upstream testing

Co-authored-by: Skip Potter <skippotter@Skips-MacBook-Air.local>
Co-authored-by: Brodie Foxworth <brodie.foxworth@pottersquill.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant