196 Commits

Author SHA1 Message Date
ca7b47e683 fix: avoid clobbering sensitive config fields in install/uninstall
openclaw config get returns redacted values for sensitive fields (apiKey,
token, etc). Reading a parent object and writing it back overwrites real
secrets with the __OPENCLAW_REDACTED__ sentinel.

- install step 5: set only the dirigent provider instead of all providers
- uninstall step 2: set only plugins.load.paths instead of entire plugins tree
2026-04-16 14:33:01 +00:00
h z
4cc787ad90 Merge pull request 'refactor' (#22) from refactor into main
Reviewed-on: #22
2026-04-10 07:49:55 +00:00
41a49e10b3 test: add test plan and test-features script
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-10 08:40:04 +01:00
32dc9a4233 refactor: new design — sidecar services, moderator Gateway client, tool execute API
- Replace standalone no-reply-api Docker service with unified sidecar (services/main.mjs)
  that routes /no-reply/* and /moderator/* and starts/stops with openclaw-gateway
- Add moderator Discord Gateway client (services/moderator/index.mjs) for real-time
  MESSAGE_CREATE push instead of polling; notifies plugin via HTTP callback
- Add plugin HTTP routes (plugin/web/dirigent-api.ts) for moderator → plugin callbacks
  (wake-from-dormant, interrupt tail-match)
- Fix tool registration format: AgentTool requires execute: not handler:; factory form
  for tools needing ctx
- Rename no-reply-process.ts → sidecar-process.ts, startNoReplyApi → startSideCar
- Remove dead config fields from openclaw.plugin.json (humanList, agentList, listMode,
  channelPoliciesFile, endSymbols, waitIdentifier, multiMessage*, bypassUserIds, etc.)
- Rename noReplyPort → sideCarPort
- Remove docker-compose.yml, dev-up/down scripts, package-plugin.mjs, test-no-reply-api.mjs
- Update install.mjs: clean dist before build, copy services/, drop dead config writes
- Update README, Makefile, smoke script for new architecture

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-10 08:07:59 +01:00
d8ac9ee0f9 fix: correct dormancy detection — isEmptyTurn last-line + blocked_pending drain
Two bugs that prevented turn-manager dormancy from ever triggering:

1. isEmptyTurn too strict: agents output multi-line text ending with
   "NO_REPLY" on the last line, but the regex ^NO_REPLY$ required the
   entire string to match. Now checks only the last non-empty line.

2. blocked_pending counter inflation: non-speaker suppressions incremented
   the counter but their stale NO_REPLYs were discarded at the
   !isCurrentSpeaker early return without decrementing. Over a full cycle
   the counter inflated by the number of suppressions, causing the agent's
   real empty turn to be misidentified as stale when it finally arrived.
   Fix: at both early-return points in agent_end (!isCurrentSpeaker and
   !isTurnPending), drain blocked_pending when the turn is empty.

Also fixed: pollForTailMatch now uses any-message detection (instead of
tail-fingerprint content matching) with a 30 s timeout, avoiding infinite
polling when agents send concise Discord messages after verbose LLM output.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-09 15:50:19 +01:00
9e61af4a16 fix: concluded discussions suppress turns and send single auto-reply
Two bugs in concluded discussion channel handling:

1. before_model_resolve did not check rec.discussion.concluded, so it
   still initialized the speaker list and ran turn management. Fixed by
   returning NO_REPLY early for concluded discussions (same as report mode).

2. message_received fired for all agent VM contexts, causing multiple
   "This discussion is closed" auto-replies per incoming message. Fixed
   with process-level dedup keyed on channelId:messageId (same pattern
   as agent_end runId dedup). Also fixed message_id extraction to look
   in metadata.conversation_info.message_id first.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-09 09:02:10 +01:00
27c968fa69 fix: prevent idle reminder from re-waking dormant discussion channel
The moderator bot's own idle reminder message triggered message_received,
which saw senderId != currentSpeaker and called wakeFromDormant, immediately
undoing the dormant state just entered.

Fix: derive the moderator bot's Discord user ID from the token and skip
wake-from-dormant when the sender is the moderator bot itself.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-09 08:17:55 +01:00
c40b756bec fix: cap blocked-pending counter to prevent unbounded drain loops
In busy channels, many messages arrive during a non-speaker turn,
each incrementing the blocked-pending counter. Without a cap the
counter grows faster than it drains, causing the speaker to spin
indefinitely consuming NO_REPLY completions.

Cap at MAX_BLOCKED_PENDING=3 in both incrementBlockedPending and
markTurnStarted (retroactive cap to recover from accumulated debt).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-09 08:11:44 +01:00
74e6d61d4d fix: correct channelId extraction and dormant check in hooks
message-received.ts:
- message_received ctx has channelId/accountId/conversationId (not
  sessionKey). Add extraction from ctx.channelId and metadata.to
  ("channel:ID" format) before the conversation_info fallback.

agent-end.ts:
- When tail-match is interrupted, only call wakeFromDormant() if the
  channel is actually dormant. For non-dormant interrupts (e.g. the
  moderator bot's own trigger messages firing message_received on
  other agents), fall through to normal advanceSpeaker() so the turn
  cycle continues correctly instead of re-triggering the same speaker.
- Import isDormant from turn-manager.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-09 06:24:05 +01:00
b9cbb7e895 fix: change control page routes from gateway to plugin auth
auth: "gateway" requires Bearer token in Authorization header,
which browser direct navigation never sends (no session cookies).
auth: "plugin" allows unauthenticated access on loopback, which
is sufficient since gateway is bound to 127.0.0.1 only.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-09 01:15:29 +01:00
b5196e972c feat: rewrite plugin as v2 with globalThis-based turn management
Complete rewrite of the Dirigent plugin turn management system to work
correctly with OpenClaw's VM-context-per-session architecture:

- All turn state stored on globalThis (persists across VM context hot-reloads)
- Hooks registered unconditionally on every api instance; event-level dedup
  (runId Set for agent_end, WeakSet for before_model_resolve) prevents
  double-processing
- Gateway lifecycle events (gateway_start/stop) guarded once via globalThis flag
- Shared initializingChannels lock prevents concurrent channel init across VM
  contexts in message_received and before_model_resolve
- New ChannelStore and IdentityRegistry replace old policy/session-state modules
- Added agent_end hook with tail-match polling for Discord delivery confirmation
- Added web control page, padded-cell auto-scan, discussion tool support
- Removed obsolete v1 modules: channel-resolver, channel-modes, discussion-service,
  session-state, turn-bootstrap, policy/store, rules, decision-input

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-08 22:41:25 +01:00
dea345698b feat: add /list-guilds slash command 2026-04-05 19:42:36 +00:00
d8dcd59715 docs: use {baseDir} placeholder in SKILL.md 2026-04-05 19:28:31 +00:00
fd33290266 feat: add /add-guild slash command 2026-04-05 19:24:06 +00:00
9aa85fdbc5 fix: simplify add-guild script using line-based insertion 2026-04-05 18:51:35 +00:00
c9bed19689 feat: add discord-guilds skill with table merge on install 2026-04-05 18:48:10 +00:00
zhi
895cfe3bab fix: align discussion workspace and tool schemas 2026-04-02 11:52:20 +00:00
zhi
7bccb660df fix: wake origin workflow after discussion callback 2026-04-02 08:20:23 +00:00
zhi
29f1f01219 docs: finalize channel mode and shuffle docs 2026-04-02 07:48:25 +00:00
zhi
15f7d211d7 test: cover discussion hook close and idle behavior 2026-04-02 07:19:57 +00:00
zhi
0f38e34bec test: cover discussion tool registration flows 2026-04-02 06:48:29 +00:00
zhi
b11c15d8c8 test: stabilize channel mode and discussion coverage 2026-04-02 06:18:16 +00:00
zhi
4e0a24333e Complete CSM and channel modes implementation
- Add comprehensive tests for shuffle mode functionality
- Add comprehensive tests for multi-message mode functionality
- Add compatibility tests between different channel modes
- Update documentation to reflect completed implementation
- Mark all completed tasks as finished in TASKLIST.md
- Update CHANNEL_MODES_AND_SHUFFLE.md with implementation status and acceptance criteria
2026-04-02 06:08:48 +00:00
zhi
b40838f259 Refine discussion closure messaging 2026-04-02 05:48:00 +00:00
zhi
16daab666b Complete remaining CSM and channel modes tasks
- Confirmed CSM MVP scope and requirements
- Finalized discussion idle reminder and closed channel templates
- Updated all remaining task statuses as completed
- Verified all functionality through tests
2026-04-02 05:33:14 +00:00
zhi
b7b405f416 test: cover discussion callback flows 2026-04-02 05:18:04 +00:00
zhi
7670d41785 Complete A6 and A7 tasks: Implement closed discussion channel protections and update tasklist
- Complete tasks A6.1, A6.2, A6.3: Turn manager discussion mode handling
- Complete tasks A7.1, A7.2, A7.3, A7.5: Hook-level discussion channel protections
- Add closed discussion channel check to message-sent hook to prevent handoffs
- Update TASKLIST.md to mark completed tasks with [x]
2026-04-02 05:04:47 +00:00
zhi
d44204fabf feat: wire channel mode runtime config and docs 2026-04-02 04:48:20 +00:00
zhi
8073c33f2c docs: update TASKLIST.md with completed multi-message and shuffle mode tasks 2026-04-02 04:37:35 +00:00
zhi
bfbe40b3c6 feat: implement multi-message mode and shuffle mode features
- Add multi-message mode with start/end/prompt markers
- Implement turn order shuffling with /turn-shuffling command
- Add channel mode state management
- Update hooks to handle multi-message mode behavior
- Update plugin config with new markers
- Update TASKLIST.md with completed tasks
2026-04-02 04:36:36 +00:00
zhi
684f8f9ee7 Refine discussion moderator messaging flow 2026-04-02 04:18:45 +00:00
zhi
d9bb5c2e21 Fix discussion channel closure handling 2026-04-02 03:49:03 +00:00
zhi
2c870ea2c5 chore(csm): remove cron helper script 2026-04-02 02:56:20 +00:00
zhi
b9933d899a chore(csm): use claimed-task state machine 2026-04-02 02:49:23 +00:00
zhi
62cd2f20cf feat(csm): bootstrap discussion callback flow 2026-04-02 02:35:08 +00:00
h z
9fa71f37bf Merge pull request 'Use api.pluginConfig directly for Dirigent runtime config' (#20) from fix/use-pluginconfig-runtime-config into main
Reviewed-on: #20
2026-04-01 20:32:39 +00:00
81687e548a Preserve existing Dirigent config during install 2026-04-01 20:17:00 +00:00
0a99abc7e3 Use pluginConfig directly for Dirigent runtime config 2026-04-01 20:01:57 +00:00
nav
0a76dae376 docs: reorganize planning and archive files 2026-03-31 12:46:09 +00:00
nav
dbd0fc68c0 docs: add channel modes plan and expand tasklist 2026-03-31 09:16:59 +00:00
nav
4dde4f6efe docs: align CSM terminology with code 2026-03-30 18:24:24 +00:00
nav
3b5ca21f40 docs: add CSM discussion callback design 2026-03-30 18:14:58 +00:00
c2fe859ea5 Merge pull request 'fix/gateway-keywords-no-empty' (#19) from fix/gateway-keywords-no-empty into main
Reviewed-on: #19
2026-03-10 13:56:45 +00:00
nav
4905f37c1a fix: limit no-reply keywords and log 2026-03-10 13:53:32 +00:00
nav
e6b20e9d52 feat: treat NO/empty as gateway no-reply 2026-03-10 13:42:50 +00:00
13d5b95081 Merge pull request 'fix/no-reply-empty-content-detection' (#18) from fix/no-reply-empty-content-detection into main
Reviewed-on: #18
2026-03-09 21:49:59 +00:00
zhi
08f42bfd92 fix: skip rules-based no-reply override when turn manager allows agent
When the turn manager determines it's an agent's turn (checkTurn.allowed),
the rules engine's evaluateDecision() could still override the model to
no-reply with reason 'rule_match_no_end_symbol'. This happened because:

1. The sender of the triggering message (another agent) was not in the
   humanList, so the rules fell through to the end-symbol check.
2. getLastChar() operates on the full prompt (including system content
   like Runtime info), so it never found the end symbol even when the
   actual message ended with one.

Fix: return early from before_model_resolve after the turn check passes,
skipping the rules-based no-reply override entirely. The turn manager is
the authoritative source for multi-agent turn coordination.

Tested: 3-agent counting chain ran successfully (3→11) with correct
NO_REPLY handling when count exceeded threshold.
2026-03-09 21:16:53 +00:00
zhi
bddc7798d8 fix: add no-reply model to agents.defaults.models allowlist
Changes:
- Change default provider ID from 'dirigentway' to 'dirigent'
- Add no-reply model to agents.defaults.models allowlist during install
- Fix no-reply-api server default model name from 'dirigent-no-reply-v1' to 'no-reply'

This fixes the issue where dirigent/no-reply model was not showing in
'openclaw models list' and was being rejected as 'not allowed'.
2026-03-09 13:12:35 +00:00
zhi
1f846fa7aa fix: stop treating empty content as NO_REPLY, detect tool calls
Problems fixed:
1. before_message_write treated empty content (isEmpty) as NO_REPLY.
   Tool-call-only assistant messages (thinking + toolCall, no text)
   had empty extracted text, causing false NO_REPLY detection.
   In single-agent channels this immediately set turn to dormant,
   blocking all subsequent responses for the entire model run.

2. Added explicit toolCall/tool_call/tool_use detection in
   before_message_write — skip turn processing for intermediate
   tool-call messages entirely.

3. no-reply-api/server.mjs: default model name changed from
   'dirigent-no-reply-v1' to 'no-reply' to match the configured
   model id in openclaw.json, fixing model list discovery.

Changes:
- plugin/hooks/before-message-write.ts: toolCall detection + remove isEmpty
- plugin/hooks/message-sent.ts: remove isEmpty from wasNoReply
- no-reply-api/server.mjs: fix default model name
- dist/dirigent/index.ts: same fixes applied to monolithic build
- dist/no-reply-api/server.mjs: same model name fix
2026-03-09 12:00:36 +00:00
68c13d9eef Merge pull request 'feat: split dirigent_tools + human @mention override' (#14) from feat/split-tools-and-mention-override into main
Reviewed-on: #14
2026-03-08 08:02:27 +00:00