agent0-sdk 0.2.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/LICENSE +21 -0
  2. package/README.md +234 -0
  3. package/dist/core/agent.d.ts +76 -0
  4. package/dist/core/agent.d.ts.map +1 -0
  5. package/dist/core/agent.js +477 -0
  6. package/dist/core/agent.js.map +1 -0
  7. package/dist/core/contracts.d.ts +688 -0
  8. package/dist/core/contracts.d.ts.map +1 -0
  9. package/dist/core/contracts.js +348 -0
  10. package/dist/core/contracts.js.map +1 -0
  11. package/dist/core/endpoint-crawler.d.ts +44 -0
  12. package/dist/core/endpoint-crawler.d.ts.map +1 -0
  13. package/dist/core/endpoint-crawler.js +280 -0
  14. package/dist/core/endpoint-crawler.js.map +1 -0
  15. package/dist/core/feedback-manager.d.ts +98 -0
  16. package/dist/core/feedback-manager.d.ts.map +1 -0
  17. package/dist/core/feedback-manager.js +543 -0
  18. package/dist/core/feedback-manager.js.map +1 -0
  19. package/dist/core/indexer.d.ts +37 -0
  20. package/dist/core/indexer.d.ts.map +1 -0
  21. package/dist/core/indexer.js +189 -0
  22. package/dist/core/indexer.js.map +1 -0
  23. package/dist/core/ipfs-client.d.ts +88 -0
  24. package/dist/core/ipfs-client.d.ts.map +1 -0
  25. package/dist/core/ipfs-client.js +334 -0
  26. package/dist/core/ipfs-client.js.map +1 -0
  27. package/dist/core/sdk.d.ts +177 -0
  28. package/dist/core/sdk.d.ts.map +1 -0
  29. package/dist/core/sdk.js +544 -0
  30. package/dist/core/sdk.js.map +1 -0
  31. package/dist/core/subgraph-client.d.ts +68 -0
  32. package/dist/core/subgraph-client.d.ts.map +1 -0
  33. package/dist/core/subgraph-client.js +635 -0
  34. package/dist/core/subgraph-client.js.map +1 -0
  35. package/dist/core/web3-client.d.ts +94 -0
  36. package/dist/core/web3-client.d.ts.map +1 -0
  37. package/dist/core/web3-client.js +197 -0
  38. package/dist/core/web3-client.js.map +1 -0
  39. package/dist/index.d.ts +20 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/index.js +20 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/models/enums.d.ts +22 -0
  44. package/dist/models/enums.d.ts.map +1 -0
  45. package/dist/models/enums.js +24 -0
  46. package/dist/models/enums.js.map +1 -0
  47. package/dist/models/generated/subgraph-types.d.ts +208 -0
  48. package/dist/models/generated/subgraph-types.d.ts.map +1 -0
  49. package/dist/models/generated/subgraph-types.js +2 -0
  50. package/dist/models/generated/subgraph-types.js.map +1 -0
  51. package/dist/models/index.d.ts +8 -0
  52. package/dist/models/index.d.ts.map +1 -0
  53. package/dist/models/index.js +8 -0
  54. package/dist/models/index.js.map +1 -0
  55. package/dist/models/interfaces.d.ts +125 -0
  56. package/dist/models/interfaces.d.ts.map +1 -0
  57. package/dist/models/interfaces.js +5 -0
  58. package/dist/models/interfaces.js.map +1 -0
  59. package/dist/models/types.d.ts +11 -0
  60. package/dist/models/types.d.ts.map +1 -0
  61. package/dist/models/types.js +5 -0
  62. package/dist/models/types.js.map +1 -0
  63. package/dist/utils/constants.d.ts +24 -0
  64. package/dist/utils/constants.d.ts.map +1 -0
  65. package/dist/utils/constants.js +28 -0
  66. package/dist/utils/constants.js.map +1 -0
  67. package/dist/utils/id-format.d.ts +30 -0
  68. package/dist/utils/id-format.d.ts.map +1 -0
  69. package/dist/utils/id-format.js +67 -0
  70. package/dist/utils/id-format.js.map +1 -0
  71. package/dist/utils/index.d.ts +7 -0
  72. package/dist/utils/index.d.ts.map +1 -0
  73. package/dist/utils/index.js +7 -0
  74. package/dist/utils/index.js.map +1 -0
  75. package/dist/utils/validation.d.ts +25 -0
  76. package/dist/utils/validation.d.ts.map +1 -0
  77. package/dist/utils/validation.js +61 -0
  78. package/dist/utils/validation.js.map +1 -0
  79. package/package.json +71 -0
@@ -0,0 +1,477 @@
1
+ /**
2
+ * Agent class for managing individual agents
3
+ */
4
+ import { ethers } from 'ethers';
5
+ import { EndpointType, TrustModel } from '../models/enums';
6
+ import { EndpointCrawler } from './endpoint-crawler';
7
+ import { parseAgentId } from '../utils/id-format';
8
+ import { TIMEOUTS } from '../utils/constants';
9
+ /**
10
+ * Agent class for managing individual agents
11
+ */
12
+ export class Agent {
13
+ constructor(sdk, registrationFile) {
14
+ this.sdk = sdk;
15
+ this._dirtyMetadata = new Set();
16
+ this.registrationFile = registrationFile;
17
+ this._endpointCrawler = new EndpointCrawler(5000);
18
+ }
19
+ // Read-only properties
20
+ get agentId() {
21
+ return this.registrationFile.agentId;
22
+ }
23
+ get agentURI() {
24
+ return this.registrationFile.agentURI;
25
+ }
26
+ get name() {
27
+ return this.registrationFile.name;
28
+ }
29
+ get description() {
30
+ return this.registrationFile.description;
31
+ }
32
+ get image() {
33
+ return this.registrationFile.image;
34
+ }
35
+ get mcpEndpoint() {
36
+ const ep = this.registrationFile.endpoints.find((e) => e.type === EndpointType.MCP);
37
+ return ep?.value;
38
+ }
39
+ get a2aEndpoint() {
40
+ const ep = this.registrationFile.endpoints.find((e) => e.type === EndpointType.A2A);
41
+ return ep?.value;
42
+ }
43
+ get ensEndpoint() {
44
+ const ep = this.registrationFile.endpoints.find((e) => e.type === EndpointType.ENS);
45
+ return ep?.value;
46
+ }
47
+ get walletAddress() {
48
+ return this.registrationFile.walletAddress;
49
+ }
50
+ get mcpTools() {
51
+ const ep = this.registrationFile.endpoints.find((e) => e.type === EndpointType.MCP);
52
+ return ep?.meta?.mcpTools;
53
+ }
54
+ get mcpPrompts() {
55
+ const ep = this.registrationFile.endpoints.find((e) => e.type === EndpointType.MCP);
56
+ return ep?.meta?.mcpPrompts;
57
+ }
58
+ get mcpResources() {
59
+ const ep = this.registrationFile.endpoints.find((e) => e.type === EndpointType.MCP);
60
+ return ep?.meta?.mcpResources;
61
+ }
62
+ get a2aSkills() {
63
+ const ep = this.registrationFile.endpoints.find((e) => e.type === EndpointType.A2A);
64
+ return ep?.meta?.a2aSkills;
65
+ }
66
+ // Endpoint management
67
+ async setMCP(endpoint, version = '2025-06-18', autoFetch = true) {
68
+ // Remove existing MCP endpoint if any
69
+ this.registrationFile.endpoints = this.registrationFile.endpoints.filter((ep) => ep.type !== EndpointType.MCP);
70
+ // Try to fetch capabilities from the endpoint (soft fail)
71
+ const meta = { version };
72
+ if (autoFetch) {
73
+ try {
74
+ const capabilities = await this._endpointCrawler.fetchMcpCapabilities(endpoint);
75
+ if (capabilities) {
76
+ if (capabilities.mcpTools)
77
+ meta.mcpTools = capabilities.mcpTools;
78
+ if (capabilities.mcpPrompts)
79
+ meta.mcpPrompts = capabilities.mcpPrompts;
80
+ if (capabilities.mcpResources)
81
+ meta.mcpResources = capabilities.mcpResources;
82
+ }
83
+ }
84
+ catch (error) {
85
+ // Soft fail - continue without capabilities
86
+ }
87
+ }
88
+ // Add new MCP endpoint
89
+ const mcpEndpoint = {
90
+ type: EndpointType.MCP,
91
+ value: endpoint,
92
+ meta,
93
+ };
94
+ this.registrationFile.endpoints.push(mcpEndpoint);
95
+ this.registrationFile.updatedAt = Math.floor(Date.now() / 1000);
96
+ return this;
97
+ }
98
+ async setA2A(agentcard, version = '0.30', autoFetch = true) {
99
+ // Remove existing A2A endpoint if any
100
+ this.registrationFile.endpoints = this.registrationFile.endpoints.filter((ep) => ep.type !== EndpointType.A2A);
101
+ // Try to fetch capabilities from the endpoint (soft fail)
102
+ const meta = { version };
103
+ if (autoFetch) {
104
+ try {
105
+ const capabilities = await this._endpointCrawler.fetchA2aCapabilities(agentcard);
106
+ if (capabilities?.a2aSkills) {
107
+ meta.a2aSkills = capabilities.a2aSkills;
108
+ }
109
+ }
110
+ catch (error) {
111
+ // Soft fail - continue without capabilities
112
+ }
113
+ }
114
+ // Add new A2A endpoint
115
+ const a2aEndpoint = {
116
+ type: EndpointType.A2A,
117
+ value: agentcard,
118
+ meta,
119
+ };
120
+ this.registrationFile.endpoints.push(a2aEndpoint);
121
+ this.registrationFile.updatedAt = Math.floor(Date.now() / 1000);
122
+ return this;
123
+ }
124
+ setENS(name, version = '1.0') {
125
+ // Remove existing ENS endpoints
126
+ this.registrationFile.endpoints = this.registrationFile.endpoints.filter((ep) => ep.type !== EndpointType.ENS);
127
+ // Check if ENS changed
128
+ if (name !== this._lastRegisteredEns) {
129
+ this._dirtyMetadata.add('agentName');
130
+ }
131
+ // Add new ENS endpoint
132
+ const ensEndpoint = {
133
+ type: EndpointType.ENS,
134
+ value: name,
135
+ meta: { version },
136
+ };
137
+ this.registrationFile.endpoints.push(ensEndpoint);
138
+ this.registrationFile.updatedAt = Math.floor(Date.now() / 1000);
139
+ return this;
140
+ }
141
+ setAgentWallet(address, chainId) {
142
+ this.registrationFile.walletAddress = address;
143
+ this.registrationFile.walletChainId = chainId;
144
+ // Check if wallet changed
145
+ if (address !== this._lastRegisteredWallet) {
146
+ this._dirtyMetadata.add('agentWallet');
147
+ }
148
+ this.registrationFile.updatedAt = Math.floor(Date.now() / 1000);
149
+ return this;
150
+ }
151
+ setActive(active) {
152
+ this.registrationFile.active = active;
153
+ this.registrationFile.updatedAt = Math.floor(Date.now() / 1000);
154
+ return this;
155
+ }
156
+ setX402Support(x402Support) {
157
+ this.registrationFile.x402support = x402Support;
158
+ this.registrationFile.updatedAt = Math.floor(Date.now() / 1000);
159
+ return this;
160
+ }
161
+ setTrust(reputation = false, cryptoEconomic = false, teeAttestation = false) {
162
+ const trustModels = [];
163
+ if (reputation)
164
+ trustModels.push(TrustModel.REPUTATION);
165
+ if (cryptoEconomic)
166
+ trustModels.push(TrustModel.CRYPTO_ECONOMIC);
167
+ if (teeAttestation)
168
+ trustModels.push(TrustModel.TEE_ATTESTATION);
169
+ this.registrationFile.trustModels = trustModels;
170
+ this.registrationFile.updatedAt = Math.floor(Date.now() / 1000);
171
+ return this;
172
+ }
173
+ setMetadata(kv) {
174
+ // Mark all provided keys as dirty
175
+ for (const key of Object.keys(kv)) {
176
+ this._dirtyMetadata.add(key);
177
+ }
178
+ Object.assign(this.registrationFile.metadata, kv);
179
+ this.registrationFile.updatedAt = Math.floor(Date.now() / 1000);
180
+ return this;
181
+ }
182
+ getMetadata() {
183
+ return { ...this.registrationFile.metadata };
184
+ }
185
+ delMetadata(key) {
186
+ if (key in this.registrationFile.metadata) {
187
+ delete this.registrationFile.metadata[key];
188
+ this._dirtyMetadata.delete(key);
189
+ this.registrationFile.updatedAt = Math.floor(Date.now() / 1000);
190
+ }
191
+ return this;
192
+ }
193
+ getRegistrationFile() {
194
+ return this.registrationFile;
195
+ }
196
+ /**
197
+ * Update basic agent information
198
+ */
199
+ updateInfo(name, description, image) {
200
+ if (name !== undefined) {
201
+ this.registrationFile.name = name;
202
+ }
203
+ if (description !== undefined) {
204
+ this.registrationFile.description = description;
205
+ }
206
+ if (image !== undefined) {
207
+ this.registrationFile.image = image;
208
+ }
209
+ this.registrationFile.updatedAt = Math.floor(Date.now() / 1000);
210
+ return this;
211
+ }
212
+ /**
213
+ * Register agent on-chain with IPFS flow
214
+ */
215
+ async registerIPFS() {
216
+ // Validate basic info
217
+ if (!this.registrationFile.name || !this.registrationFile.description) {
218
+ throw new Error('Agent must have name and description before registration');
219
+ }
220
+ if (this.registrationFile.agentId) {
221
+ // Agent already registered - update registration file and redeploy
222
+ // Option 2D: Add logging and timeout handling
223
+ const chainId = await this.sdk.chainId();
224
+ const identityRegistryAddress = await this.sdk.getIdentityRegistry().getAddress();
225
+ const ipfsCid = await this.sdk.ipfsClient.addRegistrationFile(this.registrationFile, chainId, identityRegistryAddress);
226
+ // Update metadata on-chain if changed
227
+ // Only send transactions for dirty (changed) metadata to save gas
228
+ if (this._dirtyMetadata.size > 0) {
229
+ try {
230
+ await this._updateMetadataOnChain();
231
+ }
232
+ catch (error) {
233
+ // Transaction was sent and will eventually confirm - continue silently
234
+ }
235
+ }
236
+ // Update agent URI on-chain
237
+ const { tokenId } = parseAgentId(this.registrationFile.agentId);
238
+ const txHash = await this.sdk.web3Client.transactContract(this.sdk.getIdentityRegistry(), 'setAgentUri', {}, BigInt(tokenId), `ipfs://${ipfsCid}`);
239
+ // Wait for transaction to be confirmed (30 second timeout like Python)
240
+ // If timeout, continue - transaction was sent and will eventually confirm
241
+ try {
242
+ await this.sdk.web3Client.waitForTransaction(txHash, TIMEOUTS.TRANSACTION_WAIT);
243
+ }
244
+ catch (error) {
245
+ // Transaction was sent and will eventually confirm - continue silently
246
+ }
247
+ // Clear dirty flags
248
+ this._lastRegisteredWallet = this.walletAddress;
249
+ this._lastRegisteredEns = this.ensEndpoint;
250
+ this._dirtyMetadata.clear();
251
+ this.registrationFile.agentURI = `ipfs://${ipfsCid}`;
252
+ return this.registrationFile;
253
+ }
254
+ else {
255
+ // First time registration
256
+ // Step 1: Register on-chain without URI
257
+ await this._registerWithoutUri();
258
+ // Step 2: Upload to IPFS
259
+ const chainId = await this.sdk.chainId();
260
+ const identityRegistryAddress = await this.sdk.getIdentityRegistry().getAddress();
261
+ const ipfsCid = await this.sdk.ipfsClient.addRegistrationFile(this.registrationFile, chainId, identityRegistryAddress);
262
+ // Step 3: Set agent URI on-chain
263
+ const { tokenId } = parseAgentId(this.registrationFile.agentId);
264
+ const txHash = await this.sdk.web3Client.transactContract(this.sdk.getIdentityRegistry(), 'setAgentUri', {}, BigInt(tokenId), `ipfs://${ipfsCid}`);
265
+ // Wait for transaction to be confirmed
266
+ await this.sdk.web3Client.waitForTransaction(txHash);
267
+ // Clear dirty flags
268
+ this._lastRegisteredWallet = this.walletAddress;
269
+ this._lastRegisteredEns = this.ensEndpoint;
270
+ this._dirtyMetadata.clear();
271
+ this.registrationFile.agentURI = `ipfs://${ipfsCid}`;
272
+ return this.registrationFile;
273
+ }
274
+ }
275
+ /**
276
+ * Register agent on-chain with HTTP URI
277
+ */
278
+ async registerHTTP(agentUri) {
279
+ // Validate basic info
280
+ if (!this.registrationFile.name || !this.registrationFile.description) {
281
+ throw new Error('Agent must have name and description before registration');
282
+ }
283
+ if (this.registrationFile.agentId) {
284
+ // Agent already registered - update agent URI
285
+ await this.setAgentUri(agentUri);
286
+ return this.registrationFile;
287
+ }
288
+ else {
289
+ // First time registration
290
+ return await this._registerWithUri(agentUri);
291
+ }
292
+ }
293
+ /**
294
+ * Set agent URI (for updates)
295
+ */
296
+ async setAgentUri(agentUri) {
297
+ if (!this.registrationFile.agentId) {
298
+ throw new Error('Agent must be registered before setting URI');
299
+ }
300
+ const { tokenId } = parseAgentId(this.registrationFile.agentId);
301
+ await this.sdk.web3Client.transactContract(this.sdk.getIdentityRegistry(), 'setAgentUri', {}, BigInt(tokenId), agentUri);
302
+ this.registrationFile.agentURI = agentUri;
303
+ this.registrationFile.updatedAt = Math.floor(Date.now() / 1000);
304
+ }
305
+ /**
306
+ * Transfer agent ownership
307
+ */
308
+ async transfer(newOwner) {
309
+ if (!this.registrationFile.agentId) {
310
+ throw new Error('Agent must be registered before transfer');
311
+ }
312
+ const { tokenId } = parseAgentId(this.registrationFile.agentId);
313
+ const currentOwner = this.sdk.web3Client.address;
314
+ if (!currentOwner) {
315
+ throw new Error('No signer available');
316
+ }
317
+ // Validate address - normalize to lowercase first
318
+ const normalizedAddress = newOwner.toLowerCase();
319
+ if (!this.sdk.web3Client.isAddress(normalizedAddress)) {
320
+ throw new Error(`Invalid address: ${newOwner}`);
321
+ }
322
+ // Validate not zero address (check before expensive operations)
323
+ if (normalizedAddress === '0x0000000000000000000000000000000000000000') {
324
+ throw new Error('Cannot transfer agent to zero address');
325
+ }
326
+ // Convert to checksum format
327
+ const checksumAddress = this.sdk.web3Client.toChecksumAddress(normalizedAddress);
328
+ // Validate not transferring to self
329
+ if (checksumAddress.toLowerCase() === currentOwner.toLowerCase()) {
330
+ throw new Error('Cannot transfer agent to yourself');
331
+ }
332
+ const identityRegistry = this.sdk.getIdentityRegistry();
333
+ const txHash = await this.sdk.web3Client.transactContract(identityRegistry, 'transferFrom', {}, currentOwner, checksumAddress, BigInt(tokenId));
334
+ return {
335
+ txHash,
336
+ from: currentOwner,
337
+ to: checksumAddress,
338
+ agentId: this.registrationFile.agentId,
339
+ };
340
+ }
341
+ /**
342
+ * Private helper methods
343
+ */
344
+ async _registerWithoutUri() {
345
+ // Collect metadata for registration
346
+ const metadataEntries = this._collectMetadataForRegistration();
347
+ // Mint agent with metadata
348
+ const identityRegistry = this.sdk.getIdentityRegistry();
349
+ // If we have metadata, use register(string, tuple[])
350
+ // Otherwise use register() with no args
351
+ let txHash;
352
+ if (metadataEntries.length > 0) {
353
+ txHash = await this.sdk.web3Client.transactContract(identityRegistry, 'register', {}, // Transaction options
354
+ '', // Empty tokenUri
355
+ metadataEntries);
356
+ }
357
+ else {
358
+ txHash = await this.sdk.web3Client.transactContract(identityRegistry, 'register', {} // Transaction options
359
+ // No arguments - calls register()
360
+ );
361
+ }
362
+ // Wait for transaction
363
+ const receipt = await this.sdk.web3Client.waitForTransaction(txHash);
364
+ // Extract agent ID from events
365
+ const agentId = this._extractAgentIdFromReceipt(receipt);
366
+ // Update registration file
367
+ const chainId = await this.sdk.chainId();
368
+ this.registrationFile.agentId = `${chainId}:${agentId}`;
369
+ this.registrationFile.updatedAt = Math.floor(Date.now() / 1000);
370
+ }
371
+ async _registerWithUri(agentUri) {
372
+ // Collect metadata for registration
373
+ const metadataEntries = this._collectMetadataForRegistration();
374
+ // Register with URI and metadata
375
+ const identityRegistry = this.sdk.getIdentityRegistry();
376
+ const txHash = await this.sdk.web3Client.transactContract(identityRegistry, 'register', {}, agentUri, metadataEntries);
377
+ // Wait for transaction
378
+ const receipt = await this.sdk.web3Client.waitForTransaction(txHash);
379
+ // Extract agent ID from events
380
+ const agentId = this._extractAgentIdFromReceipt(receipt);
381
+ // Update registration file
382
+ const chainId = await this.sdk.chainId();
383
+ this.registrationFile.agentId = `${chainId}:${agentId}`;
384
+ this.registrationFile.agentURI = agentUri;
385
+ this.registrationFile.updatedAt = Math.floor(Date.now() / 1000);
386
+ return this.registrationFile;
387
+ }
388
+ async _updateMetadataOnChain() {
389
+ const metadataEntries = this._collectMetadataForRegistration();
390
+ const { tokenId } = parseAgentId(this.registrationFile.agentId);
391
+ const identityRegistry = this.sdk.getIdentityRegistry();
392
+ // Update metadata one by one (like Python SDK)
393
+ // Only send transactions for dirty (changed) metadata keys
394
+ for (const entry of metadataEntries) {
395
+ if (this._dirtyMetadata.has(entry.key)) {
396
+ const txHash = await this.sdk.web3Client.transactContract(identityRegistry, 'setMetadata', {}, BigInt(tokenId), entry.key, entry.value);
397
+ // Wait with 30 second timeout (like Python SDK)
398
+ // If timeout, log warning but continue - transaction was sent and will eventually confirm
399
+ try {
400
+ await this.sdk.web3Client.waitForTransaction(txHash, TIMEOUTS.TRANSACTION_WAIT);
401
+ }
402
+ catch (error) {
403
+ // Transaction was sent and will eventually confirm - continue silently
404
+ }
405
+ }
406
+ }
407
+ }
408
+ _collectMetadataForRegistration() {
409
+ const entries = [];
410
+ // Collect wallet address if set
411
+ if (this.registrationFile.walletAddress && this.registrationFile.walletChainId) {
412
+ const walletValue = `eip155:${this.registrationFile.walletChainId}:${this.registrationFile.walletAddress}`;
413
+ entries.push({
414
+ key: 'agentWallet',
415
+ value: new TextEncoder().encode(walletValue),
416
+ });
417
+ }
418
+ // Collect custom metadata
419
+ for (const [key, value] of Object.entries(this.registrationFile.metadata)) {
420
+ let valueBytes;
421
+ if (typeof value === 'string') {
422
+ valueBytes = new TextEncoder().encode(value);
423
+ }
424
+ else if (typeof value === 'number') {
425
+ valueBytes = new TextEncoder().encode(value.toString());
426
+ }
427
+ else {
428
+ valueBytes = new TextEncoder().encode(JSON.stringify(value));
429
+ }
430
+ entries.push({ key, value: valueBytes });
431
+ }
432
+ return entries;
433
+ }
434
+ _extractAgentIdFromReceipt(receipt) {
435
+ // Parse events from receipt to find Registered event
436
+ const identityRegistry = this.sdk.getIdentityRegistry();
437
+ const transferEventTopic = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'; // Transfer(address,address,uint256)
438
+ // Find the event in the logs
439
+ for (const log of receipt.logs || []) {
440
+ try {
441
+ // Try parsing as Registered event
442
+ const parsed = identityRegistry.interface.parseLog({
443
+ topics: Array.isArray(log.topics) ? log.topics.map((t) => typeof t === 'string' ? t : ethers.hexlify(t)) : log.topics || [],
444
+ data: typeof log.data === 'string' ? log.data : ethers.hexlify(log.data || '0x'),
445
+ });
446
+ if (parsed && parsed.name === 'Registered') {
447
+ return BigInt(parsed.args.agentId.toString());
448
+ }
449
+ }
450
+ catch {
451
+ // Not a Registered event, try Transfer event MP (ERC-721)
452
+ try {
453
+ const topics = Array.isArray(log.topics) ? log.topics : [];
454
+ // Transfer event has topic[0] = Transfer signature, topic[3] = tokenId (if 4 topics)
455
+ if (topics.length >= 4) {
456
+ const topic0 = typeof topics[0] === 'string' ? topics[0] : topics[0].toString();
457
+ if (topic0 === transferEventTopic || topic0.toLowerCase() === transferEventTopic.toLowerCase()) {
458
+ // Extract tokenId from topic[3]
459
+ const tokenIdHex = typeof topics[3] === 'string' ? topics[3] : topics[3].toString();
460
+ // Remove 0x prefix if present and convert
461
+ const tokenIdStr = tokenIdHex.startsWith('0x') ? tokenIdHex.slice(2) : tokenIdHex;
462
+ return BigInt('0x' + tokenIdStr);
463
+ }
464
+ }
465
+ }
466
+ catch {
467
+ // Continue searching
468
+ }
469
+ }
470
+ }
471
+ // Fallback: try to get total supply and use latest token ID
472
+ // Note: This is async but we're in a sync method, so we'll try to call but it might not work
473
+ // Better to throw error and let caller handle
474
+ throw new Error('Could not extract agent ID from transaction receipt - no Registered or Transfer event found');
475
+ }
476
+ }
477
+ //# sourceMappingURL=agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/core/agent.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAMhC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE3D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,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