twindex-openclaw-plugin 0.4.1 → 0.4.3

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.
@@ -2,7 +2,7 @@
2
2
  "id": "twindex",
3
3
  "name": "Twindex",
4
4
  "description": "Music intelligence for AI agents. Get notified about tours, merch drops, releases, and presales for your favorite artists.",
5
- "version": "0.4.1",
5
+ "version": "0.4.2",
6
6
  "skills": ["./skills"],
7
7
  "configSchema": {
8
8
  "type": "object",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "twindex-openclaw-plugin",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "description": "Music intelligence for AI agents. Tours, merch drops, releases, presales.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/index.ts CHANGED
@@ -1,16 +1,35 @@
1
+ import { readFileSync, writeFileSync } from "fs";
2
+ import { join } from "path";
3
+ import { homedir } from "os";
1
4
  import * as twindex from "./client.js";
2
5
  import { createNotificationService } from "./sse-service.js";
3
6
 
7
+ let bootstrapping = false;
8
+
4
9
  export default function register(api: any) {
5
10
  const cfg = () => api.config?.plugins?.entries?.twindex?.config ?? {};
6
11
 
7
12
  function persistConfig(updates: Record<string, any>) {
8
13
  if (!api.config?.plugins?.entries?.twindex) return;
14
+ // Update in-memory config
9
15
  api.config.plugins.entries.twindex.config = {
10
16
  ...cfg(),
11
17
  ...updates,
12
18
  };
13
- api.config.save?.();
19
+ // Write to disk — OpenClaw plugin API does not expose config.save()
20
+ try {
21
+ const configPath = join(homedir(), ".openclaw", "openclaw.json");
22
+ const raw = readFileSync(configPath, "utf-8");
23
+ const disk = JSON.parse(raw);
24
+ if (!disk.plugins) disk.plugins = {};
25
+ if (!disk.plugins.entries) disk.plugins.entries = {};
26
+ if (!disk.plugins.entries.twindex) disk.plugins.entries.twindex = {};
27
+ disk.plugins.entries.twindex.config = api.config.plugins.entries.twindex.config;
28
+ writeFileSync(configPath, JSON.stringify(disk, null, 2) + "\n", "utf-8");
29
+ api.logger?.info?.("Twindex: config persisted to disk");
30
+ } catch (err: any) {
31
+ api.logger?.warn?.(`Twindex: failed to persist config: ${err.message}`);
32
+ }
14
33
  }
15
34
 
16
35
  // ── SSE notification service ──────────────────────────────────────
@@ -20,9 +39,11 @@ export default function register(api: any) {
20
39
  // ── Auto-bootstrap: register + subscribe ────────────────────────
21
40
 
22
41
  (async () => {
23
- const config = cfg();
24
- if (config.artists?.length > 0 && config.frequency && !config.apiKey) {
25
- try {
42
+ if (bootstrapping) return;
43
+ bootstrapping = true;
44
+ try {
45
+ const config = cfg();
46
+ if (config.artists?.length > 0 && config.frequency && !config.apiKey) {
26
47
  const agentId =
27
48
  api.agentId ?? api.config?.agentId ?? `openclaw-${crypto.randomUUID()}`;
28
49
  const reg = await twindex.register(agentId);
@@ -44,9 +65,11 @@ export default function register(api: any) {
44
65
  api.logger?.info?.(
45
66
  "Twindex: auto-bootstrap complete. Delivery via SSE push.",
46
67
  );
47
- } catch (err: any) {
48
- api.logger?.warn?.(`Twindex: auto-bootstrap failed: ${err.message}`);
49
68
  }
69
+ } catch (err: any) {
70
+ api.logger?.warn?.(`Twindex: auto-bootstrap failed: ${err.message}`);
71
+ } finally {
72
+ bootstrapping = false;
50
73
  }
51
74
  })();
52
75
 
@@ -146,8 +146,7 @@ export function createNotificationService(api: any) {
146
146
  }
147
147
 
148
148
  return {
149
- name: "twindex-notifications",
150
- description: "Real-time push notifications from Twindex via SSE",
149
+ id: "twindex-notifications",
151
150
 
152
151
  start() {
153
152
  if (running) return;