badgerclaw 0.1.7 → 1.4.0

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.
Files changed (105) hide show
  1. package/CHANGELOG.md +104 -0
  2. package/SETUP.md +291 -0
  3. package/index.ts +47 -0
  4. package/openclaw.plugin.json +1 -0
  5. package/package.json +32 -34
  6. package/scripts/postinstall.js +34 -0
  7. package/src/actions.ts +195 -0
  8. package/src/channel.ts +461 -0
  9. package/src/config-schema.ts +62 -0
  10. package/src/connect.ts +17 -0
  11. package/src/directory-live.ts +209 -0
  12. package/src/group-mentions.ts +103 -0
  13. package/src/matrix/accounts.ts +114 -0
  14. package/src/matrix/actions/client.ts +47 -0
  15. package/src/matrix/actions/limits.ts +6 -0
  16. package/src/matrix/actions/messages.ts +126 -0
  17. package/src/matrix/actions/pins.ts +84 -0
  18. package/src/matrix/actions/reactions.ts +102 -0
  19. package/src/matrix/actions/room.ts +85 -0
  20. package/src/matrix/actions/summary.ts +75 -0
  21. package/src/matrix/actions/types.ts +85 -0
  22. package/src/matrix/actions.ts +15 -0
  23. package/src/matrix/active-client.ts +32 -0
  24. package/src/matrix/client/backup.ts +91 -0
  25. package/src/matrix/client/config.ts +274 -0
  26. package/src/matrix/client/create-client.ts +125 -0
  27. package/src/matrix/client/logging.ts +46 -0
  28. package/src/matrix/client/runtime.ts +4 -0
  29. package/src/matrix/client/shared.ts +223 -0
  30. package/src/matrix/client/startup.ts +29 -0
  31. package/src/matrix/client/storage.ts +131 -0
  32. package/src/matrix/client/types.ts +34 -0
  33. package/src/matrix/client-bootstrap.ts +47 -0
  34. package/src/matrix/client.ts +14 -0
  35. package/src/matrix/credentials.ts +125 -0
  36. package/src/matrix/deps.ts +126 -0
  37. package/src/matrix/format.ts +22 -0
  38. package/src/matrix/index.ts +11 -0
  39. package/src/matrix/monitor/access-policy.ts +126 -0
  40. package/src/matrix/monitor/allowlist.ts +94 -0
  41. package/src/matrix/monitor/auto-join.ts +126 -0
  42. package/src/matrix/monitor/bot-commands.ts +431 -0
  43. package/src/matrix/monitor/chat-history.ts +75 -0
  44. package/src/matrix/monitor/direct.ts +152 -0
  45. package/src/matrix/monitor/events.ts +250 -0
  46. package/src/matrix/monitor/handler.ts +847 -0
  47. package/src/matrix/monitor/inbound-body.ts +28 -0
  48. package/src/matrix/monitor/index.ts +414 -0
  49. package/src/matrix/monitor/location.ts +100 -0
  50. package/src/matrix/monitor/media.ts +118 -0
  51. package/src/matrix/monitor/mentions.ts +62 -0
  52. package/src/matrix/monitor/replies.ts +124 -0
  53. package/src/matrix/monitor/room-info.ts +55 -0
  54. package/src/matrix/monitor/rooms.ts +47 -0
  55. package/src/matrix/monitor/threads.ts +68 -0
  56. package/src/matrix/monitor/types.ts +39 -0
  57. package/src/matrix/poll-types.ts +167 -0
  58. package/src/matrix/probe.ts +69 -0
  59. package/src/matrix/sdk-runtime.ts +18 -0
  60. package/src/matrix/send/client.ts +99 -0
  61. package/src/matrix/send/formatting.ts +93 -0
  62. package/src/matrix/send/media.ts +230 -0
  63. package/src/matrix/send/targets.ts +150 -0
  64. package/src/matrix/send/types.ts +110 -0
  65. package/src/matrix/send-queue.ts +28 -0
  66. package/src/matrix/send.ts +267 -0
  67. package/src/onboarding.ts +350 -0
  68. package/src/outbound.ts +58 -0
  69. package/src/resolve-targets.ts +125 -0
  70. package/src/runtime.ts +6 -0
  71. package/src/secret-input.ts +13 -0
  72. package/src/test-mocks.ts +53 -0
  73. package/src/tool-actions.ts +164 -0
  74. package/src/types.ts +121 -0
  75. package/README.md +0 -32
  76. package/dist/commands/autopair.d.ts +0 -3
  77. package/dist/commands/autopair.js +0 -102
  78. package/dist/commands/autopair.js.map +0 -1
  79. package/dist/commands/bot.d.ts +0 -2
  80. package/dist/commands/bot.js +0 -94
  81. package/dist/commands/bot.js.map +0 -1
  82. package/dist/commands/login.d.ts +0 -2
  83. package/dist/commands/login.js +0 -88
  84. package/dist/commands/login.js.map +0 -1
  85. package/dist/commands/logout.d.ts +0 -2
  86. package/dist/commands/logout.js +0 -36
  87. package/dist/commands/logout.js.map +0 -1
  88. package/dist/commands/status.d.ts +0 -2
  89. package/dist/commands/status.js +0 -23
  90. package/dist/commands/status.js.map +0 -1
  91. package/dist/commands/watch.d.ts +0 -2
  92. package/dist/commands/watch.js +0 -29
  93. package/dist/commands/watch.js.map +0 -1
  94. package/dist/index.d.ts +0 -2
  95. package/dist/index.js +0 -23
  96. package/dist/index.js.map +0 -1
  97. package/dist/lib/api.d.ts +0 -4
  98. package/dist/lib/api.js +0 -37
  99. package/dist/lib/api.js.map +0 -1
  100. package/dist/lib/auth.d.ts +0 -11
  101. package/dist/lib/auth.js +0 -48
  102. package/dist/lib/auth.js.map +0 -1
  103. package/dist/lib/pkce.d.ts +0 -2
  104. package/dist/lib/pkce.js +0 -15
  105. package/dist/lib/pkce.js.map +0 -1
package/CHANGELOG.md ADDED
@@ -0,0 +1,104 @@
1
+ # Changelog
2
+
3
+ ## 2026.3.13
4
+
5
+ ### Changes
6
+
7
+ - Version alignment with core OpenClaw release numbers.
8
+
9
+ ## 2026.3.12
10
+
11
+ ### Changes
12
+
13
+ - Version alignment with core OpenClaw release numbers.
14
+
15
+ ## 2026.3.11
16
+
17
+ ### Changes
18
+
19
+ - Version alignment with core OpenClaw release numbers.
20
+
21
+ ## 2026.3.10
22
+
23
+ ### Changes
24
+
25
+ - Version alignment with core OpenClaw release numbers.
26
+
27
+ ## 2026.3.9
28
+
29
+ ### Changes
30
+
31
+ - Version alignment with core OpenClaw release numbers.
32
+
33
+ ## 2026.3.8-beta.1
34
+
35
+ ### Changes
36
+
37
+ - Version alignment with core OpenClaw release numbers.
38
+
39
+ ## 2026.3.8
40
+
41
+ ### Changes
42
+
43
+ - Version alignment with core OpenClaw release numbers.
44
+
45
+ ## 2026.3.7
46
+
47
+ ### Changes
48
+
49
+ - Version alignment with core OpenClaw release numbers.
50
+
51
+ ## 2026.3.3
52
+
53
+ ### Changes
54
+
55
+ - Version alignment with core OpenClaw release numbers.
56
+
57
+ ## 2026.3.2
58
+
59
+ ### Changes
60
+
61
+ - Version alignment with core OpenClaw release numbers.
62
+
63
+ ## 2026.3.1
64
+
65
+ ### Changes
66
+
67
+ - Version alignment with core OpenClaw release numbers.
68
+
69
+ ## 2026.2.26
70
+
71
+ ### Changes
72
+
73
+ - Version alignment with core OpenClaw release numbers.
74
+
75
+ ## 2026.2.25
76
+
77
+ ### Changes
78
+
79
+ - Version alignment with core OpenClaw release numbers.
80
+
81
+ ## 2026.2.24
82
+
83
+ ### Changes
84
+
85
+ - Version alignment with core OpenClaw release numbers.
86
+
87
+ ## 2026.2.22
88
+
89
+ ### Changes
90
+
91
+ - Version alignment with core OpenClaw release numbers.
92
+
93
+ ## 2026.1.14
94
+
95
+ ### Features
96
+
97
+ - Matrix channel plugin with homeserver + user ID auth (access token or password login with device name).
98
+ - Direct messages with pairing/allowlist/open/disabled policies and allowFrom support.
99
+ - Group/room controls: allowlist policy, per-room config, mention gating, auto-reply, per-room skills/system prompts.
100
+ - Threads: replyToMode controls and thread replies (off/inbound/always).
101
+ - Messaging: text chunking, media uploads with size caps, reactions, polls, typing, and message edits/deletes.
102
+ - Actions: read messages, list/remove reactions, pin/unpin/list pins, member info, room info.
103
+ - Auto-join invites with allowlist support.
104
+ - Status + probe reporting for health checks.
package/SETUP.md ADDED
@@ -0,0 +1,291 @@
1
+ # BadgerClaw + OpenClaw — Setup Guide
2
+
3
+ Connect your OpenClaw AI agent to BadgerClaw encrypted chat rooms.
4
+
5
+ ## Prerequisites
6
+
7
+ - **BadgerClaw iOS app** installed and logged in
8
+ - **OpenClaw** installed on your machine (`npm install -g openclaw`)
9
+
10
+ ---
11
+
12
+ ## Step 1: Create a Bot in BadgerClaw
13
+
14
+ Open the BadgerClaw app on your phone.
15
+
16
+ 1. Open any room or DM with BotBadger
17
+ 2. Type: `/bot new`
18
+ 3. Follow the guided flow to set a bot name and username
19
+ 4. BotBadger responds with a pairing code:
20
+
21
+ ```
22
+ 🦡 Bot created!
23
+
24
+ Name: jarvis
25
+ Connect to OpenClaw:
26
+ openclaw badgerclaw connect BCK-A8F3-X9K2
27
+
28
+ Code expires in 24 hours.
29
+ ```
30
+
31
+ 5. **Copy the pairing code** (BCK-XXXX-XXXX)
32
+
33
+ > **Need a new code?** Type `/bot pair <name>` to regenerate.
34
+
35
+ ---
36
+
37
+ ## Step 2: Install the BadgerClaw Plugin
38
+
39
+ On your machine (Mac, PC, Linux, Pi), run:
40
+
41
+ ```bash
42
+ openclaw plugins install @badgerclaw/connect
43
+ ```
44
+
45
+ Or install from source:
46
+
47
+ ```bash
48
+ git clone https://github.com/darkstaar4/badgerclaw-plugin.git
49
+ openclaw plugins install ./badgerclaw-plugin
50
+ ```
51
+
52
+ ---
53
+
54
+ ## Step 3: Connect with Pairing Code
55
+
56
+ ```bash
57
+ openclaw badgerclaw connect BCK-XXXX-XXXX
58
+ ```
59
+
60
+ Or run the full configure wizard:
61
+
62
+ ```bash
63
+ openclaw configure
64
+ ```
65
+
66
+ The plugin automatically:
67
+ - Validates the code with BadgerClaw servers
68
+ - Retrieves your bot's credentials
69
+ - Enables end-to-end encryption
70
+ - Configures auto-join for room invites
71
+ - Sets up auto-reply in group chats
72
+
73
+ ---
74
+
75
+ ## Step 4: Start Chatting
76
+
77
+ Restart the OpenClaw gateway:
78
+
79
+ ```bash
80
+ openclaw gateway restart
81
+ ```
82
+
83
+ Now in the BadgerClaw app:
84
+
85
+ 1. **DM your bot** — find it in your contacts and send a message
86
+ 2. **Add to a room** — type `/bot add <name>` in any room
87
+ 3. **Add to a Space** — add the bot to any room inside a Space
88
+
89
+ Your OpenClaw agent will receive messages and respond — fully end-to-end encrypted.
90
+
91
+ ---
92
+
93
+ ## Bot Commands
94
+
95
+ Use these commands in any BadgerClaw room or DM where your bot is present.
96
+
97
+ | Command | Description |
98
+ |---------|-------------|
99
+ | `/bot help` | Show all available commands |
100
+ | `/bot talk on` | **Enable auto-reply** — bot responds to every message without needing an @mention. If multiple bots are in the room, you'll be asked to specify which one. |
101
+ | `/bot talk on @botname` | **Enable auto-reply for a specific bot** — use when multiple bots are in the room. |
102
+ | `/bot talk off` | **Disable auto-reply for ALL bots** — kill switch. All bots in the room go quiet and only respond when @mentioned. |
103
+ | `/bot add <name>` | Invite a bot to the current room (e.g. `/bot add jarvis`) |
104
+ | `/bot list` | List all your bots and their connection status |
105
+
106
+ ### How Auto-Reply Works
107
+
108
+ - **New installs:** Auto-reply is **ON by default** in all rooms
109
+ - **Per-room toggle:** `/bot talk on` and `/bot talk off` override the default for that specific room
110
+ - **Multi-bot rooms:** If multiple bots are present, `/bot talk on` asks which bot to enable. `/bot talk off` silences all bots at once.
111
+ - **@mentions always work:** Even with auto-reply off, the bot responds when @mentioned
112
+
113
+ ---
114
+
115
+ ## Group Chat Configuration
116
+
117
+ ### Default Behavior
118
+
119
+ When you install BadgerClaw with a fresh pairing code, the plugin automatically configures:
120
+
121
+ ```json
122
+ {
123
+ "groupPolicy": "open",
124
+ "groups": {
125
+ "*": {
126
+ "autoReply": true,
127
+ "enabled": true
128
+ }
129
+ }
130
+ }
131
+ ```
132
+
133
+ This means:
134
+ - Bot joins any room it's invited to
135
+ - Bot responds to all messages (no @mention required)
136
+ - Bot uses **your OpenClaw workspace personality** (SOUL.md, IDENTITY.md, etc.) in all conversations — groups and DMs alike
137
+
138
+ When the bot joins a new encrypted room, it sends a hint message explaining the `/bot talk on|off` commands so room members know how to control it.
139
+
140
+ ### Your Personality, Everywhere
141
+
142
+ BadgerClaw respects your OpenClaw workspace files. If you've configured a custom personality (SOUL.md), the bot uses that personality in groups and DMs. This means:
143
+
144
+ - A "pirate assistant" SOUL.md → bot talks like a pirate in groups
145
+ - A "professional COO" SOUL.md → bot acts professional in groups
146
+ - No SOUL.md → bot uses the default helpful assistant behavior
147
+
148
+ **If your bot stays silent in groups**, your workspace files may include instructions like "stay silent in groups" or "only respond when needed." To fix this:
149
+
150
+ 1. Edit your SOUL.md to allow group responses, OR
151
+ 2. Add a group-specific system prompt override:
152
+
153
+ ```json
154
+ {
155
+ "channels": {
156
+ "badgerclaw": {
157
+ "groups": {
158
+ "*": {
159
+ "autoReply": true,
160
+ "systemPrompt": "You are a helpful AI assistant. Always respond to messages in group chats."
161
+ }
162
+ }
163
+ }
164
+ }
165
+ }
166
+ ```
167
+
168
+ ### Per-Room Configuration
169
+
170
+ You can configure specific rooms differently:
171
+
172
+ ```json
173
+ {
174
+ "channels": {
175
+ "badgerclaw": {
176
+ "groups": {
177
+ "*": { "autoReply": true },
178
+ "!specificRoomId:server": {
179
+ "autoReply": false,
180
+ "systemPrompt": "Custom prompt for this room only"
181
+ }
182
+ }
183
+ }
184
+ }
185
+ }
186
+ ```
187
+
188
+ ---
189
+
190
+ ## Upgrading from v1.1.x or Earlier
191
+
192
+ If you installed BadgerClaw before v1.2.0, your config is missing the group auto-reply settings. The bot may not respond in group chats without @mentions.
193
+
194
+ **Quick fix — run the update command:**
195
+
196
+ ```bash
197
+ openclaw plugins update @badgerclaw/connect
198
+ openclaw configure
199
+ ```
200
+
201
+ Select BadgerClaw and re-enter a pairing code. The new onboarding will add the missing group config automatically.
202
+
203
+ **Manual fix — if you don't want to re-pair:**
204
+
205
+ Add this to your `~/.openclaw/openclaw.json` inside `channels.badgerclaw`:
206
+
207
+ ```json
208
+ {
209
+ "channels": {
210
+ "badgerclaw": {
211
+ "groupPolicy": "open",
212
+ "groups": {
213
+ "*": {
214
+ "autoReply": true,
215
+ "enabled": true
216
+ }
217
+ }
218
+ }
219
+ }
220
+ }
221
+ ```
222
+
223
+ Then restart: `openclaw gateway restart`
224
+
225
+ ---
226
+
227
+ ## FAQ
228
+
229
+ ### Bot doesn't respond in group chats
230
+
231
+ 1. Send `/bot talk on` in the room to enable auto-reply
232
+ 2. Make sure the bot is a member of the room (`/bot add <name>`)
233
+ 3. Check OpenClaw is running: `openclaw status`
234
+
235
+ ### Bot shows typing indicator but never replies
236
+
237
+ Your workspace personality (SOUL.md) may tell the agent to stay silent in groups. BadgerClaw respects your workspace files, so if SOUL.md says "don't respond in groups," the bot won't.
238
+
239
+ **Fix options:**
240
+ 1. Edit your SOUL.md to allow group responses
241
+ 2. Add a `systemPrompt` override in `channels.badgerclaw.groups.*` that tells the agent to respond (see Group Chat Configuration above)
242
+ 3. Run `openclaw configure` and reconfigure BadgerClaw
243
+
244
+ ### `/bot talk on` doesn't work
245
+
246
+ After changing bot commands, you may need to restart the gateway:
247
+
248
+ ```bash
249
+ openclaw gateway restart
250
+ ```
251
+
252
+ ### Bot responds with wrong personality
253
+
254
+ The bot uses your **OpenClaw workspace personality** (SOUL.md, IDENTITY.md) for both DMs and groups. To set a different personality for groups only, add a `systemPrompt` in `channels.badgerclaw.groups.*` in your config.
255
+
256
+ ### Bot keeps saying "NO_REPLY" or stays silent
257
+
258
+ Your workspace files (SOUL.md) instruct the agent to stay silent in groups. BadgerClaw respects your personality — this is intentional.
259
+
260
+ **To fix:** Add a `systemPrompt` override to your groups config that tells the agent to always respond. See the "Your Personality, Everywhere" section above. Then restart: `openclaw gateway restart`
261
+
262
+ ### "Invalid pairing code"
263
+
264
+ - Code expires after 24 hours. Run `/bot pair <name>` in the app for a new one.
265
+ - Enter the code exactly as shown (BCK-XXXX-XXXX).
266
+
267
+ ### "Pairing code already redeemed"
268
+
269
+ Each code is one-time use. Run `/bot pair <name>` to generate a fresh one.
270
+
271
+ ---
272
+
273
+ ## Architecture
274
+
275
+ ```
276
+ Your Phone (BadgerClaw App)
277
+
278
+ │ E2EE Messages (Megolm/Olm)
279
+
280
+ BadgerClaw Server (Matrix homeserver)
281
+
282
+ │ E2EE Messages
283
+
284
+ Your Machine (OpenClaw + BadgerClaw Plugin)
285
+
286
+ │ Agent Processing
287
+
288
+ AI Response → Back through the same encrypted path
289
+ ```
290
+
291
+ All messages are end-to-end encrypted. BadgerClaw servers cannot read your conversations.
package/index.ts ADDED
@@ -0,0 +1,47 @@
1
+ import type { OpenClawPluginApi } from "openclaw/plugin-sdk/matrix";
2
+ import { emptyPluginConfigSchema } from "openclaw/plugin-sdk/matrix";
3
+ import { matrixPlugin } from "./src/channel.js";
4
+ import { ensureMatrixCryptoRuntime } from "./src/matrix/deps.js";
5
+ import { setMatrixRuntime } from "./src/runtime.js";
6
+
7
+ const plugin = {
8
+ id: "badgerclaw",
9
+ name: "BadgerClaw",
10
+ description: "BadgerClaw encrypted AI agent channel",
11
+ configSchema: emptyPluginConfigSchema(),
12
+ register(api: OpenClawPluginApi) {
13
+ setMatrixRuntime(api.runtime);
14
+ void ensureMatrixCryptoRuntime({ log: api.logger.info }).catch((err) => {
15
+ const message = err instanceof Error ? err.message : String(err);
16
+ api.logger.warn?.(`badgerclaw: crypto runtime bootstrap failed: ${message}`);
17
+ });
18
+ api.registerChannel({ plugin: matrixPlugin });
19
+
20
+ api.registerCli(({ program }) => {
21
+ const cmd = program.command("badgerclaw").description("BadgerClaw bot management");
22
+ cmd
23
+ .command("connect <code>")
24
+ .description("Connect an OpenClaw instance to a BadgerClaw bot using a pairing code")
25
+ .action(async (code: string) => {
26
+ try {
27
+ const { redeemPairingCode } = await import("./src/connect.js");
28
+ const result = await redeemPairingCode(code);
29
+ console.log("\n✅ Connected to BadgerClaw bot!");
30
+ console.log(" Bot name: " + result.bot_name);
31
+ console.log(" Bot user: " + result.user_id);
32
+ console.log(" Homeserver: " + result.homeserver);
33
+ console.log("\nSave these credentials in your OpenClaw config:");
34
+ console.log(" channels.badgerclaw.accounts.default.userId = " + result.user_id);
35
+ console.log(" channels.badgerclaw.accounts.default.accessToken = " + result.access_token);
36
+ console.log(" channels.badgerclaw.accounts.default.homeserver = " + result.homeserver);
37
+ } catch (err: any) {
38
+ console.error("\n❌ Failed to connect: " + (err.message || err));
39
+ process.exit(1);
40
+ }
41
+ });
42
+ }, { commands: ["badgerclaw"] });
43
+ },
44
+ };
45
+
46
+ export { redeemPairingCode } from "./src/connect.js";
47
+ export default plugin;
@@ -0,0 +1 @@
1
+ {"id":"badgerclaw","channels":["badgerclaw"],"configSchema":{"type":"object","additionalProperties":false,"properties":{}}}
package/package.json CHANGED
@@ -1,39 +1,37 @@
1
1
  {
2
2
  "name": "badgerclaw",
3
- "version": "0.1.7",
4
- "description": "BadgerClaw CLI \u2014 one-click bot provisioning",
5
- "main": "dist/index.js",
6
- "bin": {
7
- "badgerclaw": "./dist/index.js"
8
- },
9
- "files": [
10
- "dist/",
11
- "README.md"
12
- ],
13
- "scripts": {
14
- "build": "tsc",
15
- "test": "echo \"Error: no test specified\" && exit 1"
16
- },
17
- "repository": {
18
- "type": "git",
19
- "url": "git+https://github.com/darkstaar4/badgerclaw-cli.git"
20
- },
21
- "keywords": [],
22
- "author": "",
23
- "license": "ISC",
24
- "bugs": {
25
- "url": "https://github.com/darkstaar4/badgerclaw-cli/issues"
26
- },
27
- "homepage": "https://github.com/darkstaar4/badgerclaw-cli#readme",
3
+ "version": "1.4.0",
4
+ "description": "BadgerClaw channel plugin for OpenClaw",
5
+ "type": "module",
28
6
  "dependencies": {
29
- "axios": "^1.6.0",
30
- "chalk": "^4.1.2",
31
- "commander": "^12.0.0",
32
- "open": "^8.4.2",
33
- "ora": "^5.4.1"
7
+ "@mariozechner/pi-agent-core": "0.58.0",
8
+ "@matrix-org/matrix-sdk-crypto-nodejs": "^0.4.0",
9
+ "@vector-im/matrix-bot-sdk": "0.8.0-element.3",
10
+ "markdown-it": "14.1.1",
11
+ "music-metadata": "^11.12.3",
12
+ "zod": "^4.3.6"
13
+ },
14
+ "openclaw": {
15
+ "extensions": [
16
+ "./index.ts"
17
+ ],
18
+ "channel": {
19
+ "id": "badgerclaw",
20
+ "label": "BadgerClaw",
21
+ "selectionLabel": "BadgerClaw (encrypted AI agents)",
22
+ "docsPath": "/channels/badgerclaw",
23
+ "docsLabel": "badgerclaw",
24
+ "blurb": "encrypted AI agent messaging platform",
25
+ "order": 15,
26
+ "quickstartAllowFrom": true
27
+ },
28
+ "install": {
29
+ "npmSpec": "@badgerclaw/connect",
30
+ "localPath": "extensions/badgerclaw",
31
+ "defaultChoice": "npm"
32
+ }
34
33
  },
35
- "devDependencies": {
36
- "@types/node": "^20.0.0",
37
- "typescript": "^5.3.0"
34
+ "scripts": {
35
+ "postinstall": "node scripts/postinstall.js"
38
36
  }
39
- }
37
+ }
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * postinstall.js — patches openclaw package.json exports map to expose
4
+ * plugin-sdk/compat subpath, which was removed in openclaw >=2026.3.24.
5
+ * This runs automatically after `npm install` in the plugin directory.
6
+ */
7
+ const fs = require('fs');
8
+ const path = require('path');
9
+
10
+ const OPENCLAW_PKG = path.join(
11
+ path.dirname(require.resolve('openclaw/package.json')),
12
+ 'package.json'
13
+ );
14
+
15
+ const COMPAT_EXPORT = './plugin-sdk/compat';
16
+ const COMPAT_ENTRY = {
17
+ types: './dist/plugin-sdk/compat.d.ts',
18
+ default: './dist/plugin-sdk/compat.js',
19
+ };
20
+
21
+ try {
22
+ const pkg = JSON.parse(fs.readFileSync(OPENCLAW_PKG, 'utf-8'));
23
+ if (!pkg.exports) pkg.exports = {};
24
+ if (!pkg.exports[COMPAT_EXPORT]) {
25
+ pkg.exports[COMPAT_EXPORT] = COMPAT_ENTRY;
26
+ fs.writeFileSync(OPENCLAW_PKG, JSON.stringify(pkg, null, 2));
27
+ console.log('[badgerclaw] patched openclaw exports map: added plugin-sdk/compat');
28
+ } else {
29
+ console.log('[badgerclaw] openclaw exports map already has plugin-sdk/compat');
30
+ }
31
+ } catch (e) {
32
+ // Non-fatal — openclaw may not be installed yet
33
+ console.log('[badgerclaw] postinstall: could not patch openclaw exports map:', e.message);
34
+ }