@virtuals-protocol/acp-node 0.1.0-beta.1 → 0.1.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/README.md +47 -5
  2. package/dist/index.d.mts +8480 -0
  3. package/dist/index.d.ts +8480 -0
  4. package/dist/index.js +1576 -0
  5. package/dist/index.mjs +1536 -0
  6. package/package.json +5 -2
  7. package/buyer.ts +0 -47
  8. package/docs/imgs/acp-banner.jpeg +0 -0
  9. package/examples/acp_base/README.md +0 -94
  10. package/examples/acp_base/docs/imgs/agent-wallet-page.png +0 -0
  11. package/examples/acp_base/docs/imgs/session-entity-id-location.png +0 -0
  12. package/examples/acp_base/docs/imgs/whitelist-wallet-info.png +0 -0
  13. package/examples/acp_base/docs/imgs/whitelist-wallet.png +0 -0
  14. package/examples/acp_base/external_evaluation/.env.example +0 -5
  15. package/examples/acp_base/external_evaluation/buyer.ts +0 -52
  16. package/examples/acp_base/external_evaluation/env.ts +0 -22
  17. package/examples/acp_base/external_evaluation/evaluator.ts +0 -29
  18. package/examples/acp_base/external_evaluation/seller.ts +0 -46
  19. package/examples/acp_base/self_evaluation/.env.example +0 -4
  20. package/examples/acp_base/self_evaluation/buyer.ts +0 -54
  21. package/examples/acp_base/self_evaluation/env.ts +0 -21
  22. package/examples/acp_base/self_evaluation/seller.ts +0 -46
  23. package/helpers/.env.example +0 -3
  24. package/helpers/acpHelperFunctions.ts +0 -69
  25. package/interfaces.ts +0 -24
  26. package/seller.ts +0 -46
  27. package/src/acpAbi.ts +0 -680
  28. package/src/acpClient.ts +0 -458
  29. package/src/acpContractClient.ts +0 -269
  30. package/src/acpJob.ts +0 -91
  31. package/src/acpJobOffering.ts +0 -43
  32. package/src/acpMemo.ts +0 -32
  33. package/src/configs.ts +0 -28
  34. package/src/index.ts +0 -18
  35. package/src/interfaces.ts +0 -55
  36. package/test.ts +0 -26
  37. package/tsconfig.json +0 -113
package/dist/index.mjs ADDED
@@ -0,0 +1,1536 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ var __async = (__this, __arguments, generator) => {
18
+ return new Promise((resolve, reject) => {
19
+ var fulfilled = (value) => {
20
+ try {
21
+ step(generator.next(value));
22
+ } catch (e) {
23
+ reject(e);
24
+ }
25
+ };
26
+ var rejected = (value) => {
27
+ try {
28
+ step(generator.throw(value));
29
+ } catch (e) {
30
+ reject(e);
31
+ }
32
+ };
33
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
34
+ step((generator = generator.apply(__this, __arguments)).next());
35
+ });
36
+ };
37
+
38
+ // src/acpAbi.ts
39
+ var ACP_ABI = [
40
+ { inputs: [], stateMutability: "nonpayable", type: "constructor" },
41
+ { inputs: [], name: "AccessControlBadConfirmation", type: "error" },
42
+ {
43
+ inputs: [
44
+ { internalType: "address", name: "account", type: "address" },
45
+ { internalType: "bytes32", name: "neededRole", type: "bytes32" }
46
+ ],
47
+ name: "AccessControlUnauthorizedAccount",
48
+ type: "error"
49
+ },
50
+ {
51
+ inputs: [{ internalType: "address", name: "target", type: "address" }],
52
+ name: "AddressEmptyCode",
53
+ type: "error"
54
+ },
55
+ {
56
+ inputs: [{ internalType: "address", name: "account", type: "address" }],
57
+ name: "AddressInsufficientBalance",
58
+ type: "error"
59
+ },
60
+ { inputs: [], name: "FailedInnerCall", type: "error" },
61
+ { inputs: [], name: "InvalidInitialization", type: "error" },
62
+ { inputs: [], name: "NotInitializing", type: "error" },
63
+ { inputs: [], name: "ReentrancyGuardReentrantCall", type: "error" },
64
+ {
65
+ inputs: [{ internalType: "address", name: "token", type: "address" }],
66
+ name: "SafeERC20FailedOperation",
67
+ type: "error"
68
+ },
69
+ {
70
+ anonymous: false,
71
+ inputs: [
72
+ {
73
+ indexed: true,
74
+ internalType: "uint256",
75
+ name: "jobId",
76
+ type: "uint256"
77
+ },
78
+ {
79
+ indexed: false,
80
+ internalType: "uint256",
81
+ name: "newBudget",
82
+ type: "uint256"
83
+ }
84
+ ],
85
+ name: "BudgetSet",
86
+ type: "event"
87
+ },
88
+ {
89
+ anonymous: false,
90
+ inputs: [
91
+ {
92
+ indexed: false,
93
+ internalType: "uint256",
94
+ name: "jobId",
95
+ type: "uint256"
96
+ },
97
+ {
98
+ indexed: true,
99
+ internalType: "address",
100
+ name: "evaluator",
101
+ type: "address"
102
+ },
103
+ {
104
+ indexed: false,
105
+ internalType: "uint256",
106
+ name: "evaluatorFee",
107
+ type: "uint256"
108
+ }
109
+ ],
110
+ name: "ClaimedEvaluatorFee",
111
+ type: "event"
112
+ },
113
+ {
114
+ anonymous: false,
115
+ inputs: [
116
+ {
117
+ indexed: false,
118
+ internalType: "uint256",
119
+ name: "jobId",
120
+ type: "uint256"
121
+ },
122
+ {
123
+ indexed: true,
124
+ internalType: "address",
125
+ name: "provider",
126
+ type: "address"
127
+ },
128
+ {
129
+ indexed: false,
130
+ internalType: "uint256",
131
+ name: "providerFee",
132
+ type: "uint256"
133
+ }
134
+ ],
135
+ name: "ClaimedProviderFee",
136
+ type: "event"
137
+ },
138
+ {
139
+ anonymous: false,
140
+ inputs: [
141
+ {
142
+ indexed: false,
143
+ internalType: "uint64",
144
+ name: "version",
145
+ type: "uint64"
146
+ }
147
+ ],
148
+ name: "Initialized",
149
+ type: "event"
150
+ },
151
+ {
152
+ anonymous: false,
153
+ inputs: [
154
+ {
155
+ indexed: false,
156
+ internalType: "uint256",
157
+ name: "jobId",
158
+ type: "uint256"
159
+ },
160
+ {
161
+ indexed: true,
162
+ internalType: "address",
163
+ name: "client",
164
+ type: "address"
165
+ },
166
+ {
167
+ indexed: true,
168
+ internalType: "address",
169
+ name: "provider",
170
+ type: "address"
171
+ },
172
+ {
173
+ indexed: true,
174
+ internalType: "address",
175
+ name: "evaluator",
176
+ type: "address"
177
+ }
178
+ ],
179
+ name: "JobCreated",
180
+ type: "event"
181
+ },
182
+ {
183
+ anonymous: false,
184
+ inputs: [
185
+ {
186
+ indexed: true,
187
+ internalType: "uint256",
188
+ name: "jobId",
189
+ type: "uint256"
190
+ },
191
+ {
192
+ indexed: false,
193
+ internalType: "uint8",
194
+ name: "oldPhase",
195
+ type: "uint8"
196
+ },
197
+ { indexed: false, internalType: "uint8", name: "phase", type: "uint8" }
198
+ ],
199
+ name: "JobPhaseUpdated",
200
+ type: "event"
201
+ },
202
+ {
203
+ anonymous: false,
204
+ inputs: [
205
+ {
206
+ indexed: false,
207
+ internalType: "uint256",
208
+ name: "memoId",
209
+ type: "uint256"
210
+ },
211
+ {
212
+ indexed: false,
213
+ internalType: "bool",
214
+ name: "isApproved",
215
+ type: "bool"
216
+ },
217
+ {
218
+ indexed: false,
219
+ internalType: "string",
220
+ name: "reason",
221
+ type: "string"
222
+ }
223
+ ],
224
+ name: "MemoSigned",
225
+ type: "event"
226
+ },
227
+ {
228
+ anonymous: false,
229
+ inputs: [
230
+ {
231
+ indexed: true,
232
+ internalType: "uint256",
233
+ name: "jobId",
234
+ type: "uint256"
235
+ },
236
+ {
237
+ indexed: true,
238
+ internalType: "address",
239
+ name: "sender",
240
+ type: "address"
241
+ },
242
+ {
243
+ indexed: false,
244
+ internalType: "uint256",
245
+ name: "memoId",
246
+ type: "uint256"
247
+ }
248
+ ],
249
+ name: "NewMemo",
250
+ type: "event"
251
+ },
252
+ {
253
+ anonymous: false,
254
+ inputs: [
255
+ {
256
+ indexed: false,
257
+ internalType: "uint256",
258
+ name: "jobId",
259
+ type: "uint256"
260
+ },
261
+ {
262
+ indexed: true,
263
+ internalType: "address",
264
+ name: "client",
265
+ type: "address"
266
+ },
267
+ {
268
+ indexed: false,
269
+ internalType: "uint256",
270
+ name: "amount",
271
+ type: "uint256"
272
+ }
273
+ ],
274
+ name: "RefundedBudget",
275
+ type: "event"
276
+ },
277
+ {
278
+ anonymous: false,
279
+ inputs: [
280
+ { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
281
+ {
282
+ indexed: true,
283
+ internalType: "bytes32",
284
+ name: "previousAdminRole",
285
+ type: "bytes32"
286
+ },
287
+ {
288
+ indexed: true,
289
+ internalType: "bytes32",
290
+ name: "newAdminRole",
291
+ type: "bytes32"
292
+ }
293
+ ],
294
+ name: "RoleAdminChanged",
295
+ type: "event"
296
+ },
297
+ {
298
+ anonymous: false,
299
+ inputs: [
300
+ { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
301
+ {
302
+ indexed: true,
303
+ internalType: "address",
304
+ name: "account",
305
+ type: "address"
306
+ },
307
+ {
308
+ indexed: true,
309
+ internalType: "address",
310
+ name: "sender",
311
+ type: "address"
312
+ }
313
+ ],
314
+ name: "RoleGranted",
315
+ type: "event"
316
+ },
317
+ {
318
+ anonymous: false,
319
+ inputs: [
320
+ { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
321
+ {
322
+ indexed: true,
323
+ internalType: "address",
324
+ name: "account",
325
+ type: "address"
326
+ },
327
+ {
328
+ indexed: true,
329
+ internalType: "address",
330
+ name: "sender",
331
+ type: "address"
332
+ }
333
+ ],
334
+ name: "RoleRevoked",
335
+ type: "event"
336
+ },
337
+ {
338
+ inputs: [],
339
+ name: "ADMIN_ROLE",
340
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
341
+ stateMutability: "view",
342
+ type: "function"
343
+ },
344
+ {
345
+ inputs: [],
346
+ name: "DEFAULT_ADMIN_ROLE",
347
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
348
+ stateMutability: "view",
349
+ type: "function"
350
+ },
351
+ {
352
+ inputs: [],
353
+ name: "PHASE_COMPLETED",
354
+ outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
355
+ stateMutability: "view",
356
+ type: "function"
357
+ },
358
+ {
359
+ inputs: [],
360
+ name: "PHASE_EVALUATION",
361
+ outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
362
+ stateMutability: "view",
363
+ type: "function"
364
+ },
365
+ {
366
+ inputs: [],
367
+ name: "PHASE_NEGOTIATION",
368
+ outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
369
+ stateMutability: "view",
370
+ type: "function"
371
+ },
372
+ {
373
+ inputs: [],
374
+ name: "PHASE_REJECTED",
375
+ outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
376
+ stateMutability: "view",
377
+ type: "function"
378
+ },
379
+ {
380
+ inputs: [],
381
+ name: "PHASE_REQUEST",
382
+ outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
383
+ stateMutability: "view",
384
+ type: "function"
385
+ },
386
+ {
387
+ inputs: [],
388
+ name: "PHASE_TRANSACTION",
389
+ outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
390
+ stateMutability: "view",
391
+ type: "function"
392
+ },
393
+ {
394
+ inputs: [],
395
+ name: "TOTAL_PHASES",
396
+ outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
397
+ stateMutability: "view",
398
+ type: "function"
399
+ },
400
+ {
401
+ inputs: [
402
+ { internalType: "address", name: "account", type: "address" },
403
+ { internalType: "uint256", name: "jobId", type: "uint256" }
404
+ ],
405
+ name: "canSign",
406
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
407
+ stateMutability: "view",
408
+ type: "function"
409
+ },
410
+ {
411
+ inputs: [{ internalType: "uint256", name: "id", type: "uint256" }],
412
+ name: "claimBudget",
413
+ outputs: [],
414
+ stateMutability: "nonpayable",
415
+ type: "function"
416
+ },
417
+ {
418
+ inputs: [
419
+ { internalType: "address", name: "provider", type: "address" },
420
+ { internalType: "address", name: "evaluator", type: "address" },
421
+ { internalType: "uint256", name: "expiredAt", type: "uint256" }
422
+ ],
423
+ name: "createJob",
424
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
425
+ stateMutability: "nonpayable",
426
+ type: "function"
427
+ },
428
+ {
429
+ inputs: [
430
+ { internalType: "uint256", name: "jobId", type: "uint256" },
431
+ { internalType: "string", name: "content", type: "string" },
432
+ {
433
+ internalType: "enum InteractionLedger.MemoType",
434
+ name: "memoType",
435
+ type: "uint8"
436
+ },
437
+ { internalType: "bool", name: "isSecured", type: "bool" },
438
+ { internalType: "uint8", name: "nextPhase", type: "uint8" }
439
+ ],
440
+ name: "createMemo",
441
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
442
+ stateMutability: "nonpayable",
443
+ type: "function"
444
+ },
445
+ {
446
+ inputs: [],
447
+ name: "evaluatorFeeBP",
448
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
449
+ stateMutability: "view",
450
+ type: "function"
451
+ },
452
+ {
453
+ inputs: [
454
+ { internalType: "uint256", name: "jobId", type: "uint256" },
455
+ { internalType: "uint256", name: "offset", type: "uint256" },
456
+ { internalType: "uint256", name: "limit", type: "uint256" }
457
+ ],
458
+ name: "getAllMemos",
459
+ outputs: [
460
+ {
461
+ components: [
462
+ { internalType: "string", name: "content", type: "string" },
463
+ {
464
+ internalType: "enum InteractionLedger.MemoType",
465
+ name: "memoType",
466
+ type: "uint8"
467
+ },
468
+ { internalType: "bool", name: "isSecured", type: "bool" },
469
+ { internalType: "uint8", name: "nextPhase", type: "uint8" },
470
+ { internalType: "uint256", name: "jobId", type: "uint256" },
471
+ { internalType: "address", name: "sender", type: "address" }
472
+ ],
473
+ internalType: "struct InteractionLedger.Memo[]",
474
+ name: "",
475
+ type: "tuple[]"
476
+ },
477
+ { internalType: "uint256", name: "total", type: "uint256" }
478
+ ],
479
+ stateMutability: "view",
480
+ type: "function"
481
+ },
482
+ {
483
+ inputs: [
484
+ { internalType: "uint256", name: "jobId", type: "uint256" },
485
+ { internalType: "uint8", name: "phase", type: "uint8" },
486
+ { internalType: "uint256", name: "offset", type: "uint256" },
487
+ { internalType: "uint256", name: "limit", type: "uint256" }
488
+ ],
489
+ name: "getMemosForPhase",
490
+ outputs: [
491
+ {
492
+ components: [
493
+ { internalType: "string", name: "content", type: "string" },
494
+ {
495
+ internalType: "enum InteractionLedger.MemoType",
496
+ name: "memoType",
497
+ type: "uint8"
498
+ },
499
+ { internalType: "bool", name: "isSecured", type: "bool" },
500
+ { internalType: "uint8", name: "nextPhase", type: "uint8" },
501
+ { internalType: "uint256", name: "jobId", type: "uint256" },
502
+ { internalType: "address", name: "sender", type: "address" }
503
+ ],
504
+ internalType: "struct InteractionLedger.Memo[]",
505
+ name: "",
506
+ type: "tuple[]"
507
+ },
508
+ { internalType: "uint256", name: "total", type: "uint256" }
509
+ ],
510
+ stateMutability: "view",
511
+ type: "function"
512
+ },
513
+ {
514
+ inputs: [],
515
+ name: "getPhases",
516
+ outputs: [{ internalType: "string[6]", name: "", type: "string[6]" }],
517
+ stateMutability: "pure",
518
+ type: "function"
519
+ },
520
+ {
521
+ inputs: [{ internalType: "bytes32", name: "role", type: "bytes32" }],
522
+ name: "getRoleAdmin",
523
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
524
+ stateMutability: "view",
525
+ type: "function"
526
+ },
527
+ {
528
+ inputs: [
529
+ { internalType: "bytes32", name: "role", type: "bytes32" },
530
+ { internalType: "address", name: "account", type: "address" }
531
+ ],
532
+ name: "grantRole",
533
+ outputs: [],
534
+ stateMutability: "nonpayable",
535
+ type: "function"
536
+ },
537
+ {
538
+ inputs: [
539
+ { internalType: "bytes32", name: "role", type: "bytes32" },
540
+ { internalType: "address", name: "account", type: "address" }
541
+ ],
542
+ name: "hasRole",
543
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
544
+ stateMutability: "view",
545
+ type: "function"
546
+ },
547
+ {
548
+ inputs: [
549
+ { internalType: "address", name: "paymentTokenAddress", type: "address" },
550
+ { internalType: "uint256", name: "evaluatorFeeBP_", type: "uint256" },
551
+ { internalType: "uint256", name: "platformFeeBP_", type: "uint256" },
552
+ { internalType: "address", name: "platformTreasury_", type: "address" }
553
+ ],
554
+ name: "initialize",
555
+ outputs: [],
556
+ stateMutability: "nonpayable",
557
+ type: "function"
558
+ },
559
+ {
560
+ inputs: [
561
+ { internalType: "uint256", name: "jobId", type: "uint256" },
562
+ { internalType: "address", name: "account", type: "address" }
563
+ ],
564
+ name: "isJobEvaluator",
565
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
566
+ stateMutability: "view",
567
+ type: "function"
568
+ },
569
+ {
570
+ inputs: [],
571
+ name: "jobCounter",
572
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
573
+ stateMutability: "view",
574
+ type: "function"
575
+ },
576
+ {
577
+ inputs: [
578
+ { internalType: "uint256", name: "jobId", type: "uint256" },
579
+ { internalType: "uint8", name: "phase", type: "uint8" },
580
+ { internalType: "uint256", name: "", type: "uint256" }
581
+ ],
582
+ name: "jobMemoIds",
583
+ outputs: [{ internalType: "uint256", name: "memoIds", type: "uint256" }],
584
+ stateMutability: "view",
585
+ type: "function"
586
+ },
587
+ {
588
+ inputs: [{ internalType: "uint256", name: "", type: "uint256" }],
589
+ name: "jobs",
590
+ outputs: [
591
+ { internalType: "uint256", name: "id", type: "uint256" },
592
+ { internalType: "address", name: "client", type: "address" },
593
+ { internalType: "address", name: "provider", type: "address" },
594
+ { internalType: "uint256", name: "budget", type: "uint256" },
595
+ { internalType: "uint256", name: "amountClaimed", type: "uint256" },
596
+ { internalType: "uint8", name: "phase", type: "uint8" },
597
+ { internalType: "uint256", name: "memoCount", type: "uint256" },
598
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
599
+ { internalType: "address", name: "evaluator", type: "address" }
600
+ ],
601
+ stateMutability: "view",
602
+ type: "function"
603
+ },
604
+ {
605
+ inputs: [],
606
+ name: "memoCounter",
607
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
608
+ stateMutability: "view",
609
+ type: "function"
610
+ },
611
+ {
612
+ inputs: [],
613
+ name: "numEvaluatorsPerJob",
614
+ outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
615
+ stateMutability: "view",
616
+ type: "function"
617
+ },
618
+ {
619
+ inputs: [],
620
+ name: "paymentToken",
621
+ outputs: [{ internalType: "contract IERC20", name: "", type: "address" }],
622
+ stateMutability: "view",
623
+ type: "function"
624
+ },
625
+ {
626
+ inputs: [],
627
+ name: "platformFeeBP",
628
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
629
+ stateMutability: "view",
630
+ type: "function"
631
+ },
632
+ {
633
+ inputs: [],
634
+ name: "platformTreasury",
635
+ outputs: [{ internalType: "address", name: "", type: "address" }],
636
+ stateMutability: "view",
637
+ type: "function"
638
+ },
639
+ {
640
+ inputs: [
641
+ { internalType: "bytes32", name: "role", type: "bytes32" },
642
+ { internalType: "address", name: "callerConfirmation", type: "address" }
643
+ ],
644
+ name: "renounceRole",
645
+ outputs: [],
646
+ stateMutability: "nonpayable",
647
+ type: "function"
648
+ },
649
+ {
650
+ inputs: [
651
+ { internalType: "bytes32", name: "role", type: "bytes32" },
652
+ { internalType: "address", name: "account", type: "address" }
653
+ ],
654
+ name: "revokeRole",
655
+ outputs: [],
656
+ stateMutability: "nonpayable",
657
+ type: "function"
658
+ },
659
+ {
660
+ inputs: [
661
+ { internalType: "uint256", name: "jobId", type: "uint256" },
662
+ { internalType: "uint256", name: "amount", type: "uint256" }
663
+ ],
664
+ name: "setBudget",
665
+ outputs: [],
666
+ stateMutability: "nonpayable",
667
+ type: "function"
668
+ },
669
+ {
670
+ inputs: [
671
+ { internalType: "uint256", name: "memoId", type: "uint256" },
672
+ { internalType: "bool", name: "isApproved", type: "bool" },
673
+ { internalType: "string", name: "reason", type: "string" }
674
+ ],
675
+ name: "signMemo",
676
+ outputs: [],
677
+ stateMutability: "nonpayable",
678
+ type: "function"
679
+ },
680
+ {
681
+ inputs: [
682
+ { internalType: "uint256", name: "memoId", type: "uint256" },
683
+ { internalType: "address", name: "signer", type: "address" }
684
+ ],
685
+ name: "signatories",
686
+ outputs: [{ internalType: "uint8", name: "res", type: "uint8" }],
687
+ stateMutability: "view",
688
+ type: "function"
689
+ },
690
+ {
691
+ inputs: [{ internalType: "bytes4", name: "interfaceId", type: "bytes4" }],
692
+ name: "supportsInterface",
693
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
694
+ stateMutability: "view",
695
+ type: "function"
696
+ },
697
+ {
698
+ inputs: [
699
+ { internalType: "uint256", name: "evaluatorFeeBP_", type: "uint256" }
700
+ ],
701
+ name: "updateEvaluatorFee",
702
+ outputs: [],
703
+ stateMutability: "nonpayable",
704
+ type: "function"
705
+ },
706
+ {
707
+ inputs: [
708
+ { internalType: "uint256", name: "platformFeeBP_", type: "uint256" },
709
+ { internalType: "address", name: "platformTreasury_", type: "address" }
710
+ ],
711
+ name: "updatePlatformFee",
712
+ outputs: [],
713
+ stateMutability: "nonpayable",
714
+ type: "function"
715
+ }
716
+ ];
717
+ var acpAbi_default = ACP_ABI;
718
+
719
+ // src/acpClient.ts
720
+ import { parseEther } from "viem";
721
+ import { io } from "socket.io-client";
722
+
723
+ // src/acpContractClient.ts
724
+ import { LocalAccountSigner } from "@aa-sdk/core";
725
+ import { alchemy } from "@account-kit/infra";
726
+ import {
727
+ createModularAccountV2Client
728
+ } from "@account-kit/smart-contracts";
729
+
730
+ // src/configs.ts
731
+ import { baseSepolia, base } from "@account-kit/infra";
732
+ var baseSepoliaAcpConfig = {
733
+ chain: baseSepolia,
734
+ contractAddress: "0x2422c1c43451Eb69Ff49dfD39c4Dc8C5230fA1e6",
735
+ virtualsTokenAddress: "0xbfAB80ccc15DF6fb7185f9498d6039317331846a",
736
+ alchemyRpcUrl: "https://alchemy-proxy.virtuals.io/api/proxy/rpc",
737
+ acpUrl: "https://acpx-staging.virtuals.io"
738
+ };
739
+ var baseAcpConfig = {
740
+ chain: base,
741
+ contractAddress: "0x6a1FE26D54ab0d3E1e3168f2e0c0cDa5cC0A0A4A",
742
+ virtualsTokenAddress: "0x0b3e328455c4059EEb9e3f84b5543F74E24e7E1b",
743
+ alchemyRpcUrl: "https://alchemy-proxy-prod.virtuals.io/api/proxy/rpc",
744
+ acpUrl: "https://acpx.virtuals.io"
745
+ };
746
+
747
+ // src/acpContractClient.ts
748
+ import { encodeFunctionData, erc20Abi, fromHex } from "viem";
749
+ var MemoType = /* @__PURE__ */ ((MemoType2) => {
750
+ MemoType2[MemoType2["MESSAGE"] = 0] = "MESSAGE";
751
+ MemoType2[MemoType2["CONTEXT_URL"] = 1] = "CONTEXT_URL";
752
+ MemoType2[MemoType2["IMAGE_URL"] = 2] = "IMAGE_URL";
753
+ MemoType2[MemoType2["VOICE_URL"] = 3] = "VOICE_URL";
754
+ MemoType2[MemoType2["OBJECT_URL"] = 4] = "OBJECT_URL";
755
+ MemoType2[MemoType2["TXHASH"] = 5] = "TXHASH";
756
+ return MemoType2;
757
+ })(MemoType || {});
758
+ var AcpJobPhases = /* @__PURE__ */ ((AcpJobPhases2) => {
759
+ AcpJobPhases2[AcpJobPhases2["REQUEST"] = 0] = "REQUEST";
760
+ AcpJobPhases2[AcpJobPhases2["NEGOTIATION"] = 1] = "NEGOTIATION";
761
+ AcpJobPhases2[AcpJobPhases2["TRANSACTION"] = 2] = "TRANSACTION";
762
+ AcpJobPhases2[AcpJobPhases2["EVALUATION"] = 3] = "EVALUATION";
763
+ AcpJobPhases2[AcpJobPhases2["COMPLETED"] = 4] = "COMPLETED";
764
+ AcpJobPhases2[AcpJobPhases2["REJECTED"] = 5] = "REJECTED";
765
+ AcpJobPhases2[AcpJobPhases2["EXPIRED"] = 6] = "EXPIRED";
766
+ return AcpJobPhases2;
767
+ })(AcpJobPhases || {});
768
+ var AcpContractClient = class _AcpContractClient {
769
+ constructor(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfig) {
770
+ this.walletPrivateKey = walletPrivateKey;
771
+ this.sessionEntityKeyId = sessionEntityKeyId;
772
+ this.agentWalletAddress = agentWalletAddress;
773
+ this.config = config;
774
+ this.chain = config.chain;
775
+ this.contractAddress = config.contractAddress;
776
+ this.virtualsTokenAddress = config.virtualsTokenAddress;
777
+ }
778
+ static build(_0, _1, _2) {
779
+ return __async(this, arguments, function* (walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfig) {
780
+ const acpContractClient = new _AcpContractClient(
781
+ walletPrivateKey,
782
+ sessionEntityKeyId,
783
+ agentWalletAddress,
784
+ config
785
+ );
786
+ yield acpContractClient.init();
787
+ return acpContractClient;
788
+ });
789
+ }
790
+ init() {
791
+ return __async(this, null, function* () {
792
+ const sessionKeySigner = LocalAccountSigner.privateKeyToAccountSigner(this.walletPrivateKey);
793
+ this._sessionKeyClient = yield createModularAccountV2Client({
794
+ chain: this.chain,
795
+ transport: alchemy({
796
+ rpcUrl: this.config.alchemyRpcUrl
797
+ }),
798
+ signer: sessionKeySigner,
799
+ policyId: "186aaa4a-5f57-4156-83fb-e456365a8820",
800
+ accountAddress: this.agentWalletAddress,
801
+ signerEntity: {
802
+ entityId: this.sessionEntityKeyId,
803
+ isGlobalValidation: true
804
+ }
805
+ });
806
+ });
807
+ }
808
+ get sessionKeyClient() {
809
+ if (!this._sessionKeyClient) {
810
+ throw new Error("Session key client not initialized");
811
+ }
812
+ return this._sessionKeyClient;
813
+ }
814
+ get walletAddress() {
815
+ return this.sessionKeyClient.account.address;
816
+ }
817
+ getJobId(hash) {
818
+ return __async(this, null, function* () {
819
+ const result = yield this.sessionKeyClient.getUserOperationReceipt(hash);
820
+ if (!result) {
821
+ throw new Error("Failed to get user operation receipt");
822
+ }
823
+ const contractLogs = result.logs.find(
824
+ (log) => log.address.toLowerCase() === this.contractAddress.toLowerCase()
825
+ );
826
+ if (!contractLogs) {
827
+ throw new Error("Failed to get contract logs");
828
+ }
829
+ return fromHex(contractLogs.data, "number");
830
+ });
831
+ }
832
+ createJob(providerAddress, evaluatorAddress, expireAt) {
833
+ return __async(this, null, function* () {
834
+ try {
835
+ const data = encodeFunctionData({
836
+ abi: acpAbi_default,
837
+ functionName: "createJob",
838
+ args: [
839
+ providerAddress,
840
+ evaluatorAddress,
841
+ Math.floor(expireAt.getTime() / 1e3)
842
+ ]
843
+ });
844
+ const { hash } = yield this.sessionKeyClient.sendUserOperation({
845
+ uo: {
846
+ target: this.contractAddress,
847
+ data
848
+ }
849
+ });
850
+ yield this.sessionKeyClient.waitForUserOperationTransaction({
851
+ hash
852
+ });
853
+ const jobId = yield this.getJobId(hash);
854
+ return { txHash: hash, jobId };
855
+ } catch (error) {
856
+ console.error(error);
857
+ throw new Error("Failed to create job");
858
+ }
859
+ });
860
+ }
861
+ approveAllowance(priceInWei) {
862
+ return __async(this, null, function* () {
863
+ const data = encodeFunctionData({
864
+ abi: erc20Abi,
865
+ functionName: "approve",
866
+ args: [this.contractAddress, priceInWei]
867
+ });
868
+ const { hash } = yield this.sessionKeyClient.sendUserOperation({
869
+ uo: {
870
+ target: this.virtualsTokenAddress,
871
+ data
872
+ }
873
+ });
874
+ yield this.sessionKeyClient.waitForUserOperationTransaction({
875
+ hash
876
+ });
877
+ return hash;
878
+ });
879
+ }
880
+ createMemo(jobId, content, type, isSecured, nextPhase) {
881
+ return __async(this, null, function* () {
882
+ let retries = 3;
883
+ while (retries > 0) {
884
+ try {
885
+ const data = encodeFunctionData({
886
+ abi: acpAbi_default,
887
+ functionName: "createMemo",
888
+ args: [jobId, content, type, isSecured, nextPhase]
889
+ });
890
+ const { hash } = yield this.sessionKeyClient.sendUserOperation({
891
+ uo: {
892
+ target: this.contractAddress,
893
+ data
894
+ }
895
+ });
896
+ yield this.sessionKeyClient.waitForUserOperationTransaction({
897
+ hash
898
+ });
899
+ return hash;
900
+ } catch (error) {
901
+ console.error(`failed to create memo ${jobId} ${content} ${error}`);
902
+ retries -= 1;
903
+ yield new Promise((resolve) => setTimeout(resolve, 2e3 * retries));
904
+ }
905
+ }
906
+ throw new Error("Failed to create memo");
907
+ });
908
+ }
909
+ signMemo(memoId, isApproved, reason) {
910
+ return __async(this, null, function* () {
911
+ let retries = 3;
912
+ while (retries > 0) {
913
+ try {
914
+ const data = encodeFunctionData({
915
+ abi: acpAbi_default,
916
+ functionName: "signMemo",
917
+ args: [memoId, isApproved, reason]
918
+ });
919
+ const { hash } = yield this.sessionKeyClient.sendUserOperation({
920
+ uo: {
921
+ target: this.contractAddress,
922
+ data
923
+ }
924
+ });
925
+ yield this.sessionKeyClient.waitForUserOperationTransaction({
926
+ hash
927
+ });
928
+ return hash;
929
+ } catch (error) {
930
+ console.error(`failed to sign memo ${error}`);
931
+ retries -= 1;
932
+ yield new Promise((resolve) => setTimeout(resolve, 2e3 * retries));
933
+ }
934
+ }
935
+ throw new Error("Failed to sign memo");
936
+ });
937
+ }
938
+ setBudget(jobId, budget) {
939
+ return __async(this, null, function* () {
940
+ try {
941
+ const data = encodeFunctionData({
942
+ abi: acpAbi_default,
943
+ functionName: "setBudget",
944
+ args: [jobId, budget]
945
+ });
946
+ const { hash } = yield this.sessionKeyClient.sendUserOperation({
947
+ uo: {
948
+ target: this.contractAddress,
949
+ data
950
+ }
951
+ });
952
+ yield this.sessionKeyClient.waitForUserOperationTransaction({
953
+ hash
954
+ });
955
+ return hash;
956
+ } catch (error) {
957
+ console.error(error);
958
+ throw new Error("Failed to set budget");
959
+ }
960
+ });
961
+ }
962
+ };
963
+ var acpContractClient_default = AcpContractClient;
964
+
965
+ // src/acpJob.ts
966
+ var AcpJob = class {
967
+ constructor(acpClient, id, clientAddress, providerAddress, evaluatorAddress, price, memos, phase, context) {
968
+ this.acpClient = acpClient;
969
+ this.id = id;
970
+ this.clientAddress = clientAddress;
971
+ this.providerAddress = providerAddress;
972
+ this.evaluatorAddress = evaluatorAddress;
973
+ this.price = price;
974
+ this.memos = memos;
975
+ this.phase = phase;
976
+ this.context = context;
977
+ }
978
+ get serviceRequirement() {
979
+ var _a;
980
+ return (_a = this.memos.find((m) => m.nextPhase === 1 /* NEGOTIATION */)) == null ? void 0 : _a.content;
981
+ }
982
+ get deliverable() {
983
+ var _a;
984
+ return (_a = this.memos.find((m) => m.nextPhase === 4 /* COMPLETED */)) == null ? void 0 : _a.content;
985
+ }
986
+ get providerAgent() {
987
+ return this.acpClient.getAgent(this.providerAddress);
988
+ }
989
+ get clientAgent() {
990
+ return this.acpClient.getAgent(this.clientAddress);
991
+ }
992
+ get evaluatorAgent() {
993
+ return this.acpClient.getAgent(this.evaluatorAddress);
994
+ }
995
+ pay(amount, reason) {
996
+ return __async(this, null, function* () {
997
+ const memo = this.memos.find(
998
+ (m) => m.nextPhase === 2 /* TRANSACTION */
999
+ );
1000
+ if (!memo) {
1001
+ throw new Error("No transaction memo found");
1002
+ }
1003
+ return yield this.acpClient.payJob(this.id, amount, memo.id, reason);
1004
+ });
1005
+ }
1006
+ respond(accept, reason) {
1007
+ return __async(this, null, function* () {
1008
+ const memo = this.memos.find(
1009
+ (m) => m.nextPhase === 1 /* NEGOTIATION */
1010
+ );
1011
+ if (!memo) {
1012
+ throw new Error("No negotiation memo found");
1013
+ }
1014
+ return yield this.acpClient.respondJob(this.id, memo.id, accept, reason);
1015
+ });
1016
+ }
1017
+ deliver(deliverable) {
1018
+ return __async(this, null, function* () {
1019
+ const memo = this.memos.find(
1020
+ (m) => m.nextPhase === 3 /* EVALUATION */
1021
+ );
1022
+ if (!memo) {
1023
+ throw new Error("No transaction memo found");
1024
+ }
1025
+ return yield this.acpClient.deliverJob(this.id, deliverable);
1026
+ });
1027
+ }
1028
+ evaluate(accept, reason) {
1029
+ return __async(this, null, function* () {
1030
+ const memo = this.memos.find((m) => m.nextPhase === 4 /* COMPLETED */);
1031
+ if (!memo) {
1032
+ throw new Error("No evaluation memo found");
1033
+ }
1034
+ return yield this.acpClient.acpContractClient.signMemo(
1035
+ memo.id,
1036
+ accept,
1037
+ reason
1038
+ );
1039
+ });
1040
+ }
1041
+ };
1042
+ var acpJob_default = AcpJob;
1043
+
1044
+ // src/acpMemo.ts
1045
+ var AcpMemo = class {
1046
+ constructor(acpClient, id, type, content, nextPhase) {
1047
+ this.acpClient = acpClient;
1048
+ this.id = id;
1049
+ this.type = type;
1050
+ this.content = content;
1051
+ this.nextPhase = nextPhase;
1052
+ }
1053
+ create(jobId, isSecured = true) {
1054
+ return __async(this, null, function* () {
1055
+ return yield this.acpClient.acpContractClient.createMemo(
1056
+ jobId,
1057
+ this.content,
1058
+ this.type,
1059
+ isSecured,
1060
+ this.nextPhase
1061
+ );
1062
+ });
1063
+ }
1064
+ sign(approved, reason) {
1065
+ return __async(this, null, function* () {
1066
+ return yield this.acpClient.acpContractClient.signMemo(
1067
+ this.id,
1068
+ approved,
1069
+ reason
1070
+ );
1071
+ });
1072
+ }
1073
+ };
1074
+ var acpMemo_default = AcpMemo;
1075
+
1076
+ // src/acpJobOffering.ts
1077
+ import Ajv from "ajv";
1078
+ var AcpJobOffering = class {
1079
+ constructor(acpClient, providerAddress, type, price, requirementSchema) {
1080
+ this.acpClient = acpClient;
1081
+ this.providerAddress = providerAddress;
1082
+ this.type = type;
1083
+ this.price = price;
1084
+ this.requirementSchema = requirementSchema;
1085
+ this.ajv = new Ajv({ allErrors: true });
1086
+ }
1087
+ initiateJob(_0, _1) {
1088
+ return __async(this, arguments, function* (serviceRequirement, evaluatorAddress, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
1089
+ if (this.requirementSchema) {
1090
+ const validator = this.ajv.compile(this.requirementSchema);
1091
+ const valid = validator(serviceRequirement);
1092
+ if (!valid) {
1093
+ throw new Error(this.ajv.errorsText(validator.errors));
1094
+ }
1095
+ }
1096
+ return yield this.acpClient.initiateJob(
1097
+ this.providerAddress,
1098
+ serviceRequirement,
1099
+ this.price,
1100
+ evaluatorAddress,
1101
+ expiredAt
1102
+ );
1103
+ });
1104
+ }
1105
+ };
1106
+ var acpJobOffering_default = AcpJobOffering;
1107
+
1108
+ // src/acpClient.ts
1109
+ var AcpClient = class {
1110
+ constructor(options) {
1111
+ this.acpContractClient = options.acpContractClient;
1112
+ this.onNewTask = options.onNewTask;
1113
+ this.onEvaluate = options.onEvaluate || this.defaultOnEvaluate;
1114
+ this.acpUrl = this.acpContractClient.config.acpUrl;
1115
+ this.init();
1116
+ }
1117
+ defaultOnEvaluate(job) {
1118
+ return __async(this, null, function* () {
1119
+ yield job.evaluate(true, "Evaluated by default");
1120
+ });
1121
+ }
1122
+ init() {
1123
+ return __async(this, null, function* () {
1124
+ const socket = io(this.acpUrl, {
1125
+ auth: __spreadValues(__spreadValues({}, this.onNewTask && {
1126
+ walletAddress: this.acpContractClient.walletAddress
1127
+ }), this.onEvaluate !== this.defaultOnEvaluate && {
1128
+ evaluatorAddress: this.acpContractClient.walletAddress
1129
+ })
1130
+ });
1131
+ socket.on("roomJoined" /* ROOM_JOINED */, (_, callback) => {
1132
+ console.log("Joined ACP Room");
1133
+ callback(true);
1134
+ });
1135
+ socket.on(
1136
+ "onEvaluate" /* ON_EVALUATE */,
1137
+ (data, callback) => __async(this, null, function* () {
1138
+ callback(true);
1139
+ if (this.onEvaluate) {
1140
+ const job = new acpJob_default(
1141
+ this,
1142
+ data.id,
1143
+ data.clientAddress,
1144
+ data.providerAddress,
1145
+ data.evaluatorAddress,
1146
+ data.price,
1147
+ data.memos.map((memo) => {
1148
+ return new acpMemo_default(
1149
+ this,
1150
+ memo.id,
1151
+ memo.memoType,
1152
+ memo.content,
1153
+ memo.nextPhase
1154
+ );
1155
+ }),
1156
+ data.phase,
1157
+ data.context
1158
+ );
1159
+ this.onEvaluate(job);
1160
+ }
1161
+ })
1162
+ );
1163
+ socket.on(
1164
+ "onNewTask" /* ON_NEW_TASK */,
1165
+ (data, callback) => __async(this, null, function* () {
1166
+ callback(true);
1167
+ if (this.onNewTask) {
1168
+ const job = new acpJob_default(
1169
+ this,
1170
+ data.id,
1171
+ data.clientAddress,
1172
+ data.providerAddress,
1173
+ data.evaluatorAddress,
1174
+ data.price,
1175
+ data.memos.map((memo) => {
1176
+ return new acpMemo_default(
1177
+ this,
1178
+ memo.id,
1179
+ memo.memoType,
1180
+ memo.content,
1181
+ memo.nextPhase
1182
+ );
1183
+ }),
1184
+ data.phase,
1185
+ data.context
1186
+ );
1187
+ this.onNewTask(job);
1188
+ }
1189
+ })
1190
+ );
1191
+ const cleanup = () => __async(this, null, function* () {
1192
+ if (socket) {
1193
+ socket.disconnect();
1194
+ }
1195
+ process.exit(0);
1196
+ });
1197
+ process.on("SIGINT", cleanup);
1198
+ process.on("SIGTERM", cleanup);
1199
+ });
1200
+ }
1201
+ browseAgents(keyword, options) {
1202
+ return __async(this, null, function* () {
1203
+ let { cluster, sort_by, rerank, top_k, graduated } = options;
1204
+ rerank = rerank != null ? rerank : true;
1205
+ top_k = top_k != null ? top_k : 5;
1206
+ graduated = graduated != null ? graduated : true;
1207
+ let url = `${this.acpUrl}/api/agents?search=${keyword}`;
1208
+ if (sort_by && sort_by.length > 0) {
1209
+ url += `&sort=${sort_by.map((s) => s).join(",")}`;
1210
+ }
1211
+ if (top_k) {
1212
+ url += `&top_k=${top_k}`;
1213
+ }
1214
+ if (rerank) {
1215
+ url += `&rerank=true`;
1216
+ }
1217
+ if (this.acpContractClient.walletAddress) {
1218
+ url += `&filters[walletAddress][$notIn]=${this.acpContractClient.walletAddress}`;
1219
+ }
1220
+ if (cluster) {
1221
+ url += `&filters[cluster]=${cluster}`;
1222
+ }
1223
+ if (graduated === false) {
1224
+ url += `&filters[hasGraduated]=false`;
1225
+ }
1226
+ const response = yield fetch(url);
1227
+ const data = yield response.json();
1228
+ return data.data.map((agent) => {
1229
+ return {
1230
+ id: agent.id,
1231
+ name: agent.name,
1232
+ description: agent.description,
1233
+ offerings: agent.offerings.map((offering) => {
1234
+ return new acpJobOffering_default(
1235
+ this,
1236
+ agent.walletAddress,
1237
+ offering.name,
1238
+ offering.price,
1239
+ offering.requirementSchema
1240
+ );
1241
+ }),
1242
+ twitterHandle: agent.twitterHandle,
1243
+ walletAddress: agent.walletAddress,
1244
+ metrics: agent.metrics
1245
+ };
1246
+ });
1247
+ });
1248
+ }
1249
+ initiateJob(_0, _1, _2, _3) {
1250
+ return __async(this, arguments, function* (providerAddress, serviceRequirement, amount, evaluatorAddress, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
1251
+ const { jobId } = yield this.acpContractClient.createJob(
1252
+ providerAddress,
1253
+ evaluatorAddress || this.acpContractClient.walletAddress,
1254
+ expiredAt
1255
+ );
1256
+ yield this.acpContractClient.setBudget(
1257
+ jobId,
1258
+ parseEther(amount.toString())
1259
+ );
1260
+ yield this.acpContractClient.createMemo(
1261
+ jobId,
1262
+ typeof serviceRequirement === "string" ? serviceRequirement : JSON.stringify(serviceRequirement),
1263
+ 0 /* MESSAGE */,
1264
+ true,
1265
+ 1 /* NEGOTIATION */
1266
+ );
1267
+ return jobId;
1268
+ });
1269
+ }
1270
+ respondJob(jobId, memoId, accept, reason) {
1271
+ return __async(this, null, function* () {
1272
+ yield this.acpContractClient.signMemo(memoId, accept, reason);
1273
+ if (!accept) {
1274
+ return;
1275
+ }
1276
+ return yield this.acpContractClient.createMemo(
1277
+ jobId,
1278
+ `Job ${jobId} accepted. ${reason != null ? reason : ""}`,
1279
+ 0 /* MESSAGE */,
1280
+ false,
1281
+ 2 /* TRANSACTION */
1282
+ );
1283
+ });
1284
+ }
1285
+ payJob(jobId, amount, memoId, reason) {
1286
+ return __async(this, null, function* () {
1287
+ yield this.acpContractClient.approveAllowance(
1288
+ parseEther(amount.toString())
1289
+ );
1290
+ yield this.acpContractClient.signMemo(memoId, true, reason);
1291
+ return yield this.acpContractClient.createMemo(
1292
+ jobId,
1293
+ `Payment of ${amount} made. ${reason != null ? reason : ""}`,
1294
+ 0 /* MESSAGE */,
1295
+ false,
1296
+ 3 /* EVALUATION */
1297
+ );
1298
+ });
1299
+ }
1300
+ deliverJob(jobId, deliverable) {
1301
+ return __async(this, null, function* () {
1302
+ return yield this.acpContractClient.createMemo(
1303
+ jobId,
1304
+ deliverable,
1305
+ 4 /* OBJECT_URL */,
1306
+ true,
1307
+ 4 /* COMPLETED */
1308
+ );
1309
+ });
1310
+ }
1311
+ getActiveJobs(page = 1, pageSize = 10) {
1312
+ return __async(this, null, function* () {
1313
+ let url = `${this.acpUrl}/api/jobs/active?pagination[page]=${page}&pagination[pageSize]=${pageSize}`;
1314
+ try {
1315
+ const response = yield fetch(url, {
1316
+ headers: {
1317
+ "wallet-address": this.acpContractClient.walletAddress
1318
+ }
1319
+ });
1320
+ const data = yield response.json();
1321
+ if (data.error) {
1322
+ throw new Error(data.error.message);
1323
+ }
1324
+ return data.data.map((job) => {
1325
+ return new acpJob_default(
1326
+ this,
1327
+ job.id,
1328
+ job.clientAddress,
1329
+ job.providerAddress,
1330
+ job.evaluatorAddress,
1331
+ job.price,
1332
+ job.memos.map((memo) => {
1333
+ return new acpMemo_default(
1334
+ this,
1335
+ memo.id,
1336
+ memo.memoType,
1337
+ memo.content,
1338
+ memo.nextPhase
1339
+ );
1340
+ }),
1341
+ job.phase,
1342
+ job.context
1343
+ );
1344
+ });
1345
+ } catch (error) {
1346
+ throw error;
1347
+ }
1348
+ });
1349
+ }
1350
+ getCompletedJobs(page = 1, pageSize = 10) {
1351
+ return __async(this, null, function* () {
1352
+ let url = `${this.acpUrl}/api/jobs/completed?pagination[page]=${page}&pagination[pageSize]=${pageSize}`;
1353
+ try {
1354
+ const response = yield fetch(url, {
1355
+ headers: {
1356
+ "wallet-address": this.acpContractClient.walletAddress
1357
+ }
1358
+ });
1359
+ const data = yield response.json();
1360
+ if (data.error) {
1361
+ throw new Error(data.error.message);
1362
+ }
1363
+ return data.data.map((job) => {
1364
+ return new acpJob_default(
1365
+ this,
1366
+ job.id,
1367
+ job.clientAddress,
1368
+ job.providerAddress,
1369
+ job.evaluatorAddress,
1370
+ job.price,
1371
+ job.memos.map((memo) => {
1372
+ return new acpMemo_default(
1373
+ this,
1374
+ memo.id,
1375
+ memo.memoType,
1376
+ memo.content,
1377
+ memo.nextPhase
1378
+ );
1379
+ }),
1380
+ job.phase,
1381
+ job.context
1382
+ );
1383
+ });
1384
+ } catch (error) {
1385
+ throw error;
1386
+ }
1387
+ });
1388
+ }
1389
+ getCancelledJobs(page = 1, pageSize = 10) {
1390
+ return __async(this, null, function* () {
1391
+ let url = `${this.acpUrl}/api/jobs/cancelled?pagination[page]=${page}&pagination[pageSize]=${pageSize}`;
1392
+ try {
1393
+ const response = yield fetch(url, {
1394
+ headers: {
1395
+ "wallet-address": this.acpContractClient.walletAddress
1396
+ }
1397
+ });
1398
+ const data = yield response.json();
1399
+ if (data.error) {
1400
+ throw new Error(data.error.message);
1401
+ }
1402
+ return data.data.map((job) => {
1403
+ return new acpJob_default(
1404
+ this,
1405
+ job.id,
1406
+ job.clientAddress,
1407
+ job.providerAddress,
1408
+ job.evaluatorAddress,
1409
+ job.price,
1410
+ job.memos.map((memo) => {
1411
+ return new acpMemo_default(
1412
+ this,
1413
+ memo.id,
1414
+ memo.memoType,
1415
+ memo.content,
1416
+ memo.nextPhase
1417
+ );
1418
+ }),
1419
+ job.phase,
1420
+ job.context
1421
+ );
1422
+ });
1423
+ } catch (error) {
1424
+ throw error;
1425
+ }
1426
+ });
1427
+ }
1428
+ getJobById(jobId) {
1429
+ return __async(this, null, function* () {
1430
+ let url = `${this.acpUrl}/api/jobs/${jobId}`;
1431
+ try {
1432
+ const response = yield fetch(url, {
1433
+ headers: {
1434
+ "wallet-address": this.acpContractClient.walletAddress
1435
+ }
1436
+ });
1437
+ const data = yield response.json();
1438
+ if (data.error) {
1439
+ throw new Error(data.error.message);
1440
+ }
1441
+ const job = data.data;
1442
+ if (!job) {
1443
+ return;
1444
+ }
1445
+ return new acpJob_default(
1446
+ this,
1447
+ job.id,
1448
+ job.clientAddress,
1449
+ job.providerAddress,
1450
+ job.evaluatorAddress,
1451
+ job.price,
1452
+ job.memos.map((memo) => {
1453
+ return new acpMemo_default(
1454
+ this,
1455
+ memo.id,
1456
+ memo.memoType,
1457
+ memo.content,
1458
+ memo.nextPhase
1459
+ );
1460
+ }),
1461
+ job.phase,
1462
+ job.context
1463
+ );
1464
+ } catch (error) {
1465
+ throw error;
1466
+ }
1467
+ });
1468
+ }
1469
+ getMemoById(jobId, memoId) {
1470
+ return __async(this, null, function* () {
1471
+ let url = `${this.acpUrl}/api/jobs/${jobId}/memos/${memoId}`;
1472
+ try {
1473
+ const response = yield fetch(url, {
1474
+ headers: {
1475
+ "wallet-address": this.acpContractClient.walletAddress
1476
+ }
1477
+ });
1478
+ const data = yield response.json();
1479
+ if (data.error) {
1480
+ throw new Error(data.error.message);
1481
+ }
1482
+ const memo = data.data;
1483
+ if (!memo) {
1484
+ return;
1485
+ }
1486
+ return new acpMemo_default(
1487
+ this,
1488
+ memo.id,
1489
+ memo.memoType,
1490
+ memo.content,
1491
+ memo.nextPhase
1492
+ );
1493
+ } catch (error) {
1494
+ throw error;
1495
+ }
1496
+ });
1497
+ }
1498
+ getAgent(walletAddress) {
1499
+ return __async(this, null, function* () {
1500
+ const url = `${this.acpUrl}/api/agents?filters[walletAddress]=${walletAddress}`;
1501
+ const response = yield fetch(url);
1502
+ const data = yield response.json();
1503
+ const agents = data.data || [];
1504
+ if (agents.length === 0) {
1505
+ return;
1506
+ }
1507
+ return agents[0];
1508
+ });
1509
+ }
1510
+ };
1511
+ var acpClient_default = AcpClient;
1512
+
1513
+ // src/interfaces.ts
1514
+ var AcpAgentSort = /* @__PURE__ */ ((AcpAgentSort2) => {
1515
+ AcpAgentSort2["SUCCESSFUL_JOB_COUNT"] = "successfulJobCount";
1516
+ AcpAgentSort2["SUCCESS_RATE"] = "successRate";
1517
+ AcpAgentSort2["UNIQUE_BUYER_COUNT"] = "uniqueBuyerCount";
1518
+ AcpAgentSort2["MINS_FROM_LAST_ONLINE"] = "minsFromLastOnlineTime";
1519
+ AcpAgentSort2["IS_ONLINE"] = "isOnline";
1520
+ return AcpAgentSort2;
1521
+ })(AcpAgentSort || {});
1522
+
1523
+ // src/index.ts
1524
+ var index_default = acpClient_default;
1525
+ export {
1526
+ acpAbi_default as ACP_ABI,
1527
+ AcpAgentSort,
1528
+ acpContractClient_default as AcpContractClient,
1529
+ acpJob_default as AcpJob,
1530
+ AcpJobPhases,
1531
+ acpMemo_default as AcpMemo,
1532
+ MemoType,
1533
+ baseAcpConfig,
1534
+ baseSepoliaAcpConfig,
1535
+ index_default as default
1536
+ };