@openclaw/nostr 2026.7.2-beta.3 → 2026.7.2-beta.5

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 (44) hide show
  1. package/dist/api.js +12 -4
  2. package/dist/{channel-DgBHZ53s.js → channel-DNeI-LB-.js} +785 -412
  3. package/dist/channel-plugin-api.js +1 -1
  4. package/dist/{setup-adapter-DEU3o8MF.js → setup-adapter-BjKmSwdW.js} +31 -1
  5. package/dist/setup-api.js +1 -1
  6. package/dist/setup-plugin-api.js +4 -2
  7. package/dist/{setup-surface-BF7_7BEx.js → setup-surface-BJCFpe02.js} +12 -26
  8. package/node_modules/nostr-tools/lib/cjs/abstract-pool.js +35 -3
  9. package/node_modules/nostr-tools/lib/cjs/abstract-pool.js.map +2 -2
  10. package/node_modules/nostr-tools/lib/cjs/abstract-relay.js +30 -2
  11. package/node_modules/nostr-tools/lib/cjs/abstract-relay.js.map +2 -2
  12. package/node_modules/nostr-tools/lib/cjs/index.js +35 -3
  13. package/node_modules/nostr-tools/lib/cjs/index.js.map +2 -2
  14. package/node_modules/nostr-tools/lib/cjs/nip46.js +35 -3
  15. package/node_modules/nostr-tools/lib/cjs/nip46.js.map +2 -2
  16. package/node_modules/nostr-tools/lib/cjs/nipb0.js +4 -1
  17. package/node_modules/nostr-tools/lib/cjs/nipb0.js.map +2 -2
  18. package/node_modules/nostr-tools/lib/cjs/pool.js +35 -3
  19. package/node_modules/nostr-tools/lib/cjs/pool.js.map +2 -2
  20. package/node_modules/nostr-tools/lib/cjs/relay.js +30 -2
  21. package/node_modules/nostr-tools/lib/cjs/relay.js.map +2 -2
  22. package/node_modules/nostr-tools/lib/esm/abstract-pool.js +35 -3
  23. package/node_modules/nostr-tools/lib/esm/abstract-pool.js.map +2 -2
  24. package/node_modules/nostr-tools/lib/esm/abstract-relay.js +30 -2
  25. package/node_modules/nostr-tools/lib/esm/abstract-relay.js.map +2 -2
  26. package/node_modules/nostr-tools/lib/esm/index.js +35 -3
  27. package/node_modules/nostr-tools/lib/esm/index.js.map +2 -2
  28. package/node_modules/nostr-tools/lib/esm/nip46.js +35 -3
  29. package/node_modules/nostr-tools/lib/esm/nip46.js.map +2 -2
  30. package/node_modules/nostr-tools/lib/esm/nipb0.js +4 -1
  31. package/node_modules/nostr-tools/lib/esm/nipb0.js.map +2 -2
  32. package/node_modules/nostr-tools/lib/esm/pool.js +35 -3
  33. package/node_modules/nostr-tools/lib/esm/pool.js.map +2 -2
  34. package/node_modules/nostr-tools/lib/esm/relay.js +30 -2
  35. package/node_modules/nostr-tools/lib/esm/relay.js.map +2 -2
  36. package/node_modules/nostr-tools/lib/nostr.bundle.js +35 -3
  37. package/node_modules/nostr-tools/lib/nostr.bundle.js.map +2 -2
  38. package/node_modules/nostr-tools/lib/types/abstract-pool.d.ts +1 -0
  39. package/node_modules/nostr-tools/lib/types/abstract-relay.d.ts +5 -0
  40. package/node_modules/nostr-tools/lib/types/relay.d.ts +2 -2
  41. package/node_modules/nostr-tools/package.json +1 -1
  42. package/openclaw.plugin.json +0 -5
  43. package/package.json +41 -16
  44. package/npm-shrinkwrap.json +0 -137
@@ -1,2 +1,2 @@
1
- import { n as nostrPlugin } from "./channel-DgBHZ53s.js";
1
+ import { n as nostrPlugin } from "./channel-DNeI-LB-.js";
2
2
  export { nostrPlugin };
@@ -1,6 +1,7 @@
1
1
  import { uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
2
2
  import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/routing";
3
3
  import { patchTopLevelChannelConfigSection, splitSetupEntries } from "openclaw/plugin-sdk/setup";
4
+ import { defineChannelSetupContract } from "openclaw/plugin-sdk/channel-setup";
4
5
  //#region extensions/nostr/src/default-relays.ts
5
6
  const DEFAULT_RELAYS = ["wss://relay.damus.io", "wss://nos.lol"];
6
7
  //#endregion
@@ -65,5 +66,34 @@ function createNostrSetupAdapter(params) {
65
66
  }
66
67
  };
67
68
  }
69
+ function createNostrSetupContract(adapter) {
70
+ return defineChannelSetupContract({
71
+ fields: {
72
+ privateKey: {
73
+ kind: "string",
74
+ sensitive: true,
75
+ cli: {
76
+ flags: "--private-key <key>",
77
+ description: "Nostr private key"
78
+ }
79
+ },
80
+ relayUrls: {
81
+ kind: "string",
82
+ cli: {
83
+ flags: "--relay-urls <urls>",
84
+ description: "Nostr relay URLs"
85
+ }
86
+ },
87
+ useEnv: {
88
+ kind: "boolean",
89
+ cli: {
90
+ flags: "--use-env",
91
+ description: "Use NOSTR_PRIVATE_KEY"
92
+ }
93
+ }
94
+ },
95
+ legacyAdapter: adapter
96
+ });
97
+ }
68
98
  //#endregion
69
- export { DEFAULT_RELAYS as i, createNostrSetupAdapter as n, parseRelayUrls as r, buildNostrSetupPatch as t };
99
+ export { DEFAULT_RELAYS as a, parseRelayUrls as i, createNostrSetupAdapter as n, createNostrSetupContract as r, buildNostrSetupPatch as t };
package/dist/setup-api.js CHANGED
@@ -1,2 +1,2 @@
1
- import { n as nostrSetupWizard, t as nostrSetupAdapter } from "./setup-surface-BF7_7BEx.js";
1
+ import { r as nostrSetupWizard, t as nostrSetupAdapter } from "./setup-surface-BJCFpe02.js";
2
2
  export { nostrSetupAdapter, nostrSetupWizard };
@@ -1,5 +1,5 @@
1
1
  import { i as buildChannelConfigSchema, t as NostrConfigSchema } from "./config-schema-CelPzg1N.js";
2
- import { i as DEFAULT_RELAYS, n as createNostrSetupAdapter } from "./setup-adapter-DEU3o8MF.js";
2
+ import { a as DEFAULT_RELAYS, n as createNostrSetupAdapter, r as createNostrSetupContract } from "./setup-adapter-BjKmSwdW.js";
3
3
  import { describeAccountSnapshot } from "openclaw/plugin-sdk/account-helpers";
4
4
  import { DEFAULT_ACCOUNT_ID, createDelegatedSetupWizardProxy, createSetupTranslator, createStandardChannelSetupStatus } from "openclaw/plugin-sdk/setup-runtime";
5
5
  //#region extensions/nostr/src/channel.setup.ts
@@ -49,9 +49,10 @@ const nostrSetupAdapter = createNostrSetupAdapter({
49
49
  resolveAccountId: (cfg, accountId) => accountId?.trim() || resolveDefaultSetupNostrAccountId(cfg),
50
50
  validatePrivateKey: looksLikeNostrPrivateKey
51
51
  });
52
+ const nostrSetupContract = createNostrSetupContract(nostrSetupAdapter);
52
53
  const nostrSetupWizard = createDelegatedSetupWizardProxy({
53
54
  channel,
54
- loadWizard: async () => (await import("./setup-surface-BF7_7BEx.js").then((n) => n.r)).nostrSetupWizard,
55
+ loadWizard: async () => (await import("./setup-surface-BJCFpe02.js").then((n) => n.i)).nostrSetupWizard,
55
56
  status: { ...createStandardChannelSetupStatus({
56
57
  channelLabel: "Nostr",
57
58
  configuredLabel: t("wizard.channels.statusConfigured"),
@@ -91,6 +92,7 @@ const nostrSetupPlugin = {
91
92
  reload: { configPrefixes: ["channels.nostr"] },
92
93
  configSchema: buildChannelConfigSchema(NostrConfigSchema),
93
94
  setup: nostrSetupAdapter,
95
+ setupContract: nostrSetupContract,
94
96
  setupWizard: nostrSetupWizard,
95
97
  config: {
96
98
  listAccountIds: listSetupNostrAccountIds,
@@ -1,9 +1,9 @@
1
- import { i as DEFAULT_RELAYS, n as createNostrSetupAdapter, r as parseRelayUrls, t as buildNostrSetupPatch } from "./setup-adapter-DEU3o8MF.js";
1
+ import { a as DEFAULT_RELAYS, i as parseRelayUrls, n as createNostrSetupAdapter, r as createNostrSetupContract, t as buildNostrSetupPatch } from "./setup-adapter-BjKmSwdW.js";
2
+ import { createAccountListHelpers } from "openclaw/plugin-sdk/account-helpers";
2
3
  import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
3
4
  import { hasConfiguredSecretInput, normalizeSecretInputString } from "openclaw/plugin-sdk/secret-input";
4
5
  import { getPublicKey, nip19 } from "nostr-tools";
5
6
  import { DEFAULT_ACCOUNT_ID, normalizeAccountId, normalizeOptionalAccountId } from "openclaw/plugin-sdk/account-id";
6
- import { listCombinedAccountIds, resolveListedDefaultAccountId } from "openclaw/plugin-sdk/account-resolution";
7
7
  import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$1 } from "openclaw/plugin-sdk/routing";
8
8
  import { createSetupTranslator, createStandardChannelSetupStatus, createTopLevelChannelDmPolicy, createTopLevelChannelParsedAllowFromPrompt, defineTokenCredential, formatDocsLink, mergeAllowFromEntries, parseSetupEntriesWithParser, patchTopLevelChannelConfigSection, setSetupChannelEnabled } from "openclaw/plugin-sdk/setup";
9
9
  //#region \0rolldown/runtime.js
@@ -55,29 +55,13 @@ function normalizePubkey(input) {
55
55
  }
56
56
  //#endregion
57
57
  //#region extensions/nostr/src/types.ts
58
- function resolveConfiguredDefaultNostrAccountId(cfg) {
59
- const nostrCfg = cfg.channels?.nostr;
60
- return normalizeOptionalAccountId(nostrCfg?.defaultAccount);
61
- }
62
- /**
63
- * List all configured Nostr account IDs
64
- */
65
- function listNostrAccountIds(cfg) {
66
- const nostrCfg = cfg.channels?.nostr;
67
- return listCombinedAccountIds({
68
- configuredAccountIds: [],
69
- implicitAccountId: normalizeSecretInputString(nostrCfg?.privateKey) ? resolveConfiguredDefaultNostrAccountId(cfg) ?? DEFAULT_ACCOUNT_ID : void 0
70
- });
71
- }
72
- /**
73
- * Get the default account ID
74
- */
75
- function resolveDefaultNostrAccountId(cfg) {
76
- return resolveListedDefaultAccountId({
77
- accountIds: listNostrAccountIds(cfg),
78
- configuredDefaultAccountId: resolveConfiguredDefaultNostrAccountId(cfg)
79
- });
80
- }
58
+ const { listAccountIds: listNostrAccountIds, resolveDefaultAccountId: resolveDefaultNostrAccountId } = createAccountListHelpers("nostr", {
59
+ fallbackAccountIdWhenEmpty: false,
60
+ resolveImplicitAccountId: (cfg) => {
61
+ const account = cfg.channels?.nostr;
62
+ return normalizeSecretInputString(account?.privateKey) ? normalizeOptionalAccountId(account?.defaultAccount) ?? DEFAULT_ACCOUNT_ID : void 0;
63
+ }
64
+ });
81
65
  /**
82
66
  * Resolve a Nostr account from config
83
67
  */
@@ -115,6 +99,7 @@ function resolveNostrAccount(opts) {
115
99
  //#region extensions/nostr/src/setup-surface.ts
116
100
  var setup_surface_exports = /* @__PURE__ */ __exportAll({
117
101
  nostrSetupAdapter: () => nostrSetupAdapter,
102
+ nostrSetupContract: () => nostrSetupContract,
118
103
  nostrSetupWizard: () => nostrSetupWizard
119
104
  });
120
105
  const t = createSetupTranslator();
@@ -172,6 +157,7 @@ const nostrSetupAdapter = createNostrSetupAdapter({
172
157
  }
173
158
  }
174
159
  });
160
+ const nostrSetupContract = createNostrSetupContract(nostrSetupAdapter);
175
161
  const nostrSetupWizard = {
176
162
  channel,
177
163
  resolveAccountIdForConfigure: ({ accountOverride, defaultAccountId }) => accountOverride?.trim() || defaultAccountId,
@@ -271,4 +257,4 @@ const nostrSetupWizard = {
271
257
  disable: (cfg) => setSetupChannelEnabled(cfg, channel, false)
272
258
  };
273
259
  //#endregion
274
- export { resolveDefaultNostrAccountId as a, validatePrivateKey as c, listNostrAccountIds as i, nostrSetupWizard as n, resolveNostrAccount as o, setup_surface_exports as r, normalizePubkey as s, nostrSetupAdapter as t };
260
+ export { listNostrAccountIds as a, normalizePubkey as c, setup_surface_exports as i, validatePrivateKey as l, nostrSetupContract as n, resolveDefaultNostrAccountId as o, nostrSetupWizard as r, resolveNostrAccount as s, nostrSetupAdapter as t };
@@ -146,12 +146,14 @@ var AbstractRelay = class {
146
146
  openSubs = /* @__PURE__ */ new Map();
147
147
  enablePing;
148
148
  enableReconnect;
149
+ idleTimeout = 0;
149
150
  idleSince = Date.now();
150
151
  ongoingOperations = 0;
151
152
  reconnectTimeoutHandle;
152
153
  pingIntervalHandle;
153
154
  reconnectAttempts = 0;
154
155
  skipReconnection = false;
156
+ idleTimeoutHandle;
155
157
  connectionPromise;
156
158
  openCountRequests = /* @__PURE__ */ new Map();
157
159
  openEventPublishes = /* @__PURE__ */ new Map();
@@ -167,6 +169,8 @@ var AbstractRelay = class {
167
169
  this._WebSocket = opts.websocketImplementation || WebSocket;
168
170
  this.enablePing = opts.enablePing;
169
171
  this.enableReconnect = opts.enableReconnect || false;
172
+ if (opts.idleTimeout)
173
+ this.idleTimeout = opts.idleTimeout;
170
174
  }
171
175
  static async connect(url, opts) {
172
176
  const relay = new AbstractRelay(url, opts);
@@ -190,6 +194,22 @@ var AbstractRelay = class {
190
194
  get connected() {
191
195
  return this._connected;
192
196
  }
197
+ clearIdleTimeout() {
198
+ if (this.idleTimeoutHandle) {
199
+ clearTimeout(this.idleTimeoutHandle);
200
+ this.idleTimeoutHandle = void 0;
201
+ }
202
+ }
203
+ scheduleIdleClose() {
204
+ this.clearIdleTimeout();
205
+ if (this.idleTimeout > 0) {
206
+ this.idleTimeoutHandle = setTimeout(() => {
207
+ if (this.ongoingOperations === 0 && this.idleSince) {
208
+ this.close();
209
+ }
210
+ }, this.idleTimeout);
211
+ }
212
+ }
193
213
  async reconnect() {
194
214
  const backoff = this.resubscribeBackoff[Math.min(this.reconnectAttempts, this.resubscribeBackoff.length - 1)];
195
215
  this.reconnectAttempts++;
@@ -208,6 +228,7 @@ var AbstractRelay = class {
208
228
  this._connected = false;
209
229
  this.connectionPromise = void 0;
210
230
  this.idleSince = void 0;
231
+ this.clearIdleTimeout();
211
232
  if (this.enableReconnect && !this.skipReconnection) {
212
233
  this.reconnect();
213
234
  } else {
@@ -365,6 +386,7 @@ var AbstractRelay = class {
365
386
  }
366
387
  async publish(event) {
367
388
  this.idleSince = void 0;
389
+ this.clearIdleTimeout();
368
390
  this.ongoingOperations++;
369
391
  const ret = new Promise((resolve, reject) => {
370
392
  const timeout = setTimeout(() => {
@@ -386,8 +408,10 @@ var AbstractRelay = class {
386
408
  }
387
409
  }
388
410
  this.ongoingOperations--;
389
- if (this.ongoingOperations === 0)
411
+ if (this.ongoingOperations === 0) {
390
412
  this.idleSince = Date.now();
413
+ this.scheduleIdleClose();
414
+ }
391
415
  return ret;
392
416
  }
393
417
  async count(filters, params) {
@@ -413,6 +437,7 @@ var AbstractRelay = class {
413
437
  subscribe(filters, params) {
414
438
  if (params.label !== "<forced-ping>") {
415
439
  this.idleSince = void 0;
440
+ this.clearIdleTimeout();
416
441
  this.ongoingOperations++;
417
442
  }
418
443
  const sub = this.prepareSubscription(filters, params);
@@ -442,6 +467,7 @@ var AbstractRelay = class {
442
467
  this.closeAllSubscriptions("relay connection closed by us");
443
468
  this._connected = false;
444
469
  this.idleSince = void 0;
470
+ this.clearIdleTimeout();
445
471
  this.onclose?.();
446
472
  if (this.ws?.readyState === this._WebSocket.OPEN) {
447
473
  this.ws?.close();
@@ -619,8 +645,10 @@ var Subscription = class {
619
645
  }
620
646
  this.relay.openSubs.delete(this.id);
621
647
  this.relay.ongoingOperations--;
622
- if (this.relay.ongoingOperations === 0)
648
+ if (this.relay.ongoingOperations === 0) {
623
649
  this.relay.idleSince = Date.now();
650
+ this.relay.scheduleIdleClose();
651
+ }
624
652
  this.onclose?.(reason);
625
653
  }
626
654
  };
@@ -696,6 +724,7 @@ var AbstractSimplePool = class {
696
724
  verifyEvent;
697
725
  enablePing;
698
726
  enableReconnect;
727
+ idleTimeout = 2e4;
699
728
  automaticallyAuth;
700
729
  trustedRelayURLs = /* @__PURE__ */ new Set();
701
730
  onRelayConnectionFailure;
@@ -708,6 +737,8 @@ var AbstractSimplePool = class {
708
737
  this._WebSocket = opts.websocketImplementation;
709
738
  this.enablePing = opts.enablePing;
710
739
  this.enableReconnect = opts.enableReconnect || false;
740
+ if (opts.idleTimeout)
741
+ this.idleTimeout = opts.idleTimeout;
711
742
  this.automaticallyAuth = opts.automaticallyAuth;
712
743
  this.onRelayConnectionFailure = opts.onRelayConnectionFailure;
713
744
  this.onRelayConnectionSuccess = opts.onRelayConnectionSuccess;
@@ -722,7 +753,8 @@ var AbstractSimplePool = class {
722
753
  verifyEvent: this.trustedRelayURLs.has(url) ? alwaysTrue : this.verifyEvent,
723
754
  websocketImplementation: this._WebSocket,
724
755
  enablePing: this.enablePing,
725
- enableReconnect: this.enableReconnect
756
+ enableReconnect: this.enableReconnect,
757
+ idleTimeout: this.idleTimeout
726
758
  });
727
759
  relay.onclose = () => {
728
760
  this.relays.delete(url);