@clawnch/clawtomaton 0.3.0 → 0.4.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.
Files changed (79) hide show
  1. package/README.md +2 -2
  2. package/dist/agent/index.d.ts +5 -1
  3. package/dist/agent/index.d.ts.map +1 -1
  4. package/dist/agent/index.js +108 -10
  5. package/dist/agent/index.js.map +1 -1
  6. package/dist/agent/prompt.d.ts.map +1 -1
  7. package/dist/agent/prompt.js +158 -2
  8. package/dist/agent/prompt.js.map +1 -1
  9. package/dist/heartbeat/index.d.ts +18 -0
  10. package/dist/heartbeat/index.d.ts.map +1 -1
  11. package/dist/heartbeat/index.js +153 -2
  12. package/dist/heartbeat/index.js.map +1 -1
  13. package/dist/index.d.ts +3 -1
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +3 -1
  16. package/dist/index.js.map +1 -1
  17. package/dist/market/index.d.ts +8 -1
  18. package/dist/market/index.d.ts.map +1 -1
  19. package/dist/market/index.js +28 -2
  20. package/dist/market/index.js.map +1 -1
  21. package/dist/skills/analyze-market.d.ts +17 -0
  22. package/dist/skills/analyze-market.d.ts.map +1 -0
  23. package/dist/skills/analyze-market.js +156 -0
  24. package/dist/skills/analyze-market.js.map +1 -0
  25. package/dist/skills/check-balance.d.ts +2 -2
  26. package/dist/skills/check-balance.d.ts.map +1 -1
  27. package/dist/skills/check-balance.js +43 -8
  28. package/dist/skills/check-balance.js.map +1 -1
  29. package/dist/skills/check-price.d.ts +11 -0
  30. package/dist/skills/check-price.d.ts.map +1 -0
  31. package/dist/skills/check-price.js +83 -0
  32. package/dist/skills/check-price.js.map +1 -0
  33. package/dist/skills/claim-vault.d.ts +15 -0
  34. package/dist/skills/claim-vault.d.ts.map +1 -0
  35. package/dist/skills/claim-vault.js +96 -0
  36. package/dist/skills/claim-vault.js.map +1 -0
  37. package/dist/skills/deploy.d.ts.map +1 -1
  38. package/dist/skills/deploy.js +10 -1
  39. package/dist/skills/deploy.js.map +1 -1
  40. package/dist/skills/index.d.ts +8 -1
  41. package/dist/skills/index.d.ts.map +1 -1
  42. package/dist/skills/index.js +29 -1
  43. package/dist/skills/index.js.map +1 -1
  44. package/dist/skills/manage-orders.d.ts +26 -0
  45. package/dist/skills/manage-orders.d.ts.map +1 -0
  46. package/dist/skills/manage-orders.js +470 -0
  47. package/dist/skills/manage-orders.js.map +1 -0
  48. package/dist/skills/portfolio.d.ts +19 -0
  49. package/dist/skills/portfolio.d.ts.map +1 -0
  50. package/dist/skills/portfolio.js +189 -0
  51. package/dist/skills/portfolio.js.map +1 -0
  52. package/dist/skills/watch-activity.d.ts +12 -0
  53. package/dist/skills/watch-activity.d.ts.map +1 -0
  54. package/dist/skills/watch-activity.js +130 -0
  55. package/dist/skills/watch-activity.js.map +1 -0
  56. package/dist/skills/xmtp.d.ts +24 -0
  57. package/dist/skills/xmtp.d.ts.map +1 -0
  58. package/dist/skills/xmtp.js +282 -0
  59. package/dist/skills/xmtp.js.map +1 -0
  60. package/dist/state/index.d.ts +19 -0
  61. package/dist/state/index.d.ts.map +1 -1
  62. package/dist/state/index.js +101 -0
  63. package/dist/state/index.js.map +1 -1
  64. package/dist/types.d.ts +16 -0
  65. package/dist/types.d.ts.map +1 -1
  66. package/dist/types.js.map +1 -1
  67. package/dist/xmtp/client.d.ts +127 -0
  68. package/dist/xmtp/client.d.ts.map +1 -0
  69. package/dist/xmtp/client.js +454 -0
  70. package/dist/xmtp/client.js.map +1 -0
  71. package/dist/xmtp/index.d.ts +9 -0
  72. package/dist/xmtp/index.d.ts.map +1 -0
  73. package/dist/xmtp/index.js +8 -0
  74. package/dist/xmtp/index.js.map +1 -0
  75. package/dist/xmtp/types.d.ts +80 -0
  76. package/dist/xmtp/types.d.ts.map +1 -0
  77. package/dist/xmtp/types.js +5 -0
  78. package/dist/xmtp/types.js.map +1 -0
  79. package/package.json +3 -2
@@ -0,0 +1,127 @@
1
+ /**
2
+ * XMTP client wrapper for Clawtomaton.
3
+ *
4
+ * Manages the XMTP Agent SDK lifecycle: creation, message streaming,
5
+ * conversation management, and graceful shutdown.
6
+ *
7
+ * The agent's existing Ethereum wallet key is used as the XMTP identity —
8
+ * no new keypair needed.
9
+ *
10
+ * IMPORTANT: XMTP creates local SQLite database files that MUST persist
11
+ * across restarts. Each restart without the DB creates a new installation,
12
+ * and you're limited to 10 installations per inbox.
13
+ */
14
+ import type { XmtpConfig, XmtpMessage, XmtpConversationInfo } from './types.js';
15
+ import type { StateStore } from '../state/index.js';
16
+ export declare class XmtpClient {
17
+ private agent;
18
+ private config;
19
+ private state;
20
+ private walletKey;
21
+ private started;
22
+ private messageQueue;
23
+ private maxQueueSize;
24
+ private lastProcessedTime;
25
+ constructor(config: XmtpConfig, walletKey: `0x${string}`, state: StateStore);
26
+ /**
27
+ * Initialize and start the XMTP agent.
28
+ * Begins streaming messages into the internal queue.
29
+ */
30
+ start(): Promise<void>;
31
+ /**
32
+ * Stop the XMTP agent gracefully.
33
+ */
34
+ stop(): Promise<void>;
35
+ /**
36
+ * Check if there are unprocessed messages in the queue.
37
+ * Used by the heartbeat to decide whether to wake the agent.
38
+ */
39
+ hasUnreadMessages(): boolean;
40
+ /**
41
+ * Drain all queued messages (marks them as processed).
42
+ * Returns messages ordered by sentAt.
43
+ */
44
+ drainMessages(): XmtpMessage[];
45
+ /**
46
+ * Peek at queued messages without draining.
47
+ */
48
+ peekMessages(): XmtpMessage[];
49
+ /**
50
+ * Send a text message to a conversation by ID.
51
+ */
52
+ sendMessage(conversationId: string, text: string): Promise<void>;
53
+ /**
54
+ * Send a text message to an address (creates DM if needed).
55
+ * Uses agent.createDmWithAddress() which handles identity resolution.
56
+ */
57
+ sendToAddress(address: string, text: string): Promise<string>;
58
+ /**
59
+ * List recent conversations with metadata.
60
+ */
61
+ listConversations(limit?: number): Promise<XmtpConversationInfo[]>;
62
+ /**
63
+ * Get recent messages from a specific conversation.
64
+ */
65
+ getConversationHistory(conversationId: string, limit?: number): Promise<XmtpMessage[]>;
66
+ /**
67
+ * Request an ETH payment from a user via wallet_sendCalls.
68
+ * The user's wallet app prompts them to approve the transfer.
69
+ *
70
+ * @param conversationId - The conversation to send the request in
71
+ * @param amount - Amount in wei (bigint)
72
+ * @param description - Human-readable description shown in the wallet prompt
73
+ * @param chainId - Chain ID (default: 8453 for Base)
74
+ */
75
+ requestEthPayment(conversationId: string, amount: bigint, description: string, chainId?: number): Promise<void>;
76
+ /**
77
+ * Request an ERC-20 token payment from a user via wallet_sendCalls.
78
+ *
79
+ * @param conversationId - The conversation to send the request in
80
+ * @param tokenAddress - ERC-20 contract address
81
+ * @param amount - Raw token amount (bigint, accounting for decimals)
82
+ * @param description - Human-readable description
83
+ * @param chainId - Chain ID (default: 8453 for Base)
84
+ */
85
+ requestTokenPayment(conversationId: string, tokenAddress: string, amount: bigint, description: string, chainId?: number): Promise<void>;
86
+ /**
87
+ * Send a transaction reference (share a confirmed tx hash in a conversation).
88
+ *
89
+ * @param conversationId - The conversation to share in
90
+ * @param txHash - The transaction hash
91
+ * @param chainId - Chain ID (default: 8453 for Base)
92
+ * @param metadata - Optional metadata (currency, amount, addresses)
93
+ */
94
+ sendTransactionReference(conversationId: string, txHash: string, chainId?: number, metadata?: {
95
+ transactionType?: string;
96
+ currency?: string;
97
+ amount?: number;
98
+ decimals?: number;
99
+ fromAddress?: string;
100
+ toAddress?: string;
101
+ }): Promise<void>;
102
+ /**
103
+ * Check an ERC-20 token balance for an address.
104
+ *
105
+ * @param tokenAddress - ERC-20 contract address
106
+ * @param walletAddress - The address to check
107
+ * @param chainId - Chain ID (default: 8453 for Base)
108
+ * @returns Raw balance (bigint) and decimals
109
+ */
110
+ getTokenBalance(tokenAddress: string, walletAddress: string, chainId?: number): Promise<{
111
+ balance: bigint;
112
+ decimals: number;
113
+ }>;
114
+ /**
115
+ * Get the XMTP address (same as wallet address).
116
+ */
117
+ getAddress(): string | null;
118
+ /**
119
+ * Check if the client is running.
120
+ */
121
+ isStarted(): boolean;
122
+ /**
123
+ * Get the number of queued messages.
124
+ */
125
+ getQueueSize(): number;
126
+ }
127
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/xmtp/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAChF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AA6BpD,qBAAa,UAAU;IACrB,OAAO,CAAC,KAAK,CAAa;IAC1B,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,KAAK,CAAa;IAC1B,OAAO,CAAC,SAAS,CAAgB;IACjC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,YAAY,CAAO;IAC3B,OAAO,CAAC,iBAAiB,CAAK;gBAElB,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,MAAM,EAAE,EAAE,KAAK,EAAE,UAAU;IAM3E;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA+G5B;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAa3B;;;OAGG;IACH,iBAAiB,IAAI,OAAO;IAI5B;;;OAGG;IACH,aAAa,IAAI,WAAW,EAAE;IAO9B;;OAEG;IACH,YAAY,IAAI,WAAW,EAAE;IAI7B;;OAEG;IACG,WAAW,CAAC,cAAc,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IActE;;;OAGG;IACG,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAanE;;OAEG;IACG,iBAAiB,CAAC,KAAK,GAAE,MAAW,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC;IA2C5E;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 * Manages the XMTP Agent SDK lifecycle: creation, message streaming,
5
+ * conversation management, and graceful shutdown.
6
+ *
7
+ * The agent's existing Ethereum wallet key is used as the XMTP identity —
8
+ * no new keypair needed.
9
+ *
10
+ * IMPORTANT: XMTP creates local SQLite database files that MUST persist
11
+ * across restarts. Each restart without the DB creates a new installation,
12
+ * and you're limited to 10 installations per inbox.
13
+ */
14
+ // Lazy-loaded to keep XMTP optional
15
+ let _Agent = null;
16
+ let _createSigner = null;
17
+ let _createUser = null;
18
+ let _createERC20TransferCalls = null;
19
+ let _createNativeTransferCalls = null;
20
+ let _getERC20Balance = null;
21
+ let _getERC20Decimals = null;
22
+ let _validHex = null;
23
+ async function loadXmtpSdk() {
24
+ if (_Agent)
25
+ return;
26
+ const sdk = await import('@xmtp/agent-sdk');
27
+ _Agent = sdk.Agent;
28
+ _createSigner = sdk.createSigner;
29
+ _createUser = sdk.createUser;
30
+ _createERC20TransferCalls = sdk.createERC20TransferCalls;
31
+ _createNativeTransferCalls = sdk.createNativeTransferCalls;
32
+ _getERC20Balance = sdk.getERC20Balance;
33
+ _getERC20Decimals = sdk.getERC20Decimals;
34
+ _validHex = sdk.validHex;
35
+ }
36
+ // ============================================================================
37
+ // XMTP Client
38
+ // ============================================================================
39
+ export class XmtpClient {
40
+ agent = null; // XMTP Agent instance
41
+ config;
42
+ state;
43
+ walletKey;
44
+ started = false;
45
+ messageQueue = [];
46
+ maxQueueSize = 100;
47
+ lastProcessedTime = 0;
48
+ constructor(config, walletKey, state) {
49
+ this.config = config;
50
+ this.walletKey = walletKey;
51
+ this.state = state;
52
+ }
53
+ /**
54
+ * Initialize and start the XMTP agent.
55
+ * Begins streaming messages into the internal queue.
56
+ */
57
+ async start() {
58
+ if (this.started)
59
+ return;
60
+ await loadXmtpSdk();
61
+ const user = _createUser(this.walletKey);
62
+ const signer = _createSigner(user);
63
+ // Derive encryption key from wallet key (deterministic — same wallet = same key)
64
+ const encryptionKey = this.config.dbEncryptionKey
65
+ ? hexToBytes(this.config.dbEncryptionKey)
66
+ : deriveEncryptionKey(this.walletKey);
67
+ this.agent = await _Agent.create(signer, {
68
+ env: this.config.env ?? 'production',
69
+ dbEncryptionKey: encryptionKey,
70
+ dbPath: this.config.dbPath ?? undefined,
71
+ appVersion: 'clawtomaton/0.4.0',
72
+ });
73
+ // Stream text messages into our queue
74
+ this.agent.on('text', async (ctx) => {
75
+ const senderAddress = await ctx.getSenderAddress();
76
+ const agentAddress = ctx.getClientAddress();
77
+ // Don't queue our own messages
78
+ if (senderAddress?.toLowerCase() === agentAddress?.toLowerCase())
79
+ return;
80
+ const msg = {
81
+ id: ctx.message.id,
82
+ conversationId: ctx.conversation.id,
83
+ senderAddress: senderAddress ?? 'unknown',
84
+ content: ctx.message.content,
85
+ sentAt: ctx.message.sentAt?.getTime?.() ?? Date.now(),
86
+ isDm: ctx.isDm?.() ?? true,
87
+ isGroup: ctx.isGroup?.() ?? false,
88
+ };
89
+ this.messageQueue.push(msg);
90
+ // Cap queue size
91
+ if (this.messageQueue.length > this.maxQueueSize) {
92
+ this.messageQueue = this.messageQueue.slice(-this.maxQueueSize);
93
+ }
94
+ });
95
+ // Track new conversations
96
+ this.agent.on('dm', async (ctx) => {
97
+ this.state.audit('xmtp_dm', `New DM conversation: ${ctx.conversation.id}`);
98
+ });
99
+ this.agent.on('group', async (ctx) => {
100
+ this.state.audit('xmtp_group', `Added to group: ${ctx.conversation.id}`);
101
+ });
102
+ // Stream transaction confirmations into the queue
103
+ this.agent.on('transaction-reference', async (ctx) => {
104
+ try {
105
+ const senderAddress = await ctx.getSenderAddress();
106
+ const agentAddress = ctx.getClientAddress();
107
+ // Don't queue our own transaction references
108
+ if (senderAddress?.toLowerCase() === agentAddress?.toLowerCase())
109
+ return;
110
+ const { networkId, reference, metadata } = ctx.message.content ?? {};
111
+ const chainId = networkId ? parseInt(networkId, 16) || parseInt(networkId, 10) || 0 : 0;
112
+ const msg = {
113
+ id: ctx.message.id,
114
+ conversationId: ctx.conversation.id,
115
+ senderAddress: senderAddress ?? 'unknown',
116
+ content: `Transaction confirmed: ${reference ?? 'unknown'} on chain ${chainId}`,
117
+ sentAt: ctx.message.sentAt?.getTime?.() ?? Date.now(),
118
+ isDm: ctx.isDm?.() ?? true,
119
+ isGroup: ctx.isGroup?.() ?? false,
120
+ type: 'transaction_confirmed',
121
+ transaction: {
122
+ chainId,
123
+ txHash: reference ?? '',
124
+ transactionType: metadata?.transactionType,
125
+ currency: metadata?.currency,
126
+ amount: metadata?.amount != null ? String(metadata.amount) : undefined,
127
+ from: metadata?.fromAddress,
128
+ to: metadata?.toAddress,
129
+ },
130
+ };
131
+ this.messageQueue.push(msg);
132
+ if (this.messageQueue.length > this.maxQueueSize) {
133
+ this.messageQueue = this.messageQueue.slice(-this.maxQueueSize);
134
+ }
135
+ this.state.audit('xmtp_tx_confirmed', `TX ${reference} on chain ${chainId} from ${senderAddress}`);
136
+ }
137
+ catch {
138
+ // Non-fatal — don't crash the stream on bad transaction references
139
+ }
140
+ });
141
+ this.agent.on('unhandledError', (error) => {
142
+ console.error(`[xmtp] Unhandled error: ${error}`);
143
+ this.state.audit('xmtp_error', String(error));
144
+ });
145
+ await this.agent.start();
146
+ this.started = true;
147
+ this.lastProcessedTime = Date.now();
148
+ console.log(`[xmtp] Started — address: ${this.agent.address}`);
149
+ this.state.audit('xmtp_started', `XMTP agent started. Address: ${this.agent.address}`);
150
+ }
151
+ /**
152
+ * Stop the XMTP agent gracefully.
153
+ */
154
+ async stop() {
155
+ if (!this.started || !this.agent)
156
+ return;
157
+ try {
158
+ await this.agent.stop();
159
+ }
160
+ catch (err) {
161
+ console.error(`[xmtp] Error stopping: ${err}`);
162
+ }
163
+ this.started = false;
164
+ console.log('[xmtp] Stopped.');
165
+ }
166
+ /**
167
+ * Check if there are unprocessed messages in the queue.
168
+ * Used by the heartbeat to decide whether to wake the agent.
169
+ */
170
+ hasUnreadMessages() {
171
+ return this.messageQueue.length > 0;
172
+ }
173
+ /**
174
+ * Drain all queued messages (marks them as processed).
175
+ * Returns messages ordered by sentAt.
176
+ */
177
+ drainMessages() {
178
+ const messages = [...this.messageQueue].sort((a, b) => a.sentAt - b.sentAt);
179
+ this.messageQueue = [];
180
+ this.lastProcessedTime = Date.now();
181
+ return messages;
182
+ }
183
+ /**
184
+ * Peek at queued messages without draining.
185
+ */
186
+ peekMessages() {
187
+ return [...this.messageQueue].sort((a, b) => a.sentAt - b.sentAt);
188
+ }
189
+ /**
190
+ * Send a text message to a conversation by ID.
191
+ */
192
+ async sendMessage(conversationId, text) {
193
+ if (!this.started || !this.agent) {
194
+ throw new Error('XMTP client not started');
195
+ }
196
+ const conversation = await this.agent.client.conversations.getConversationById(conversationId);
197
+ if (!conversation) {
198
+ throw new Error(`Conversation not found: ${conversationId}`);
199
+ }
200
+ await conversation.sendText(text);
201
+ this.state.audit('xmtp_sent', `Sent message to ${conversationId}: ${text.slice(0, 100)}`);
202
+ }
203
+ /**
204
+ * Send a text message to an address (creates DM if needed).
205
+ * Uses agent.createDmWithAddress() which handles identity resolution.
206
+ */
207
+ async sendToAddress(address, text) {
208
+ if (!this.started || !this.agent) {
209
+ throw new Error('XMTP client not started');
210
+ }
211
+ const conversation = await this.agent.createDmWithAddress(address);
212
+ await conversation.sendText(text);
213
+ const conversationId = conversation.id;
214
+ this.state.audit('xmtp_sent', `Sent DM to ${address}: ${text.slice(0, 100)}`);
215
+ return conversationId;
216
+ }
217
+ /**
218
+ * List recent conversations with metadata.
219
+ */
220
+ async listConversations(limit = 20) {
221
+ if (!this.started || !this.agent) {
222
+ throw new Error('XMTP client not started');
223
+ }
224
+ await this.agent.client.conversations.sync();
225
+ const convos = await this.agent.client.conversations.list();
226
+ const results = [];
227
+ for (const convo of convos.slice(0, limit)) {
228
+ try {
229
+ const messages = await convo.messages();
230
+ // Find the last text message (skip system/group_updated messages)
231
+ const textMessages = messages.filter((m) => typeof m.content === 'string' && m.contentType?.typeId === 'text');
232
+ const lastMessage = textMessages[textMessages.length - 1];
233
+ const members = await convo.members();
234
+ // Check if DM by constructor name (Dm vs Group)
235
+ const isDm = convo.constructor?.name === 'Dm';
236
+ results.push({
237
+ id: convo.id,
238
+ isDm,
239
+ memberCount: members.length,
240
+ lastMessageAt: lastMessage?.sentAt?.getTime?.() ?? 0,
241
+ lastMessagePreview: lastMessage?.content
242
+ ? String(lastMessage.content).slice(0, 80)
243
+ : undefined,
244
+ });
245
+ }
246
+ catch {
247
+ results.push({
248
+ id: convo.id,
249
+ isDm: false,
250
+ memberCount: 0,
251
+ lastMessageAt: 0,
252
+ });
253
+ }
254
+ }
255
+ return results.sort((a, b) => b.lastMessageAt - a.lastMessageAt);
256
+ }
257
+ /**
258
+ * Get recent messages from a specific conversation.
259
+ */
260
+ async getConversationHistory(conversationId, limit = 20) {
261
+ if (!this.started || !this.agent) {
262
+ throw new Error('XMTP client not started');
263
+ }
264
+ const conversation = await this.agent.client.conversations.getConversationById(conversationId);
265
+ if (!conversation) {
266
+ throw new Error(`Conversation not found: ${conversationId}`);
267
+ }
268
+ await conversation.sync();
269
+ const allMessages = await conversation.messages();
270
+ // Filter to text messages only (skip group_updated, reactions, etc.)
271
+ const textMessages = allMessages.filter((m) => typeof m.content === 'string' && m.contentType?.typeId === 'text');
272
+ // Take the most recent `limit` messages
273
+ const recent = textMessages.slice(-limit);
274
+ const isDm = conversation.constructor?.name === 'Dm';
275
+ const results = [];
276
+ for (const msg of recent) {
277
+ results.push({
278
+ id: msg.id,
279
+ conversationId,
280
+ senderAddress: msg.senderInboxId ?? 'unknown',
281
+ content: msg.content,
282
+ sentAt: msg.sentAt?.getTime?.() ?? 0,
283
+ isDm,
284
+ isGroup: !isDm,
285
+ });
286
+ }
287
+ return results;
288
+ }
289
+ // ==========================================================================
290
+ // Payments
291
+ // ==========================================================================
292
+ /**
293
+ * Request an ETH payment from a user via wallet_sendCalls.
294
+ * The user's wallet app prompts them to approve the transfer.
295
+ *
296
+ * @param conversationId - The conversation to send the request in
297
+ * @param amount - Amount in wei (bigint)
298
+ * @param description - Human-readable description shown in the wallet prompt
299
+ * @param chainId - Chain ID (default: 8453 for Base)
300
+ */
301
+ async requestEthPayment(conversationId, amount, description, chainId = 8453) {
302
+ if (!this.started || !this.agent)
303
+ throw new Error('XMTP client not started');
304
+ const conversation = await this.agent.client.conversations.getConversationById(conversationId);
305
+ if (!conversation)
306
+ throw new Error(`Conversation not found: ${conversationId}`);
307
+ // Get sender address from conversation members (the other party)
308
+ const members = await conversation.members();
309
+ const agentInboxId = this.agent.client.inboxId;
310
+ const otherMember = members.find((m) => m.inboxId !== agentInboxId);
311
+ if (!otherMember)
312
+ throw new Error('No other member in conversation');
313
+ // Resolve the other member's address
314
+ const otherAddresses = otherMember.accountAddresses ?? [];
315
+ const fromAddress = otherAddresses[0];
316
+ if (!fromAddress)
317
+ throw new Error('Could not resolve sender address');
318
+ const { base } = await import('viem/chains');
319
+ const chain = chainId === 8453 ? base : { id: chainId, name: `Chain ${chainId}` };
320
+ const walletSendCalls = _createNativeTransferCalls({
321
+ chain,
322
+ from: _validHex(fromAddress),
323
+ to: _validHex(this.agent.address),
324
+ amount,
325
+ description,
326
+ });
327
+ await conversation.sendWalletSendCalls(walletSendCalls);
328
+ const ethAmount = Number(amount) / 1e18;
329
+ this.state.audit('xmtp_payment_request', `Requested ${ethAmount.toFixed(6)} ETH in ${conversationId}`);
330
+ }
331
+ /**
332
+ * Request an ERC-20 token payment from a user via wallet_sendCalls.
333
+ *
334
+ * @param conversationId - The conversation to send the request in
335
+ * @param tokenAddress - ERC-20 contract address
336
+ * @param amount - Raw token amount (bigint, accounting for decimals)
337
+ * @param description - Human-readable description
338
+ * @param chainId - Chain ID (default: 8453 for Base)
339
+ */
340
+ async requestTokenPayment(conversationId, tokenAddress, amount, description, chainId = 8453) {
341
+ if (!this.started || !this.agent)
342
+ throw new Error('XMTP client not started');
343
+ const conversation = await this.agent.client.conversations.getConversationById(conversationId);
344
+ if (!conversation)
345
+ throw new Error(`Conversation not found: ${conversationId}`);
346
+ const members = await conversation.members();
347
+ const agentInboxId = this.agent.client.inboxId;
348
+ const otherMember = members.find((m) => m.inboxId !== agentInboxId);
349
+ if (!otherMember)
350
+ throw new Error('No other member in conversation');
351
+ const otherAddresses = otherMember.accountAddresses ?? [];
352
+ const fromAddress = otherAddresses[0];
353
+ if (!fromAddress)
354
+ throw new Error('Could not resolve sender address');
355
+ const { base } = await import('viem/chains');
356
+ const chain = chainId === 8453 ? base : { id: chainId, name: `Chain ${chainId}` };
357
+ const walletSendCalls = _createERC20TransferCalls({
358
+ chain,
359
+ tokenAddress: _validHex(tokenAddress),
360
+ from: _validHex(fromAddress),
361
+ to: _validHex(this.agent.address),
362
+ amount,
363
+ description,
364
+ });
365
+ await conversation.sendWalletSendCalls(walletSendCalls);
366
+ this.state.audit('xmtp_payment_request', `Requested token ${tokenAddress} in ${conversationId}`);
367
+ }
368
+ /**
369
+ * Send a transaction reference (share a confirmed tx hash in a conversation).
370
+ *
371
+ * @param conversationId - The conversation to share in
372
+ * @param txHash - The transaction hash
373
+ * @param chainId - Chain ID (default: 8453 for Base)
374
+ * @param metadata - Optional metadata (currency, amount, addresses)
375
+ */
376
+ async sendTransactionReference(conversationId, txHash, chainId = 8453, metadata) {
377
+ if (!this.started || !this.agent)
378
+ throw new Error('XMTP client not started');
379
+ const conversation = await this.agent.client.conversations.getConversationById(conversationId);
380
+ if (!conversation)
381
+ throw new Error(`Conversation not found: ${conversationId}`);
382
+ const ref = {
383
+ namespace: 'eip155',
384
+ networkId: chainId,
385
+ reference: txHash,
386
+ metadata: metadata ?? {},
387
+ };
388
+ await conversation.sendTransactionReference(ref);
389
+ this.state.audit('xmtp_tx_ref', `Shared tx ${txHash} in ${conversationId}`);
390
+ }
391
+ /**
392
+ * Check an ERC-20 token balance for an address.
393
+ *
394
+ * @param tokenAddress - ERC-20 contract address
395
+ * @param walletAddress - The address to check
396
+ * @param chainId - Chain ID (default: 8453 for Base)
397
+ * @returns Raw balance (bigint) and decimals
398
+ */
399
+ async getTokenBalance(tokenAddress, walletAddress, chainId = 8453) {
400
+ await loadXmtpSdk();
401
+ const { base } = await import('viem/chains');
402
+ const chain = chainId === 8453 ? base : { id: chainId, name: `Chain ${chainId}` };
403
+ const decimals = await _getERC20Decimals({
404
+ chain,
405
+ tokenAddress: _validHex(tokenAddress),
406
+ });
407
+ const balance = await _getERC20Balance({
408
+ chain,
409
+ tokenAddress: _validHex(tokenAddress),
410
+ address: _validHex(walletAddress),
411
+ });
412
+ return { balance, decimals };
413
+ }
414
+ /**
415
+ * Get the XMTP address (same as wallet address).
416
+ */
417
+ getAddress() {
418
+ return this.agent?.address ?? null;
419
+ }
420
+ /**
421
+ * Check if the client is running.
422
+ */
423
+ isStarted() {
424
+ return this.started;
425
+ }
426
+ /**
427
+ * Get the number of queued messages.
428
+ */
429
+ getQueueSize() {
430
+ return this.messageQueue.length;
431
+ }
432
+ }
433
+ // ============================================================================
434
+ // Helpers
435
+ // ============================================================================
436
+ /**
437
+ * Derive a deterministic 32-byte encryption key from the wallet private key.
438
+ * Uses a simple hash approach — the key is always the same for the same wallet.
439
+ */
440
+ function deriveEncryptionKey(walletKey) {
441
+ // Simple derivation: take the raw bytes of the private key
442
+ // The wallet key is already 32 bytes (64 hex chars after 0x prefix)
443
+ const hex = walletKey.slice(2);
444
+ return hexToBytes(`0x${hex}`);
445
+ }
446
+ function hexToBytes(hex) {
447
+ const cleanHex = hex.startsWith('0x') ? hex.slice(2) : hex;
448
+ const bytes = new Uint8Array(cleanHex.length / 2);
449
+ for (let i = 0; i < bytes.length; i++) {
450
+ bytes[i] = parseInt(cleanHex.slice(i * 2, i * 2 + 2), 16);
451
+ }
452
+ return bytes;
453
+ }
454
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/xmtp/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,oCAAoC;AACpC,IAAI,MAAM,GAAkD,IAAI,CAAC;AACjE,IAAI,aA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IAED;;OAEG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,KAAK,EAAE,OAAO,IAAI,IAAI,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,YAAY;QACV,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC;IAClC,CAAC;CACF;AAED,+EAA+E;AAC/E,UAAU;AACV,+EAA+E;AAE/E;;;GAGG;AACH,SAAS,mBAAmB,CAAC,SAAwB;IACnD,2DAA2D;IAC3D,oEAAoE;IACpE,MAAM,GAAG,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC/B,OAAO,UAAU,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;AAChC,CAAC;AAED,SAAS,UAAU,CAAC,GAAW;IAC7B,MAAM,QAAQ,GAAG,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAC3D,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAClD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,KAAK,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * XMTP module — bidirectional encrypted messaging for Clawtomaton agents.
3
+ *
4
+ * Agents can receive commands and send updates via XMTP.
5
+ * Discoverable on Base App, World App, and xmtp.chat.
6
+ */
7
+ export { XmtpClient } from './client.js';
8
+ export type { XmtpConfig, XmtpMessage, XmtpMessageType, XmtpConversationInfo, XmtpTransactionRef } from './types.js';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/xmtp/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * XMTP module — bidirectional encrypted messaging for Clawtomaton agents.
3
+ *
4
+ * Agents can receive commands and send updates via XMTP.
5
+ * Discoverable on Base App, World App, and xmtp.chat.
6
+ */
7
+ export { XmtpClient } from './client.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/xmtp/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}