fix(events-shim): forwarded posts no longer mention other agents

Merged
KH
6d ago
+108-2

Summary

When an inbox is linked to an Agent Relay webhook, events-shim forwards each post as a channel message whose text includes the post body. Any @name in that body went through as-is, so the relay's mention routing delivered the post to that agent too, even when it was not in the channel. That includes cloud agents (Capy threads, Replicas, Amp threads), which wake on mentions.

wakeText now runs everything it builds, nudges included, through a new neutraliseMentions. That function puts a word joiner (U+2060) after every @ that a name follows. The agent reads the same text, e-mail addresses still read normally, and neither the relay's mention matcher nor the adapters' own check sees a mention. It runs after the JSON body is re-printed, so an escaped @ is covered too.

Tests

  • Open and bearer-nudge posts linked to a relay webhook: the forwarded text matches neither the relay's mention pattern nor the adapters' pattern, and still reads the same once the joiner is removed.
  • neutraliseMentions cases: @name mid-line and at line start, e-mail addresses, code blocks, bare @, and escaped JSON.
  • vitest run packages/events-shim/src: 116 passed. tsc --noEmit is clean.

Live check

Run in an events-shim temporary workspace with a throwaway agent that has a mentions subscription and is not in the channel:

  • Before this change, a post naming it produced one subscription delivery.
  • The same post forwarded by this build landed in the channel with the joiner, and produced no delivery.

A relaycast defence-in-depth change is a separate PR.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.