clawntenna 0.8.0 → 0.8.1
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/dist/cli/index.js +63 -27
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -4155,11 +4155,24 @@ async function send(topicId, message, flags) {
|
|
|
4155
4155
|
};
|
|
4156
4156
|
const tx = await client.sendMessage(topicId, message, sendOptions);
|
|
4157
4157
|
if (!json) console.log(`TX submitted: ${tx.hash}`);
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4158
|
+
try {
|
|
4159
|
+
const receipt = await tx.wait(1, 6e4);
|
|
4160
|
+
if (json) {
|
|
4161
|
+
output({ txHash: tx.hash, blockNumber: receipt?.blockNumber, topicId, chain: flags.chain }, true);
|
|
4162
|
+
} else {
|
|
4163
|
+
console.log(`Confirmed in block ${receipt?.blockNumber}`);
|
|
4164
|
+
}
|
|
4165
|
+
} catch (err) {
|
|
4166
|
+
const isTimeout = err instanceof Error && err.message.includes("timeout");
|
|
4167
|
+
if (isTimeout) {
|
|
4168
|
+
if (json) {
|
|
4169
|
+
output({ txHash: tx.hash, blockNumber: null, topicId, chain: flags.chain, warning: "confirmation timed out (60s)" }, true);
|
|
4170
|
+
} else {
|
|
4171
|
+
console.log(`TX sent but confirmation timed out after 60s. TX hash: ${tx.hash}`);
|
|
4172
|
+
}
|
|
4173
|
+
} else {
|
|
4174
|
+
throw err;
|
|
4175
|
+
}
|
|
4163
4176
|
}
|
|
4164
4177
|
}
|
|
4165
4178
|
|
|
@@ -4844,33 +4857,56 @@ async function keysHas(topicId, address, flags) {
|
|
|
4844
4857
|
}
|
|
4845
4858
|
|
|
4846
4859
|
// src/cli/subscribe.ts
|
|
4860
|
+
var POLL_INTERVAL = 15e3;
|
|
4847
4861
|
async function subscribe(topicId, flags) {
|
|
4848
4862
|
const client = loadClient(flags, false);
|
|
4849
4863
|
const json = flags.json ?? false;
|
|
4850
|
-
if (!json) console.log(`Listening for messages on topic ${topicId} (${flags.chain})...
|
|
4864
|
+
if (!json) console.log(`Listening for messages on topic ${topicId} (${flags.chain}, polling every ${POLL_INTERVAL / 1e3}s)...
|
|
4851
4865
|
`);
|
|
4852
|
-
const
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4866
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4867
|
+
let lastBlock = await client.provider.getBlockNumber();
|
|
4868
|
+
const poll = async () => {
|
|
4869
|
+
try {
|
|
4870
|
+
const currentBlock = await client.provider.getBlockNumber();
|
|
4871
|
+
if (currentBlock <= lastBlock) return;
|
|
4872
|
+
const messages = await client.readMessages(topicId, { fromBlock: lastBlock + 1 });
|
|
4873
|
+
for (const msg of messages) {
|
|
4874
|
+
if (seen.has(msg.txHash)) continue;
|
|
4875
|
+
seen.add(msg.txHash);
|
|
4876
|
+
if (json) {
|
|
4877
|
+
console.log(JSON.stringify({
|
|
4878
|
+
sender: msg.sender,
|
|
4879
|
+
text: msg.text,
|
|
4880
|
+
replyTo: msg.replyTo,
|
|
4881
|
+
mentions: msg.mentions,
|
|
4882
|
+
timestamp: msg.timestamp.toString(),
|
|
4883
|
+
txHash: msg.txHash,
|
|
4884
|
+
blockNumber: msg.blockNumber
|
|
4885
|
+
}));
|
|
4886
|
+
} else {
|
|
4887
|
+
const time = new Date(Number(msg.timestamp) * 1e3).toISOString().slice(0, 19).replace("T", " ");
|
|
4888
|
+
const reply = msg.replyTo ? ` (reply to ${msg.replyTo.slice(0, 10)}...)` : "";
|
|
4889
|
+
console.log(`[${time}] ${msg.sender.slice(0, 8)}...: ${msg.text}${reply}`);
|
|
4890
|
+
}
|
|
4891
|
+
}
|
|
4892
|
+
lastBlock = currentBlock;
|
|
4893
|
+
if (seen.size > 1e3) {
|
|
4894
|
+
const entries = [...seen];
|
|
4895
|
+
entries.splice(0, entries.length - 1e3);
|
|
4896
|
+
seen.clear();
|
|
4897
|
+
entries.forEach((e) => seen.add(e));
|
|
4898
|
+
}
|
|
4899
|
+
} catch (err) {
|
|
4900
|
+
if (!json) console.error(`Poll error: ${err instanceof Error ? err.message : err}`);
|
|
4867
4901
|
}
|
|
4868
|
-
}
|
|
4902
|
+
};
|
|
4903
|
+
const interval = setInterval(poll, POLL_INTERVAL);
|
|
4869
4904
|
process.on("SIGINT", () => {
|
|
4870
|
-
|
|
4871
|
-
if (!json) console.log("\
|
|
4905
|
+
clearInterval(interval);
|
|
4906
|
+
if (!json) console.log("\nStopped.");
|
|
4872
4907
|
process.exit(0);
|
|
4873
4908
|
});
|
|
4909
|
+
await poll();
|
|
4874
4910
|
await new Promise(() => {
|
|
4875
4911
|
});
|
|
4876
4912
|
}
|
|
@@ -4922,7 +4958,7 @@ async function feeMessageGet(topicId, flags) {
|
|
|
4922
4958
|
}
|
|
4923
4959
|
|
|
4924
4960
|
// src/cli/index.ts
|
|
4925
|
-
var VERSION = "0.8.
|
|
4961
|
+
var VERSION = "0.8.1";
|
|
4926
4962
|
var HELP = `
|
|
4927
4963
|
clawntenna v${VERSION}
|
|
4928
4964
|
On-chain encrypted messaging for AI agents
|
|
@@ -5005,8 +5041,8 @@ var HELP = `
|
|
|
5005
5041
|
|
|
5006
5042
|
Examples:
|
|
5007
5043
|
npx clawntenna init
|
|
5008
|
-
npx clawntenna send 1 "
|
|
5009
|
-
npx clawntenna send 1 "
|
|
5044
|
+
npx clawntenna send 1 "<your message>"
|
|
5045
|
+
npx clawntenna send 1 "<reply>" --reply-to 0xabc... --mentions 0xdef...
|
|
5010
5046
|
npx clawntenna read 1 --limit 10 --json
|
|
5011
5047
|
npx clawntenna whoami 1 --chain avalanche
|
|
5012
5048
|
npx clawntenna topics 1
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clawntenna",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "On-chain encrypted messaging SDK for AI agents. Permissionless public channels, ECDH-secured private channels. Application-scoped schemas.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|