@badgerclaw/connect 1.4.9 → 1.4.10
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/index.ts
CHANGED
|
@@ -4,11 +4,12 @@ import { matrixPlugin } from "./src/channel.js";
|
|
|
4
4
|
import { ensureMatrixCryptoRuntime } from "./src/matrix/deps.js";
|
|
5
5
|
import { setMatrixRuntime } from "./src/runtime.js";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// Use global scope so the flag persists across module reloads (channel restarts)
|
|
8
|
+
const _g = global as any;
|
|
8
9
|
|
|
9
10
|
async function startPairWatcher(logger: { info?: (msg: string) => void; warn?: (msg: string) => void }): Promise<void> {
|
|
10
|
-
if (
|
|
11
|
-
|
|
11
|
+
if (_g._badgerclawPairWatcherStarted) return;
|
|
12
|
+
_g._badgerclawPairWatcherStarted = true;
|
|
12
13
|
const log = logger.info ?? console.log;
|
|
13
14
|
const warn = logger.warn ?? console.warn;
|
|
14
15
|
|
package/package.json
CHANGED
package/scripts/postinstall.cjs
CHANGED
|
@@ -1,79 +1,36 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
'/opt/homebrew/lib/node_modules/openclaw',
|
|
8
|
-
'/usr/local/lib/node_modules/openclaw',
|
|
9
|
-
path.join(os.homedir(), '.npm-global/lib/node_modules/openclaw'),
|
|
2
|
+
const fs = require('fs'), path = require('path'), os = require('os');
|
|
3
|
+
const CANDIDATES = [
|
|
4
|
+
'/opt/homebrew/lib/node_modules/openclaw/package.json',
|
|
5
|
+
'/usr/local/lib/node_modules/openclaw/package.json',
|
|
6
|
+
path.join(os.homedir(), '.npm-global/lib/node_modules/openclaw/package.json'),
|
|
10
7
|
];
|
|
11
|
-
|
|
12
8
|
const MISSING_EXPORTS = {
|
|
13
9
|
'./plugin-sdk/compat': { types: './dist/plugin-sdk/compat.d.ts', default: './dist/plugin-sdk/compat.js' },
|
|
14
10
|
'./plugin-sdk/extension-shared': { types: './dist/plugin-sdk/extension-shared.d.ts', default: './dist/plugin-sdk/extension-shared.js' },
|
|
15
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' },
|
|
16
13
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (!openclawDir) {
|
|
21
|
-
console.log('[badgerclaw] openclaw not found — skipping setup');
|
|
22
|
-
process.exit(0);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// 1. Patch exports map
|
|
14
|
+
const pkgPath = CANDIDATES.find(p => fs.existsSync(p));
|
|
15
|
+
if (!pkgPath) { console.log('[badgerclaw] openclaw not found'); process.exit(0); }
|
|
26
16
|
try {
|
|
27
|
-
const pkgPath = path.join(openclawDir, 'package.json');
|
|
28
17
|
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
29
18
|
pkg.exports = pkg.exports || {};
|
|
30
19
|
let patched = false;
|
|
31
20
|
for (const [key, entry] of Object.entries(MISSING_EXPORTS)) {
|
|
32
|
-
if (!pkg.exports[key]) { pkg.exports[key] = entry; console.log(`[badgerclaw] patched
|
|
21
|
+
if (!pkg.exports[key]) { pkg.exports[key] = entry; console.log(`[badgerclaw] patched: ${key}`); patched = true; }
|
|
33
22
|
}
|
|
34
23
|
if (patched) fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
|
|
35
|
-
else console.log('[badgerclaw] exports
|
|
36
|
-
} catch (e) { console.log('[badgerclaw]
|
|
37
|
-
|
|
38
|
-
// 2. Symlink openclaw into plugin node_modules so imports resolve
|
|
24
|
+
else console.log('[badgerclaw] exports up to date');
|
|
25
|
+
} catch (e) { console.log('[badgerclaw] patch warning:', e.message); }
|
|
26
|
+
// Symlink openclaw
|
|
39
27
|
try {
|
|
40
28
|
const pluginDir = path.join(os.homedir(), '.openclaw', 'extensions', 'badgerclaw');
|
|
41
|
-
const
|
|
42
|
-
const
|
|
29
|
+
const symlink = path.join(pluginDir, 'node_modules', 'openclaw');
|
|
30
|
+
const openclawDir = path.dirname(pkgPath);
|
|
43
31
|
if (!fs.existsSync(symlink)) {
|
|
44
|
-
fs.mkdirSync(
|
|
32
|
+
fs.mkdirSync(path.dirname(symlink), { recursive: true });
|
|
45
33
|
fs.symlinkSync(openclawDir, symlink);
|
|
46
|
-
console.log(`[badgerclaw] symlinked openclaw
|
|
47
|
-
} else {
|
|
48
|
-
console.log('[badgerclaw] openclaw symlink already exists');
|
|
34
|
+
console.log(`[badgerclaw] symlinked openclaw`);
|
|
49
35
|
}
|
|
50
|
-
} catch (e) { console.log('[badgerclaw] symlink
|
|
51
|
-
|
|
52
|
-
// 3. Config stash/restore for reinstalls
|
|
53
|
-
const configPath = path.join(os.homedir(), '.openclaw', 'openclaw.json');
|
|
54
|
-
const stashPath = configPath + '.badgerclaw-stash';
|
|
55
|
-
|
|
56
|
-
if (!fs.existsSync(configPath)) { process.exit(0); }
|
|
57
|
-
|
|
58
|
-
try {
|
|
59
|
-
const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
|
60
|
-
const bcConfig = config.channels?.badgerclaw;
|
|
61
|
-
if (!bcConfig) { process.exit(0); }
|
|
62
|
-
|
|
63
|
-
delete config.channels.badgerclaw;
|
|
64
|
-
if (config.plugins?.entries?.badgerclaw) delete config.plugins.entries.badgerclaw;
|
|
65
|
-
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
66
|
-
fs.writeFileSync(stashPath, JSON.stringify(bcConfig, null, 2));
|
|
67
|
-
console.log('[badgerclaw] stashed channels.badgerclaw config');
|
|
68
|
-
|
|
69
|
-
setTimeout(() => {
|
|
70
|
-
try {
|
|
71
|
-
const cur = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
|
72
|
-
cur.channels = cur.channels || {};
|
|
73
|
-
cur.channels.badgerclaw = JSON.parse(fs.readFileSync(stashPath, 'utf-8'));
|
|
74
|
-
fs.writeFileSync(configPath, JSON.stringify(cur, null, 2));
|
|
75
|
-
fs.unlinkSync(stashPath);
|
|
76
|
-
console.log('[badgerclaw] restored channels.badgerclaw config');
|
|
77
|
-
} catch (e) { console.log('[badgerclaw] restore warning:', e.message); }
|
|
78
|
-
}, 500);
|
|
79
|
-
} catch (e) { console.log('[badgerclaw] config stash warning:', e.message); }
|
|
36
|
+
} catch (e) { console.log('[badgerclaw] symlink:', e.message); }
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
formatAllowlistMatchMeta,
|
|
3
3
|
issuePairingChallenge,
|
|
4
|
-
readStoreAllowFromForDmPolicy,
|
|
5
|
-
resolveDmGroupAccessWithLists,
|
|
6
4
|
resolveSenderScopedGroupPolicy,
|
|
7
5
|
} from "openclaw/plugin-sdk/matrix";
|
|
6
|
+
import {
|
|
7
|
+
readStoreAllowFromForDmPolicy,
|
|
8
|
+
resolveDmGroupAccessWithLists,
|
|
9
|
+
} from "openclaw/plugin-sdk/compat";
|
|
8
10
|
import {
|
|
9
11
|
normalizeMatrixAllowList,
|
|
10
12
|
resolveMatrixAllowListMatch,
|
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
createChannelPairingController,
|
|
5
5
|
createReplyPrefixOptions,
|
|
6
6
|
createTypingCallbacks,
|
|
7
|
-
dispatchReplyFromConfigWithSettledDispatcher,
|
|
8
7
|
evaluateGroupRouteAccessForPolicy,
|
|
9
8
|
formatAllowlistMatchMeta,
|
|
10
9
|
logInboundDrop,
|
|
@@ -15,6 +14,7 @@ import {
|
|
|
15
14
|
type RuntimeEnv,
|
|
16
15
|
type RuntimeLogger,
|
|
17
16
|
} from "openclaw/plugin-sdk/matrix";
|
|
17
|
+
import { dispatchReplyFromConfigWithSettledDispatcher } from "openclaw/plugin-sdk/matrix-runtime-heavy";
|
|
18
18
|
import type { CoreConfig, MatrixRoomConfig, ReplyToMode } from "../../types.js";
|
|
19
19
|
import { fetchEventSummary } from "../actions/summary.js";
|
|
20
20
|
import {
|