@pulseai/sdk 0.1.0

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/index.js ADDED
@@ -0,0 +1,4330 @@
1
+ // src/client.ts
2
+ import {
3
+ createPublicClient,
4
+ createWalletClient,
5
+ http
6
+ } from "viem";
7
+
8
+ // src/chains.ts
9
+ import { defineChain } from "viem";
10
+ var megaethTestnet = defineChain({
11
+ id: 6343,
12
+ name: "MegaETH Testnet",
13
+ nativeCurrency: { name: "ETH", symbol: "ETH", decimals: 18 },
14
+ rpcUrls: {
15
+ default: { http: ["https://carrot.megaeth.com/rpc"] }
16
+ }
17
+ });
18
+ var megaethMainnet = defineChain({
19
+ id: 4326,
20
+ name: "MegaETH",
21
+ nativeCurrency: { name: "ETH", symbol: "ETH", decimals: 18 },
22
+ rpcUrls: {
23
+ default: { http: ["https://mainnet.megaeth.com/rpc"] }
24
+ }
25
+ });
26
+
27
+ // src/config.ts
28
+ var TESTNET_ADDRESSES = {
29
+ pulseExtension: "0x332073288B1fBeBe41FCB212E9fF280c216b803A",
30
+ serviceMarketplace: "0x8F9da275D80b5022208DE373cEcB09c431FfceeB",
31
+ jobEngine: "0x8582103b5fAAa6846f4F031159b45CccB28AA111",
32
+ feeDistributor: "0xD47eF976D4A637Ad0432274CcFe0Fc8885B23d20",
33
+ identityRegistry: "0x8004A818BFB912233c491871b3d84c89A494BD9e",
34
+ reputationRegistry: "0x8004B663056A597Dffe9eCcC1965A193B7388713",
35
+ usdm: "0x939Ff43f7c4A2E94069af7DBbc4497377DdcCE3f"
36
+ };
37
+ var PLACEHOLDER_ADDRESS = "0x0";
38
+ var MAINNET_ADDRESSES = {
39
+ pulseExtension: PLACEHOLDER_ADDRESS,
40
+ serviceMarketplace: PLACEHOLDER_ADDRESS,
41
+ jobEngine: PLACEHOLDER_ADDRESS,
42
+ feeDistributor: PLACEHOLDER_ADDRESS,
43
+ identityRegistry: "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432",
44
+ reputationRegistry: "0x8004BAa17C55a88189AE136b182e5fdA19dE9b63",
45
+ usdm: "0xFAfDdbb3FC7688494971a79cc65DCa3EF82079E7"
46
+ };
47
+ var DEFAULT_INDEXER_URLS = {
48
+ testnet: "https://pulse-indexer.up.railway.app",
49
+ mainnet: "https://pulse-indexer.up.railway.app"
50
+ };
51
+ var testnetERC8004 = {
52
+ identityRegistry: "0x8004A818BFB912233c491871b3d84c89A494BD9e",
53
+ reputationRegistry: "0x8004B663056A597Dffe9eCcC1965A193B7388713"
54
+ };
55
+ var mainnetERC8004 = {
56
+ identityRegistry: "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432",
57
+ reputationRegistry: "0x8004BAa17C55a88189AE136b182e5fdA19dE9b63"
58
+ };
59
+ var USDM_MAINNET = "0xFAfDdbb3FC7688494971a79cc65DCa3EF82079E7";
60
+ var FEE_BPS = 500n;
61
+ var BPS_DENOMINATOR = 10000n;
62
+ var TREASURY_BPS = 8000n;
63
+ var RISK_POOL_BPS = 2000n;
64
+ var ACCEPT_TIMEOUT = 24n * 60n * 60n;
65
+ var EVALUATION_TIMEOUT = 72n * 60n * 60n;
66
+
67
+ // src/client.ts
68
+ function requireWallet(client) {
69
+ if (!client.walletClient?.account) throw new Error("Wallet client with account required");
70
+ return { wallet: client.walletClient, account: client.walletClient.account, chain: client.chain };
71
+ }
72
+ async function write(client, params) {
73
+ const { wallet, account, chain } = requireWallet(client);
74
+ return wallet.writeContract({
75
+ ...params,
76
+ chain,
77
+ account
78
+ });
79
+ }
80
+ function createPulseClient(options) {
81
+ const { chain, addresses, account } = options;
82
+ const transport = options.transport ?? http();
83
+ const publicClient = createPublicClient({ chain, transport });
84
+ const walletClient = account ? createWalletClient({ chain, transport, account }) : void 0;
85
+ return { publicClient, walletClient, addresses, chain };
86
+ }
87
+ function createTestnetClient(options = {}) {
88
+ const { account, transport, indexerUrl = DEFAULT_INDEXER_URLS.testnet } = options;
89
+ const client = createPulseClient({
90
+ chain: megaethTestnet,
91
+ addresses: TESTNET_ADDRESSES,
92
+ account,
93
+ transport
94
+ });
95
+ return { ...client, indexerUrl };
96
+ }
97
+ function createMainnetClient(options = {}) {
98
+ const { account, transport, indexerUrl = DEFAULT_INDEXER_URLS.mainnet } = options;
99
+ const client = createPulseClient({
100
+ chain: megaethMainnet,
101
+ addresses: MAINNET_ADDRESSES,
102
+ account,
103
+ transport
104
+ });
105
+ return { ...client, indexerUrl };
106
+ }
107
+
108
+ // src/abis/PulseExtension.ts
109
+ var pulseExtensionAbi = [
110
+ {
111
+ "type": "constructor",
112
+ "inputs": [
113
+ {
114
+ "name": "_identityRegistry",
115
+ "type": "address",
116
+ "internalType": "address"
117
+ }
118
+ ],
119
+ "stateMutability": "nonpayable"
120
+ },
121
+ {
122
+ "type": "function",
123
+ "name": "getAgentPulseData",
124
+ "inputs": [
125
+ {
126
+ "name": "agentId",
127
+ "type": "uint256",
128
+ "internalType": "uint256"
129
+ }
130
+ ],
131
+ "outputs": [
132
+ {
133
+ "name": "pulseData",
134
+ "type": "tuple",
135
+ "internalType": "struct DataTypes.PulseAgentData",
136
+ "components": [
137
+ {
138
+ "name": "operator",
139
+ "type": "address",
140
+ "internalType": "address"
141
+ },
142
+ {
143
+ "name": "warrenMasterContract",
144
+ "type": "address",
145
+ "internalType": "address"
146
+ },
147
+ {
148
+ "name": "registeredAt",
149
+ "type": "uint64",
150
+ "internalType": "uint64"
151
+ },
152
+ {
153
+ "name": "active",
154
+ "type": "bool",
155
+ "internalType": "bool"
156
+ }
157
+ ]
158
+ }
159
+ ],
160
+ "stateMutability": "view"
161
+ },
162
+ {
163
+ "type": "function",
164
+ "name": "identityRegistry",
165
+ "inputs": [],
166
+ "outputs": [
167
+ {
168
+ "name": "",
169
+ "type": "address",
170
+ "internalType": "contract IERC8004Identity"
171
+ }
172
+ ],
173
+ "stateMutability": "view"
174
+ },
175
+ {
176
+ "type": "function",
177
+ "name": "initAgent",
178
+ "inputs": [
179
+ {
180
+ "name": "agentId",
181
+ "type": "uint256",
182
+ "internalType": "uint256"
183
+ },
184
+ {
185
+ "name": "operator",
186
+ "type": "address",
187
+ "internalType": "address"
188
+ }
189
+ ],
190
+ "outputs": [],
191
+ "stateMutability": "nonpayable"
192
+ },
193
+ {
194
+ "type": "function",
195
+ "name": "isAgentActive",
196
+ "inputs": [
197
+ {
198
+ "name": "agentId",
199
+ "type": "uint256",
200
+ "internalType": "uint256"
201
+ }
202
+ ],
203
+ "outputs": [
204
+ {
205
+ "name": "active",
206
+ "type": "bool",
207
+ "internalType": "bool"
208
+ }
209
+ ],
210
+ "stateMutability": "view"
211
+ },
212
+ {
213
+ "type": "function",
214
+ "name": "setOperator",
215
+ "inputs": [
216
+ {
217
+ "name": "agentId",
218
+ "type": "uint256",
219
+ "internalType": "uint256"
220
+ },
221
+ {
222
+ "name": "newOperator",
223
+ "type": "address",
224
+ "internalType": "address"
225
+ }
226
+ ],
227
+ "outputs": [],
228
+ "stateMutability": "nonpayable"
229
+ },
230
+ {
231
+ "type": "function",
232
+ "name": "setWarrenContract",
233
+ "inputs": [
234
+ {
235
+ "name": "agentId",
236
+ "type": "uint256",
237
+ "internalType": "uint256"
238
+ },
239
+ {
240
+ "name": "warrenAddr",
241
+ "type": "address",
242
+ "internalType": "address"
243
+ }
244
+ ],
245
+ "outputs": [],
246
+ "stateMutability": "nonpayable"
247
+ },
248
+ {
249
+ "type": "event",
250
+ "name": "AgentInitialized",
251
+ "inputs": [
252
+ {
253
+ "name": "agentId",
254
+ "type": "uint256",
255
+ "indexed": true,
256
+ "internalType": "uint256"
257
+ },
258
+ {
259
+ "name": "operator",
260
+ "type": "address",
261
+ "indexed": true,
262
+ "internalType": "address"
263
+ }
264
+ ],
265
+ "anonymous": false
266
+ },
267
+ {
268
+ "type": "event",
269
+ "name": "OperatorChanged",
270
+ "inputs": [
271
+ {
272
+ "name": "agentId",
273
+ "type": "uint256",
274
+ "indexed": true,
275
+ "internalType": "uint256"
276
+ },
277
+ {
278
+ "name": "newOperator",
279
+ "type": "address",
280
+ "indexed": true,
281
+ "internalType": "address"
282
+ }
283
+ ],
284
+ "anonymous": false
285
+ },
286
+ {
287
+ "type": "event",
288
+ "name": "WarrenContractSet",
289
+ "inputs": [
290
+ {
291
+ "name": "agentId",
292
+ "type": "uint256",
293
+ "indexed": true,
294
+ "internalType": "uint256"
295
+ },
296
+ {
297
+ "name": "warrenAddr",
298
+ "type": "address",
299
+ "indexed": true,
300
+ "internalType": "address"
301
+ }
302
+ ],
303
+ "anonymous": false
304
+ },
305
+ {
306
+ "type": "error",
307
+ "name": "AgentAlreadyInitialized",
308
+ "inputs": []
309
+ },
310
+ {
311
+ "type": "error",
312
+ "name": "AgentNotActive",
313
+ "inputs": []
314
+ },
315
+ {
316
+ "type": "error",
317
+ "name": "NotAgentOwnerOrOperator",
318
+ "inputs": []
319
+ },
320
+ {
321
+ "type": "error",
322
+ "name": "ZeroAddress",
323
+ "inputs": []
324
+ }
325
+ ];
326
+
327
+ // src/abis/Erc8004Identity.ts
328
+ var erc8004IdentityAbi = [
329
+ {
330
+ "type": "function",
331
+ "name": "approve",
332
+ "inputs": [
333
+ {
334
+ "name": "to",
335
+ "type": "address",
336
+ "internalType": "address"
337
+ },
338
+ {
339
+ "name": "tokenId",
340
+ "type": "uint256",
341
+ "internalType": "uint256"
342
+ }
343
+ ],
344
+ "outputs": [],
345
+ "stateMutability": "nonpayable"
346
+ },
347
+ {
348
+ "type": "function",
349
+ "name": "balanceOf",
350
+ "inputs": [
351
+ {
352
+ "name": "owner",
353
+ "type": "address",
354
+ "internalType": "address"
355
+ }
356
+ ],
357
+ "outputs": [
358
+ {
359
+ "name": "balance",
360
+ "type": "uint256",
361
+ "internalType": "uint256"
362
+ }
363
+ ],
364
+ "stateMutability": "view"
365
+ },
366
+ {
367
+ "type": "function",
368
+ "name": "getAgentWallet",
369
+ "inputs": [
370
+ {
371
+ "name": "agentId",
372
+ "type": "uint256",
373
+ "internalType": "uint256"
374
+ }
375
+ ],
376
+ "outputs": [
377
+ {
378
+ "name": "",
379
+ "type": "address",
380
+ "internalType": "address"
381
+ }
382
+ ],
383
+ "stateMutability": "view"
384
+ },
385
+ {
386
+ "type": "function",
387
+ "name": "getApproved",
388
+ "inputs": [
389
+ {
390
+ "name": "tokenId",
391
+ "type": "uint256",
392
+ "internalType": "uint256"
393
+ }
394
+ ],
395
+ "outputs": [
396
+ {
397
+ "name": "operator",
398
+ "type": "address",
399
+ "internalType": "address"
400
+ }
401
+ ],
402
+ "stateMutability": "view"
403
+ },
404
+ {
405
+ "type": "function",
406
+ "name": "getMetadata",
407
+ "inputs": [
408
+ {
409
+ "name": "agentId",
410
+ "type": "uint256",
411
+ "internalType": "uint256"
412
+ },
413
+ {
414
+ "name": "metadataKey",
415
+ "type": "string",
416
+ "internalType": "string"
417
+ }
418
+ ],
419
+ "outputs": [
420
+ {
421
+ "name": "",
422
+ "type": "bytes",
423
+ "internalType": "bytes"
424
+ }
425
+ ],
426
+ "stateMutability": "view"
427
+ },
428
+ {
429
+ "type": "function",
430
+ "name": "isApprovedForAll",
431
+ "inputs": [
432
+ {
433
+ "name": "owner",
434
+ "type": "address",
435
+ "internalType": "address"
436
+ },
437
+ {
438
+ "name": "operator",
439
+ "type": "address",
440
+ "internalType": "address"
441
+ }
442
+ ],
443
+ "outputs": [
444
+ {
445
+ "name": "",
446
+ "type": "bool",
447
+ "internalType": "bool"
448
+ }
449
+ ],
450
+ "stateMutability": "view"
451
+ },
452
+ {
453
+ "type": "function",
454
+ "name": "ownerOf",
455
+ "inputs": [
456
+ {
457
+ "name": "tokenId",
458
+ "type": "uint256",
459
+ "internalType": "uint256"
460
+ }
461
+ ],
462
+ "outputs": [
463
+ {
464
+ "name": "owner",
465
+ "type": "address",
466
+ "internalType": "address"
467
+ }
468
+ ],
469
+ "stateMutability": "view"
470
+ },
471
+ {
472
+ "type": "function",
473
+ "name": "register",
474
+ "inputs": [],
475
+ "outputs": [
476
+ {
477
+ "name": "agentId",
478
+ "type": "uint256",
479
+ "internalType": "uint256"
480
+ }
481
+ ],
482
+ "stateMutability": "nonpayable"
483
+ },
484
+ {
485
+ "type": "function",
486
+ "name": "register",
487
+ "inputs": [
488
+ {
489
+ "name": "agentURI",
490
+ "type": "string",
491
+ "internalType": "string"
492
+ },
493
+ {
494
+ "name": "metadata",
495
+ "type": "tuple[]",
496
+ "internalType": "struct IERC8004Identity.MetadataEntry[]",
497
+ "components": [
498
+ {
499
+ "name": "key",
500
+ "type": "string",
501
+ "internalType": "string"
502
+ },
503
+ {
504
+ "name": "value",
505
+ "type": "bytes",
506
+ "internalType": "bytes"
507
+ }
508
+ ]
509
+ }
510
+ ],
511
+ "outputs": [
512
+ {
513
+ "name": "agentId",
514
+ "type": "uint256",
515
+ "internalType": "uint256"
516
+ }
517
+ ],
518
+ "stateMutability": "nonpayable"
519
+ },
520
+ {
521
+ "type": "function",
522
+ "name": "register",
523
+ "inputs": [
524
+ {
525
+ "name": "agentURI",
526
+ "type": "string",
527
+ "internalType": "string"
528
+ }
529
+ ],
530
+ "outputs": [
531
+ {
532
+ "name": "agentId",
533
+ "type": "uint256",
534
+ "internalType": "uint256"
535
+ }
536
+ ],
537
+ "stateMutability": "nonpayable"
538
+ },
539
+ {
540
+ "type": "function",
541
+ "name": "safeTransferFrom",
542
+ "inputs": [
543
+ {
544
+ "name": "from",
545
+ "type": "address",
546
+ "internalType": "address"
547
+ },
548
+ {
549
+ "name": "to",
550
+ "type": "address",
551
+ "internalType": "address"
552
+ },
553
+ {
554
+ "name": "tokenId",
555
+ "type": "uint256",
556
+ "internalType": "uint256"
557
+ }
558
+ ],
559
+ "outputs": [],
560
+ "stateMutability": "nonpayable"
561
+ },
562
+ {
563
+ "type": "function",
564
+ "name": "safeTransferFrom",
565
+ "inputs": [
566
+ {
567
+ "name": "from",
568
+ "type": "address",
569
+ "internalType": "address"
570
+ },
571
+ {
572
+ "name": "to",
573
+ "type": "address",
574
+ "internalType": "address"
575
+ },
576
+ {
577
+ "name": "tokenId",
578
+ "type": "uint256",
579
+ "internalType": "uint256"
580
+ },
581
+ {
582
+ "name": "data",
583
+ "type": "bytes",
584
+ "internalType": "bytes"
585
+ }
586
+ ],
587
+ "outputs": [],
588
+ "stateMutability": "nonpayable"
589
+ },
590
+ {
591
+ "type": "function",
592
+ "name": "setAgentURI",
593
+ "inputs": [
594
+ {
595
+ "name": "agentId",
596
+ "type": "uint256",
597
+ "internalType": "uint256"
598
+ },
599
+ {
600
+ "name": "newURI",
601
+ "type": "string",
602
+ "internalType": "string"
603
+ }
604
+ ],
605
+ "outputs": [],
606
+ "stateMutability": "nonpayable"
607
+ },
608
+ {
609
+ "type": "function",
610
+ "name": "setAgentWallet",
611
+ "inputs": [
612
+ {
613
+ "name": "agentId",
614
+ "type": "uint256",
615
+ "internalType": "uint256"
616
+ },
617
+ {
618
+ "name": "newWallet",
619
+ "type": "address",
620
+ "internalType": "address"
621
+ },
622
+ {
623
+ "name": "deadline",
624
+ "type": "uint256",
625
+ "internalType": "uint256"
626
+ },
627
+ {
628
+ "name": "signature",
629
+ "type": "bytes",
630
+ "internalType": "bytes"
631
+ }
632
+ ],
633
+ "outputs": [],
634
+ "stateMutability": "nonpayable"
635
+ },
636
+ {
637
+ "type": "function",
638
+ "name": "setApprovalForAll",
639
+ "inputs": [
640
+ {
641
+ "name": "operator",
642
+ "type": "address",
643
+ "internalType": "address"
644
+ },
645
+ {
646
+ "name": "approved",
647
+ "type": "bool",
648
+ "internalType": "bool"
649
+ }
650
+ ],
651
+ "outputs": [],
652
+ "stateMutability": "nonpayable"
653
+ },
654
+ {
655
+ "type": "function",
656
+ "name": "setMetadata",
657
+ "inputs": [
658
+ {
659
+ "name": "agentId",
660
+ "type": "uint256",
661
+ "internalType": "uint256"
662
+ },
663
+ {
664
+ "name": "metadataKey",
665
+ "type": "string",
666
+ "internalType": "string"
667
+ },
668
+ {
669
+ "name": "metadataValue",
670
+ "type": "bytes",
671
+ "internalType": "bytes"
672
+ }
673
+ ],
674
+ "outputs": [],
675
+ "stateMutability": "nonpayable"
676
+ },
677
+ {
678
+ "type": "function",
679
+ "name": "supportsInterface",
680
+ "inputs": [
681
+ {
682
+ "name": "interfaceId",
683
+ "type": "bytes4",
684
+ "internalType": "bytes4"
685
+ }
686
+ ],
687
+ "outputs": [
688
+ {
689
+ "name": "",
690
+ "type": "bool",
691
+ "internalType": "bool"
692
+ }
693
+ ],
694
+ "stateMutability": "view"
695
+ },
696
+ {
697
+ "type": "function",
698
+ "name": "transferFrom",
699
+ "inputs": [
700
+ {
701
+ "name": "from",
702
+ "type": "address",
703
+ "internalType": "address"
704
+ },
705
+ {
706
+ "name": "to",
707
+ "type": "address",
708
+ "internalType": "address"
709
+ },
710
+ {
711
+ "name": "tokenId",
712
+ "type": "uint256",
713
+ "internalType": "uint256"
714
+ }
715
+ ],
716
+ "outputs": [],
717
+ "stateMutability": "nonpayable"
718
+ },
719
+ {
720
+ "type": "function",
721
+ "name": "unsetAgentWallet",
722
+ "inputs": [
723
+ {
724
+ "name": "agentId",
725
+ "type": "uint256",
726
+ "internalType": "uint256"
727
+ }
728
+ ],
729
+ "outputs": [],
730
+ "stateMutability": "nonpayable"
731
+ },
732
+ {
733
+ "type": "event",
734
+ "name": "Approval",
735
+ "inputs": [
736
+ {
737
+ "name": "owner",
738
+ "type": "address",
739
+ "indexed": true,
740
+ "internalType": "address"
741
+ },
742
+ {
743
+ "name": "approved",
744
+ "type": "address",
745
+ "indexed": true,
746
+ "internalType": "address"
747
+ },
748
+ {
749
+ "name": "tokenId",
750
+ "type": "uint256",
751
+ "indexed": true,
752
+ "internalType": "uint256"
753
+ }
754
+ ],
755
+ "anonymous": false
756
+ },
757
+ {
758
+ "type": "event",
759
+ "name": "ApprovalForAll",
760
+ "inputs": [
761
+ {
762
+ "name": "owner",
763
+ "type": "address",
764
+ "indexed": true,
765
+ "internalType": "address"
766
+ },
767
+ {
768
+ "name": "operator",
769
+ "type": "address",
770
+ "indexed": true,
771
+ "internalType": "address"
772
+ },
773
+ {
774
+ "name": "approved",
775
+ "type": "bool",
776
+ "indexed": false,
777
+ "internalType": "bool"
778
+ }
779
+ ],
780
+ "anonymous": false
781
+ },
782
+ {
783
+ "type": "event",
784
+ "name": "MetadataSet",
785
+ "inputs": [
786
+ {
787
+ "name": "agentId",
788
+ "type": "uint256",
789
+ "indexed": true,
790
+ "internalType": "uint256"
791
+ },
792
+ {
793
+ "name": "indexedMetadataKey",
794
+ "type": "string",
795
+ "indexed": true,
796
+ "internalType": "string"
797
+ },
798
+ {
799
+ "name": "metadataKey",
800
+ "type": "string",
801
+ "indexed": false,
802
+ "internalType": "string"
803
+ },
804
+ {
805
+ "name": "metadataValue",
806
+ "type": "bytes",
807
+ "indexed": false,
808
+ "internalType": "bytes"
809
+ }
810
+ ],
811
+ "anonymous": false
812
+ },
813
+ {
814
+ "type": "event",
815
+ "name": "Registered",
816
+ "inputs": [
817
+ {
818
+ "name": "agentId",
819
+ "type": "uint256",
820
+ "indexed": true,
821
+ "internalType": "uint256"
822
+ },
823
+ {
824
+ "name": "agentURI",
825
+ "type": "string",
826
+ "indexed": false,
827
+ "internalType": "string"
828
+ },
829
+ {
830
+ "name": "owner",
831
+ "type": "address",
832
+ "indexed": true,
833
+ "internalType": "address"
834
+ }
835
+ ],
836
+ "anonymous": false
837
+ },
838
+ {
839
+ "type": "event",
840
+ "name": "Transfer",
841
+ "inputs": [
842
+ {
843
+ "name": "from",
844
+ "type": "address",
845
+ "indexed": true,
846
+ "internalType": "address"
847
+ },
848
+ {
849
+ "name": "to",
850
+ "type": "address",
851
+ "indexed": true,
852
+ "internalType": "address"
853
+ },
854
+ {
855
+ "name": "tokenId",
856
+ "type": "uint256",
857
+ "indexed": true,
858
+ "internalType": "uint256"
859
+ }
860
+ ],
861
+ "anonymous": false
862
+ },
863
+ {
864
+ "type": "event",
865
+ "name": "URIUpdated",
866
+ "inputs": [
867
+ {
868
+ "name": "agentId",
869
+ "type": "uint256",
870
+ "indexed": true,
871
+ "internalType": "uint256"
872
+ },
873
+ {
874
+ "name": "newURI",
875
+ "type": "string",
876
+ "indexed": false,
877
+ "internalType": "string"
878
+ },
879
+ {
880
+ "name": "updatedBy",
881
+ "type": "address",
882
+ "indexed": true,
883
+ "internalType": "address"
884
+ }
885
+ ],
886
+ "anonymous": false
887
+ }
888
+ ];
889
+
890
+ // src/agent/index.ts
891
+ async function registerAgent(client, agentURI) {
892
+ const txHash = await write(client, {
893
+ address: client.addresses.identityRegistry,
894
+ abi: erc8004IdentityAbi,
895
+ functionName: "register",
896
+ args: [agentURI]
897
+ });
898
+ const receipt = await client.publicClient.waitForTransactionReceipt({ hash: txHash });
899
+ const transferTopic = "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef";
900
+ const transferLog = receipt.logs.find((log) => log.topics[0] === transferTopic);
901
+ const agentId = transferLog?.topics[3] ? BigInt(transferLog.topics[3]) : 0n;
902
+ return { agentId, txHash };
903
+ }
904
+ async function initAgent(client, agentId, operator) {
905
+ return write(client, {
906
+ address: client.addresses.pulseExtension,
907
+ abi: pulseExtensionAbi,
908
+ functionName: "initAgent",
909
+ args: [agentId, operator]
910
+ });
911
+ }
912
+ async function setOperator(client, agentId, newOperator) {
913
+ return write(client, {
914
+ address: client.addresses.pulseExtension,
915
+ abi: pulseExtensionAbi,
916
+ functionName: "setOperator",
917
+ args: [agentId, newOperator]
918
+ });
919
+ }
920
+ async function setWarrenContract(client, agentId, warrenAddr) {
921
+ return write(client, {
922
+ address: client.addresses.pulseExtension,
923
+ abi: pulseExtensionAbi,
924
+ functionName: "setWarrenContract",
925
+ args: [agentId, warrenAddr]
926
+ });
927
+ }
928
+ async function getAgent(client, agentId) {
929
+ const [owner, pulseData, active] = await Promise.all([
930
+ client.publicClient.readContract({
931
+ address: client.addresses.identityRegistry,
932
+ abi: erc8004IdentityAbi,
933
+ functionName: "ownerOf",
934
+ args: [agentId]
935
+ }),
936
+ client.publicClient.readContract({
937
+ address: client.addresses.pulseExtension,
938
+ abi: pulseExtensionAbi,
939
+ functionName: "getAgentPulseData",
940
+ args: [agentId]
941
+ }),
942
+ client.publicClient.readContract({
943
+ address: client.addresses.pulseExtension,
944
+ abi: pulseExtensionAbi,
945
+ functionName: "isAgentActive",
946
+ args: [agentId]
947
+ })
948
+ ]);
949
+ return {
950
+ owner,
951
+ pulseData,
952
+ active
953
+ };
954
+ }
955
+
956
+ // src/abis/ServiceMarketplace.ts
957
+ var serviceMarketplaceAbi = [
958
+ {
959
+ "type": "constructor",
960
+ "inputs": [
961
+ {
962
+ "name": "_identityRegistry",
963
+ "type": "address",
964
+ "internalType": "address"
965
+ },
966
+ {
967
+ "name": "_pulseExtension",
968
+ "type": "address",
969
+ "internalType": "address"
970
+ }
971
+ ],
972
+ "stateMutability": "nonpayable"
973
+ },
974
+ {
975
+ "type": "function",
976
+ "name": "activateOffering",
977
+ "inputs": [
978
+ {
979
+ "name": "offeringId",
980
+ "type": "uint256",
981
+ "internalType": "uint256"
982
+ }
983
+ ],
984
+ "outputs": [],
985
+ "stateMutability": "nonpayable"
986
+ },
987
+ {
988
+ "type": "function",
989
+ "name": "deactivateOffering",
990
+ "inputs": [
991
+ {
992
+ "name": "offeringId",
993
+ "type": "uint256",
994
+ "internalType": "uint256"
995
+ }
996
+ ],
997
+ "outputs": [],
998
+ "stateMutability": "nonpayable"
999
+ },
1000
+ {
1001
+ "type": "function",
1002
+ "name": "getOffering",
1003
+ "inputs": [
1004
+ {
1005
+ "name": "offeringId",
1006
+ "type": "uint256",
1007
+ "internalType": "uint256"
1008
+ }
1009
+ ],
1010
+ "outputs": [
1011
+ {
1012
+ "name": "offering",
1013
+ "type": "tuple",
1014
+ "internalType": "struct DataTypes.JobOffering",
1015
+ "components": [
1016
+ {
1017
+ "name": "agentId",
1018
+ "type": "uint256",
1019
+ "internalType": "uint256"
1020
+ },
1021
+ {
1022
+ "name": "serviceType",
1023
+ "type": "uint8",
1024
+ "internalType": "enum DataTypes.ServiceType"
1025
+ },
1026
+ {
1027
+ "name": "priceUSDm",
1028
+ "type": "uint256",
1029
+ "internalType": "uint256"
1030
+ },
1031
+ {
1032
+ "name": "slaMinutes",
1033
+ "type": "uint32",
1034
+ "internalType": "uint32"
1035
+ },
1036
+ {
1037
+ "name": "description",
1038
+ "type": "string",
1039
+ "internalType": "string"
1040
+ },
1041
+ {
1042
+ "name": "requirementsSchemaURI",
1043
+ "type": "string",
1044
+ "internalType": "string"
1045
+ },
1046
+ {
1047
+ "name": "active",
1048
+ "type": "bool",
1049
+ "internalType": "bool"
1050
+ }
1051
+ ]
1052
+ }
1053
+ ],
1054
+ "stateMutability": "view"
1055
+ },
1056
+ {
1057
+ "type": "function",
1058
+ "name": "getOfferingCount",
1059
+ "inputs": [],
1060
+ "outputs": [
1061
+ {
1062
+ "name": "count",
1063
+ "type": "uint256",
1064
+ "internalType": "uint256"
1065
+ }
1066
+ ],
1067
+ "stateMutability": "view"
1068
+ },
1069
+ {
1070
+ "type": "function",
1071
+ "name": "identityRegistry",
1072
+ "inputs": [],
1073
+ "outputs": [
1074
+ {
1075
+ "name": "",
1076
+ "type": "address",
1077
+ "internalType": "contract IERC8004Identity"
1078
+ }
1079
+ ],
1080
+ "stateMutability": "view"
1081
+ },
1082
+ {
1083
+ "type": "function",
1084
+ "name": "listOffering",
1085
+ "inputs": [
1086
+ {
1087
+ "name": "agentId",
1088
+ "type": "uint256",
1089
+ "internalType": "uint256"
1090
+ },
1091
+ {
1092
+ "name": "serviceType",
1093
+ "type": "uint8",
1094
+ "internalType": "enum DataTypes.ServiceType"
1095
+ },
1096
+ {
1097
+ "name": "priceUSDm",
1098
+ "type": "uint256",
1099
+ "internalType": "uint256"
1100
+ },
1101
+ {
1102
+ "name": "slaMinutes",
1103
+ "type": "uint32",
1104
+ "internalType": "uint32"
1105
+ },
1106
+ {
1107
+ "name": "description",
1108
+ "type": "string",
1109
+ "internalType": "string"
1110
+ },
1111
+ {
1112
+ "name": "requirementsSchemaURI",
1113
+ "type": "string",
1114
+ "internalType": "string"
1115
+ }
1116
+ ],
1117
+ "outputs": [
1118
+ {
1119
+ "name": "offeringId",
1120
+ "type": "uint256",
1121
+ "internalType": "uint256"
1122
+ }
1123
+ ],
1124
+ "stateMutability": "nonpayable"
1125
+ },
1126
+ {
1127
+ "type": "function",
1128
+ "name": "pulseExtension",
1129
+ "inputs": [],
1130
+ "outputs": [
1131
+ {
1132
+ "name": "",
1133
+ "type": "address",
1134
+ "internalType": "contract IPulseExtension"
1135
+ }
1136
+ ],
1137
+ "stateMutability": "view"
1138
+ },
1139
+ {
1140
+ "type": "function",
1141
+ "name": "updateOffering",
1142
+ "inputs": [
1143
+ {
1144
+ "name": "offeringId",
1145
+ "type": "uint256",
1146
+ "internalType": "uint256"
1147
+ },
1148
+ {
1149
+ "name": "priceUSDm",
1150
+ "type": "uint256",
1151
+ "internalType": "uint256"
1152
+ },
1153
+ {
1154
+ "name": "slaMinutes",
1155
+ "type": "uint32",
1156
+ "internalType": "uint32"
1157
+ },
1158
+ {
1159
+ "name": "description",
1160
+ "type": "string",
1161
+ "internalType": "string"
1162
+ }
1163
+ ],
1164
+ "outputs": [],
1165
+ "stateMutability": "nonpayable"
1166
+ },
1167
+ {
1168
+ "type": "event",
1169
+ "name": "OfferingActivated",
1170
+ "inputs": [
1171
+ {
1172
+ "name": "offeringId",
1173
+ "type": "uint256",
1174
+ "indexed": true,
1175
+ "internalType": "uint256"
1176
+ }
1177
+ ],
1178
+ "anonymous": false
1179
+ },
1180
+ {
1181
+ "type": "event",
1182
+ "name": "OfferingDeactivated",
1183
+ "inputs": [
1184
+ {
1185
+ "name": "offeringId",
1186
+ "type": "uint256",
1187
+ "indexed": true,
1188
+ "internalType": "uint256"
1189
+ }
1190
+ ],
1191
+ "anonymous": false
1192
+ },
1193
+ {
1194
+ "type": "event",
1195
+ "name": "OfferingListed",
1196
+ "inputs": [
1197
+ {
1198
+ "name": "offeringId",
1199
+ "type": "uint256",
1200
+ "indexed": true,
1201
+ "internalType": "uint256"
1202
+ },
1203
+ {
1204
+ "name": "agentId",
1205
+ "type": "uint256",
1206
+ "indexed": true,
1207
+ "internalType": "uint256"
1208
+ },
1209
+ {
1210
+ "name": "serviceType",
1211
+ "type": "uint8",
1212
+ "indexed": true,
1213
+ "internalType": "enum DataTypes.ServiceType"
1214
+ },
1215
+ {
1216
+ "name": "priceUSDm",
1217
+ "type": "uint256",
1218
+ "indexed": false,
1219
+ "internalType": "uint256"
1220
+ }
1221
+ ],
1222
+ "anonymous": false
1223
+ },
1224
+ {
1225
+ "type": "event",
1226
+ "name": "OfferingUpdated",
1227
+ "inputs": [
1228
+ {
1229
+ "name": "offeringId",
1230
+ "type": "uint256",
1231
+ "indexed": true,
1232
+ "internalType": "uint256"
1233
+ },
1234
+ {
1235
+ "name": "priceUSDm",
1236
+ "type": "uint256",
1237
+ "indexed": false,
1238
+ "internalType": "uint256"
1239
+ },
1240
+ {
1241
+ "name": "slaMinutes",
1242
+ "type": "uint32",
1243
+ "indexed": false,
1244
+ "internalType": "uint32"
1245
+ }
1246
+ ],
1247
+ "anonymous": false
1248
+ },
1249
+ {
1250
+ "type": "error",
1251
+ "name": "AgentNotActive",
1252
+ "inputs": []
1253
+ },
1254
+ {
1255
+ "type": "error",
1256
+ "name": "NotAgentOwnerOrOperator",
1257
+ "inputs": []
1258
+ },
1259
+ {
1260
+ "type": "error",
1261
+ "name": "OfferingNotActive",
1262
+ "inputs": []
1263
+ },
1264
+ {
1265
+ "type": "error",
1266
+ "name": "OfferingNotFound",
1267
+ "inputs": []
1268
+ },
1269
+ {
1270
+ "type": "error",
1271
+ "name": "ZeroAddress",
1272
+ "inputs": []
1273
+ }
1274
+ ];
1275
+
1276
+ // src/marketplace/index.ts
1277
+ async function listOffering(client, params) {
1278
+ const txHash = await write(client, {
1279
+ address: client.addresses.serviceMarketplace,
1280
+ abi: serviceMarketplaceAbi,
1281
+ functionName: "listOffering",
1282
+ args: [
1283
+ params.agentId,
1284
+ params.serviceType,
1285
+ params.priceUSDm,
1286
+ params.slaMinutes,
1287
+ params.description,
1288
+ params.requirementsSchemaURI ?? ""
1289
+ ]
1290
+ });
1291
+ const receipt = await client.publicClient.waitForTransactionReceipt({ hash: txHash });
1292
+ const offeringLog = receipt.logs.find(
1293
+ (log) => log.address.toLowerCase() === client.addresses.serviceMarketplace.toLowerCase()
1294
+ );
1295
+ const offeringId = offeringLog?.topics[1] ? BigInt(offeringLog.topics[1]) : 0n;
1296
+ return { offeringId, txHash };
1297
+ }
1298
+ async function updateOffering(client, offeringId, priceUSDm, slaMinutes, description) {
1299
+ return write(client, {
1300
+ address: client.addresses.serviceMarketplace,
1301
+ abi: serviceMarketplaceAbi,
1302
+ functionName: "updateOffering",
1303
+ args: [offeringId, priceUSDm, slaMinutes, description]
1304
+ });
1305
+ }
1306
+ async function deactivateOffering(client, offeringId) {
1307
+ return write(client, {
1308
+ address: client.addresses.serviceMarketplace,
1309
+ abi: serviceMarketplaceAbi,
1310
+ functionName: "deactivateOffering",
1311
+ args: [offeringId]
1312
+ });
1313
+ }
1314
+ async function activateOffering(client, offeringId) {
1315
+ return write(client, {
1316
+ address: client.addresses.serviceMarketplace,
1317
+ abi: serviceMarketplaceAbi,
1318
+ functionName: "activateOffering",
1319
+ args: [offeringId]
1320
+ });
1321
+ }
1322
+ async function getOffering(client, offeringId) {
1323
+ const raw = await client.publicClient.readContract({
1324
+ address: client.addresses.serviceMarketplace,
1325
+ abi: serviceMarketplaceAbi,
1326
+ functionName: "getOffering",
1327
+ args: [offeringId]
1328
+ });
1329
+ return raw;
1330
+ }
1331
+ async function getOfferingCount(client) {
1332
+ return client.publicClient.readContract({
1333
+ address: client.addresses.serviceMarketplace,
1334
+ abi: serviceMarketplaceAbi,
1335
+ functionName: "getOfferingCount"
1336
+ });
1337
+ }
1338
+
1339
+ // src/abis/JobEngine.ts
1340
+ var jobEngineAbi = [
1341
+ {
1342
+ "type": "constructor",
1343
+ "inputs": [],
1344
+ "stateMutability": "nonpayable"
1345
+ },
1346
+ {
1347
+ "type": "function",
1348
+ "name": "ACCEPT_TIMEOUT",
1349
+ "inputs": [],
1350
+ "outputs": [
1351
+ {
1352
+ "name": "",
1353
+ "type": "uint64",
1354
+ "internalType": "uint64"
1355
+ }
1356
+ ],
1357
+ "stateMutability": "view"
1358
+ },
1359
+ {
1360
+ "type": "function",
1361
+ "name": "EVALUATION_TIMEOUT",
1362
+ "inputs": [],
1363
+ "outputs": [
1364
+ {
1365
+ "name": "",
1366
+ "type": "uint64",
1367
+ "internalType": "uint64"
1368
+ }
1369
+ ],
1370
+ "stateMutability": "view"
1371
+ },
1372
+ {
1373
+ "type": "function",
1374
+ "name": "FEE_BPS",
1375
+ "inputs": [],
1376
+ "outputs": [
1377
+ {
1378
+ "name": "",
1379
+ "type": "uint256",
1380
+ "internalType": "uint256"
1381
+ }
1382
+ ],
1383
+ "stateMutability": "view"
1384
+ },
1385
+ {
1386
+ "type": "function",
1387
+ "name": "UPGRADE_INTERFACE_VERSION",
1388
+ "inputs": [],
1389
+ "outputs": [
1390
+ {
1391
+ "name": "",
1392
+ "type": "string",
1393
+ "internalType": "string"
1394
+ }
1395
+ ],
1396
+ "stateMutability": "view"
1397
+ },
1398
+ {
1399
+ "type": "function",
1400
+ "name": "acceptJob",
1401
+ "inputs": [
1402
+ {
1403
+ "name": "jobId",
1404
+ "type": "uint256",
1405
+ "internalType": "uint256"
1406
+ },
1407
+ {
1408
+ "name": "providerSignature",
1409
+ "type": "bytes",
1410
+ "internalType": "bytes"
1411
+ }
1412
+ ],
1413
+ "outputs": [],
1414
+ "stateMutability": "nonpayable"
1415
+ },
1416
+ {
1417
+ "type": "function",
1418
+ "name": "cancelJob",
1419
+ "inputs": [
1420
+ {
1421
+ "name": "jobId",
1422
+ "type": "uint256",
1423
+ "internalType": "uint256"
1424
+ }
1425
+ ],
1426
+ "outputs": [],
1427
+ "stateMutability": "nonpayable"
1428
+ },
1429
+ {
1430
+ "type": "function",
1431
+ "name": "createJob",
1432
+ "inputs": [
1433
+ {
1434
+ "name": "offeringId",
1435
+ "type": "uint256",
1436
+ "internalType": "uint256"
1437
+ },
1438
+ {
1439
+ "name": "buyerAgentId",
1440
+ "type": "uint256",
1441
+ "internalType": "uint256"
1442
+ },
1443
+ {
1444
+ "name": "warrenTermsHash",
1445
+ "type": "bytes32",
1446
+ "internalType": "bytes32"
1447
+ }
1448
+ ],
1449
+ "outputs": [
1450
+ {
1451
+ "name": "jobId",
1452
+ "type": "uint256",
1453
+ "internalType": "uint256"
1454
+ }
1455
+ ],
1456
+ "stateMutability": "nonpayable"
1457
+ },
1458
+ {
1459
+ "type": "function",
1460
+ "name": "domainSeparator",
1461
+ "inputs": [],
1462
+ "outputs": [
1463
+ {
1464
+ "name": "",
1465
+ "type": "bytes32",
1466
+ "internalType": "bytes32"
1467
+ }
1468
+ ],
1469
+ "stateMutability": "view"
1470
+ },
1471
+ {
1472
+ "type": "function",
1473
+ "name": "eip712Domain",
1474
+ "inputs": [],
1475
+ "outputs": [
1476
+ {
1477
+ "name": "fields",
1478
+ "type": "bytes1",
1479
+ "internalType": "bytes1"
1480
+ },
1481
+ {
1482
+ "name": "name",
1483
+ "type": "string",
1484
+ "internalType": "string"
1485
+ },
1486
+ {
1487
+ "name": "version",
1488
+ "type": "string",
1489
+ "internalType": "string"
1490
+ },
1491
+ {
1492
+ "name": "chainId",
1493
+ "type": "uint256",
1494
+ "internalType": "uint256"
1495
+ },
1496
+ {
1497
+ "name": "verifyingContract",
1498
+ "type": "address",
1499
+ "internalType": "address"
1500
+ },
1501
+ {
1502
+ "name": "salt",
1503
+ "type": "bytes32",
1504
+ "internalType": "bytes32"
1505
+ },
1506
+ {
1507
+ "name": "extensions",
1508
+ "type": "uint256[]",
1509
+ "internalType": "uint256[]"
1510
+ }
1511
+ ],
1512
+ "stateMutability": "view"
1513
+ },
1514
+ {
1515
+ "type": "function",
1516
+ "name": "evaluate",
1517
+ "inputs": [
1518
+ {
1519
+ "name": "jobId",
1520
+ "type": "uint256",
1521
+ "internalType": "uint256"
1522
+ },
1523
+ {
1524
+ "name": "approved",
1525
+ "type": "bool",
1526
+ "internalType": "bool"
1527
+ },
1528
+ {
1529
+ "name": "feedback",
1530
+ "type": "string",
1531
+ "internalType": "string"
1532
+ }
1533
+ ],
1534
+ "outputs": [],
1535
+ "stateMutability": "nonpayable"
1536
+ },
1537
+ {
1538
+ "type": "function",
1539
+ "name": "feeDistributor",
1540
+ "inputs": [],
1541
+ "outputs": [
1542
+ {
1543
+ "name": "",
1544
+ "type": "address",
1545
+ "internalType": "contract IFeeDistributor"
1546
+ }
1547
+ ],
1548
+ "stateMutability": "view"
1549
+ },
1550
+ {
1551
+ "type": "function",
1552
+ "name": "getJob",
1553
+ "inputs": [
1554
+ {
1555
+ "name": "jobId",
1556
+ "type": "uint256",
1557
+ "internalType": "uint256"
1558
+ }
1559
+ ],
1560
+ "outputs": [
1561
+ {
1562
+ "name": "job",
1563
+ "type": "tuple",
1564
+ "internalType": "struct DataTypes.Job",
1565
+ "components": [
1566
+ {
1567
+ "name": "offeringId",
1568
+ "type": "uint256",
1569
+ "internalType": "uint256"
1570
+ },
1571
+ {
1572
+ "name": "buyerAgentId",
1573
+ "type": "uint256",
1574
+ "internalType": "uint256"
1575
+ },
1576
+ {
1577
+ "name": "providerAgentId",
1578
+ "type": "uint256",
1579
+ "internalType": "uint256"
1580
+ },
1581
+ {
1582
+ "name": "priceUSDm",
1583
+ "type": "uint256",
1584
+ "internalType": "uint256"
1585
+ },
1586
+ {
1587
+ "name": "status",
1588
+ "type": "uint8",
1589
+ "internalType": "enum DataTypes.JobStatus"
1590
+ },
1591
+ {
1592
+ "name": "warrenTermsHash",
1593
+ "type": "bytes32",
1594
+ "internalType": "bytes32"
1595
+ },
1596
+ {
1597
+ "name": "deliverableHash",
1598
+ "type": "bytes32",
1599
+ "internalType": "bytes32"
1600
+ },
1601
+ {
1602
+ "name": "createdAt",
1603
+ "type": "uint64",
1604
+ "internalType": "uint64"
1605
+ },
1606
+ {
1607
+ "name": "acceptedAt",
1608
+ "type": "uint64",
1609
+ "internalType": "uint64"
1610
+ },
1611
+ {
1612
+ "name": "deliveredAt",
1613
+ "type": "uint64",
1614
+ "internalType": "uint64"
1615
+ },
1616
+ {
1617
+ "name": "evaluatedAt",
1618
+ "type": "uint64",
1619
+ "internalType": "uint64"
1620
+ },
1621
+ {
1622
+ "name": "settledAt",
1623
+ "type": "uint64",
1624
+ "internalType": "uint64"
1625
+ },
1626
+ {
1627
+ "name": "slaMinutes",
1628
+ "type": "uint32",
1629
+ "internalType": "uint32"
1630
+ }
1631
+ ]
1632
+ }
1633
+ ],
1634
+ "stateMutability": "view"
1635
+ },
1636
+ {
1637
+ "type": "function",
1638
+ "name": "getJobCount",
1639
+ "inputs": [],
1640
+ "outputs": [
1641
+ {
1642
+ "name": "count",
1643
+ "type": "uint256",
1644
+ "internalType": "uint256"
1645
+ }
1646
+ ],
1647
+ "stateMutability": "view"
1648
+ },
1649
+ {
1650
+ "type": "function",
1651
+ "name": "identityRegistry",
1652
+ "inputs": [],
1653
+ "outputs": [
1654
+ {
1655
+ "name": "",
1656
+ "type": "address",
1657
+ "internalType": "contract IERC8004Identity"
1658
+ }
1659
+ ],
1660
+ "stateMutability": "view"
1661
+ },
1662
+ {
1663
+ "type": "function",
1664
+ "name": "initialize",
1665
+ "inputs": [
1666
+ {
1667
+ "name": "owner_",
1668
+ "type": "address",
1669
+ "internalType": "address"
1670
+ },
1671
+ {
1672
+ "name": "identityRegistry_",
1673
+ "type": "address",
1674
+ "internalType": "address"
1675
+ },
1676
+ {
1677
+ "name": "pulseExtension_",
1678
+ "type": "address",
1679
+ "internalType": "address"
1680
+ },
1681
+ {
1682
+ "name": "serviceMarketplace_",
1683
+ "type": "address",
1684
+ "internalType": "address"
1685
+ },
1686
+ {
1687
+ "name": "feeDistributor_",
1688
+ "type": "address",
1689
+ "internalType": "address"
1690
+ },
1691
+ {
1692
+ "name": "reputationRegistry_",
1693
+ "type": "address",
1694
+ "internalType": "address"
1695
+ },
1696
+ {
1697
+ "name": "usdm_",
1698
+ "type": "address",
1699
+ "internalType": "address"
1700
+ }
1701
+ ],
1702
+ "outputs": [],
1703
+ "stateMutability": "nonpayable"
1704
+ },
1705
+ {
1706
+ "type": "function",
1707
+ "name": "nonces",
1708
+ "inputs": [
1709
+ {
1710
+ "name": "",
1711
+ "type": "address",
1712
+ "internalType": "address"
1713
+ }
1714
+ ],
1715
+ "outputs": [
1716
+ {
1717
+ "name": "",
1718
+ "type": "uint256",
1719
+ "internalType": "uint256"
1720
+ }
1721
+ ],
1722
+ "stateMutability": "view"
1723
+ },
1724
+ {
1725
+ "type": "function",
1726
+ "name": "owner",
1727
+ "inputs": [],
1728
+ "outputs": [
1729
+ {
1730
+ "name": "",
1731
+ "type": "address",
1732
+ "internalType": "address"
1733
+ }
1734
+ ],
1735
+ "stateMutability": "view"
1736
+ },
1737
+ {
1738
+ "type": "function",
1739
+ "name": "proxiableUUID",
1740
+ "inputs": [],
1741
+ "outputs": [
1742
+ {
1743
+ "name": "",
1744
+ "type": "bytes32",
1745
+ "internalType": "bytes32"
1746
+ }
1747
+ ],
1748
+ "stateMutability": "view"
1749
+ },
1750
+ {
1751
+ "type": "function",
1752
+ "name": "pulseExtension",
1753
+ "inputs": [],
1754
+ "outputs": [
1755
+ {
1756
+ "name": "",
1757
+ "type": "address",
1758
+ "internalType": "contract IPulseExtension"
1759
+ }
1760
+ ],
1761
+ "stateMutability": "view"
1762
+ },
1763
+ {
1764
+ "type": "function",
1765
+ "name": "renounceOwnership",
1766
+ "inputs": [],
1767
+ "outputs": [],
1768
+ "stateMutability": "nonpayable"
1769
+ },
1770
+ {
1771
+ "type": "function",
1772
+ "name": "reputationRegistry",
1773
+ "inputs": [],
1774
+ "outputs": [
1775
+ {
1776
+ "name": "",
1777
+ "type": "address",
1778
+ "internalType": "contract IERC8004Reputation"
1779
+ }
1780
+ ],
1781
+ "stateMutability": "view"
1782
+ },
1783
+ {
1784
+ "type": "function",
1785
+ "name": "resolveDispute",
1786
+ "inputs": [
1787
+ {
1788
+ "name": "jobId",
1789
+ "type": "uint256",
1790
+ "internalType": "uint256"
1791
+ },
1792
+ {
1793
+ "name": "favorBuyer",
1794
+ "type": "bool",
1795
+ "internalType": "bool"
1796
+ }
1797
+ ],
1798
+ "outputs": [],
1799
+ "stateMutability": "nonpayable"
1800
+ },
1801
+ {
1802
+ "type": "function",
1803
+ "name": "serviceMarketplace",
1804
+ "inputs": [],
1805
+ "outputs": [
1806
+ {
1807
+ "name": "",
1808
+ "type": "address",
1809
+ "internalType": "contract IServiceMarketplace"
1810
+ }
1811
+ ],
1812
+ "stateMutability": "view"
1813
+ },
1814
+ {
1815
+ "type": "function",
1816
+ "name": "settle",
1817
+ "inputs": [
1818
+ {
1819
+ "name": "jobId",
1820
+ "type": "uint256",
1821
+ "internalType": "uint256"
1822
+ }
1823
+ ],
1824
+ "outputs": [],
1825
+ "stateMutability": "nonpayable"
1826
+ },
1827
+ {
1828
+ "type": "function",
1829
+ "name": "submitDeliverable",
1830
+ "inputs": [
1831
+ {
1832
+ "name": "jobId",
1833
+ "type": "uint256",
1834
+ "internalType": "uint256"
1835
+ },
1836
+ {
1837
+ "name": "deliverableHash",
1838
+ "type": "bytes32",
1839
+ "internalType": "bytes32"
1840
+ }
1841
+ ],
1842
+ "outputs": [],
1843
+ "stateMutability": "nonpayable"
1844
+ },
1845
+ {
1846
+ "type": "function",
1847
+ "name": "transferOwnership",
1848
+ "inputs": [
1849
+ {
1850
+ "name": "newOwner",
1851
+ "type": "address",
1852
+ "internalType": "address"
1853
+ }
1854
+ ],
1855
+ "outputs": [],
1856
+ "stateMutability": "nonpayable"
1857
+ },
1858
+ {
1859
+ "type": "function",
1860
+ "name": "upgradeToAndCall",
1861
+ "inputs": [
1862
+ {
1863
+ "name": "newImplementation",
1864
+ "type": "address",
1865
+ "internalType": "address"
1866
+ },
1867
+ {
1868
+ "name": "data",
1869
+ "type": "bytes",
1870
+ "internalType": "bytes"
1871
+ }
1872
+ ],
1873
+ "outputs": [],
1874
+ "stateMutability": "payable"
1875
+ },
1876
+ {
1877
+ "type": "function",
1878
+ "name": "usdm",
1879
+ "inputs": [],
1880
+ "outputs": [
1881
+ {
1882
+ "name": "",
1883
+ "type": "address",
1884
+ "internalType": "address"
1885
+ }
1886
+ ],
1887
+ "stateMutability": "view"
1888
+ },
1889
+ {
1890
+ "type": "event",
1891
+ "name": "DeliverableSubmitted",
1892
+ "inputs": [
1893
+ {
1894
+ "name": "jobId",
1895
+ "type": "uint256",
1896
+ "indexed": true,
1897
+ "internalType": "uint256"
1898
+ },
1899
+ {
1900
+ "name": "deliverableHash",
1901
+ "type": "bytes32",
1902
+ "indexed": false,
1903
+ "internalType": "bytes32"
1904
+ }
1905
+ ],
1906
+ "anonymous": false
1907
+ },
1908
+ {
1909
+ "type": "event",
1910
+ "name": "DisputeResolved",
1911
+ "inputs": [
1912
+ {
1913
+ "name": "jobId",
1914
+ "type": "uint256",
1915
+ "indexed": true,
1916
+ "internalType": "uint256"
1917
+ },
1918
+ {
1919
+ "name": "favorBuyer",
1920
+ "type": "bool",
1921
+ "indexed": false,
1922
+ "internalType": "bool"
1923
+ }
1924
+ ],
1925
+ "anonymous": false
1926
+ },
1927
+ {
1928
+ "type": "event",
1929
+ "name": "EIP712DomainChanged",
1930
+ "inputs": [],
1931
+ "anonymous": false
1932
+ },
1933
+ {
1934
+ "type": "event",
1935
+ "name": "Initialized",
1936
+ "inputs": [
1937
+ {
1938
+ "name": "version",
1939
+ "type": "uint64",
1940
+ "indexed": false,
1941
+ "internalType": "uint64"
1942
+ }
1943
+ ],
1944
+ "anonymous": false
1945
+ },
1946
+ {
1947
+ "type": "event",
1948
+ "name": "JobAccepted",
1949
+ "inputs": [
1950
+ {
1951
+ "name": "jobId",
1952
+ "type": "uint256",
1953
+ "indexed": true,
1954
+ "internalType": "uint256"
1955
+ },
1956
+ {
1957
+ "name": "providerAgentId",
1958
+ "type": "uint256",
1959
+ "indexed": true,
1960
+ "internalType": "uint256"
1961
+ }
1962
+ ],
1963
+ "anonymous": false
1964
+ },
1965
+ {
1966
+ "type": "event",
1967
+ "name": "JobCancelled",
1968
+ "inputs": [
1969
+ {
1970
+ "name": "jobId",
1971
+ "type": "uint256",
1972
+ "indexed": true,
1973
+ "internalType": "uint256"
1974
+ },
1975
+ {
1976
+ "name": "previousStatus",
1977
+ "type": "uint8",
1978
+ "indexed": false,
1979
+ "internalType": "enum DataTypes.JobStatus"
1980
+ }
1981
+ ],
1982
+ "anonymous": false
1983
+ },
1984
+ {
1985
+ "type": "event",
1986
+ "name": "JobCreated",
1987
+ "inputs": [
1988
+ {
1989
+ "name": "jobId",
1990
+ "type": "uint256",
1991
+ "indexed": true,
1992
+ "internalType": "uint256"
1993
+ },
1994
+ {
1995
+ "name": "offeringId",
1996
+ "type": "uint256",
1997
+ "indexed": true,
1998
+ "internalType": "uint256"
1999
+ },
2000
+ {
2001
+ "name": "buyerAgentId",
2002
+ "type": "uint256",
2003
+ "indexed": true,
2004
+ "internalType": "uint256"
2005
+ },
2006
+ {
2007
+ "name": "providerAgentId",
2008
+ "type": "uint256",
2009
+ "indexed": false,
2010
+ "internalType": "uint256"
2011
+ },
2012
+ {
2013
+ "name": "priceUSDm",
2014
+ "type": "uint256",
2015
+ "indexed": false,
2016
+ "internalType": "uint256"
2017
+ }
2018
+ ],
2019
+ "anonymous": false
2020
+ },
2021
+ {
2022
+ "type": "event",
2023
+ "name": "JobEvaluated",
2024
+ "inputs": [
2025
+ {
2026
+ "name": "jobId",
2027
+ "type": "uint256",
2028
+ "indexed": true,
2029
+ "internalType": "uint256"
2030
+ },
2031
+ {
2032
+ "name": "approved",
2033
+ "type": "bool",
2034
+ "indexed": false,
2035
+ "internalType": "bool"
2036
+ },
2037
+ {
2038
+ "name": "feedback",
2039
+ "type": "string",
2040
+ "indexed": false,
2041
+ "internalType": "string"
2042
+ }
2043
+ ],
2044
+ "anonymous": false
2045
+ },
2046
+ {
2047
+ "type": "event",
2048
+ "name": "JobSettled",
2049
+ "inputs": [
2050
+ {
2051
+ "name": "jobId",
2052
+ "type": "uint256",
2053
+ "indexed": true,
2054
+ "internalType": "uint256"
2055
+ },
2056
+ {
2057
+ "name": "providerAmount",
2058
+ "type": "uint256",
2059
+ "indexed": false,
2060
+ "internalType": "uint256"
2061
+ },
2062
+ {
2063
+ "name": "feeAmount",
2064
+ "type": "uint256",
2065
+ "indexed": false,
2066
+ "internalType": "uint256"
2067
+ }
2068
+ ],
2069
+ "anonymous": false
2070
+ },
2071
+ {
2072
+ "type": "event",
2073
+ "name": "OwnershipTransferred",
2074
+ "inputs": [
2075
+ {
2076
+ "name": "previousOwner",
2077
+ "type": "address",
2078
+ "indexed": true,
2079
+ "internalType": "address"
2080
+ },
2081
+ {
2082
+ "name": "newOwner",
2083
+ "type": "address",
2084
+ "indexed": true,
2085
+ "internalType": "address"
2086
+ }
2087
+ ],
2088
+ "anonymous": false
2089
+ },
2090
+ {
2091
+ "type": "event",
2092
+ "name": "Upgraded",
2093
+ "inputs": [
2094
+ {
2095
+ "name": "implementation",
2096
+ "type": "address",
2097
+ "indexed": true,
2098
+ "internalType": "address"
2099
+ }
2100
+ ],
2101
+ "anonymous": false
2102
+ },
2103
+ {
2104
+ "type": "error",
2105
+ "name": "AddressEmptyCode",
2106
+ "inputs": [
2107
+ {
2108
+ "name": "target",
2109
+ "type": "address",
2110
+ "internalType": "address"
2111
+ }
2112
+ ]
2113
+ },
2114
+ {
2115
+ "type": "error",
2116
+ "name": "AgentNotActive",
2117
+ "inputs": []
2118
+ },
2119
+ {
2120
+ "type": "error",
2121
+ "name": "ERC1967InvalidImplementation",
2122
+ "inputs": [
2123
+ {
2124
+ "name": "implementation",
2125
+ "type": "address",
2126
+ "internalType": "address"
2127
+ }
2128
+ ]
2129
+ },
2130
+ {
2131
+ "type": "error",
2132
+ "name": "ERC1967NonPayable",
2133
+ "inputs": []
2134
+ },
2135
+ {
2136
+ "type": "error",
2137
+ "name": "FailedCall",
2138
+ "inputs": []
2139
+ },
2140
+ {
2141
+ "type": "error",
2142
+ "name": "InvalidInitialization",
2143
+ "inputs": []
2144
+ },
2145
+ {
2146
+ "type": "error",
2147
+ "name": "InvalidJobStatus",
2148
+ "inputs": [
2149
+ {
2150
+ "name": "current",
2151
+ "type": "uint8",
2152
+ "internalType": "enum DataTypes.JobStatus"
2153
+ },
2154
+ {
2155
+ "name": "expected",
2156
+ "type": "uint8",
2157
+ "internalType": "enum DataTypes.JobStatus"
2158
+ }
2159
+ ]
2160
+ },
2161
+ {
2162
+ "type": "error",
2163
+ "name": "InvalidSignature",
2164
+ "inputs": []
2165
+ },
2166
+ {
2167
+ "type": "error",
2168
+ "name": "JobNotFound",
2169
+ "inputs": []
2170
+ },
2171
+ {
2172
+ "type": "error",
2173
+ "name": "NotAgentOwnerOrOperator",
2174
+ "inputs": []
2175
+ },
2176
+ {
2177
+ "type": "error",
2178
+ "name": "NotInitializing",
2179
+ "inputs": []
2180
+ },
2181
+ {
2182
+ "type": "error",
2183
+ "name": "OfferingNotActive",
2184
+ "inputs": []
2185
+ },
2186
+ {
2187
+ "type": "error",
2188
+ "name": "OwnableInvalidOwner",
2189
+ "inputs": [
2190
+ {
2191
+ "name": "owner",
2192
+ "type": "address",
2193
+ "internalType": "address"
2194
+ }
2195
+ ]
2196
+ },
2197
+ {
2198
+ "type": "error",
2199
+ "name": "OwnableUnauthorizedAccount",
2200
+ "inputs": [
2201
+ {
2202
+ "name": "account",
2203
+ "type": "address",
2204
+ "internalType": "address"
2205
+ }
2206
+ ]
2207
+ },
2208
+ {
2209
+ "type": "error",
2210
+ "name": "SelfService",
2211
+ "inputs": []
2212
+ },
2213
+ {
2214
+ "type": "error",
2215
+ "name": "TimeoutNotReached",
2216
+ "inputs": []
2217
+ },
2218
+ {
2219
+ "type": "error",
2220
+ "name": "UUPSUnauthorizedCallContext",
2221
+ "inputs": []
2222
+ },
2223
+ {
2224
+ "type": "error",
2225
+ "name": "UUPSUnsupportedProxiableUUID",
2226
+ "inputs": [
2227
+ {
2228
+ "name": "slot",
2229
+ "type": "bytes32",
2230
+ "internalType": "bytes32"
2231
+ }
2232
+ ]
2233
+ },
2234
+ {
2235
+ "type": "error",
2236
+ "name": "ZeroAddress",
2237
+ "inputs": []
2238
+ }
2239
+ ];
2240
+
2241
+ // src/abis/ERC20.ts
2242
+ var erc20Abi = [
2243
+ {
2244
+ type: "function",
2245
+ name: "approve",
2246
+ inputs: [
2247
+ { name: "spender", type: "address" },
2248
+ { name: "amount", type: "uint256" }
2249
+ ],
2250
+ outputs: [{ name: "", type: "bool" }],
2251
+ stateMutability: "nonpayable"
2252
+ },
2253
+ {
2254
+ type: "function",
2255
+ name: "transfer",
2256
+ inputs: [
2257
+ { name: "to", type: "address" },
2258
+ { name: "amount", type: "uint256" }
2259
+ ],
2260
+ outputs: [{ name: "", type: "bool" }],
2261
+ stateMutability: "nonpayable"
2262
+ },
2263
+ {
2264
+ type: "function",
2265
+ name: "transferFrom",
2266
+ inputs: [
2267
+ { name: "from", type: "address" },
2268
+ { name: "to", type: "address" },
2269
+ { name: "amount", type: "uint256" }
2270
+ ],
2271
+ outputs: [{ name: "", type: "bool" }],
2272
+ stateMutability: "nonpayable"
2273
+ },
2274
+ {
2275
+ type: "function",
2276
+ name: "balanceOf",
2277
+ inputs: [{ name: "account", type: "address" }],
2278
+ outputs: [{ name: "", type: "uint256" }],
2279
+ stateMutability: "view"
2280
+ },
2281
+ {
2282
+ type: "function",
2283
+ name: "allowance",
2284
+ inputs: [
2285
+ { name: "owner", type: "address" },
2286
+ { name: "spender", type: "address" }
2287
+ ],
2288
+ outputs: [{ name: "", type: "uint256" }],
2289
+ stateMutability: "view"
2290
+ },
2291
+ {
2292
+ type: "function",
2293
+ name: "mint",
2294
+ inputs: [
2295
+ { name: "to", type: "address" },
2296
+ { name: "amount", type: "uint256" }
2297
+ ],
2298
+ outputs: [],
2299
+ stateMutability: "nonpayable"
2300
+ }
2301
+ ];
2302
+
2303
+ // src/utils/signing.ts
2304
+ var MEMO_TYPES = {
2305
+ Memo: [
2306
+ { name: "jobId", type: "uint256" },
2307
+ { name: "signer", type: "address" },
2308
+ { name: "contentHash", type: "bytes32" },
2309
+ { name: "timestamp", type: "uint64" },
2310
+ { name: "nonce", type: "uint256" }
2311
+ ]
2312
+ };
2313
+ var PULSE_DOMAIN = {
2314
+ name: "PulseJobEngine",
2315
+ version: "1"
2316
+ };
2317
+ async function signMemo(walletClient, params) {
2318
+ const account = walletClient.account;
2319
+ if (!account) throw new Error("WalletClient must have an account");
2320
+ return walletClient.signTypedData({
2321
+ account,
2322
+ domain: {
2323
+ ...PULSE_DOMAIN,
2324
+ chainId: params.chainId,
2325
+ verifyingContract: params.verifyingContract
2326
+ },
2327
+ types: MEMO_TYPES,
2328
+ primaryType: "Memo",
2329
+ message: {
2330
+ jobId: params.jobId,
2331
+ signer: account.address,
2332
+ contentHash: params.contentHash,
2333
+ timestamp: 0n,
2334
+ nonce: params.nonce
2335
+ }
2336
+ });
2337
+ }
2338
+
2339
+ // src/jobs/index.ts
2340
+ async function createJob(client, params) {
2341
+ const offering = await client.publicClient.readContract({
2342
+ address: client.addresses.serviceMarketplace,
2343
+ abi: serviceMarketplaceAbi,
2344
+ functionName: "getOffering",
2345
+ args: [params.offeringId]
2346
+ });
2347
+ const price = offering.priceUSDm;
2348
+ const approveTx = await write(client, {
2349
+ address: client.addresses.usdm,
2350
+ abi: erc20Abi,
2351
+ functionName: "approve",
2352
+ args: [client.addresses.jobEngine, price]
2353
+ });
2354
+ await client.publicClient.waitForTransactionReceipt({ hash: approveTx });
2355
+ const txHash = await write(client, {
2356
+ address: client.addresses.jobEngine,
2357
+ abi: jobEngineAbi,
2358
+ functionName: "createJob",
2359
+ args: [params.offeringId, params.buyerAgentId, params.warrenTermsHash]
2360
+ });
2361
+ const receipt = await client.publicClient.waitForTransactionReceipt({ hash: txHash });
2362
+ const jobLog = receipt.logs.find(
2363
+ (log) => log.address.toLowerCase() === client.addresses.jobEngine.toLowerCase()
2364
+ );
2365
+ const jobId = jobLog?.topics[1] ? BigInt(jobLog.topics[1]) : 0n;
2366
+ return { jobId, txHash };
2367
+ }
2368
+ async function acceptJob(client, jobId, warrenTermsHash) {
2369
+ const { wallet, account } = requireWallet(client);
2370
+ const nonce = await client.publicClient.readContract({
2371
+ address: client.addresses.jobEngine,
2372
+ abi: jobEngineAbi,
2373
+ functionName: "nonces",
2374
+ args: [account.address]
2375
+ });
2376
+ const signature = await signMemo(wallet, {
2377
+ jobId,
2378
+ contentHash: warrenTermsHash,
2379
+ nonce,
2380
+ verifyingContract: client.addresses.jobEngine,
2381
+ chainId: client.chain.id
2382
+ });
2383
+ return write(client, {
2384
+ address: client.addresses.jobEngine,
2385
+ abi: jobEngineAbi,
2386
+ functionName: "acceptJob",
2387
+ args: [jobId, signature]
2388
+ });
2389
+ }
2390
+ async function submitDeliverable(client, jobId, deliverableHash) {
2391
+ return write(client, {
2392
+ address: client.addresses.jobEngine,
2393
+ abi: jobEngineAbi,
2394
+ functionName: "submitDeliverable",
2395
+ args: [jobId, deliverableHash]
2396
+ });
2397
+ }
2398
+ async function evaluate(client, jobId, approved, feedback) {
2399
+ return write(client, {
2400
+ address: client.addresses.jobEngine,
2401
+ abi: jobEngineAbi,
2402
+ functionName: "evaluate",
2403
+ args: [jobId, approved, feedback]
2404
+ });
2405
+ }
2406
+ async function settle(client, jobId) {
2407
+ return write(client, {
2408
+ address: client.addresses.jobEngine,
2409
+ abi: jobEngineAbi,
2410
+ functionName: "settle",
2411
+ args: [jobId]
2412
+ });
2413
+ }
2414
+ async function cancelJob(client, jobId) {
2415
+ return write(client, {
2416
+ address: client.addresses.jobEngine,
2417
+ abi: jobEngineAbi,
2418
+ functionName: "cancelJob",
2419
+ args: [jobId]
2420
+ });
2421
+ }
2422
+ async function getJob(client, jobId) {
2423
+ const raw = await client.publicClient.readContract({
2424
+ address: client.addresses.jobEngine,
2425
+ abi: jobEngineAbi,
2426
+ functionName: "getJob",
2427
+ args: [jobId]
2428
+ });
2429
+ return raw;
2430
+ }
2431
+ async function getJobCount(client) {
2432
+ return client.publicClient.readContract({
2433
+ address: client.addresses.jobEngine,
2434
+ abi: jobEngineAbi,
2435
+ functionName: "getJobCount"
2436
+ });
2437
+ }
2438
+
2439
+ // src/warren/index.ts
2440
+ import { keccak256, toHex as toHex2 } from "viem";
2441
+
2442
+ // src/warren/deploy.ts
2443
+ import { toHex } from "viem";
2444
+
2445
+ // src/abis/Page.ts
2446
+ var pageAbi = [
2447
+ {
2448
+ type: "constructor",
2449
+ inputs: [{ name: "_content", type: "bytes", internalType: "bytes" }],
2450
+ stateMutability: "nonpayable"
2451
+ },
2452
+ {
2453
+ type: "function",
2454
+ name: "DATA_POINTER",
2455
+ inputs: [],
2456
+ outputs: [{ name: "", type: "address", internalType: "address" }],
2457
+ stateMutability: "view"
2458
+ },
2459
+ {
2460
+ type: "function",
2461
+ name: "read",
2462
+ inputs: [],
2463
+ outputs: [{ name: "", type: "string", internalType: "string" }],
2464
+ stateMutability: "view"
2465
+ }
2466
+ ];
2467
+ var pageBytecode = "0x60a0604052346100e45761025c80380380610019816100fc565b9283398101906020818303126100e4578051906001600160401b0382116100e4570181601f820112156100e4578051906001600160401b0382116100e85761006a601f8301601f19166020016100fc565b92828452602083830101116100e457815f9260208093018386015e8301015280518060401b6bfe61000180600a3d393df3000161fffe8211830152600b8101601583015ff09182156100d7575260805260405161013a908161012282396080518181816044015260d50152f35b63301164255f526004601cfd5b5f80fd5b634e487b7160e01b5f52604160045260245ffd5b6040519190601f01601f191682016001600160401b038111838210176100e85760405256fe6080806040526004361015610012575f80fd5b5f3560e01c9081634822da1c146100c357506357de26a414610032575f80fd5b346100bf575f3660031901126100bf577f00000000000000000000000000000000000000000000000000000000000000006020608060405180935f19813b0164ffffffffff16905f6021830191601f8501903c808252016040810193846040528385528051938491826060850152018383015e5f828483010152603f1992601f8019910116810103010190f35b5f80fd5b346100bf575f3660031901126100bf577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f3fea2646970667358221220ef127603f0186dbb6931afd2c82c51ffac70e74b017d0969deb60d346c35a49c64736f6c634300081a0033";
2468
+
2469
+ // src/abis/Master.ts
2470
+ var masterAbi = [
2471
+ {
2472
+ type: "constructor",
2473
+ inputs: [
2474
+ { name: "_nftContract", type: "address", internalType: "address" },
2475
+ { name: "_adminTokenId", type: "uint256", internalType: "uint256" },
2476
+ { name: "_relayers", type: "address[]", internalType: "address[]" }
2477
+ ],
2478
+ stateMutability: "nonpayable"
2479
+ },
2480
+ {
2481
+ type: "function",
2482
+ name: "publish",
2483
+ inputs: [
2484
+ { name: "_rootChunk", type: "address", internalType: "address" },
2485
+ { name: "_depth", type: "uint8", internalType: "uint8" },
2486
+ { name: "_totalSize", type: "uint256", internalType: "uint256" },
2487
+ { name: "_siteType", type: "uint8", internalType: "uint8" }
2488
+ ],
2489
+ outputs: [],
2490
+ stateMutability: "nonpayable"
2491
+ },
2492
+ {
2493
+ type: "function",
2494
+ name: "getCurrentSiteInfo",
2495
+ inputs: [],
2496
+ outputs: [
2497
+ {
2498
+ name: "",
2499
+ type: "tuple",
2500
+ internalType: "struct Master.SiteInfo",
2501
+ components: [
2502
+ { name: "rootChunk", type: "address", internalType: "address" },
2503
+ { name: "depth", type: "uint8", internalType: "uint8" },
2504
+ { name: "totalSize", type: "uint256", internalType: "uint256" },
2505
+ { name: "siteType", type: "uint8", internalType: "uint8" }
2506
+ ]
2507
+ }
2508
+ ],
2509
+ stateMutability: "view"
2510
+ },
2511
+ {
2512
+ type: "function",
2513
+ name: "currentVersion",
2514
+ inputs: [],
2515
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
2516
+ stateMutability: "view"
2517
+ },
2518
+ {
2519
+ type: "function",
2520
+ name: "nftContract",
2521
+ inputs: [],
2522
+ outputs: [{ name: "", type: "address", internalType: "address" }],
2523
+ stateMutability: "view"
2524
+ },
2525
+ {
2526
+ type: "function",
2527
+ name: "adminTokenId",
2528
+ inputs: [],
2529
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
2530
+ stateMutability: "view"
2531
+ },
2532
+ {
2533
+ type: "function",
2534
+ name: "addRelayer",
2535
+ inputs: [{ name: "_relayer", type: "address", internalType: "address" }],
2536
+ outputs: [],
2537
+ stateMutability: "nonpayable"
2538
+ },
2539
+ {
2540
+ type: "function",
2541
+ name: "removeRelayer",
2542
+ inputs: [{ name: "_relayer", type: "address", internalType: "address" }],
2543
+ outputs: [],
2544
+ stateMutability: "nonpayable"
2545
+ },
2546
+ {
2547
+ type: "function",
2548
+ name: "isAuthorizedRelayer",
2549
+ inputs: [{ name: "_relayer", type: "address", internalType: "address" }],
2550
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
2551
+ stateMutability: "view"
2552
+ },
2553
+ {
2554
+ type: "event",
2555
+ name: "SiteUpdated",
2556
+ inputs: [
2557
+ { name: "version", type: "uint256", indexed: true, internalType: "uint256" },
2558
+ { name: "rootChunk", type: "address", indexed: false, internalType: "address" },
2559
+ { name: "depth", type: "uint8", indexed: false, internalType: "uint8" },
2560
+ { name: "totalSize", type: "uint256", indexed: false, internalType: "uint256" },
2561
+ { name: "siteType", type: "uint8", indexed: false, internalType: "uint8" }
2562
+ ],
2563
+ anonymous: false
2564
+ }
2565
+ ];
2566
+ var masterBytecode = "0x60806040523461015357610861803803806100198161016b565b9283398101906060818303126101535761003281610190565b6020820151604083015190926001600160401b03821161015357019280601f85011215610153578351936001600160401b038511610157578460051b9060208061007d81850161016b565b80988152019282010192831161015357602001905b82821061013b5750505060018060a01b031660018060a01b03195f5416175f556001555f6003555f5b815181101561012c576001906001600160a01b036100d982856101a4565b51165f52600260205260405f208260ff19825416179055818060a01b0361010082856101a4565b51167f03580ee9f53a62b7cb409a2cb56f9be87747dd15017afc5cef6eef321e4fb2c55f80a2016100bb565b60405161069490816101cd8239f35b6020809161014884610190565b815201910190610092565b5f80fd5b634e487b7160e01b5f52604160045260245ffd5b6040519190601f01601f191682016001600160401b0381118382101761015757604052565b51906001600160a01b038216820361015357565b80518210156101b85760209160051b010190565b634e487b7160e01b5f52603260045260245ffdfe6080806040526004361015610012575f80fd5b5f3560e01c908163183fb9d8146104fc575080631a2321ef146103b457806329e295c51461008a57806360f0a5ac146103045780637f2b8c03146102635780639d888e8614610246578063d56d229d1461021f578063dd39f00d1461012d578063dff11fab146100cb5763e0f324d91461008a575f80fd5b346100c75760203660031901126100c7576001600160a01b036100ab610516565b165f526002602052602060ff60405f2054166040519015158152f35b5f80fd5b346100c75760203660031901126100c757600480355f90815260209182526040908190208054600182015460029092015483516001600160a01b038316815260ff60a09390931c83169581019590955292840191909152166060820152608090f35b346100c75760203660031901126100c757610146610516565b61014e61055c565b6001600160a01b031680156101e857805f52600260205260ff60405f2054166101ae57805f52600260205260405f20600160ff198254161790557f03580ee9f53a62b7cb409a2cb56f9be87747dd15017afc5cef6eef321e4fb2c55f80a2005b60405162461bcd60e51b8152602060048201526012602482015271105b1c9958591e48185d5d1a1bdc9a5e995960721b6044820152606490fd5b60405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b6044820152606490fd5b346100c7575f3660031901126100c7575f546040516001600160a01b039091168152602090f35b346100c7575f3660031901126100c7576020600354604051908152f35b346100c7575f3660031901126100c7575f60606040516102828161052c565b82815282602082015282604082015201526003545f526004602052608060405f2060ff6040516102b18161052c565b8254928260018060a01b0385169485845281602085019160a01c16815260608260026001860154956040880196875201541694019384526040519586525116602085015251604084015251166060820152f35b346100c75760203660031901126100c75761031d610516565b61032561055c565b6001600160a01b03165f8181526002602052604090205460ff161561037e57805f52600260205260405f2060ff1981541690557f10e1f7ce9fd7d1b90a66d13a2ab3cb8dd7f29f3f8d520b143b063ccfbab6906b5f80a2005b60405162461bcd60e51b815260206004820152600e60248201526d139bdd08185d5d1a1bdc9a5e995960921b6044820152606490fd5b346100c75760803660031901126100c7576103cd610516565b60243560ff8116908181036100c7576044359260643560ff8116908181036100c7576103f761055c565b600354915f1983146104e85760ff60027f663edd0a8a23886fef2b8806157fdadc2d45fb10e1f93e01d812f595127f79ac9760016104e3960180600355604051916104418361052c565b60018060a01b03891683526020830190815260408301918c8352606084019687525f52600460205260405f209260018060a01b039051168354918660a01b905160a01b16916affffffffffffffffffffff60a81b16171782555160018201550191511660ff198254161790556003549560405194859485929360ff91959482606094608087019860018060a01b03168752166020860152604085015216910152565b0390a2005b634e487b7160e01b5f52601160045260245ffd5b346100c7575f3660031901126100c7576020906001548152f35b600435906001600160a01b03821682036100c757565b6080810190811067ffffffffffffffff82111761054857604052565b634e487b7160e01b5f52604160045260245ffd5b335f52600260205260ff60405f2054165f60018060a01b035f541660206001546024604051809481936331a9108f60e11b835260048301525afa5f9181610604575b506105f1575b5081156105e9575b50156105b457565b60405162461bcd60e51b815260206004820152600d60248201526c1058d8d95cdcc811195b9a5959609a1b6044820152606490fd5b90505f6105ac565b6001600160a01b0316331490505f6105a4565b90915060203d602011610657575b601f8101601f1916820167ffffffffffffffff811183821017610548576020918391604052810103126100c757516001600160a01b03811681036100c757905f61059e565b503d61061256fea26469706673582212206225772043545238e3ab16ab29d2b12e11e5a5dc26aa7bc6042d4847bc0059c764736f6c634300081a0033";
2567
+
2568
+ // src/warren/deploy.ts
2569
+ async function deployWarrenPage(client, content) {
2570
+ const { wallet, account, chain } = requireWallet(client);
2571
+ const contentBytes = toHex(new TextEncoder().encode(content));
2572
+ const txHash = await wallet.deployContract({
2573
+ abi: pageAbi,
2574
+ bytecode: pageBytecode,
2575
+ args: [contentBytes],
2576
+ chain,
2577
+ account
2578
+ });
2579
+ const receipt = await client.publicClient.waitForTransactionReceipt({ hash: txHash });
2580
+ if (!receipt.contractAddress) throw new Error("Page deployment failed");
2581
+ return { pageAddress: receipt.contractAddress, txHash };
2582
+ }
2583
+ async function deployWarrenMaster(client, agentId, pageAddress, contentSize, siteType) {
2584
+ const { wallet, account, chain } = requireWallet(client);
2585
+ const txHash = await wallet.deployContract({
2586
+ abi: masterAbi,
2587
+ bytecode: masterBytecode,
2588
+ args: [client.addresses.identityRegistry, agentId, [account.address]],
2589
+ chain,
2590
+ account
2591
+ });
2592
+ const receipt = await client.publicClient.waitForTransactionReceipt({ hash: txHash });
2593
+ if (!receipt.contractAddress) throw new Error("Master deployment failed");
2594
+ const masterAddress = receipt.contractAddress;
2595
+ await wallet.writeContract({
2596
+ address: masterAddress,
2597
+ abi: masterAbi,
2598
+ functionName: "publish",
2599
+ args: [pageAddress, 0, BigInt(contentSize), siteType ?? 2],
2600
+ chain,
2601
+ account
2602
+ });
2603
+ return { masterAddress, txHash };
2604
+ }
2605
+ async function readWarrenPage(client, pageAddress) {
2606
+ const data = await client.publicClient.readContract({
2607
+ address: pageAddress,
2608
+ abi: pageAbi,
2609
+ functionName: "read"
2610
+ });
2611
+ return data;
2612
+ }
2613
+ async function readWarrenMaster(client, masterAddress) {
2614
+ const siteInfo = await client.publicClient.readContract({
2615
+ address: masterAddress,
2616
+ abi: masterAbi,
2617
+ functionName: "getCurrentSiteInfo"
2618
+ });
2619
+ return readWarrenPage(client, siteInfo.rootChunk);
2620
+ }
2621
+ async function deployAgentCard(client, agentId, params) {
2622
+ const { json, hash } = createAgentCard(params);
2623
+ const contentBytes = new TextEncoder().encode(json);
2624
+ const { pageAddress, txHash: deployTx } = await deployWarrenPage(client, json);
2625
+ const { masterAddress } = await deployWarrenMaster(client, agentId, pageAddress, contentBytes.length, 2);
2626
+ await write(client, {
2627
+ address: client.addresses.pulseExtension,
2628
+ abi: pulseExtensionAbi,
2629
+ functionName: "setWarrenContract",
2630
+ args: [agentId, masterAddress]
2631
+ });
2632
+ return { masterAddress, pageAddress, hash, txHash: deployTx };
2633
+ }
2634
+ async function deployJobTerms(client, agentId, params) {
2635
+ const { json, hash } = createJobTerms(params);
2636
+ const contentBytes = new TextEncoder().encode(json);
2637
+ const { pageAddress, txHash } = await deployWarrenPage(client, json);
2638
+ const { masterAddress } = await deployWarrenMaster(client, agentId, pageAddress, contentBytes.length, 0);
2639
+ return { masterAddress, pageAddress, hash, txHash };
2640
+ }
2641
+ async function deployDeliverable(client, agentId, jobId, params, indexerUrl) {
2642
+ const { json, hash } = createDeliverable(params);
2643
+ const contentBytes = new TextEncoder().encode(json);
2644
+ const { pageAddress, txHash } = await deployWarrenPage(client, json);
2645
+ const { masterAddress } = await deployWarrenMaster(client, agentId, pageAddress, contentBytes.length, 1);
2646
+ await write(client, {
2647
+ address: client.addresses.jobEngine,
2648
+ abi: jobEngineAbi,
2649
+ functionName: "submitDeliverable",
2650
+ args: [jobId, hash]
2651
+ });
2652
+ if (indexerUrl) {
2653
+ try {
2654
+ await fetch(`${indexerUrl}/warren-links`, {
2655
+ method: "POST",
2656
+ headers: { "Content-Type": "application/json" },
2657
+ body: JSON.stringify({
2658
+ jobId: Number(jobId),
2659
+ linkType: "deliverable",
2660
+ masterAddress,
2661
+ contentHash: hash
2662
+ })
2663
+ });
2664
+ } catch {
2665
+ }
2666
+ }
2667
+ return { masterAddress, pageAddress, hash, txHash };
2668
+ }
2669
+ async function readDeliverable(client, jobId, indexerUrl) {
2670
+ const res = await fetch(`${indexerUrl}/warren-links/${Number(jobId)}`);
2671
+ if (!res.ok) throw new Error(`Failed to fetch warren link for job ${jobId}`);
2672
+ const { data } = await res.json();
2673
+ if (!data.deliverable) throw new Error(`No deliverable WARREN link for job ${jobId}`);
2674
+ const content = await readWarrenMaster(client, data.deliverable.master_address);
2675
+ if (!verifyContentHash(content, data.deliverable.content_hash)) {
2676
+ throw new Error("Deliverable content hash mismatch");
2677
+ }
2678
+ return JSON.parse(content);
2679
+ }
2680
+ async function deployRequirements(client, agentId, jobId, params, indexerUrl) {
2681
+ const { json, hash } = createRequirements(params);
2682
+ const contentBytes = new TextEncoder().encode(json);
2683
+ const { pageAddress, txHash } = await deployWarrenPage(client, json);
2684
+ const { masterAddress } = await deployWarrenMaster(client, agentId, pageAddress, contentBytes.length, 3);
2685
+ if (indexerUrl) {
2686
+ try {
2687
+ await fetch(`${indexerUrl}/warren-links`, {
2688
+ method: "POST",
2689
+ headers: { "Content-Type": "application/json" },
2690
+ body: JSON.stringify({
2691
+ jobId: Number(jobId),
2692
+ linkType: "requirements",
2693
+ masterAddress,
2694
+ contentHash: hash
2695
+ })
2696
+ });
2697
+ } catch {
2698
+ }
2699
+ }
2700
+ return { masterAddress, pageAddress, hash, txHash };
2701
+ }
2702
+ async function readRequirements(client, jobId, indexerUrl) {
2703
+ try {
2704
+ const res = await fetch(`${indexerUrl}/warren-links/${Number(jobId)}`);
2705
+ if (!res.ok) return null;
2706
+ const { data } = await res.json();
2707
+ if (!data.requirements) return null;
2708
+ const content = await readWarrenMaster(client, data.requirements.master_address);
2709
+ if (!verifyContentHash(content, data.requirements.content_hash)) {
2710
+ throw new Error("Requirements content hash mismatch");
2711
+ }
2712
+ return JSON.parse(content);
2713
+ } catch {
2714
+ return null;
2715
+ }
2716
+ }
2717
+
2718
+ // src/warren/index.ts
2719
+ function createAgentCard(params) {
2720
+ const card = {
2721
+ name: params.name,
2722
+ description: params.description,
2723
+ serviceCategory: params.serviceCategory,
2724
+ capabilities: params.capabilities,
2725
+ priceRange: {
2726
+ min: params.priceRange.min.toString(),
2727
+ max: params.priceRange.max.toString(),
2728
+ currency: params.priceRange.currency ?? "USDm"
2729
+ },
2730
+ owner: params.owner,
2731
+ version: params.version ?? 1
2732
+ };
2733
+ const json = JSON.stringify(card, null, 2);
2734
+ const hash = keccak256(toHex2(json));
2735
+ return { json, hash };
2736
+ }
2737
+ function createJobTerms(params) {
2738
+ const terms = {
2739
+ jobId: params.jobId.toString(),
2740
+ offeringId: params.offeringId.toString(),
2741
+ agreedPrice: params.agreedPrice.toString(),
2742
+ slaMinutes: params.slaMinutes,
2743
+ qualityCriteria: params.qualityCriteria,
2744
+ refundConditions: params.refundConditions ?? "",
2745
+ buyerAgent: params.buyerAgent,
2746
+ providerAgent: params.providerAgent,
2747
+ timestamp: Math.floor(Date.now() / 1e3)
2748
+ };
2749
+ const json = JSON.stringify(terms, null, 2);
2750
+ const hash = keccak256(toHex2(json));
2751
+ return { json, hash };
2752
+ }
2753
+ function verifyContentHash(content, expectedHash) {
2754
+ const computedHash = keccak256(toHex2(content));
2755
+ return computedHash === expectedHash;
2756
+ }
2757
+ function createDeliverable(params) {
2758
+ const deliverable = {
2759
+ type: params.type,
2760
+ jobId: params.jobId.toString(),
2761
+ mimeType: params.mimeType ?? "application/json",
2762
+ timestamp: Math.floor(Date.now() / 1e3)
2763
+ };
2764
+ if (params.type === "inline") {
2765
+ if (!params.content) throw new Error("content required for inline deliverable");
2766
+ deliverable.content = params.content;
2767
+ deliverable.size = new TextEncoder().encode(params.content).length;
2768
+ } else {
2769
+ if (!params.url) throw new Error("url required for url deliverable");
2770
+ deliverable.url = params.url;
2771
+ deliverable.contentHash = params.contentHash ?? "";
2772
+ deliverable.size = 0;
2773
+ }
2774
+ const json = JSON.stringify(deliverable, null, 2);
2775
+ const hash = keccak256(toHex2(json));
2776
+ return { json, hash };
2777
+ }
2778
+ function createRequirements(params) {
2779
+ const data = {
2780
+ jobId: params.jobId.toString(),
2781
+ offeringId: params.offeringId.toString(),
2782
+ requirements: params.requirements,
2783
+ timestamp: Math.floor(Date.now() / 1e3)
2784
+ };
2785
+ const json = JSON.stringify(data, null, 2);
2786
+ const hash = keccak256(toHex2(json));
2787
+ return { json, hash };
2788
+ }
2789
+
2790
+ // src/utils.ts
2791
+ var USDM_DECIMALS = 18;
2792
+ var USDM_SCALE = 10n ** BigInt(USDM_DECIMALS);
2793
+ function parseUsdm(value) {
2794
+ const normalized = value.trim();
2795
+ if (normalized.length === 0) {
2796
+ throw new Error("USDm amount cannot be empty");
2797
+ }
2798
+ const match = normalized.match(/^([+]?)(\d+)(?:\.(\d*))?$/);
2799
+ if (!match) {
2800
+ throw new Error(`Invalid USDm amount: "${value}"`);
2801
+ }
2802
+ const wholePart = BigInt(match[2]);
2803
+ const decimalPart = match[3] ?? "";
2804
+ if (decimalPart.length > USDM_DECIMALS) {
2805
+ throw new Error(`USDm amount supports up to ${USDM_DECIMALS} decimal places`);
2806
+ }
2807
+ const fraction = decimalPart.length > 0 ? BigInt(decimalPart.padEnd(USDM_DECIMALS, "0")) : 0n;
2808
+ return wholePart * USDM_SCALE + fraction;
2809
+ }
2810
+ function formatUsdm(amount) {
2811
+ if (amount < 0n) {
2812
+ throw new Error("USDm amount cannot be negative");
2813
+ }
2814
+ const whole = amount / USDM_SCALE;
2815
+ const fraction = amount % USDM_SCALE;
2816
+ if (fraction === 0n) {
2817
+ return `${whole}.00`;
2818
+ }
2819
+ const trimmedFraction = fraction.toString().padStart(USDM_DECIMALS, "0").replace(/0+$/, "");
2820
+ if (trimmedFraction.length >= 2) {
2821
+ return `${whole}.${trimmedFraction}`;
2822
+ }
2823
+ return `${whole}.${trimmedFraction.padEnd(2, "0")}`;
2824
+ }
2825
+
2826
+ // src/types.ts
2827
+ var JobStatus = /* @__PURE__ */ ((JobStatus2) => {
2828
+ JobStatus2[JobStatus2["Created"] = 0] = "Created";
2829
+ JobStatus2[JobStatus2["Accepted"] = 1] = "Accepted";
2830
+ JobStatus2[JobStatus2["InProgress"] = 2] = "InProgress";
2831
+ JobStatus2[JobStatus2["Delivered"] = 3] = "Delivered";
2832
+ JobStatus2[JobStatus2["Evaluated"] = 4] = "Evaluated";
2833
+ JobStatus2[JobStatus2["Completed"] = 5] = "Completed";
2834
+ JobStatus2[JobStatus2["Disputed"] = 6] = "Disputed";
2835
+ JobStatus2[JobStatus2["Cancelled"] = 7] = "Cancelled";
2836
+ return JobStatus2;
2837
+ })(JobStatus || {});
2838
+ var ServiceType = /* @__PURE__ */ ((ServiceType2) => {
2839
+ ServiceType2[ServiceType2["TextGeneration"] = 0] = "TextGeneration";
2840
+ ServiceType2[ServiceType2["ImageGeneration"] = 1] = "ImageGeneration";
2841
+ ServiceType2[ServiceType2["DataAnalysis"] = 2] = "DataAnalysis";
2842
+ ServiceType2[ServiceType2["CodeGeneration"] = 3] = "CodeGeneration";
2843
+ ServiceType2[ServiceType2["Translation"] = 4] = "Translation";
2844
+ ServiceType2[ServiceType2["Custom"] = 5] = "Custom";
2845
+ return ServiceType2;
2846
+ })(ServiceType || {});
2847
+
2848
+ // src/indexer/client.ts
2849
+ var IndexerClientError = class extends Error {
2850
+ status;
2851
+ url;
2852
+ body;
2853
+ constructor(message, options) {
2854
+ super(message, { cause: options.cause });
2855
+ this.name = "IndexerClientError";
2856
+ this.status = options.status;
2857
+ this.url = options.url;
2858
+ this.body = options.body;
2859
+ }
2860
+ };
2861
+ function isRecord(value) {
2862
+ return typeof value === "object" && value !== null;
2863
+ }
2864
+ function toIndexerAgent(raw) {
2865
+ return {
2866
+ agentId: raw.agent_id,
2867
+ owner: raw.owner,
2868
+ agentUri: raw.agent_uri,
2869
+ operator: raw.operator,
2870
+ warrenContract: raw.warren_contract,
2871
+ active: raw.active === 1,
2872
+ registeredAt: raw.registered_at,
2873
+ blockNumber: raw.block_number,
2874
+ txHash: raw.tx_hash
2875
+ };
2876
+ }
2877
+ function toIndexerOffering(raw) {
2878
+ return {
2879
+ offeringId: raw.offering_id,
2880
+ agentId: raw.agent_id,
2881
+ serviceType: raw.service_type,
2882
+ priceUsdm: raw.price_usdm,
2883
+ slaMinutes: raw.sla_minutes,
2884
+ description: raw.description,
2885
+ active: raw.active === 1,
2886
+ blockNumber: raw.block_number,
2887
+ txHash: raw.tx_hash
2888
+ };
2889
+ }
2890
+ function toIndexerWarrenLinks(raw) {
2891
+ const links = {};
2892
+ for (const [linkType, link] of Object.entries(raw)) {
2893
+ links[linkType] = {
2894
+ masterAddress: link.master_address,
2895
+ contentHash: link.content_hash
2896
+ };
2897
+ }
2898
+ return links;
2899
+ }
2900
+ function toIndexerJob(raw) {
2901
+ return {
2902
+ jobId: raw.job_id,
2903
+ offeringId: raw.offering_id,
2904
+ buyerAgentId: raw.buyer_agent_id,
2905
+ providerAgentId: raw.provider_agent_id,
2906
+ priceUsdm: raw.price_usdm,
2907
+ status: raw.status,
2908
+ warrenTermsHash: raw.warren_terms_hash,
2909
+ deliverableHash: raw.deliverable_hash,
2910
+ createdAt: raw.created_at,
2911
+ acceptedAt: raw.accepted_at,
2912
+ deliveredAt: raw.delivered_at,
2913
+ evaluatedAt: raw.evaluated_at,
2914
+ settledAt: raw.settled_at,
2915
+ slaMinutes: raw.sla_minutes,
2916
+ blockNumber: raw.block_number,
2917
+ txHash: raw.tx_hash,
2918
+ warrenLinks: raw.warrenLinks ? toIndexerWarrenLinks(raw.warrenLinks) : void 0
2919
+ };
2920
+ }
2921
+ var IndexerClient = class {
2922
+ baseUrl;
2923
+ timeoutMs;
2924
+ fetchFn;
2925
+ constructor(options) {
2926
+ this.baseUrl = options.baseUrl.replace(/\/$/, "");
2927
+ this.timeoutMs = options.timeoutMs ?? 1e4;
2928
+ this.fetchFn = options.fetchFn ?? fetch;
2929
+ }
2930
+ async getOfferings(filter) {
2931
+ const params = new URLSearchParams();
2932
+ if (filter?.serviceType !== void 0) {
2933
+ params.set("service_type", String(filter.serviceType));
2934
+ }
2935
+ if (filter?.active !== void 0) {
2936
+ params.set("active", String(filter.active));
2937
+ }
2938
+ if (filter?.agentId !== void 0) {
2939
+ params.set("agent_id", String(filter.agentId));
2940
+ }
2941
+ const query = params.toString();
2942
+ const path = query.length > 0 ? `/offerings?${query}` : "/offerings";
2943
+ const payload = await this.requestJson(path);
2944
+ return payload.data.map((offering) => toIndexerOffering(offering));
2945
+ }
2946
+ async getJobs(filter) {
2947
+ const params = new URLSearchParams();
2948
+ if (filter?.status !== void 0) {
2949
+ params.set("status", String(filter.status));
2950
+ }
2951
+ if (filter?.agentId !== void 0) {
2952
+ params.set("agent_id", String(filter.agentId));
2953
+ }
2954
+ const query = params.toString();
2955
+ const path = query.length > 0 ? `/jobs?${query}` : "/jobs";
2956
+ const payload = await this.requestJson(path);
2957
+ return payload.data.map((job) => toIndexerJob(job));
2958
+ }
2959
+ async getJob(jobId) {
2960
+ const payload = await this.requestJson(`/jobs/${jobId}`, void 0, `Job ${jobId} not found`);
2961
+ return toIndexerJob(payload.data);
2962
+ }
2963
+ async getAgent(agentId) {
2964
+ const payload = await this.requestJson(
2965
+ `/agents/${agentId}`,
2966
+ void 0,
2967
+ `Agent ${agentId} not found`
2968
+ );
2969
+ return toIndexerAgent(payload.data);
2970
+ }
2971
+ async registerWarrenLink(jobId, linkType, masterAddress, contentHash) {
2972
+ await this.requestJson("/warren-links", {
2973
+ method: "POST",
2974
+ headers: { "Content-Type": "application/json" },
2975
+ body: JSON.stringify({ jobId, linkType, masterAddress, contentHash })
2976
+ });
2977
+ }
2978
+ async getWarrenLinks(jobId) {
2979
+ const response = await this.request(`/warren-links/${jobId}`);
2980
+ if (response.status === 404) {
2981
+ return {};
2982
+ }
2983
+ const payload = await this.parseResponse(
2984
+ response,
2985
+ `/warren-links/${jobId}`
2986
+ );
2987
+ return toIndexerWarrenLinks(payload.data);
2988
+ }
2989
+ async request(path, init) {
2990
+ const url = `${this.baseUrl}${path}`;
2991
+ const controller = new AbortController();
2992
+ const timeout = setTimeout(() => controller.abort(), this.timeoutMs);
2993
+ try {
2994
+ return await this.fetchFn(url, { ...init, signal: controller.signal });
2995
+ } catch (error) {
2996
+ if (error instanceof Error && error.name === "AbortError") {
2997
+ throw new IndexerClientError(
2998
+ `Indexer request timed out after ${this.timeoutMs}ms`,
2999
+ { url, cause: error }
3000
+ );
3001
+ }
3002
+ throw new IndexerClientError("Indexer request failed", { url, cause: error });
3003
+ } finally {
3004
+ clearTimeout(timeout);
3005
+ }
3006
+ }
3007
+ async requestJson(path, init, notFoundMessage) {
3008
+ const response = await this.request(path, init);
3009
+ return this.parseResponse(response, path, notFoundMessage);
3010
+ }
3011
+ async parseResponse(response, path, notFoundMessage) {
3012
+ const url = `${this.baseUrl}${path}`;
3013
+ let payload;
3014
+ try {
3015
+ payload = await response.json();
3016
+ } catch (error) {
3017
+ throw new IndexerClientError("Indexer returned an invalid JSON payload", {
3018
+ url,
3019
+ status: response.status,
3020
+ cause: error
3021
+ });
3022
+ }
3023
+ if (!response.ok) {
3024
+ const apiError = isRecord(payload) ? payload : void 0;
3025
+ const message = response.status === 404 && notFoundMessage ? notFoundMessage : apiError?.error ?? apiError?.message ?? `Indexer request failed (${response.status})`;
3026
+ throw new IndexerClientError(message, {
3027
+ url,
3028
+ status: response.status,
3029
+ body: payload
3030
+ });
3031
+ }
3032
+ return payload;
3033
+ }
3034
+ };
3035
+
3036
+ // src/runtime/provider.ts
3037
+ var ProviderRuntime = class {
3038
+ client;
3039
+ agentId;
3040
+ callbacks;
3041
+ indexer;
3042
+ pollInterval;
3043
+ running = false;
3044
+ processedJobs = /* @__PURE__ */ new Set();
3045
+ constructor(client, agentId, callbacks, options) {
3046
+ this.client = client;
3047
+ this.agentId = agentId;
3048
+ this.callbacks = callbacks;
3049
+ this.indexer = new IndexerClient({ baseUrl: options.indexerUrl });
3050
+ this.pollInterval = options.pollInterval ?? 5e3;
3051
+ }
3052
+ start() {
3053
+ this.running = true;
3054
+ this.poll();
3055
+ }
3056
+ stop() {
3057
+ this.running = false;
3058
+ }
3059
+ async poll() {
3060
+ while (this.running) {
3061
+ try {
3062
+ await this.checkNewJobs();
3063
+ await this.checkInProgressJobs();
3064
+ await this.checkCompletedJobs();
3065
+ } catch (e) {
3066
+ this.callbacks.onError?.(e instanceof Error ? e : new Error(String(e)));
3067
+ }
3068
+ await new Promise((r) => setTimeout(r, this.pollInterval));
3069
+ }
3070
+ }
3071
+ async checkNewJobs() {
3072
+ const offerings = await this.indexer.getOfferings({
3073
+ agentId: Number(this.agentId),
3074
+ active: true
3075
+ });
3076
+ const jobs = await this.indexer.getJobs({ status: 0 });
3077
+ for (const job of jobs) {
3078
+ if (this.processedJobs.has(job.jobId)) continue;
3079
+ const matchesOffering = offerings.some((o) => o.offeringId === job.offeringId);
3080
+ if (!matchesOffering) continue;
3081
+ this.processedJobs.add(job.jobId);
3082
+ if (this.callbacks.onJobReceived) {
3083
+ try {
3084
+ const accept = await this.callbacks.onJobReceived(job);
3085
+ if (accept) {
3086
+ await acceptJob(
3087
+ this.client,
3088
+ BigInt(job.jobId),
3089
+ job.warrenTermsHash
3090
+ );
3091
+ }
3092
+ } catch (e) {
3093
+ this.callbacks.onError?.(
3094
+ e instanceof Error ? e : new Error(String(e))
3095
+ );
3096
+ }
3097
+ }
3098
+ }
3099
+ }
3100
+ async checkInProgressJobs() {
3101
+ const inProgressJobs = await this.indexer.getJobs({
3102
+ status: 2,
3103
+ agentId: Number(this.agentId)
3104
+ });
3105
+ for (const job of inProgressJobs) {
3106
+ const deliverKey = job.jobId * 1e3;
3107
+ if (this.processedJobs.has(deliverKey)) continue;
3108
+ if (this.callbacks.onDeliverableRequested) {
3109
+ try {
3110
+ const params = await this.callbacks.onDeliverableRequested(job);
3111
+ this.processedJobs.add(deliverKey);
3112
+ await deployDeliverable(
3113
+ this.client,
3114
+ this.agentId,
3115
+ BigInt(job.jobId),
3116
+ { ...params, jobId: BigInt(job.jobId) },
3117
+ this.indexer["baseUrl"]
3118
+ );
3119
+ } catch (e) {
3120
+ this.callbacks.onError?.(
3121
+ e instanceof Error ? e : new Error(String(e))
3122
+ );
3123
+ }
3124
+ }
3125
+ }
3126
+ }
3127
+ async checkCompletedJobs() {
3128
+ const completedJobs = await this.indexer.getJobs({
3129
+ status: 5,
3130
+ agentId: Number(this.agentId)
3131
+ });
3132
+ for (const job of completedJobs) {
3133
+ const completeKey = job.jobId * 1e4;
3134
+ if (this.processedJobs.has(completeKey)) continue;
3135
+ this.processedJobs.add(completeKey);
3136
+ this.callbacks.onJobCompleted?.(job);
3137
+ }
3138
+ }
3139
+ };
3140
+
3141
+ // src/runtime/buyer.ts
3142
+ var BuyerRuntime = class {
3143
+ client;
3144
+ agentId;
3145
+ callbacks;
3146
+ indexer;
3147
+ pollInterval;
3148
+ searchFilter;
3149
+ running = false;
3150
+ processedOfferings = /* @__PURE__ */ new Set();
3151
+ processedJobs = /* @__PURE__ */ new Set();
3152
+ constructor(client, agentId, callbacks, options) {
3153
+ this.client = client;
3154
+ this.agentId = agentId;
3155
+ this.callbacks = callbacks;
3156
+ this.indexer = new IndexerClient({ baseUrl: options.indexerUrl });
3157
+ this.pollInterval = options.pollInterval ?? 5e3;
3158
+ this.searchFilter = options.searchFilter;
3159
+ }
3160
+ start() {
3161
+ this.running = true;
3162
+ this.poll();
3163
+ }
3164
+ stop() {
3165
+ this.running = false;
3166
+ }
3167
+ async poll() {
3168
+ while (this.running) {
3169
+ try {
3170
+ await this.checkOfferings();
3171
+ await this.checkDeliveredJobs();
3172
+ await this.checkCompletedJobs();
3173
+ } catch (e) {
3174
+ this.callbacks.onError?.(e instanceof Error ? e : new Error(String(e)));
3175
+ }
3176
+ await new Promise((r) => setTimeout(r, this.pollInterval));
3177
+ }
3178
+ }
3179
+ async checkOfferings() {
3180
+ if (!this.callbacks.onOfferingFound) return;
3181
+ const offerings = await this.indexer.getOfferings({
3182
+ active: true,
3183
+ serviceType: this.searchFilter?.serviceType
3184
+ });
3185
+ for (const offering of offerings) {
3186
+ if (this.processedOfferings.has(offering.offeringId)) continue;
3187
+ if (this.searchFilter?.maxPrice && BigInt(offering.priceUsdm) > BigInt(this.searchFilter.maxPrice)) {
3188
+ continue;
3189
+ }
3190
+ try {
3191
+ const create = await this.callbacks.onOfferingFound(offering);
3192
+ if (create) {
3193
+ const buyerAddress = requireWallet(this.client).account.address;
3194
+ const providerAgent = await this.indexer.getAgent(offering.agentId);
3195
+ const offeringId = BigInt(offering.offeringId);
3196
+ const agreedPrice = BigInt(offering.priceUsdm);
3197
+ const slaMinutes = offering.slaMinutes ?? 60;
3198
+ const { hash } = await deployJobTerms(this.client, this.agentId, {
3199
+ jobId: 0n,
3200
+ offeringId,
3201
+ agreedPrice,
3202
+ slaMinutes,
3203
+ qualityCriteria: "Standard quality",
3204
+ buyerAgent: buyerAddress,
3205
+ providerAgent: providerAgent.owner
3206
+ });
3207
+ const { jobId } = await createJob(this.client, {
3208
+ offeringId,
3209
+ buyerAgentId: this.agentId,
3210
+ warrenTermsHash: hash
3211
+ });
3212
+ this.processedOfferings.add(offering.offeringId);
3213
+ if (this.callbacks.onBuildRequirements) {
3214
+ const reqs = await this.callbacks.onBuildRequirements(offering);
3215
+ if (reqs) {
3216
+ await deployRequirements(
3217
+ this.client,
3218
+ this.agentId,
3219
+ jobId,
3220
+ {
3221
+ jobId,
3222
+ offeringId,
3223
+ requirements: reqs
3224
+ },
3225
+ this.indexer["baseUrl"]
3226
+ );
3227
+ }
3228
+ }
3229
+ }
3230
+ } catch (e) {
3231
+ this.callbacks.onError?.(
3232
+ e instanceof Error ? e : new Error(String(e))
3233
+ );
3234
+ }
3235
+ }
3236
+ }
3237
+ async checkDeliveredJobs() {
3238
+ if (!this.callbacks.onJobDelivered) return;
3239
+ const deliveredJobs = await this.indexer.getJobs({
3240
+ status: 3,
3241
+ agentId: Number(this.agentId)
3242
+ });
3243
+ for (const job of deliveredJobs) {
3244
+ if (this.processedJobs.has(job.jobId)) continue;
3245
+ this.processedJobs.add(job.jobId);
3246
+ try {
3247
+ const deliverable = await readDeliverable(
3248
+ this.client,
3249
+ BigInt(job.jobId),
3250
+ this.indexer["baseUrl"]
3251
+ );
3252
+ const approve = await this.callbacks.onJobDelivered(job, deliverable);
3253
+ if (approve) {
3254
+ await evaluate(this.client, BigInt(job.jobId), true, "Auto-approved");
3255
+ await settle(this.client, BigInt(job.jobId));
3256
+ }
3257
+ } catch (e) {
3258
+ this.callbacks.onError?.(
3259
+ e instanceof Error ? e : new Error(String(e))
3260
+ );
3261
+ }
3262
+ }
3263
+ }
3264
+ async checkCompletedJobs() {
3265
+ const completedJobs = await this.indexer.getJobs({
3266
+ status: 5,
3267
+ agentId: Number(this.agentId)
3268
+ });
3269
+ for (const job of completedJobs) {
3270
+ const completeKey = job.jobId * 1e3;
3271
+ if (this.processedJobs.has(completeKey)) continue;
3272
+ this.processedJobs.add(completeKey);
3273
+ this.callbacks.onJobCompleted?.(job);
3274
+ }
3275
+ }
3276
+ };
3277
+
3278
+ // src/runtime/handler-provider.ts
3279
+ var HandlerProviderRuntime = class {
3280
+ client;
3281
+ agentId;
3282
+ handlers = /* @__PURE__ */ new Map();
3283
+ indexer;
3284
+ indexerUrl;
3285
+ pollInterval;
3286
+ running = false;
3287
+ processedJobs = /* @__PURE__ */ new Set();
3288
+ onError;
3289
+ constructor(client, agentId, options) {
3290
+ this.client = client;
3291
+ this.agentId = agentId;
3292
+ this.indexer = new IndexerClient({ baseUrl: options.indexerUrl });
3293
+ this.indexerUrl = options.indexerUrl.replace(/\/$/, "");
3294
+ this.pollInterval = options.pollInterval ?? 5e3;
3295
+ }
3296
+ registerHandler(handler) {
3297
+ this.handlers.set(handler.offeringId, handler);
3298
+ }
3299
+ setErrorHandler(fn) {
3300
+ this.onError = fn;
3301
+ }
3302
+ start() {
3303
+ this.running = true;
3304
+ this.poll();
3305
+ }
3306
+ stop() {
3307
+ this.running = false;
3308
+ }
3309
+ async poll() {
3310
+ while (this.running) {
3311
+ try {
3312
+ await this.checkNewJobs();
3313
+ await this.checkInProgressJobs();
3314
+ } catch (e) {
3315
+ this.onError?.(e instanceof Error ? e : new Error(String(e)));
3316
+ }
3317
+ await new Promise((r) => setTimeout(r, this.pollInterval));
3318
+ }
3319
+ }
3320
+ async checkNewJobs() {
3321
+ const offerings = await this.indexer.getOfferings({
3322
+ agentId: Number(this.agentId),
3323
+ active: true
3324
+ });
3325
+ const jobs = await this.indexer.getJobs({ status: 0 });
3326
+ for (const job of jobs) {
3327
+ if (this.processedJobs.has(job.jobId)) continue;
3328
+ const matchesOffering = offerings.some((o) => o.offeringId === job.offeringId);
3329
+ if (!matchesOffering) continue;
3330
+ const handler = this.handlers.get(job.offeringId);
3331
+ if (!handler) continue;
3332
+ this.processedJobs.add(job.jobId);
3333
+ try {
3334
+ if (handler.autoAccept !== false) {
3335
+ await acceptJob(
3336
+ this.client,
3337
+ BigInt(job.jobId),
3338
+ job.warrenTermsHash
3339
+ );
3340
+ }
3341
+ } catch (e) {
3342
+ this.onError?.(e instanceof Error ? e : new Error(String(e)));
3343
+ }
3344
+ }
3345
+ }
3346
+ async checkInProgressJobs() {
3347
+ const inProgressJobs = await this.indexer.getJobs({
3348
+ status: 2,
3349
+ agentId: Number(this.agentId)
3350
+ });
3351
+ for (const job of inProgressJobs) {
3352
+ const deliverKey = job.jobId * 1e3;
3353
+ if (this.processedJobs.has(deliverKey)) continue;
3354
+ const handler = this.handlers.get(job.offeringId);
3355
+ if (!handler) continue;
3356
+ this.processedJobs.add(deliverKey);
3357
+ try {
3358
+ if (job.slaMinutes === null) {
3359
+ this.onError?.(new Error(`Job ${job.jobId} is missing slaMinutes`));
3360
+ continue;
3361
+ }
3362
+ const context = {
3363
+ jobId: BigInt(job.jobId),
3364
+ offeringId: BigInt(job.offeringId),
3365
+ buyerAgentId: BigInt(job.buyerAgentId),
3366
+ providerAgentId: BigInt(job.providerAgentId),
3367
+ priceUsdm: job.priceUsdm,
3368
+ slaMinutes: job.slaMinutes
3369
+ };
3370
+ const reqData = await readRequirements(
3371
+ this.client,
3372
+ BigInt(job.jobId),
3373
+ this.indexerUrl
3374
+ );
3375
+ if (reqData) {
3376
+ context.requirements = reqData.requirements;
3377
+ }
3378
+ if (handler.validateRequirements) {
3379
+ const validation = await handler.validateRequirements(context);
3380
+ if (!validation.valid) {
3381
+ this.onError?.(
3382
+ new Error(`Validation failed for job ${job.jobId}: ${validation.reason}`)
3383
+ );
3384
+ continue;
3385
+ }
3386
+ }
3387
+ const result = await handler.executeJob(context);
3388
+ const deliverableParams = {
3389
+ type: result.type,
3390
+ content: result.content,
3391
+ url: result.url,
3392
+ mimeType: result.mimeType,
3393
+ jobId: BigInt(job.jobId)
3394
+ };
3395
+ await deployDeliverable(
3396
+ this.client,
3397
+ this.agentId,
3398
+ BigInt(job.jobId),
3399
+ deliverableParams,
3400
+ this.indexerUrl
3401
+ );
3402
+ } catch (e) {
3403
+ this.onError?.(e instanceof Error ? e : new Error(String(e)));
3404
+ }
3405
+ }
3406
+ }
3407
+ };
3408
+
3409
+ // src/abis/FeeDistributor.ts
3410
+ var feeDistributorAbi = [
3411
+ {
3412
+ "type": "constructor",
3413
+ "inputs": [],
3414
+ "stateMutability": "nonpayable"
3415
+ },
3416
+ {
3417
+ "type": "function",
3418
+ "name": "RISK_POOL_BPS",
3419
+ "inputs": [],
3420
+ "outputs": [
3421
+ {
3422
+ "name": "",
3423
+ "type": "uint256",
3424
+ "internalType": "uint256"
3425
+ }
3426
+ ],
3427
+ "stateMutability": "view"
3428
+ },
3429
+ {
3430
+ "type": "function",
3431
+ "name": "TREASURY_BPS",
3432
+ "inputs": [],
3433
+ "outputs": [
3434
+ {
3435
+ "name": "",
3436
+ "type": "uint256",
3437
+ "internalType": "uint256"
3438
+ }
3439
+ ],
3440
+ "stateMutability": "view"
3441
+ },
3442
+ {
3443
+ "type": "function",
3444
+ "name": "UPGRADE_INTERFACE_VERSION",
3445
+ "inputs": [],
3446
+ "outputs": [
3447
+ {
3448
+ "name": "",
3449
+ "type": "string",
3450
+ "internalType": "string"
3451
+ }
3452
+ ],
3453
+ "stateMutability": "view"
3454
+ },
3455
+ {
3456
+ "type": "function",
3457
+ "name": "distribute",
3458
+ "inputs": [
3459
+ {
3460
+ "name": "token",
3461
+ "type": "address",
3462
+ "internalType": "address"
3463
+ },
3464
+ {
3465
+ "name": "amount",
3466
+ "type": "uint256",
3467
+ "internalType": "uint256"
3468
+ }
3469
+ ],
3470
+ "outputs": [],
3471
+ "stateMutability": "nonpayable"
3472
+ },
3473
+ {
3474
+ "type": "function",
3475
+ "name": "initialize",
3476
+ "inputs": [
3477
+ {
3478
+ "name": "owner_",
3479
+ "type": "address",
3480
+ "internalType": "address"
3481
+ },
3482
+ {
3483
+ "name": "treasury_",
3484
+ "type": "address",
3485
+ "internalType": "address"
3486
+ },
3487
+ {
3488
+ "name": "riskPool_",
3489
+ "type": "address",
3490
+ "internalType": "address"
3491
+ }
3492
+ ],
3493
+ "outputs": [],
3494
+ "stateMutability": "nonpayable"
3495
+ },
3496
+ {
3497
+ "type": "function",
3498
+ "name": "owner",
3499
+ "inputs": [],
3500
+ "outputs": [
3501
+ {
3502
+ "name": "",
3503
+ "type": "address",
3504
+ "internalType": "address"
3505
+ }
3506
+ ],
3507
+ "stateMutability": "view"
3508
+ },
3509
+ {
3510
+ "type": "function",
3511
+ "name": "proxiableUUID",
3512
+ "inputs": [],
3513
+ "outputs": [
3514
+ {
3515
+ "name": "",
3516
+ "type": "bytes32",
3517
+ "internalType": "bytes32"
3518
+ }
3519
+ ],
3520
+ "stateMutability": "view"
3521
+ },
3522
+ {
3523
+ "type": "function",
3524
+ "name": "renounceOwnership",
3525
+ "inputs": [],
3526
+ "outputs": [],
3527
+ "stateMutability": "nonpayable"
3528
+ },
3529
+ {
3530
+ "type": "function",
3531
+ "name": "riskPool",
3532
+ "inputs": [],
3533
+ "outputs": [
3534
+ {
3535
+ "name": "",
3536
+ "type": "address",
3537
+ "internalType": "address"
3538
+ }
3539
+ ],
3540
+ "stateMutability": "view"
3541
+ },
3542
+ {
3543
+ "type": "function",
3544
+ "name": "setRiskPool",
3545
+ "inputs": [
3546
+ {
3547
+ "name": "newRiskPool",
3548
+ "type": "address",
3549
+ "internalType": "address"
3550
+ }
3551
+ ],
3552
+ "outputs": [],
3553
+ "stateMutability": "nonpayable"
3554
+ },
3555
+ {
3556
+ "type": "function",
3557
+ "name": "setTreasury",
3558
+ "inputs": [
3559
+ {
3560
+ "name": "newTreasury",
3561
+ "type": "address",
3562
+ "internalType": "address"
3563
+ }
3564
+ ],
3565
+ "outputs": [],
3566
+ "stateMutability": "nonpayable"
3567
+ },
3568
+ {
3569
+ "type": "function",
3570
+ "name": "transferOwnership",
3571
+ "inputs": [
3572
+ {
3573
+ "name": "newOwner",
3574
+ "type": "address",
3575
+ "internalType": "address"
3576
+ }
3577
+ ],
3578
+ "outputs": [],
3579
+ "stateMutability": "nonpayable"
3580
+ },
3581
+ {
3582
+ "type": "function",
3583
+ "name": "treasury",
3584
+ "inputs": [],
3585
+ "outputs": [
3586
+ {
3587
+ "name": "",
3588
+ "type": "address",
3589
+ "internalType": "address"
3590
+ }
3591
+ ],
3592
+ "stateMutability": "view"
3593
+ },
3594
+ {
3595
+ "type": "function",
3596
+ "name": "upgradeToAndCall",
3597
+ "inputs": [
3598
+ {
3599
+ "name": "newImplementation",
3600
+ "type": "address",
3601
+ "internalType": "address"
3602
+ },
3603
+ {
3604
+ "name": "data",
3605
+ "type": "bytes",
3606
+ "internalType": "bytes"
3607
+ }
3608
+ ],
3609
+ "outputs": [],
3610
+ "stateMutability": "payable"
3611
+ },
3612
+ {
3613
+ "type": "event",
3614
+ "name": "FeeDistributed",
3615
+ "inputs": [
3616
+ {
3617
+ "name": "token",
3618
+ "type": "address",
3619
+ "indexed": true,
3620
+ "internalType": "address"
3621
+ },
3622
+ {
3623
+ "name": "treasuryAmount",
3624
+ "type": "uint256",
3625
+ "indexed": false,
3626
+ "internalType": "uint256"
3627
+ },
3628
+ {
3629
+ "name": "riskPoolAmount",
3630
+ "type": "uint256",
3631
+ "indexed": false,
3632
+ "internalType": "uint256"
3633
+ }
3634
+ ],
3635
+ "anonymous": false
3636
+ },
3637
+ {
3638
+ "type": "event",
3639
+ "name": "Initialized",
3640
+ "inputs": [
3641
+ {
3642
+ "name": "version",
3643
+ "type": "uint64",
3644
+ "indexed": false,
3645
+ "internalType": "uint64"
3646
+ }
3647
+ ],
3648
+ "anonymous": false
3649
+ },
3650
+ {
3651
+ "type": "event",
3652
+ "name": "OwnershipTransferred",
3653
+ "inputs": [
3654
+ {
3655
+ "name": "previousOwner",
3656
+ "type": "address",
3657
+ "indexed": true,
3658
+ "internalType": "address"
3659
+ },
3660
+ {
3661
+ "name": "newOwner",
3662
+ "type": "address",
3663
+ "indexed": true,
3664
+ "internalType": "address"
3665
+ }
3666
+ ],
3667
+ "anonymous": false
3668
+ },
3669
+ {
3670
+ "type": "event",
3671
+ "name": "RiskPoolUpdated",
3672
+ "inputs": [
3673
+ {
3674
+ "name": "newRiskPool",
3675
+ "type": "address",
3676
+ "indexed": true,
3677
+ "internalType": "address"
3678
+ }
3679
+ ],
3680
+ "anonymous": false
3681
+ },
3682
+ {
3683
+ "type": "event",
3684
+ "name": "TreasuryUpdated",
3685
+ "inputs": [
3686
+ {
3687
+ "name": "newTreasury",
3688
+ "type": "address",
3689
+ "indexed": true,
3690
+ "internalType": "address"
3691
+ }
3692
+ ],
3693
+ "anonymous": false
3694
+ },
3695
+ {
3696
+ "type": "event",
3697
+ "name": "Upgraded",
3698
+ "inputs": [
3699
+ {
3700
+ "name": "implementation",
3701
+ "type": "address",
3702
+ "indexed": true,
3703
+ "internalType": "address"
3704
+ }
3705
+ ],
3706
+ "anonymous": false
3707
+ },
3708
+ {
3709
+ "type": "error",
3710
+ "name": "AddressEmptyCode",
3711
+ "inputs": [
3712
+ {
3713
+ "name": "target",
3714
+ "type": "address",
3715
+ "internalType": "address"
3716
+ }
3717
+ ]
3718
+ },
3719
+ {
3720
+ "type": "error",
3721
+ "name": "ERC1967InvalidImplementation",
3722
+ "inputs": [
3723
+ {
3724
+ "name": "implementation",
3725
+ "type": "address",
3726
+ "internalType": "address"
3727
+ }
3728
+ ]
3729
+ },
3730
+ {
3731
+ "type": "error",
3732
+ "name": "ERC1967NonPayable",
3733
+ "inputs": []
3734
+ },
3735
+ {
3736
+ "type": "error",
3737
+ "name": "FailedCall",
3738
+ "inputs": []
3739
+ },
3740
+ {
3741
+ "type": "error",
3742
+ "name": "InvalidInitialization",
3743
+ "inputs": []
3744
+ },
3745
+ {
3746
+ "type": "error",
3747
+ "name": "NotInitializing",
3748
+ "inputs": []
3749
+ },
3750
+ {
3751
+ "type": "error",
3752
+ "name": "OwnableInvalidOwner",
3753
+ "inputs": [
3754
+ {
3755
+ "name": "owner",
3756
+ "type": "address",
3757
+ "internalType": "address"
3758
+ }
3759
+ ]
3760
+ },
3761
+ {
3762
+ "type": "error",
3763
+ "name": "OwnableUnauthorizedAccount",
3764
+ "inputs": [
3765
+ {
3766
+ "name": "account",
3767
+ "type": "address",
3768
+ "internalType": "address"
3769
+ }
3770
+ ]
3771
+ },
3772
+ {
3773
+ "type": "error",
3774
+ "name": "UUPSUnauthorizedCallContext",
3775
+ "inputs": []
3776
+ },
3777
+ {
3778
+ "type": "error",
3779
+ "name": "UUPSUnsupportedProxiableUUID",
3780
+ "inputs": [
3781
+ {
3782
+ "name": "slot",
3783
+ "type": "bytes32",
3784
+ "internalType": "bytes32"
3785
+ }
3786
+ ]
3787
+ },
3788
+ {
3789
+ "type": "error",
3790
+ "name": "ZeroAddress",
3791
+ "inputs": []
3792
+ }
3793
+ ];
3794
+
3795
+ // src/abis/Erc8004Reputation.ts
3796
+ var erc8004ReputationAbi = [
3797
+ {
3798
+ "type": "function",
3799
+ "name": "appendResponse",
3800
+ "inputs": [
3801
+ {
3802
+ "name": "agentId",
3803
+ "type": "uint256",
3804
+ "internalType": "uint256"
3805
+ },
3806
+ {
3807
+ "name": "clientAddress",
3808
+ "type": "address",
3809
+ "internalType": "address"
3810
+ },
3811
+ {
3812
+ "name": "feedbackIndex",
3813
+ "type": "uint64",
3814
+ "internalType": "uint64"
3815
+ },
3816
+ {
3817
+ "name": "responseURI",
3818
+ "type": "string",
3819
+ "internalType": "string"
3820
+ },
3821
+ {
3822
+ "name": "responseHash",
3823
+ "type": "bytes32",
3824
+ "internalType": "bytes32"
3825
+ }
3826
+ ],
3827
+ "outputs": [],
3828
+ "stateMutability": "nonpayable"
3829
+ },
3830
+ {
3831
+ "type": "function",
3832
+ "name": "getClients",
3833
+ "inputs": [
3834
+ {
3835
+ "name": "agentId",
3836
+ "type": "uint256",
3837
+ "internalType": "uint256"
3838
+ }
3839
+ ],
3840
+ "outputs": [
3841
+ {
3842
+ "name": "clients",
3843
+ "type": "address[]",
3844
+ "internalType": "address[]"
3845
+ }
3846
+ ],
3847
+ "stateMutability": "view"
3848
+ },
3849
+ {
3850
+ "type": "function",
3851
+ "name": "getIdentityRegistry",
3852
+ "inputs": [],
3853
+ "outputs": [
3854
+ {
3855
+ "name": "identityRegistry",
3856
+ "type": "address",
3857
+ "internalType": "address"
3858
+ }
3859
+ ],
3860
+ "stateMutability": "view"
3861
+ },
3862
+ {
3863
+ "type": "function",
3864
+ "name": "getLastIndex",
3865
+ "inputs": [
3866
+ {
3867
+ "name": "agentId",
3868
+ "type": "uint256",
3869
+ "internalType": "uint256"
3870
+ },
3871
+ {
3872
+ "name": "clientAddress",
3873
+ "type": "address",
3874
+ "internalType": "address"
3875
+ }
3876
+ ],
3877
+ "outputs": [
3878
+ {
3879
+ "name": "lastIndex",
3880
+ "type": "uint64",
3881
+ "internalType": "uint64"
3882
+ }
3883
+ ],
3884
+ "stateMutability": "view"
3885
+ },
3886
+ {
3887
+ "type": "function",
3888
+ "name": "getSummary",
3889
+ "inputs": [
3890
+ {
3891
+ "name": "agentId",
3892
+ "type": "uint256",
3893
+ "internalType": "uint256"
3894
+ },
3895
+ {
3896
+ "name": "clientAddresses",
3897
+ "type": "address[]",
3898
+ "internalType": "address[]"
3899
+ },
3900
+ {
3901
+ "name": "tag1",
3902
+ "type": "string",
3903
+ "internalType": "string"
3904
+ },
3905
+ {
3906
+ "name": "tag2",
3907
+ "type": "string",
3908
+ "internalType": "string"
3909
+ }
3910
+ ],
3911
+ "outputs": [
3912
+ {
3913
+ "name": "count",
3914
+ "type": "uint64",
3915
+ "internalType": "uint64"
3916
+ },
3917
+ {
3918
+ "name": "summaryValue",
3919
+ "type": "int128",
3920
+ "internalType": "int128"
3921
+ },
3922
+ {
3923
+ "name": "summaryValueDecimals",
3924
+ "type": "uint8",
3925
+ "internalType": "uint8"
3926
+ }
3927
+ ],
3928
+ "stateMutability": "view"
3929
+ },
3930
+ {
3931
+ "type": "function",
3932
+ "name": "giveFeedback",
3933
+ "inputs": [
3934
+ {
3935
+ "name": "agentId",
3936
+ "type": "uint256",
3937
+ "internalType": "uint256"
3938
+ },
3939
+ {
3940
+ "name": "value",
3941
+ "type": "int128",
3942
+ "internalType": "int128"
3943
+ },
3944
+ {
3945
+ "name": "valueDecimals",
3946
+ "type": "uint8",
3947
+ "internalType": "uint8"
3948
+ },
3949
+ {
3950
+ "name": "tag1",
3951
+ "type": "string",
3952
+ "internalType": "string"
3953
+ },
3954
+ {
3955
+ "name": "tag2",
3956
+ "type": "string",
3957
+ "internalType": "string"
3958
+ },
3959
+ {
3960
+ "name": "endpoint",
3961
+ "type": "string",
3962
+ "internalType": "string"
3963
+ },
3964
+ {
3965
+ "name": "feedbackURI",
3966
+ "type": "string",
3967
+ "internalType": "string"
3968
+ },
3969
+ {
3970
+ "name": "feedbackHash",
3971
+ "type": "bytes32",
3972
+ "internalType": "bytes32"
3973
+ }
3974
+ ],
3975
+ "outputs": [],
3976
+ "stateMutability": "nonpayable"
3977
+ },
3978
+ {
3979
+ "type": "function",
3980
+ "name": "readAllFeedback",
3981
+ "inputs": [
3982
+ {
3983
+ "name": "agentId",
3984
+ "type": "uint256",
3985
+ "internalType": "uint256"
3986
+ },
3987
+ {
3988
+ "name": "clientAddresses",
3989
+ "type": "address[]",
3990
+ "internalType": "address[]"
3991
+ },
3992
+ {
3993
+ "name": "tag1",
3994
+ "type": "string",
3995
+ "internalType": "string"
3996
+ },
3997
+ {
3998
+ "name": "tag2",
3999
+ "type": "string",
4000
+ "internalType": "string"
4001
+ },
4002
+ {
4003
+ "name": "includeRevoked",
4004
+ "type": "bool",
4005
+ "internalType": "bool"
4006
+ }
4007
+ ],
4008
+ "outputs": [
4009
+ {
4010
+ "name": "clients",
4011
+ "type": "address[]",
4012
+ "internalType": "address[]"
4013
+ },
4014
+ {
4015
+ "name": "feedbackIndexes",
4016
+ "type": "uint64[]",
4017
+ "internalType": "uint64[]"
4018
+ },
4019
+ {
4020
+ "name": "values",
4021
+ "type": "int128[]",
4022
+ "internalType": "int128[]"
4023
+ },
4024
+ {
4025
+ "name": "valueDecimals",
4026
+ "type": "uint8[]",
4027
+ "internalType": "uint8[]"
4028
+ },
4029
+ {
4030
+ "name": "tag1s",
4031
+ "type": "string[]",
4032
+ "internalType": "string[]"
4033
+ },
4034
+ {
4035
+ "name": "tag2s",
4036
+ "type": "string[]",
4037
+ "internalType": "string[]"
4038
+ },
4039
+ {
4040
+ "name": "revokedStatuses",
4041
+ "type": "bool[]",
4042
+ "internalType": "bool[]"
4043
+ }
4044
+ ],
4045
+ "stateMutability": "view"
4046
+ },
4047
+ {
4048
+ "type": "function",
4049
+ "name": "readFeedback",
4050
+ "inputs": [
4051
+ {
4052
+ "name": "agentId",
4053
+ "type": "uint256",
4054
+ "internalType": "uint256"
4055
+ },
4056
+ {
4057
+ "name": "clientAddress",
4058
+ "type": "address",
4059
+ "internalType": "address"
4060
+ },
4061
+ {
4062
+ "name": "feedbackIndex",
4063
+ "type": "uint64",
4064
+ "internalType": "uint64"
4065
+ }
4066
+ ],
4067
+ "outputs": [
4068
+ {
4069
+ "name": "value",
4070
+ "type": "int128",
4071
+ "internalType": "int128"
4072
+ },
4073
+ {
4074
+ "name": "valueDecimals",
4075
+ "type": "uint8",
4076
+ "internalType": "uint8"
4077
+ },
4078
+ {
4079
+ "name": "tag1",
4080
+ "type": "string",
4081
+ "internalType": "string"
4082
+ },
4083
+ {
4084
+ "name": "tag2",
4085
+ "type": "string",
4086
+ "internalType": "string"
4087
+ },
4088
+ {
4089
+ "name": "isRevoked",
4090
+ "type": "bool",
4091
+ "internalType": "bool"
4092
+ }
4093
+ ],
4094
+ "stateMutability": "view"
4095
+ },
4096
+ {
4097
+ "type": "function",
4098
+ "name": "revokeFeedback",
4099
+ "inputs": [
4100
+ {
4101
+ "name": "agentId",
4102
+ "type": "uint256",
4103
+ "internalType": "uint256"
4104
+ },
4105
+ {
4106
+ "name": "feedbackIndex",
4107
+ "type": "uint64",
4108
+ "internalType": "uint64"
4109
+ }
4110
+ ],
4111
+ "outputs": [],
4112
+ "stateMutability": "nonpayable"
4113
+ },
4114
+ {
4115
+ "type": "event",
4116
+ "name": "FeedbackRevoked",
4117
+ "inputs": [
4118
+ {
4119
+ "name": "agentId",
4120
+ "type": "uint256",
4121
+ "indexed": true,
4122
+ "internalType": "uint256"
4123
+ },
4124
+ {
4125
+ "name": "clientAddress",
4126
+ "type": "address",
4127
+ "indexed": true,
4128
+ "internalType": "address"
4129
+ },
4130
+ {
4131
+ "name": "feedbackIndex",
4132
+ "type": "uint64",
4133
+ "indexed": true,
4134
+ "internalType": "uint64"
4135
+ }
4136
+ ],
4137
+ "anonymous": false
4138
+ },
4139
+ {
4140
+ "type": "event",
4141
+ "name": "NewFeedback",
4142
+ "inputs": [
4143
+ {
4144
+ "name": "agentId",
4145
+ "type": "uint256",
4146
+ "indexed": true,
4147
+ "internalType": "uint256"
4148
+ },
4149
+ {
4150
+ "name": "clientAddress",
4151
+ "type": "address",
4152
+ "indexed": true,
4153
+ "internalType": "address"
4154
+ },
4155
+ {
4156
+ "name": "feedbackIndex",
4157
+ "type": "uint64",
4158
+ "indexed": false,
4159
+ "internalType": "uint64"
4160
+ },
4161
+ {
4162
+ "name": "value",
4163
+ "type": "int128",
4164
+ "indexed": false,
4165
+ "internalType": "int128"
4166
+ },
4167
+ {
4168
+ "name": "valueDecimals",
4169
+ "type": "uint8",
4170
+ "indexed": false,
4171
+ "internalType": "uint8"
4172
+ },
4173
+ {
4174
+ "name": "indexedTag1",
4175
+ "type": "string",
4176
+ "indexed": true,
4177
+ "internalType": "string"
4178
+ },
4179
+ {
4180
+ "name": "tag1",
4181
+ "type": "string",
4182
+ "indexed": false,
4183
+ "internalType": "string"
4184
+ },
4185
+ {
4186
+ "name": "tag2",
4187
+ "type": "string",
4188
+ "indexed": false,
4189
+ "internalType": "string"
4190
+ },
4191
+ {
4192
+ "name": "endpoint",
4193
+ "type": "string",
4194
+ "indexed": false,
4195
+ "internalType": "string"
4196
+ },
4197
+ {
4198
+ "name": "feedbackURI",
4199
+ "type": "string",
4200
+ "indexed": false,
4201
+ "internalType": "string"
4202
+ },
4203
+ {
4204
+ "name": "feedbackHash",
4205
+ "type": "bytes32",
4206
+ "indexed": false,
4207
+ "internalType": "bytes32"
4208
+ }
4209
+ ],
4210
+ "anonymous": false
4211
+ },
4212
+ {
4213
+ "type": "event",
4214
+ "name": "ResponseAppended",
4215
+ "inputs": [
4216
+ {
4217
+ "name": "agentId",
4218
+ "type": "uint256",
4219
+ "indexed": true,
4220
+ "internalType": "uint256"
4221
+ },
4222
+ {
4223
+ "name": "clientAddress",
4224
+ "type": "address",
4225
+ "indexed": true,
4226
+ "internalType": "address"
4227
+ },
4228
+ {
4229
+ "name": "feedbackIndex",
4230
+ "type": "uint64",
4231
+ "indexed": false,
4232
+ "internalType": "uint64"
4233
+ },
4234
+ {
4235
+ "name": "responder",
4236
+ "type": "address",
4237
+ "indexed": true,
4238
+ "internalType": "address"
4239
+ },
4240
+ {
4241
+ "name": "responseURI",
4242
+ "type": "string",
4243
+ "indexed": false,
4244
+ "internalType": "string"
4245
+ },
4246
+ {
4247
+ "name": "responseHash",
4248
+ "type": "bytes32",
4249
+ "indexed": false,
4250
+ "internalType": "bytes32"
4251
+ }
4252
+ ],
4253
+ "anonymous": false
4254
+ }
4255
+ ];
4256
+ export {
4257
+ ACCEPT_TIMEOUT,
4258
+ BPS_DENOMINATOR,
4259
+ BuyerRuntime,
4260
+ DEFAULT_INDEXER_URLS,
4261
+ EVALUATION_TIMEOUT,
4262
+ FEE_BPS,
4263
+ HandlerProviderRuntime,
4264
+ IndexerClient,
4265
+ IndexerClientError,
4266
+ JobStatus,
4267
+ MAINNET_ADDRESSES,
4268
+ MEMO_TYPES,
4269
+ PULSE_DOMAIN,
4270
+ ProviderRuntime,
4271
+ RISK_POOL_BPS,
4272
+ ServiceType,
4273
+ TESTNET_ADDRESSES,
4274
+ TREASURY_BPS,
4275
+ USDM_MAINNET,
4276
+ acceptJob,
4277
+ activateOffering,
4278
+ cancelJob,
4279
+ createAgentCard,
4280
+ createDeliverable,
4281
+ createJob,
4282
+ createJobTerms,
4283
+ createMainnetClient,
4284
+ createPulseClient,
4285
+ createRequirements,
4286
+ createTestnetClient,
4287
+ deactivateOffering,
4288
+ deployAgentCard,
4289
+ deployDeliverable,
4290
+ deployJobTerms,
4291
+ deployRequirements,
4292
+ deployWarrenMaster,
4293
+ deployWarrenPage,
4294
+ erc20Abi,
4295
+ erc8004IdentityAbi,
4296
+ erc8004ReputationAbi,
4297
+ evaluate,
4298
+ feeDistributorAbi,
4299
+ formatUsdm,
4300
+ getAgent,
4301
+ getJob,
4302
+ getJobCount,
4303
+ getOffering,
4304
+ getOfferingCount,
4305
+ initAgent,
4306
+ jobEngineAbi,
4307
+ listOffering,
4308
+ mainnetERC8004,
4309
+ masterAbi,
4310
+ megaethMainnet,
4311
+ megaethTestnet,
4312
+ pageAbi,
4313
+ parseUsdm,
4314
+ pulseExtensionAbi,
4315
+ readDeliverable,
4316
+ readRequirements,
4317
+ readWarrenMaster,
4318
+ readWarrenPage,
4319
+ registerAgent,
4320
+ serviceMarketplaceAbi,
4321
+ setOperator,
4322
+ setWarrenContract,
4323
+ settle,
4324
+ signMemo,
4325
+ submitDeliverable,
4326
+ testnetERC8004,
4327
+ updateOffering,
4328
+ verifyContentHash
4329
+ };
4330
+ //# sourceMappingURL=index.js.map