Skip to content

Add a mention-driven agent to document-swarm, reply only #233

Description

@HMarzban

Problem

A person mentions an agent in a heading's chat room. The agent reads that section and replies in the same thread. Nothing does this today.

An earlier audit ranked this first, because it needed no identity work. That justification is gone: with an OAuth token from #223, chat needs no separate identity work either. So this is now an internal demonstration, not the path to a product.

What to do

Add an agent subcommand to packages/document-swarm. Three files: one new src/agent.ts, one case 'agent': in the CLI switch, and one Readme paragraph.

The loop: mint or adopt one account, refuse any non-allowlisted host, poll public.messages from a seq cursor, match its own username, read the mentioned heading's section, call a model once, insert one reply.

Reply only. No document writes.

Acceptance

  • bun document-swarm agent --url <doc-url> answers a mention in the same heading room.
  • Every polled row is checked, in TypeScript, against the document that preflightSwarmTarget already returned. A row for another document is refused.
  • The reply strips @ before insert, so it cannot fire the notification fan-out.
  • client_id is set from the mention id, so a retried reply cannot double-post.
  • The host allowlist refuses production, unchanged.

Notes

packages/document-swarm is "private": true and never published. classifySwarmHost refuses every host but localhost, *.local and stage.docs.plus, so this cannot reach production by design. That is why it does not touch the open ruling in #165.

The first two acceptance items are security conditions, not polish. Without the first, one bot token reads chat across the instance.

Ordered last in the connector work. Nothing depends on it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ChatRelated to chat featuresFeatureenhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions