Skip to content

feat!: universal agent messaging — no hooks, no plugins, stdin injection#10

Merged
nazq merged 5 commits intomainfrom
feat/agent-messaging-contract
Mar 15, 2026
Merged

feat!: universal agent messaging — no hooks, no plugins, stdin injection#10
nazq merged 5 commits intomainfrom
feat/agent-messaging-contract

Conversation

@nazq
Copy link
Copy Markdown
Owner

@nazq nazq commented Mar 15, 2026

Summary

Replace Claude Code-specific hooks and plugins with a universal agent messaging model that works for all agent types (Claude Code, Codex, OpenCode, scripts).

Phase 1: Delete plugin directory

  • Remove all hooks (stop, idle, heartbeat), skills (SKILL.md), plugin config
  • Inbox endpoint returns raw message objects (no more hook format)
  • Update all docs and tests

Phase 2: Idle-wake message delivery

  • Server-side inbox check on active→idle state transition
  • Peek-then-consume pattern: message survives delivery failure
  • Write to stdin via heimdall INPUT frame
  • Message format: [drasill:message from {sender}] {body}

Phase 3: Mesh awareness system prompt

  • Inject mesh prompt at launch via --append-system-prompt
  • Includes peer discovery and messaging curl commands
  • Port from server config, not hardcoded
  • Uses --json flag in curl (avoids escaping issues)

Test plan

  • 212 tests passing, 96% coverage
  • Each phase reviewed by Sonnet 4.6 — all findings remediated
  • Peek-then-consume verified: message preserved on delivery failure
  • ValueError/TimeoutError/OSError all caught in delivery path
  • Port config propagation tested
  • Agent name appears in JSON payload (not just intro text)

…tion

Delete all hooks, skills, and plugin infrastructure. Agents no longer
need Claude Code-specific plugins for mesh participation.

- Delete plugin/ directory (hooks.json, stop_inbox.sh, idle_inbox.sh,
  SKILL.md, plugin.json, marketplace.json)
- Remove hook format from inbox endpoint — returns raw message object
  instead of Claude Stop hook JSON ({decision: "block", reason: "..."})
- Update all docs: ARCH.md (data flow, lifecycle, ASCII art), mesh.md
  (heartbeat refs, endpoint table, delivery mechanism), plugin.md
  (rewritten as agent integration guide), database.md (column desc),
  README.md (plugin section, project structure, scheduler ref)
- Update test suite: rename hook-format tests, assert against raw
  message fields, remove format=hook/raw parameter tests
- 203 tests passing, 96% coverage
When the pruning loop detects an active→idle transition, deliver
pending inbox messages by writing to the agent's stdin via heimdall
INPUT frame.

- Add peek_next_message() to db.py — reads without consuming
- Add _deliver_inbox_on_idle() to pruning.py — peek → send → consume
  pattern ensures messages survive delivery failure
- Catch OSError, TimeoutError, ValueError from send_input — message
  stays in inbox for retry on next idle cycle
- Cap message body at 4096 bytes to avoid pty buffer overflow
- 5 new tests: delivery, empty inbox, no session, OSError preserves
  message, ValueError handled
- 208 tests passing, 96% coverage
@nazq nazq force-pushed the feat/agent-messaging-contract branch from 8e5e2a5 to 2ed63b7 Compare March 15, 2026 18:09
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.11%. Comparing base (7f34490) to head (13a4ea8).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #10      +/-   ##
==========================================
+ Coverage   96.03%   96.11%   +0.07%     
==========================================
  Files          15       15              
  Lines        1035     1054      +19     
==========================================
+ Hits          994     1013      +19     
  Misses         41       41              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Every agent gets mesh awareness via --append-system-prompt at launch.
The prompt includes the agent's name, peer discovery curl, and message
sending curl — all pointing at the configured server port.

- Add _build_mesh_prompt() to terminal/router.py
- Inject into Claude command via --append-system-prompt
- Use --json flag in curl snippet (avoids single-quote escaping issue)
- Port from AppConfig.server.port, not hardcoded
- Safety comment: agent_name sanitizer ensures JSON/shell safety
- 4 new tests: prompt content, agent name in JSON payload, port config
- 212 tests passing, 96% coverage
@nazq nazq force-pushed the feat/agent-messaging-contract branch from 2ed63b7 to f52f3f2 Compare March 15, 2026 18:15
CLAUDE.md was project instructions for the AI agent — not meant for
contributors. Replace with a proper CONTRIBUTING.md covering setup,
development workflow, code style, testing, architecture, and CI.
All 7 docs updated to reflect heimdall migration, plugin deletion,
and universal agent messaging:

- ARCH.md: fix diagram (remove plugin system, add monitoring loop),
  update module map, fix terminal data flow (subscription not polling),
  fix agent lifecycle (immediate deletion on session gone)
- database.md: add agent_state/state_ms columns, state field semantics
- deployment.md: replace dashboard config with pruning config
- mesh.md: two-stage message delivery, 5s monitoring interval,
  immediate session-gone deletion, RequireAgent type fix
- plugin.md: two-stage delivery model with message formats
- terminal.md: complete rewrite — subscription push model, binary
  WebSocket, mesh prompt injection, file drop endpoint
@nazq nazq merged commit 71ee84a into main Mar 15, 2026
3 checks passed
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