Skip to content

fix: stabilize ChatGPT Web Telegram daemon - #84

Open
stavmatis wants to merge 9 commits into
cosmicstack-labs:mainfrom
stavmatis:fix/chatgpt-web-telegram-stalls
Open

fix: stabilize ChatGPT Web Telegram daemon#84
stavmatis wants to merge 9 commits into
cosmicstack-labs:mainfrom
stavmatis:fix/chatgpt-web-telegram-stalls

Conversation

@stavmatis

Copy link
Copy Markdown

Summary

  • strip non-persisted Responses API item references for ChatGPT Web when using store=false
  • refresh ChatGPT Web OAuth inside daemon fetch calls
  • keep short Telegram final replies visible instead of swallowing them as status notices
  • make daemon children claim and clean up their own PID file safely

Tests

  • npm run typecheck
  • npm test -- src/providers/chatgpt-web.test.ts src/cli/daemon.test.ts
  • npm run build
  • npm install -g .
  • launchctl kickstart -k gui/501/com.cosmicstack.mercury
  • mercury status

shehzensidiq and others added 9 commits June 20, 2026 14:50
…essaging

- Add WhatsAppChannel implementing Channel interface via @whiskeysockets/baileys
- Group-based approach: Mercury listens to a WhatsApp group named 'Mercury'
- QR code pairing via qrcode-terminal (device linking)
- Admin pairing via /pair command in the group
- Auto-detect group after connection using groupFetchAllParticipating()
- Rate limiting (3s min, 60/hr per chat, 200/hr global, 1000/day)
- Reconnection with exponential backoff; immediate reconnect on 515
- Suppress Baileys internal logs (pino level: fatal)
- Config tracks: registered, paired, adminPaired, groupId, groupName
- CLI: mercury whatsapp status/pair/reset/unregister/list/detect-group/groups/set-group
- Onboarding flow resumes from incomplete steps (doctor)
- send_file tool supports 'whatsapp' channel
- Notification priority: Signal > Telegram > Discord > Slack > WhatsApp > CLI
- .env.example: WHATSAPP_ENABLED, WHATSAPP_PHONE_NUMBER, WHATSAPP_MODE, WHATSAPP_GROUP_NAME
- tsup externals: @whiskeysockets/baileys, protobufjs, qrcode-terminal, discord.js
- protobufjs pinned to 7.4.0 for directory structure stability
- Discord: if already paired (token + admins), show 'Reconfigure? (y/N)'
  instead of all setup instructions. Default No skips to next section.
- Slack: same pattern — 'Reconfigure? (y/N)' when already paired.
  Full setup extracted to runSlackSetup() helper.
- WhatsApp: if fully paired (device + group + admin), show
  'WhatsApp linked to [phone] — group detected, admin paired. Reconfigure? (y/N)'.
  If partially paired, resume from incomplete step (unchanged).
  If not configured, show first-time setup instructions (unchanged).
…channels

- Telegram: if already paired (token + admins), show 'Reconfigure? (y/N)'
  with status summary instead of full setup instructions. Default No skips.
- Signal: if already paired (phone + admins), show 'Reconfigure? (y/N)'
  with phone number and group name instead of 'Keep existing? (Y/n)'.
  Full setup extracted to runSignalSetup() and runTelegramSetup() helpers.
- completeInitialSignalSetup: removed redundant 'already paired' prompt
  since the reconfigure decision is now handled by the caller.
- Add ImessagesChannel with full Spectrum SDK integration (cloud mode)
- Supports text, markdown, attachments, typing indicators
- Auto-captures bot phone number from inbound space.phone
- Caches Space objects from inbound messages for reliable reply routing
- Echo suppression (sender.kind === 'agent') and LRU dedup
- Static allowlist (IMESSAGES_ALLOWED_USERS) accepts phone numbers and Apple ID emails
- Add IMessagesChannelConfig and IMessagesAccessUser types
- Add channels.imessages config block with env defaults (IMESSAGES_*)
- Register imessages in ChannelRegistry and barrel exports
- Add iMessages onboarding step to configure/doctor flow
- Fix send_file tool: add 'imessages' to channel enum
- Fix sendFileHandler: route file sends to iMessages channel
- Fix sendFile: add file existence/size checks and MIME type hints
- Fix Spectrum API field mapping: sender.address (not .phone), content.markdown (not .text)
- Fix timestamp: handle Date objects from Spectrum
- Add spectrum-ts 5.1.0 dependency (pinned exact)
- New OpenRouterProvider using @ai-sdk/openai with attribution headers
- OpenRouter appears as option 4 in doctor/onboarding provider selection
- Search-based model selector with type-to-filter for 300+ models
- Model validation against full OpenRouter catalog (rejects typos with suggestions)
- 15 curated preferred models shown by default, search for more
- Config: OPENROUTER_API_KEY, OPENROUTER_BASE_URL, OPENROUTER_MODEL, OPENROUTER_ENABLED
- Web API: openrouter in valid provider names, model validation on save
- Provider registry: openrouter entry with fallback chain support
- Increased model limit for OpenRouter from 7 to 15 in catalog
- Add SIGPIPE handler at process entry point to prevent Node.js from
  terminating on closed pipe writes
- Filter EPIPE errors in uncaughtException/unhandledRejection handlers
  instead of writing crash flags for harmless pipe closures
- Add process.exit(1) to uncaughtException handler for real errors
  (previously continued after fatal errors)
- Remove crash-flag writes from unhandledRejection (non-fatal, was
  over-aggressive)
- Suppress spectrum-ts INFO logs by setting logLevel to 'error' in
  the Spectrum constructor (eliminates [spectrum.lifecycle] noise)
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.

2 participants