@badgerclaw/connect 1.4.10 → 1.4.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@badgerclaw/connect",
3
- "version": "1.4.10",
3
+ "version": "1.4.12",
4
4
  "description": "BadgerClaw channel plugin for OpenClaw",
5
5
  "type": "module",
6
6
  "dependencies": {
@@ -5,32 +5,61 @@ const CANDIDATES = [
5
5
  '/usr/local/lib/node_modules/openclaw/package.json',
6
6
  path.join(os.homedir(), '.npm-global/lib/node_modules/openclaw/package.json'),
7
7
  ];
8
- const MISSING_EXPORTS = {
9
- './plugin-sdk/compat': { types: './dist/plugin-sdk/compat.d.ts', default: './dist/plugin-sdk/compat.js' },
10
- './plugin-sdk/extension-shared': { types: './dist/plugin-sdk/extension-shared.d.ts', default: './dist/plugin-sdk/extension-shared.js' },
11
- './plugin-sdk/config-runtime': { types: './dist/plugin-sdk/config-runtime.d.ts', default: './dist/plugin-sdk/config-runtime.js' },
12
- './plugin-sdk/matrix-runtime-heavy': { types: './dist/plugin-sdk/matrix-runtime-heavy.d.ts', default: './dist/plugin-sdk/matrix-runtime-heavy.js' },
13
- };
14
8
  const pkgPath = CANDIDATES.find(p => fs.existsSync(p));
15
9
  if (!pkgPath) { console.log('[badgerclaw] openclaw not found'); process.exit(0); }
10
+
11
+ // Patch exports map
16
12
  try {
17
13
  const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
18
14
  pkg.exports = pkg.exports || {};
15
+ const sdkDir = path.join(path.dirname(pkgPath), 'dist', 'plugin-sdk');
16
+ const needed = ['compat','extension-shared','config-runtime','matrix-runtime-heavy',
17
+ 'account-id','bluebubbles','channel-runtime','googlechat','allow-from','channel-inbound'];
19
18
  let patched = false;
20
- for (const [key, entry] of Object.entries(MISSING_EXPORTS)) {
21
- if (!pkg.exports[key]) { pkg.exports[key] = entry; console.log(`[badgerclaw] patched: ${key}`); patched = true; }
19
+ for (const sub of needed) {
20
+ const key = `./plugin-sdk/${sub}`;
21
+ const jsPath = path.join(sdkDir, `${sub}.js`);
22
+ if (!pkg.exports[key] && fs.existsSync(jsPath)) {
23
+ pkg.exports[key] = { types: `./dist/plugin-sdk/${sub}.d.ts`, default: `./dist/plugin-sdk/${sub}.js` };
24
+ console.log(`[badgerclaw] patched: ${key}`);
25
+ patched = true;
26
+ }
22
27
  }
23
28
  if (patched) fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
24
- else console.log('[badgerclaw] exports up to date');
29
+ else console.log('[badgerclaw] exports map up to date');
25
30
  } catch (e) { console.log('[badgerclaw] patch warning:', e.message); }
31
+
26
32
  // Symlink openclaw
27
33
  try {
28
- const pluginDir = path.join(os.homedir(), '.openclaw', 'extensions', 'badgerclaw');
29
- const symlink = path.join(pluginDir, 'node_modules', 'openclaw');
30
- const openclawDir = path.dirname(pkgPath);
34
+ const symlink = path.join(os.homedir(), '.openclaw', 'extensions', 'badgerclaw', 'node_modules', 'openclaw');
31
35
  if (!fs.existsSync(symlink)) {
32
36
  fs.mkdirSync(path.dirname(symlink), { recursive: true });
33
- fs.symlinkSync(openclawDir, symlink);
34
- console.log(`[badgerclaw] symlinked openclaw`);
37
+ fs.symlinkSync(path.dirname(pkgPath), symlink);
38
+ console.log('[badgerclaw] symlinked openclaw');
35
39
  }
36
40
  } catch (e) { console.log('[badgerclaw] symlink:', e.message); }
41
+
42
+ // Config stash/restore
43
+ const configPath = path.join(os.homedir(), '.openclaw', 'openclaw.json');
44
+ const stashPath = configPath + '.badgerclaw-stash';
45
+ if (!fs.existsSync(configPath)) process.exit(0);
46
+ try {
47
+ const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
48
+ const bcConfig = config.channels?.badgerclaw;
49
+ if (!bcConfig || Object.keys(bcConfig).length === 0) process.exit(0);
50
+ delete config.channels.badgerclaw;
51
+ if (config.plugins?.entries?.badgerclaw) delete config.plugins.entries.badgerclaw;
52
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
53
+ fs.writeFileSync(stashPath, JSON.stringify(bcConfig, null, 2));
54
+ console.log('[badgerclaw] stashed channels.badgerclaw config');
55
+ setTimeout(() => {
56
+ try {
57
+ const cur = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
58
+ cur.channels = cur.channels || {};
59
+ cur.channels.badgerclaw = JSON.parse(fs.readFileSync(stashPath, 'utf-8'));
60
+ fs.writeFileSync(configPath, JSON.stringify(cur, null, 2));
61
+ fs.unlinkSync(stashPath);
62
+ console.log('[badgerclaw] restored channels.badgerclaw config');
63
+ } catch (e) { console.log('[badgerclaw] restore warning:', e.message); }
64
+ }, 500);
65
+ } catch (e) { console.log('[badgerclaw] stash warning:', e.message); }
package/src/actions.ts CHANGED
@@ -12,6 +12,20 @@ import { handleMatrixAction } from "./tool-actions.js";
12
12
  import type { CoreConfig } from "./types.js";
13
13
 
14
14
  export const matrixMessageActions: ChannelMessageActionAdapter = {
15
+ describeMessageTool: ({ cfg }) => {
16
+ const account = resolveMatrixAccount({ cfg: cfg as CoreConfig });
17
+ if (!account.enabled || !account.configured) {
18
+ return { actions: [], capabilities: [] };
19
+ }
20
+ const gate = createActionGate((cfg as CoreConfig).channels?.badgerclaw?.actions);
21
+ const actions: ChannelMessageActionName[] = ["send"];
22
+ if (gate("reactions")) actions.push("react", "reactions");
23
+ if (gate("messages")) actions.push("read", "edit", "delete");
24
+ if (gate("pins")) actions.push("pin", "unpin", "list-pins");
25
+ if (gate("memberInfo")) actions.push("member-info");
26
+ if (gate("channelInfo")) actions.push("channel-info");
27
+ return { actions, capabilities: [] };
28
+ },
15
29
  listActions: ({ cfg }) => {
16
30
  const account = resolveMatrixAccount({ cfg: cfg as CoreConfig });
17
31
  if (!account.enabled || !account.configured) {
@@ -1,19 +1,15 @@
1
1
  import type { LocationMessageEventContent, MatrixClient } from "@vector-im/matrix-bot-sdk";
2
2
  import {
3
- DEFAULT_ACCOUNT_ID,
4
- createChannelPairingController,
5
- createReplyPrefixOptions,
6
- createTypingCallbacks,
7
- evaluateGroupRouteAccessForPolicy,
8
- formatAllowlistMatchMeta,
9
- logInboundDrop,
10
- logTypingFailure,
11
- resolveInboundSessionEnvelopeContext,
12
- resolveControlCommandGate,
13
3
  type PluginRuntime,
14
4
  type RuntimeEnv,
15
5
  type RuntimeLogger,
16
6
  } from "openclaw/plugin-sdk/matrix";
7
+ import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-id";
8
+ import { createChannelPairingController, logInboundDrop, logTypingFailure, resolveControlCommandGate } from "openclaw/plugin-sdk/bluebubbles";
9
+ import { createReplyPrefixOptions, createTypingCallbacks } from "openclaw/plugin-sdk/channel-runtime";
10
+ import { evaluateGroupRouteAccessForPolicy } from "openclaw/plugin-sdk/googlechat";
11
+ import { formatAllowlistMatchMeta } from "openclaw/plugin-sdk/allow-from";
12
+ import { resolveInboundSessionEnvelopeContext } from "openclaw/plugin-sdk/channel-inbound";
17
13
  import { dispatchReplyFromConfigWithSettledDispatcher } from "openclaw/plugin-sdk/matrix-runtime-heavy";
18
14
  import type { CoreConfig, MatrixRoomConfig, ReplyToMode } from "../../types.js";
19
15
  import { fetchEventSummary } from "../actions/summary.js";