feat(presence): F-5b presence-sync — mirror sm.Machine into Fabric
Adds an internal/presence package that ticks every 30s (configurable
via presence_interval_seconds), reads each bound agent's sm.Machine
state through host.ReadAgentState, maps to Fabric's 6-status enum,
and PUTs diffs to /api/agents/:userId/presence on every guild the
agent belongs to.
Semantic mapping (the part flagged "needed" in the prior README):
idle → idle
working → on_call
busy → busy
offline → offline
exhausted/unknown reserved for backend-side fallbacks; we don't push.
Tick is mutex-guarded (avoids the upsert race the openclaw incident
called out in agent-presence.service.ts) and diff-gated so writes are
sparse. Token-cache invalidation on PUT failure handles guild JWT
rotation.
fabric.Client gains SetAgentPresence helper. README marks F-5b ✅.
This commit is contained in:
15
README.md
15
README.md
@@ -15,7 +15,7 @@ real channel members. Port of `Fabric.OpenclawPlugin` — delivered in phases.
|
||||
| **F-6** | attachments → temp-dir + footer | ✅ |
|
||||
| **F-7** | sub-discussion KV + create-*-channel + discussion-complete | ✅ |
|
||||
| **F-8** | coalesce parity | ⏭ no-op — Plexum doesn't segment deliver |
|
||||
| **F-5b** | presence-sync | ⏭ deferred — Plexum state machine ≠ HF semantics |
|
||||
| **F-5b** | presence-sync | ✅ |
|
||||
|
||||
### Agent-facing tools (16)
|
||||
|
||||
@@ -53,10 +53,21 @@ Then:
|
||||
`~/.plexum/plugins/plexum-fabric-channel/config.json`:
|
||||
```json
|
||||
{
|
||||
"center_api_base": "http://localhost:7001/api"
|
||||
"center_api_base": "http://localhost:7001/api",
|
||||
"commands_sync_key": "...",
|
||||
"presence_interval_seconds": 30
|
||||
}
|
||||
```
|
||||
|
||||
`presence_interval_seconds` (F-5b) controls how often the plugin
|
||||
polls each bound agent's `sm.Machine` state via the host
|
||||
`plexum/host/agent-state/read` RPC and pushes diffs to
|
||||
`PUT /api/agents/:userId/presence` on every guild the agent belongs
|
||||
to. Defaults to 30s; set to 0 to fall back to default. The mapping
|
||||
is `idle→idle`, `working→on_call`, `busy→busy`, `offline→offline`
|
||||
(Fabric's `exhausted`/`unknown` are reserved for backend-side
|
||||
fallbacks; we don't push them). Diff-gated so writes are sparse.
|
||||
|
||||
4. **Bind a Plexum channel name to a Fabric channel** at
|
||||
`~/.plexum/channels/<plexum-channel-name>.json`:
|
||||
```json
|
||||
|
||||
Reference in New Issue
Block a user