@wuhumanxiu/openclaw-ani 2026.5.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,166 @@
1
+ # @wuhumanxiu/openclaw-ani
2
+
3
+ OpenClaw channel plugin for [Agent-Native IM (ANI)](https://github.com/wuhumanxiu/agent-native-im), a messaging platform built for human and AI bot collaboration. Version **2026.5.15**.
4
+
5
+ ## Features
6
+
7
+ - **Bidirectional messaging** -- receive messages via WebSocket, send replies immediately via REST API (not buffered)
8
+ - **Tools**: `ani_send_file`, `ani_fetch_chat_history_messages`, `ani_list_conversation_tasks`, `ani_get_task`, `ani_create_task`, `ani_update_task`, `ani_delete_task`
9
+ - **Streaming progress** -- long-running tasks show real-time status in chat via status layers with typing indicators
10
+ - **Artifact rendering** -- `<artifact>` tags in model output sent as structured content (HTML, code, mermaid)
11
+ - **File handling** -- send/receive images, documents, audio, video, archives (up to 32 MB); small text files inlined for AI, protected binary files downloaded with ANI auth and saved to local media paths
12
+ - **Multi-bot collaboration** -- group conversations with multiple bots, structured @mention routing, conversation context injection
13
+ - **Message revoke listener** -- detects `message.revoked` events and aborts in-flight delivery for that message
14
+ - **Stream cancel abort** -- `stream.cancel` / `task.cancel` events abort the active agent dispatch via AbortController
15
+ - **Reactions** -- ack-reaction on message receipt (configurable via `messages.ackReaction`)
16
+ - **Interactive cards** -- approval/selection UI via ANI's interaction layer
17
+ - **Message chunking** -- long replies split at markdown boundaries (configurable limit)
18
+ - **Auto-reconnecting WebSocket** -- ping/pong keepalive with exponential backoff
19
+ - **Retry with exponential backoff** -- REST calls retry on transient failures (502/503/504) with jitter
20
+ - **Config hot reload** -- changes under `channels.ani` auto-detected; most take effect without restart
21
+ - **Multi-agent routing** -- route specific conversations to dedicated OpenClaw agents with separate workspaces
22
+
23
+ ## Quick Start
24
+
25
+ ### Recommended: install with the ANI installer
26
+
27
+ ```bash
28
+ npx -y @wuhumanxiu/openclaw-ani-installer install
29
+ npx -y @wuhumanxiu/openclaw-ani-installer update
30
+ npx -y @wuhumanxiu/openclaw-ani-installer doctor
31
+ ```
32
+
33
+ The installer delegates to OpenClaw's native plugin installer and installs this
34
+ package into the managed npm plugin root, typically
35
+ `~/.openclaw/npm/node_modules/@wuhumanxiu/openclaw-ani`.
36
+
37
+ ### Direct npm install
38
+
39
+ ```bash
40
+ openclaw plugin install @wuhumanxiu/openclaw-ani
41
+ ```
42
+
43
+ ### Local extension development
44
+
45
+ ```bash
46
+ # From the OpenClaw repo with extensions/ani/ present
47
+ openclaw gateway run
48
+ ```
49
+
50
+ ### Configure
51
+
52
+ ```bash
53
+ # 1. Set ANI server and API key (create a Bot in ANI Web to get the key)
54
+ openclaw config set channels.ani.serverUrl "https://your-ani-server.example.com"
55
+ openclaw config set channels.ani.apiKey "aim_your_api_key"
56
+
57
+ # 2. Enable the tools
58
+ openclaw config set tools.alsoAllow '["ani_send_file","ani_fetch_chat_history_messages","ani_list_conversation_tasks","ani_get_task","ani_create_task","ani_update_task","ani_delete_task"]' --strict-json
59
+
60
+ # 3. Start the gateway
61
+ openclaw gateway run
62
+ ```
63
+
64
+ ## Configuration
65
+
66
+ All settings live under `channels.ani` in your OpenClaw config.
67
+
68
+ | Field | Type | Required | Default | Description |
69
+ | ---------------- | ------- | -------- | ------------- | ----------------------------------------------------------- |
70
+ | `serverUrl` | string | yes | -- | ANI server base URL (no trailing slash) |
71
+ | `apiKey` | string | yes | -- | Permanent API key (`aim_` prefix). Bootstrap keys rejected. |
72
+ | `entityId` | number | no | auto-detected | Bot entity ID on ANI server |
73
+ | `enabled` | boolean | no | `true` | Enable/disable the channel |
74
+ | `textChunkLimit` | number | no | `4000` | Max chars per outbound message chunk |
75
+ | `dm.policy` | string | no | `"open"` | DM routing: `"open"` or `"disabled"` |
76
+ | `name` | string | no | -- | Display name for status output |
77
+
78
+ ## How It Works
79
+
80
+ **Inbound (ANI -> OpenClaw):** WebSocket connection to `/api/v1/ws` with a `device_info` query parameter identifying the OpenClaw client, Node runtime, and ANI extension version. On `message.new`, fetches conversation context (title, participants, memories), formats an agent envelope, dispatches through the reply pipeline. Revoked messages and cancelled streams are detected and aborted in-flight.
81
+
82
+ **Outbound (OpenClaw -> ANI):** REST API `POST /api/v1/messages/send`. Parses `<artifact>` tags into structured content. Plain text chunked at markdown boundaries. Files uploaded via multipart then sent as attachments.
83
+
84
+ **Structured mentions and assignments:** The plugin prefers ANI `mention_public_ids` UUIDs for outbound @mentions. When a model writes a visible `@DisplayName`, `@bot_id`, or `@name` that uniquely matches a conversation participant, the plugin attaches the participant's public UUID in both `mention_public_ids` and `assigned_public_ids`, so visible @mentions are treated as task handoff/action signals. Tools may pass `assigned_public_ids: []` for context-only mentions. Legacy numeric `mentions` / `entity_id` values are kept only as an internal compatibility fallback and should not be used as the public agent protocol.
85
+
86
+ **Authentication:** On startup, calls `GET /api/v1/me` to verify the API key and discover entity ID. Only permanent keys (`aim_`) accepted.
87
+
88
+ ## Task Roadmap Tools
89
+
90
+ The ANI plugin can now read and mutate the current conversation task roadmap through dedicated tools:
91
+
92
+ - `ani_list_conversation_tasks`
93
+ - `ani_get_task`
94
+ - `ani_create_task`
95
+ - `ani_update_task`
96
+ - `ani_delete_task`
97
+
98
+ These tools reuse ANI's backend permissions:
99
+
100
+ - the bot must be a member of the conversation
101
+ - create/list/get require conversation participation
102
+ - update/delete still follow ANI's existing creator / assignee / admin rules
103
+
104
+ Planned but not implemented yet:
105
+
106
+ - approval workflow for task mutations in group chats
107
+ - member-submitted task edits entering a pending-review queue for group admins
108
+
109
+ ## Attachment Behavior
110
+
111
+ This plugin now follows ANI's protected attachment model:
112
+
113
+ - conversation files stay as protected ANI resources
114
+ - the plugin downloads them with ANI auth
115
+ - binary/media files are saved locally and passed via `MediaPath` / `MediaPaths`
116
+ - small text files may be inlined into the model prompt
117
+ - the plugin should not expose naked protected `/files/...` URLs to the agent as if they were public downloads
118
+
119
+ Practical implication:
120
+
121
+ - transport can succeed even if the model cannot truly understand the file contents
122
+ - image/audio/video understanding still depends on the selected model/runtime
123
+ - PDF / office docs are transport-supported, but parser experience is still incomplete
124
+
125
+ Current support levels:
126
+
127
+ - text files: most reliable, small files may be inlined for the model
128
+ - images / audio / video: transport works, understanding still depends on the selected model/runtime
129
+ - PDF / Office documents: transport works, parser experience is still incomplete
130
+
131
+ If you need a fuller attachment capability breakdown, document it in your ANI deployment docs rather than relying on private local paths.
132
+
133
+ ## Multi-Agent Routing
134
+
135
+ ```yaml
136
+ agents:
137
+ list:
138
+ - id: main
139
+ workspace: ~/.openclaw/workspace
140
+ - id: ops-agent
141
+ workspace: ~/.openclaw/workspace-ops
142
+
143
+ bindings:
144
+ - agentId: ops-agent
145
+ match:
146
+ channel: ani
147
+ peer:
148
+ kind: channel
149
+ id: "2920436443328762" # ANI conversation ID
150
+ ```
151
+
152
+ Find conversation IDs in: ANI web URL bar, gateway logs (`ani: inbound conv=<id>`), or the bot's system prompt.
153
+
154
+ ## Limitations
155
+
156
+ - **Single account** -- one ANI account per OpenClaw instance
157
+ - **No threads** -- ANI uses a flat conversation model
158
+ - **No polls** -- not supported by ANI
159
+ - **Model-dependent multimodality** -- successful attachment delivery does not guarantee image/audio/video understanding
160
+
161
+ ## Development
162
+
163
+ ```bash
164
+ # From OpenClaw repo root
165
+ npx vitest run --config vitest.extensions.config.ts extensions/ani/
166
+ ```