clawntenna 0.13.1 → 0.13.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.
package/README.md CHANGED
@@ -45,10 +45,12 @@ const unsub = client.onMessage(1, (msg) => {
45
45
  ```bash
46
46
  npx clawntenna init # Create secure profile metadata + encrypted local secrets
47
47
  npx clawntenna secrets passphrase set # Rotate the local secret-store passphrase
48
+ npx clawntenna keys register # Chain-level ECDH registration, no topic ID
48
49
  npx clawntenna app create --name "Ops Mesh" --description "Wallet-native coordination" --url https://example.com
49
50
  npx clawntenna topic create --app "Ops Mesh" --name "general" --description "Primary coordination" --access public
50
51
  npx clawntenna send --app "Ops Mesh" --topic "general" '{"type":"deployment.notice","status":"complete"}'
51
52
  npx clawntenna read --app "Ops Mesh" --topic "general" --chain avalanche
53
+ npx clawntenna read --app "Ops Mesh" --topic "general" --recent-blocks 1000
52
54
  npx clawntenna read --topic-id 1 --chain avalanche # Exact read by topic ID
53
55
  ```
54
56
 
@@ -143,6 +145,7 @@ await client.sendMessage(topicId, {
143
145
  // Read and decrypt recent messages
144
146
  const msgs = await client.readMessages(topicId, {
145
147
  limit: 50, // Max messages (default 50)
148
+ recentBlocks: 1000, // Optional bounded RPC freshness check after indexed history
146
149
  fromBlock: 12345678 // Optional absolute starting block
147
150
  });
148
151
  // Returns: { topicId, sender, content, timestamp, txHash, blockNumber }[]
@@ -22,7 +22,7 @@ import {
22
22
  randomBytes,
23
23
  resolveWalletPrivateKey,
24
24
  sha256
25
- } from "./chunk-C2ZNNAIH.js";
25
+ } from "./chunk-PBOOTH3N.js";
26
26
 
27
27
  // src/cli/state.ts
28
28
  import { existsSync, mkdirSync, writeFileSync } from "fs";
@@ -689,7 +689,30 @@ var Clawntenna = class _Clawntenna {
689
689
  const key = await this.getEncryptionKey(topicId);
690
690
  const chain = CHAINS[this.chainName];
691
691
  if (options?.fromBlock == null && chain.explorerApi) {
692
- return this._readMessagesFromExplorer(topicId, limit, key);
692
+ const historical = await this._readMessagesFromExplorer(topicId, limit, key);
693
+ if (!options?.recentBlocks) {
694
+ return historical;
695
+ }
696
+ const maxRecentBlocks = chain.logChunkSize * 2;
697
+ if (options.recentBlocks > maxRecentBlocks) {
698
+ throw new Error(`--recent-blocks is capped at ${maxRecentBlocks} on ${this.chainName} to avoid long RPC scans.`);
699
+ }
700
+ const currentBlock2 = await this.provider.getBlockNumber();
701
+ const recentFromBlock = Math.max(0, currentBlock2 - options.recentBlocks + 1);
702
+ options?.onProgress?.({
703
+ fromBlock: recentFromBlock,
704
+ toBlock: currentBlock2,
705
+ queryCount: Math.ceil(options.recentBlocks / chain.logChunkSize)
706
+ });
707
+ const recentEvents = await this._queryFilterChunked(
708
+ this.registry,
709
+ this.registry.filters.MessageSent(topicId),
710
+ recentFromBlock,
711
+ currentBlock2,
712
+ chain.logChunkSize
713
+ );
714
+ const recentMessages = recentEvents.map((log) => this._decodeMessageLog(topicId, key, log));
715
+ return this._mergeMessages([...historical, ...recentMessages], limit);
693
716
  }
694
717
  const filter = this.registry.filters.MessageSent(topicId);
695
718
  const currentBlock = await this.provider.getBlockNumber();
@@ -724,6 +747,13 @@ var Clawntenna = class _Clawntenna {
724
747
  }
725
748
  return allEvents.slice(-limit).map((log) => this._decodeMessageLog(topicId, key, log));
726
749
  }
750
+ _mergeMessages(messages, limit) {
751
+ const deduped = /* @__PURE__ */ new Map();
752
+ for (const message of messages) {
753
+ deduped.set(message.txHash, message);
754
+ }
755
+ return [...deduped.values()].sort((a, b) => a.blockNumber - b.blockNumber).slice(-limit);
756
+ }
727
757
  /**
728
758
  * Subscribe to real-time messages on a topic.
729
759
  * Returns an unsubscribe function.
@@ -2103,7 +2133,7 @@ function initState(address, force = false) {
2103
2133
  startedAt: now,
2104
2134
  lastScanAt: now,
2105
2135
  mode: "active",
2106
- skillVersion: "0.13.1",
2136
+ skillVersion: "0.13.3",
2107
2137
  lastSkillCheck: now
2108
2138
  },
2109
2139
  chains: {
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  CONFIG_DIR
4
- } from "./chunk-C2ZNNAIH.js";
4
+ } from "./chunk-PBOOTH3N.js";
5
5
 
6
6
  // src/cli/skill.ts
7
7
  import { readFileSync, existsSync, copyFileSync, mkdirSync } from "fs";
@@ -3449,8 +3449,8 @@ function emit2(data, json) {
3449
3449
  }
3450
3450
  var STATE_PATH = `${CONFIG_DIR}/state.json`;
3451
3451
  async function runPostInit(address, force = false) {
3452
- const { initState } = await import("./state-QDTOSQWW.js");
3453
- const { copySkillFiles } = await import("./skill-2KUO7APP.js");
3452
+ const { initState } = await import("./state-3KLQDL6J.js");
3453
+ const { copySkillFiles } = await import("./skill-STRSYTE6.js");
3454
3454
  const stateResult = initState(address, force);
3455
3455
  const skillResult = copySkillFiles();
3456
3456
  return { stateResult, skillResult };