@badgerclaw/connect 1.4.3 → 1.4.4
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 +22 -0
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -4,6 +4,27 @@ 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
|
+
async function checkPluginUpdate(log: (msg: string) => void): Promise<void> {
|
|
8
|
+
try {
|
|
9
|
+
const CURRENT = "1.4.3";
|
|
10
|
+
const controller = new AbortController();
|
|
11
|
+
setTimeout(() => controller.abort(), 3000);
|
|
12
|
+
const resp = await fetch("https://registry.npmjs.org/@badgerclaw/connect/latest", { signal: controller.signal });
|
|
13
|
+
if (!resp.ok) return;
|
|
14
|
+
const data = await resp.json() as { version: string };
|
|
15
|
+
const latest = data.version;
|
|
16
|
+
const toNum = (v: string) => v.split(".").map(Number);
|
|
17
|
+
const [cm, cmi, cp] = toNum(CURRENT);
|
|
18
|
+
const [lm, lmi, lp] = toNum(latest);
|
|
19
|
+
const isNewer = lm > cm || (lm === cm && lmi > cmi) || (lm === cm && lmi === cmi && lp > cp);
|
|
20
|
+
if (isNewer) {
|
|
21
|
+
log(`⚠️ BadgerClaw plugin update available: ${CURRENT} → ${latest}. Run: openclaw plugins install @badgerclaw/connect`);
|
|
22
|
+
}
|
|
23
|
+
} catch {
|
|
24
|
+
// non-fatal
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
7
28
|
const plugin = {
|
|
8
29
|
id: "badgerclaw",
|
|
9
30
|
name: "BadgerClaw",
|
|
@@ -11,6 +32,7 @@ const plugin = {
|
|
|
11
32
|
configSchema: emptyPluginConfigSchema(),
|
|
12
33
|
register(api: OpenClawPluginApi) {
|
|
13
34
|
setMatrixRuntime(api.runtime);
|
|
35
|
+
void checkPluginUpdate(api.logger.info ?? console.log);
|
|
14
36
|
void ensureMatrixCryptoRuntime({ log: api.logger.info }).catch((err) => {
|
|
15
37
|
const message = err instanceof Error ? err.message : String(err);
|
|
16
38
|
api.logger.warn?.(`badgerclaw: crypto runtime bootstrap failed: ${message}`);
|