hzhang d6bea46d00 feat: Phase F-3 + F-4 — exp backoff + agent tool surface (batch 1)
F-3 refinements:
- internal/inbound: replace fixed 3s reconnect wait with exponential
  backoff (1s → 60s, ×2, reset when prior session lasted >30s); proxy
  for "healthy" vs "flapping" and avoids hot reconnect loops when the
  server is sick

F-4 agent tool surface (port of openclaw plugin's tools.ts):
- internal/tools/tools.go (~370 LOC): Registry binds Deps {Client,
  Tokens, Identities} and exposes 8 agent-facing tools:
    fabric-send-message     post a normal message to any channel
    fabric-send-sys-msg     post a kind=sys message (bypasses turn engine)
    fabric-channel-list     list channels visible in a guild
    fabric-guild-list       list guilds the agent is in
    fabric-message-history  paginate channel messages by seq
    fabric-channel-set-purpose  PATCH the channel's purpose
    fabric-channel          fetch metadata + members for one channel
    fabric-canvas           get/share/update/remove channel canvas
- internal/tools/contracts.go: static ToolContract list — kept in sync
  with install.sh's manifest emitter
- Every agent-scoped tool requires agent_id in input args (Plexum SDK
  doesn't propagate calling agent id through CallTool today)
- guild_node_id defaults to agent's first guild for fabric-send-message

internal/fabric/client.go: new REST methods needed by tools —
PostSystemMessage, CreateChannel, CloseChannel, JoinChannel,
LeaveChannel, SetChannelPurpose, GetCanvas, ShareCanvas, UpdateCanvas,
RemoveCanvas, SyncCommands.

cmd/plexum-fabric-channel-plugin/main.go:
- Manifest declares the tool surface via tools.New(...).Contracts()
- CallTool dispatches "send" to handleSend (outbound for channel
  manager), everything else to tools.Registry.Handler(name)

scripts/install.sh:
- Manifest tools[] now lists all 9 tools with schemas — matches what
  internal/tools/contracts.go advertises

Live verified against running Fabric stack:
  $ plexum plugin-call fabric-guild-list '{"agent_id":"fabrictester"}'
    → "guilds for agent fabrictester (1): test-guild2 @ http://localhost:7003"
  $ plexum plugin-call fabric-channel-list '{...,"guild_node_id":"test-guild2"}'
    → 2 channels listed
  $ plexum plugin-call fabric-message-history '{...,"limit":5}'
    → 5 messages with timestamps + authors

F-5+ deferred:
- create-{chat,work,report,discussion}-channel (batch 2)
- sub-discussion family (state store + 3 tools)
- presence-sync + command-sync
- attachments

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-31 15:35:39 +01:00

Plexum-fabric-channel-plugin

Native Plexum channel plugin connecting Plexum agents to Fabric guilds as real channel members. Inspired by Fabric.OpenclawPlugin — Plexum port, delivered in phases.

Status

Phase F-1 (foundation) — current: identity registry, Center auth, REST client, plugin scaffold, channel-binding discovery. The send outbound tool posts plain text to a Fabric channel as the bound agent.

Phase F-2 (deferred): socket.io inbound, wakeup-gated dispatch, token refresh, per-channel serial queue.

Phase F-3+ (deferred): tools.ts port (~15 MCP tools — channel/canvas/ sub-discussion/etc.), presence sync, command sync, attachments, coalesce parity.

Install

cd ~/Plexum-fabric-channel-plugin
./scripts/install.sh                  # build + install plugin + register CLI

Then:

  1. Mint a Center API key for each Plexum agent that should speak in Fabric:

    docker exec fabric-backend-center node dist/cli.js user apikey --email <agent-email>
    
  2. Register the key with Plexum:

    plexum-fabric-register --agent-id alice --api-key fak_xxxx
    # writes ~/.plexum/fabric-identity.json
    
  3. Configure plugin-level settings at ~/.plexum/plugins/plexum-fabric-channel/config.json:

    {
      "center_api_base": "http://localhost:7001/api"
    }
    
  4. Bind a Plexum channel name to a Fabric channel at ~/.plexum/channels/<plexum-channel-name>.json:

    {
      "agent_id": "alice",
      "plugin": "plexum-fabric-channel",
      "fabric": {
        "guild_node_id": "test-guild1",
        "channel_id": "ch_xxxxxxxxx"
      }
    }
    
  5. Allow the plugin in ~/.plexum/plexum.json:

    {"plugins": {"allow": ["plexum-fabric-channel"]}}
    
  6. Restart the gateway: systemctl --user restart plexum

What you get in F-1

  • Plugin loads at gateway start, validates every bound agent's API key against Center via agentLogin, and warms a session per agent.
  • send MCP tool posts plain text to the bound Fabric channel as the agent user.
  • No inbound yet — Fabric → Plexum routing arrives in F-2.

Build manually

go build -o bin/plexum-fabric-channel-plugin ./cmd/plexum-fabric-channel-plugin
go build -o bin/plexum-fabric-register      ./cmd/plexum-fabric-register

License

Same as Plexum.

Description
Native Plexum channel plugin for Fabric
Readme 158 KiB
Languages
Go 92.9%
Shell 7.1%