Skip to content

feat: doctor checks for service Restart policy and daemon-reload#71

Open
changhansung wants to merge 258 commits into
suzuke:mainfrom
songsid:feat/doctor-service-check
Open

feat: doctor checks for service Restart policy and daemon-reload#71
changhansung wants to merge 258 commits into
suzuke:mainfrom
songsid:feat/doctor-service-check

Conversation

@changhansung

Copy link
Copy Markdown
Contributor

Adds two service health checks to agend doctor:

  1. Restart=on-failure — verifies service file has crash recovery configured
  2. NeedDaemonReload — detects when systemd needs daemon-reload after service file changes

AgEnD Dev and others added 30 commits April 18, 2026 22:47
…ownload

- Discord adapter: MIME-based attachment kind detection (photo/video/audio/document)
- Discord adapter: attachmentUrls Map with 1000 cap, fetch-to-file downloadAttachment
- Classic mode: processAttachments in handleClassicChannelMessage with extraMeta passthrough
- Discord adapter: fetch referenced message content via fetchReference()
- Classic mode: pass replyToText through IPC meta as reply_to_text
…all users

Discord adapter now emits all messages. Fleet-manager checks access:
- Classic channels: all users allowed (for chat logging)
- Topic/general: only allowed_users pass
- Remove guildId filter from messageCreate — messages from any server pass through
- Fleet-manager access control + routing handles which channels are valid
- Fixes: messages from non-primary server were silently dropped
- Restore .kiro/settings/mcp.json to .gitignore (machine-specific)
- Remove ~/Projects/ from .gitignore (local path)
- Remove plugin package-lock.json (managed by root workspaces)
… stale drop

- Reduce waitForIdle timeout to 10s for lightweight (classic) instances
- Add queue depth counter with warning at depth > 3
- Drop stale user messages (>60s in queue), preserve cross-instance messages
- Apply sanitizeInstanceName in ClassicChannelManager.load() to match
  handleClassicStart registration path, preventing workspace directory
  drift after rebase/restart
- Allow bare attachments (images without /chat prefix) to be forwarded
  to classic channel agents
- Include attachment info in classic channel chat logs
restartInstances() killed classic tmux windows during orphan cleanup
but never restarted them. Only reregisterClassicChannels() was called
(routing only). Add the same startup logic from startAll() to restart
classic instances with concurrency 3.
capture-pane leaks 'can't find window' to stderr when instances
are still starting up. Pipe stderr to suppress.
…bare attachments

- Bare image (no /chat): download to ~/.agend/workspaces/<instance>/inbox/,
  log path in chat-log, react 📸, don't forward to agent
- /chat + image: download to workspace inbox, forward to agent with
  correct workspace path in image_path and text
- Topic mode image handling unchanged (still uses processAttachments directly)
Strip photo from attachments before processAttachments when already
saved to workspace inbox, preventing orphan file in daemon inbox.
P0: Discord adapter security hardening
- messageCreate: reject messages from other guilds
- interactionCreate: reject interactions from other guilds

P1: setup-wizard Discord channel type support
- Add channel type selection step (Telegram / Discord)
- Discord flow: token verification, guild selection, user ID input
- buildFleetConfig generates correct Discord config (type: discord,
  bot_token_env: AGEND_DISCORD_TOKEN, guild_id)
- WizardAnswers extended with channelType and guildId fields
- Telegram flow unchanged
Adds optional general_channel_id prompt after User ID step.
Written to fleet.yaml under channel.options when provided.
After Discord flow completion, both setup-wizard and quickstart now
display: 'Classic Bot Mode: Use /start in any Discord channel to start
an agent. Use /chat to talk.'
…ugh guildId check

messageCreate, interactionCreate, and channelDelete handlers now check
openChannels set before rejecting messages from non-primary guilds.
This allows classic bot channels registered across multiple servers to
continue functioning while still blocking unregistered channels.

Added debug logging for non-primary guild classic channel events.
…dcoded 1

Telegram General Topic has thread_id=1 by convention, but Discord
channels have snowflake IDs. When general_channel_id is set in
fleet.yaml options, use it as the general instance's topic_id.
Fixes 'Unknown Channel' error on fleet start with Discord.
changhansung and others added 30 commits June 11, 2026 11:15
defaults.model now only applies to backends that recognize the model
name pattern. e.g. claude-opus-4.6 won't be passed to codex backend.
resolveReplyThreadId returns undefined for classic instances (not in
fleetConfig.instances). Add fallback to classicChannels.getChannelIdByInstance()
so reply/react/edit tools work correctly for classic bot channels.
Format: [user:name via platform, id:USER_ID] message
Enables classic agents to @mention users in replies.
Teaches all instances how to @mention users and bots using the id:
field from inbound messages.
In topic mode, daemon should not block reply when lastChatId is unset.
Fleet-manager has the classicBot channelId fallback to route correctly.
allowed_guilds: {} (object instead of array) caused all groups to be
rejected. Now uses Array.isArray check — non-array values treated as
'allow all'.
/stop@other_bot was being stripped to /stop and executed by all bots
in the group. Now checks if the @suffix matches our bot username —
if not, ignores the command entirely.
…fore start()

Two bugs:
1. Primary adapter's 'started' handler never set world.botUsername
   (only secondary adapter did). This caused isBotMentioned to always
   be false for TG classic mode on the primary adapter.
2. adapter.start() was called BEFORE event listeners were attached,
   so if 'started' fired synchronously it would be missed.

Fix: set botUsername in primary handler + move start() after all
event registrations.
- /start in groups: requires admin after isGroupAllowed passes
- /stop: requires admin
- /raw via @mention: requires admin
- Regular @mention conversation remains open to all users
- systemd: Restart=on-failure + RestartSec=5 (auto-restart on crash)
- launchd: already has KeepAlive=true (no change needed)
- Startup priority: general_topic instances start first and wait,
  then remaining instances start with staggered concurrency
- Both initial start and restart paths use same priority logic
- General instance failures logged but don't block other startups
TG: /status, /restart, /sysinfo → [Fleet]
TG: /start, /stop, /chat → [ClassicBot]
DC: all slash commands → [ClassicBot]
1. Daily update check: fleet daemon checks npm for new versions every
   24h (first check after 1h). Notifies general topic if update available.
   Beta instances also check @beta tag.

2. /update detached restart: after npm install, spawns a detached shell
   that sleeps 2s then restarts the service. Prevents the restart from
   killing the update response.

3. agend doctor expansion: adds fleet-level checks for fleet.yaml syntax,
   port 19280 availability, stale MCP sockets, service ExecStart mismatch,
   kiro-cli auth, and working_directory existence.
feat: daily update check, /update detached restart, doctor expansion
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