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

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 (36) hide show
  1. package/dist/index.d.mts +8450 -0
  2. package/dist/index.d.ts +8450 -0
  3. package/dist/index.js +1522 -0
  4. package/dist/index.mjs +1484 -0
  5. package/package.json +5 -2
  6. package/buyer.ts +0 -47
  7. package/docs/imgs/acp-banner.jpeg +0 -0
  8. package/examples/acp_base/README.md +0 -94
  9. package/examples/acp_base/docs/imgs/agent-wallet-page.png +0 -0
  10. package/examples/acp_base/docs/imgs/session-entity-id-location.png +0 -0
  11. package/examples/acp_base/docs/imgs/whitelist-wallet-info.png +0 -0
  12. package/examples/acp_base/docs/imgs/whitelist-wallet.png +0 -0
  13. package/examples/acp_base/external_evaluation/.env.example +0 -5
  14. package/examples/acp_base/external_evaluation/buyer.ts +0 -52
  15. package/examples/acp_base/external_evaluation/env.ts +0 -22
  16. package/examples/acp_base/external_evaluation/evaluator.ts +0 -29
  17. package/examples/acp_base/external_evaluation/seller.ts +0 -46
  18. package/examples/acp_base/self_evaluation/.env.example +0 -4
  19. package/examples/acp_base/self_evaluation/buyer.ts +0 -54
  20. package/examples/acp_base/self_evaluation/env.ts +0 -21
  21. package/examples/acp_base/self_evaluation/seller.ts +0 -46
  22. package/helpers/.env.example +0 -3
  23. package/helpers/acpHelperFunctions.ts +0 -69
  24. package/interfaces.ts +0 -24
  25. package/seller.ts +0 -46
  26. package/src/acpAbi.ts +0 -680
  27. package/src/acpClient.ts +0 -458
  28. package/src/acpContractClient.ts +0 -269
  29. package/src/acpJob.ts +0 -91
  30. package/src/acpJobOffering.ts +0 -43
  31. package/src/acpMemo.ts +0 -32
  32. package/src/configs.ts +0 -28
  33. package/src/index.ts +0 -18
  34. package/src/interfaces.ts +0 -55
  35. package/test.ts +0 -26
  36. package/tsconfig.json +0 -113
package/dist/index.mjs ADDED
@@ -0,0 +1,1484 @@
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
+ import { encodeFunctionData, erc20Abi, fromHex } from "viem";
730
+ var MemoType = /* @__PURE__ */ ((MemoType2) => {
731
+ MemoType2[MemoType2["MESSAGE"] = 0] = "MESSAGE";
732
+ MemoType2[MemoType2["CONTEXT_URL"] = 1] = "CONTEXT_URL";
733
+ MemoType2[MemoType2["IMAGE_URL"] = 2] = "IMAGE_URL";
734
+ MemoType2[MemoType2["VOICE_URL"] = 3] = "VOICE_URL";
735
+ MemoType2[MemoType2["OBJECT_URL"] = 4] = "OBJECT_URL";
736
+ MemoType2[MemoType2["TXHASH"] = 5] = "TXHASH";
737
+ return MemoType2;
738
+ })(MemoType || {});
739
+ var AcpJobPhases = /* @__PURE__ */ ((AcpJobPhases2) => {
740
+ AcpJobPhases2[AcpJobPhases2["REQUEST"] = 0] = "REQUEST";
741
+ AcpJobPhases2[AcpJobPhases2["NEGOTIATION"] = 1] = "NEGOTIATION";
742
+ AcpJobPhases2[AcpJobPhases2["TRANSACTION"] = 2] = "TRANSACTION";
743
+ AcpJobPhases2[AcpJobPhases2["EVALUATION"] = 3] = "EVALUATION";
744
+ AcpJobPhases2[AcpJobPhases2["COMPLETED"] = 4] = "COMPLETED";
745
+ AcpJobPhases2[AcpJobPhases2["REJECTED"] = 5] = "REJECTED";
746
+ return AcpJobPhases2;
747
+ })(AcpJobPhases || {});
748
+ var AcpContractClient = class _AcpContractClient {
749
+ constructor(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config) {
750
+ this.walletPrivateKey = walletPrivateKey;
751
+ this.sessionEntityKeyId = sessionEntityKeyId;
752
+ this.agentWalletAddress = agentWalletAddress;
753
+ this.config = config;
754
+ this.chain = config.chain;
755
+ this.contractAddress = config.contractAddress;
756
+ this.virtualsTokenAddress = config.virtualsTokenAddress;
757
+ }
758
+ static build(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config) {
759
+ return __async(this, null, function* () {
760
+ const acpContractClient = new _AcpContractClient(
761
+ walletPrivateKey,
762
+ sessionEntityKeyId,
763
+ agentWalletAddress,
764
+ config
765
+ );
766
+ yield acpContractClient.init();
767
+ return acpContractClient;
768
+ });
769
+ }
770
+ init() {
771
+ return __async(this, null, function* () {
772
+ const sessionKeySigner = LocalAccountSigner.privateKeyToAccountSigner(this.walletPrivateKey);
773
+ this._sessionKeyClient = yield createModularAccountV2Client({
774
+ chain: this.chain,
775
+ transport: alchemy({
776
+ rpcUrl: this.config.alchemyRpcUrl
777
+ }),
778
+ signer: sessionKeySigner,
779
+ policyId: "186aaa4a-5f57-4156-83fb-e456365a8820",
780
+ accountAddress: this.agentWalletAddress,
781
+ signerEntity: {
782
+ entityId: this.sessionEntityKeyId,
783
+ isGlobalValidation: true
784
+ }
785
+ });
786
+ });
787
+ }
788
+ get sessionKeyClient() {
789
+ if (!this._sessionKeyClient) {
790
+ throw new Error("Session key client not initialized");
791
+ }
792
+ return this._sessionKeyClient;
793
+ }
794
+ get walletAddress() {
795
+ return this.sessionKeyClient.account.address;
796
+ }
797
+ getJobId(hash) {
798
+ return __async(this, null, function* () {
799
+ const result = yield this.sessionKeyClient.getUserOperationReceipt(hash);
800
+ if (!result) {
801
+ throw new Error("Failed to get user operation receipt");
802
+ }
803
+ const contractLogs = result.logs.find(
804
+ (log) => log.address.toLowerCase() === this.contractAddress.toLowerCase()
805
+ );
806
+ if (!contractLogs) {
807
+ throw new Error("Failed to get contract logs");
808
+ }
809
+ return fromHex(contractLogs.data, "number");
810
+ });
811
+ }
812
+ createJob(providerAddress, evaluatorAddress, expireAt) {
813
+ return __async(this, null, function* () {
814
+ try {
815
+ const data = encodeFunctionData({
816
+ abi: acpAbi_default,
817
+ functionName: "createJob",
818
+ args: [
819
+ providerAddress,
820
+ evaluatorAddress,
821
+ Math.floor(expireAt.getTime() / 1e3)
822
+ ]
823
+ });
824
+ const { hash } = yield this.sessionKeyClient.sendUserOperation({
825
+ uo: {
826
+ target: this.contractAddress,
827
+ data
828
+ }
829
+ });
830
+ yield this.sessionKeyClient.waitForUserOperationTransaction({
831
+ hash
832
+ });
833
+ const jobId = yield this.getJobId(hash);
834
+ return { txHash: hash, jobId };
835
+ } catch (error) {
836
+ console.error(error);
837
+ throw new Error("Failed to create job");
838
+ }
839
+ });
840
+ }
841
+ approveAllowance(priceInWei) {
842
+ return __async(this, null, function* () {
843
+ const data = encodeFunctionData({
844
+ abi: erc20Abi,
845
+ functionName: "approve",
846
+ args: [this.contractAddress, priceInWei]
847
+ });
848
+ const { hash } = yield this.sessionKeyClient.sendUserOperation({
849
+ uo: {
850
+ target: this.virtualsTokenAddress,
851
+ data
852
+ }
853
+ });
854
+ yield this.sessionKeyClient.waitForUserOperationTransaction({
855
+ hash
856
+ });
857
+ return hash;
858
+ });
859
+ }
860
+ createMemo(jobId, content, type, isSecured, nextPhase) {
861
+ return __async(this, null, function* () {
862
+ let retries = 3;
863
+ while (retries > 0) {
864
+ try {
865
+ const data = encodeFunctionData({
866
+ abi: acpAbi_default,
867
+ functionName: "createMemo",
868
+ args: [jobId, content, type, isSecured, nextPhase]
869
+ });
870
+ const { hash } = yield this.sessionKeyClient.sendUserOperation({
871
+ uo: {
872
+ target: this.contractAddress,
873
+ data
874
+ }
875
+ });
876
+ yield this.sessionKeyClient.waitForUserOperationTransaction({
877
+ hash
878
+ });
879
+ return hash;
880
+ } catch (error) {
881
+ console.error(`failed to create memo ${jobId} ${content} ${error}`);
882
+ retries -= 1;
883
+ yield new Promise((resolve) => setTimeout(resolve, 2e3 * retries));
884
+ }
885
+ }
886
+ throw new Error("Failed to create memo");
887
+ });
888
+ }
889
+ signMemo(memoId, isApproved, reason) {
890
+ return __async(this, null, function* () {
891
+ let retries = 3;
892
+ while (retries > 0) {
893
+ try {
894
+ const data = encodeFunctionData({
895
+ abi: acpAbi_default,
896
+ functionName: "signMemo",
897
+ args: [memoId, isApproved, reason]
898
+ });
899
+ const { hash } = yield this.sessionKeyClient.sendUserOperation({
900
+ uo: {
901
+ target: this.contractAddress,
902
+ data
903
+ }
904
+ });
905
+ yield this.sessionKeyClient.waitForUserOperationTransaction({
906
+ hash
907
+ });
908
+ return hash;
909
+ } catch (error) {
910
+ console.error(`failed to sign memo ${error}`);
911
+ retries -= 1;
912
+ yield new Promise((resolve) => setTimeout(resolve, 2e3 * retries));
913
+ }
914
+ }
915
+ throw new Error("Failed to sign memo");
916
+ });
917
+ }
918
+ setBudget(jobId, budget) {
919
+ return __async(this, null, function* () {
920
+ try {
921
+ const data = encodeFunctionData({
922
+ abi: acpAbi_default,
923
+ functionName: "setBudget",
924
+ args: [jobId, budget]
925
+ });
926
+ const { hash } = yield this.sessionKeyClient.sendUserOperation({
927
+ uo: {
928
+ target: this.contractAddress,
929
+ data
930
+ }
931
+ });
932
+ yield this.sessionKeyClient.waitForUserOperationTransaction({
933
+ hash
934
+ });
935
+ return hash;
936
+ } catch (error) {
937
+ console.error(error);
938
+ throw new Error("Failed to set budget");
939
+ }
940
+ });
941
+ }
942
+ };
943
+ var acpContractClient_default = AcpContractClient;
944
+
945
+ // src/acpJob.ts
946
+ var AcpJob = class {
947
+ constructor(acpClient, id, clientAddress, providerAddress, evaluatorAddress, price, memos, phase) {
948
+ this.acpClient = acpClient;
949
+ this.id = id;
950
+ this.clientAddress = clientAddress;
951
+ this.providerAddress = providerAddress;
952
+ this.evaluatorAddress = evaluatorAddress;
953
+ this.price = price;
954
+ this.memos = memos;
955
+ this.phase = phase;
956
+ }
957
+ get serviceRequirement() {
958
+ var _a;
959
+ return (_a = this.memos.find((m) => m.nextPhase === 1 /* NEGOTIATION */)) == null ? void 0 : _a.content;
960
+ }
961
+ get deliverable() {
962
+ var _a;
963
+ return (_a = this.memos.find((m) => m.nextPhase === 4 /* COMPLETED */)) == null ? void 0 : _a.content;
964
+ }
965
+ get providerAgent() {
966
+ return this.acpClient.getAgent(this.providerAddress);
967
+ }
968
+ get clientAgent() {
969
+ return this.acpClient.getAgent(this.clientAddress);
970
+ }
971
+ get evaluatorAgent() {
972
+ return this.acpClient.getAgent(this.evaluatorAddress);
973
+ }
974
+ pay(amount, reason) {
975
+ return __async(this, null, function* () {
976
+ const memo = this.memos.find(
977
+ (m) => m.nextPhase === 2 /* TRANSACTION */
978
+ );
979
+ if (!memo) {
980
+ throw new Error("No transaction memo found");
981
+ }
982
+ return yield this.acpClient.payJob(this.id, amount, memo.id, reason);
983
+ });
984
+ }
985
+ respond(accept, reason) {
986
+ return __async(this, null, function* () {
987
+ const memo = this.memos.find(
988
+ (m) => m.nextPhase === 1 /* NEGOTIATION */
989
+ );
990
+ if (!memo) {
991
+ throw new Error("No negotiation memo found");
992
+ }
993
+ return yield this.acpClient.respondJob(this.id, memo.id, accept, reason);
994
+ });
995
+ }
996
+ deliver(deliverable) {
997
+ return __async(this, null, function* () {
998
+ const memo = this.memos.find(
999
+ (m) => m.nextPhase === 3 /* EVALUATION */
1000
+ );
1001
+ if (!memo) {
1002
+ throw new Error("No transaction memo found");
1003
+ }
1004
+ return yield this.acpClient.deliverJob(this.id, deliverable);
1005
+ });
1006
+ }
1007
+ evaluate(accept, reason) {
1008
+ return __async(this, null, function* () {
1009
+ const memo = this.memos.find((m) => m.nextPhase === 4 /* COMPLETED */);
1010
+ if (!memo) {
1011
+ throw new Error("No evaluation memo found");
1012
+ }
1013
+ return yield this.acpClient.acpContractClient.signMemo(
1014
+ memo.id,
1015
+ accept,
1016
+ reason
1017
+ );
1018
+ });
1019
+ }
1020
+ };
1021
+ var acpJob_default = AcpJob;
1022
+
1023
+ // src/acpMemo.ts
1024
+ var AcpMemo = class {
1025
+ constructor(acpClient, id, type, content, nextPhase) {
1026
+ this.acpClient = acpClient;
1027
+ this.id = id;
1028
+ this.type = type;
1029
+ this.content = content;
1030
+ this.nextPhase = nextPhase;
1031
+ }
1032
+ create(jobId, isSecured = true) {
1033
+ return __async(this, null, function* () {
1034
+ return yield this.acpClient.acpContractClient.createMemo(
1035
+ jobId,
1036
+ this.content,
1037
+ this.type,
1038
+ isSecured,
1039
+ this.nextPhase
1040
+ );
1041
+ });
1042
+ }
1043
+ sign(approved, reason) {
1044
+ return __async(this, null, function* () {
1045
+ return yield this.acpClient.acpContractClient.signMemo(
1046
+ this.id,
1047
+ approved,
1048
+ reason
1049
+ );
1050
+ });
1051
+ }
1052
+ };
1053
+ var acpMemo_default = AcpMemo;
1054
+
1055
+ // src/acpJobOffering.ts
1056
+ import Ajv from "ajv";
1057
+ var AcpJobOffering = class {
1058
+ constructor(acpClient, providerAddress, type, price, requirementSchema) {
1059
+ this.acpClient = acpClient;
1060
+ this.providerAddress = providerAddress;
1061
+ this.type = type;
1062
+ this.price = price;
1063
+ this.requirementSchema = requirementSchema;
1064
+ this.ajv = new Ajv({ allErrors: true });
1065
+ }
1066
+ initiateJob(_0, _1, _2) {
1067
+ return __async(this, arguments, function* (serviceRequirement, amount, evaluatorAddress, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
1068
+ if (this.requirementSchema) {
1069
+ const validator = this.ajv.compile(this.requirementSchema);
1070
+ const valid = validator(serviceRequirement);
1071
+ if (!valid) {
1072
+ throw new Error(this.ajv.errorsText(validator.errors));
1073
+ }
1074
+ }
1075
+ return yield this.acpClient.initiateJob(
1076
+ this.providerAddress,
1077
+ serviceRequirement,
1078
+ amount,
1079
+ evaluatorAddress,
1080
+ expiredAt
1081
+ );
1082
+ });
1083
+ }
1084
+ };
1085
+ var acpJobOffering_default = AcpJobOffering;
1086
+
1087
+ // src/acpClient.ts
1088
+ var AcpClient = class {
1089
+ constructor(options) {
1090
+ this.acpContractClient = options.acpContractClient;
1091
+ this.onNewTask = options.onNewTask;
1092
+ this.onEvaluate = options.onEvaluate || this.defaultOnEvaluate;
1093
+ this.acpUrl = this.acpContractClient.config.acpUrl;
1094
+ this.init();
1095
+ }
1096
+ defaultOnEvaluate(job) {
1097
+ return __async(this, null, function* () {
1098
+ yield job.evaluate(true, "Evaluated by default");
1099
+ });
1100
+ }
1101
+ init() {
1102
+ return __async(this, null, function* () {
1103
+ const socket = io(this.acpUrl, {
1104
+ auth: __spreadValues(__spreadValues({}, this.onNewTask && {
1105
+ walletAddress: this.acpContractClient.walletAddress
1106
+ }), this.onEvaluate !== this.defaultOnEvaluate && {
1107
+ evaluatorAddress: this.acpContractClient.walletAddress
1108
+ })
1109
+ });
1110
+ socket.on("roomJoined" /* ROOM_JOINED */, (_, callback) => {
1111
+ console.log("Joined ACP Room");
1112
+ callback(true);
1113
+ });
1114
+ socket.on(
1115
+ "onEvaluate" /* ON_EVALUATE */,
1116
+ (data, callback) => __async(this, null, function* () {
1117
+ callback(true);
1118
+ if (this.onEvaluate) {
1119
+ const job = new acpJob_default(
1120
+ this,
1121
+ data.id,
1122
+ data.clientAddress,
1123
+ data.providerAddress,
1124
+ data.evaluatorAddress,
1125
+ data.price,
1126
+ data.memos.map((memo) => {
1127
+ return new acpMemo_default(
1128
+ this,
1129
+ memo.id,
1130
+ memo.memoType,
1131
+ memo.content,
1132
+ memo.nextPhase
1133
+ );
1134
+ }),
1135
+ data.phase
1136
+ );
1137
+ this.onEvaluate(job);
1138
+ }
1139
+ })
1140
+ );
1141
+ socket.on(
1142
+ "onNewTask" /* ON_NEW_TASK */,
1143
+ (data, callback) => __async(this, null, function* () {
1144
+ callback(true);
1145
+ if (this.onNewTask) {
1146
+ const job = new acpJob_default(
1147
+ this,
1148
+ data.id,
1149
+ data.clientAddress,
1150
+ data.providerAddress,
1151
+ data.evaluatorAddress,
1152
+ data.price,
1153
+ data.memos.map((memo) => {
1154
+ return new acpMemo_default(
1155
+ this,
1156
+ memo.id,
1157
+ memo.memoType,
1158
+ memo.content,
1159
+ memo.nextPhase
1160
+ );
1161
+ }),
1162
+ data.phase
1163
+ );
1164
+ this.onNewTask(job);
1165
+ }
1166
+ })
1167
+ );
1168
+ const cleanup = () => __async(this, null, function* () {
1169
+ if (socket) {
1170
+ socket.disconnect();
1171
+ }
1172
+ process.exit(0);
1173
+ });
1174
+ process.on("SIGINT", cleanup);
1175
+ process.on("SIGTERM", cleanup);
1176
+ });
1177
+ }
1178
+ browseAgents(keyword, cluster) {
1179
+ return __async(this, null, function* () {
1180
+ let url = `${this.acpUrl}/api/agents?search=${keyword}&filters[walletAddress][$notIn]=${this.acpContractClient.walletAddress}`;
1181
+ if (cluster) {
1182
+ url += `&filters[cluster]=${cluster}`;
1183
+ }
1184
+ const response = yield fetch(url);
1185
+ const data = yield response.json();
1186
+ return data.data.map((agent) => {
1187
+ return {
1188
+ id: agent.id,
1189
+ name: agent.name,
1190
+ description: agent.description,
1191
+ offerings: agent.offerings.map((offering) => {
1192
+ return new acpJobOffering_default(
1193
+ this,
1194
+ agent.walletAddress,
1195
+ offering.name,
1196
+ offering.price,
1197
+ offering.requirementSchema
1198
+ );
1199
+ }),
1200
+ twitterHandle: agent.twitterHandle,
1201
+ walletAddress: agent.walletAddress
1202
+ };
1203
+ });
1204
+ });
1205
+ }
1206
+ initiateJob(_0, _1, _2, _3) {
1207
+ return __async(this, arguments, function* (providerAddress, serviceRequirement, amount, evaluatorAddress, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
1208
+ const { jobId } = yield this.acpContractClient.createJob(
1209
+ providerAddress,
1210
+ evaluatorAddress || this.acpContractClient.walletAddress,
1211
+ expiredAt
1212
+ );
1213
+ yield this.acpContractClient.setBudget(
1214
+ jobId,
1215
+ parseEther(amount.toString())
1216
+ );
1217
+ yield this.acpContractClient.createMemo(
1218
+ jobId,
1219
+ typeof serviceRequirement === "string" ? serviceRequirement : JSON.stringify(serviceRequirement),
1220
+ 0 /* MESSAGE */,
1221
+ true,
1222
+ 1 /* NEGOTIATION */
1223
+ );
1224
+ return jobId;
1225
+ });
1226
+ }
1227
+ respondJob(jobId, memoId, accept, reason) {
1228
+ return __async(this, null, function* () {
1229
+ yield this.acpContractClient.signMemo(memoId, accept, reason);
1230
+ return yield this.acpContractClient.createMemo(
1231
+ jobId,
1232
+ `Job ${jobId} accepted. ${reason != null ? reason : ""}`,
1233
+ 0 /* MESSAGE */,
1234
+ false,
1235
+ 2 /* TRANSACTION */
1236
+ );
1237
+ });
1238
+ }
1239
+ payJob(jobId, amount, memoId, reason) {
1240
+ return __async(this, null, function* () {
1241
+ yield this.acpContractClient.approveAllowance(
1242
+ parseEther(amount.toString())
1243
+ );
1244
+ yield this.acpContractClient.signMemo(memoId, true, reason);
1245
+ return yield this.acpContractClient.createMemo(
1246
+ jobId,
1247
+ `Payment of ${amount} made. ${reason != null ? reason : ""}`,
1248
+ 0 /* MESSAGE */,
1249
+ false,
1250
+ 3 /* EVALUATION */
1251
+ );
1252
+ });
1253
+ }
1254
+ deliverJob(jobId, deliverable) {
1255
+ return __async(this, null, function* () {
1256
+ return yield this.acpContractClient.createMemo(
1257
+ jobId,
1258
+ deliverable,
1259
+ 4 /* OBJECT_URL */,
1260
+ true,
1261
+ 4 /* COMPLETED */
1262
+ );
1263
+ });
1264
+ }
1265
+ getActiveJobs(page = 1, pageSize = 10) {
1266
+ return __async(this, null, function* () {
1267
+ let url = `${this.acpUrl}/api/jobs/active?pagination[page]=${page}&pagination[pageSize]=${pageSize}`;
1268
+ try {
1269
+ const response = yield fetch(url, {
1270
+ headers: {
1271
+ "wallet-address": this.acpContractClient.walletAddress
1272
+ }
1273
+ });
1274
+ const data = yield response.json();
1275
+ if (data.error) {
1276
+ throw new Error(data.error.message);
1277
+ }
1278
+ return data.data.map((job) => {
1279
+ return new acpJob_default(
1280
+ this,
1281
+ job.id,
1282
+ job.clientAddress,
1283
+ job.providerAddress,
1284
+ job.evaluatorAddress,
1285
+ job.price,
1286
+ job.memos.map((memo) => {
1287
+ return new acpMemo_default(
1288
+ this,
1289
+ memo.id,
1290
+ memo.memoType,
1291
+ memo.content,
1292
+ memo.nextPhase
1293
+ );
1294
+ }),
1295
+ job.phase
1296
+ );
1297
+ });
1298
+ } catch (error) {
1299
+ throw error;
1300
+ }
1301
+ });
1302
+ }
1303
+ getCompletedJobs(page = 1, pageSize = 10) {
1304
+ return __async(this, null, function* () {
1305
+ let url = `${this.acpUrl}/api/jobs/completed?pagination[page]=${page}&pagination[pageSize]=${pageSize}`;
1306
+ try {
1307
+ const response = yield fetch(url, {
1308
+ headers: {
1309
+ "wallet-address": this.acpContractClient.walletAddress
1310
+ }
1311
+ });
1312
+ const data = yield response.json();
1313
+ if (data.error) {
1314
+ throw new Error(data.error.message);
1315
+ }
1316
+ return data.data.map((job) => {
1317
+ return new acpJob_default(
1318
+ this,
1319
+ job.id,
1320
+ job.clientAddress,
1321
+ job.providerAddress,
1322
+ job.evaluatorAddress,
1323
+ job.price,
1324
+ job.memos.map((memo) => {
1325
+ return new acpMemo_default(
1326
+ this,
1327
+ memo.id,
1328
+ memo.memoType,
1329
+ memo.content,
1330
+ memo.nextPhase
1331
+ );
1332
+ }),
1333
+ job.phase
1334
+ );
1335
+ });
1336
+ } catch (error) {
1337
+ throw error;
1338
+ }
1339
+ });
1340
+ }
1341
+ getCancelledJobs(page = 1, pageSize = 10) {
1342
+ return __async(this, null, function* () {
1343
+ let url = `${this.acpUrl}/api/jobs/cancelled?pagination[page]=${page}&pagination[pageSize]=${pageSize}`;
1344
+ try {
1345
+ const response = yield fetch(url, {
1346
+ headers: {
1347
+ "wallet-address": this.acpContractClient.walletAddress
1348
+ }
1349
+ });
1350
+ const data = yield response.json();
1351
+ if (data.error) {
1352
+ throw new Error(data.error.message);
1353
+ }
1354
+ return data.data.map((job) => {
1355
+ return new acpJob_default(
1356
+ this,
1357
+ job.id,
1358
+ job.clientAddress,
1359
+ job.providerAddress,
1360
+ job.evaluatorAddress,
1361
+ job.price,
1362
+ job.memos.map((memo) => {
1363
+ return new acpMemo_default(
1364
+ this,
1365
+ memo.id,
1366
+ memo.memoType,
1367
+ memo.content,
1368
+ memo.nextPhase
1369
+ );
1370
+ }),
1371
+ job.phase
1372
+ );
1373
+ });
1374
+ } catch (error) {
1375
+ throw error;
1376
+ }
1377
+ });
1378
+ }
1379
+ getJobById(jobId) {
1380
+ return __async(this, null, function* () {
1381
+ let url = `${this.acpUrl}/api/jobs/${jobId}`;
1382
+ try {
1383
+ const response = yield fetch(url, {
1384
+ headers: {
1385
+ "wallet-address": this.acpContractClient.walletAddress
1386
+ }
1387
+ });
1388
+ const data = yield response.json();
1389
+ if (data.error) {
1390
+ throw new Error(data.error.message);
1391
+ }
1392
+ const job = data.data;
1393
+ if (!job) {
1394
+ return;
1395
+ }
1396
+ return new acpJob_default(
1397
+ this,
1398
+ job.id,
1399
+ job.clientAddress,
1400
+ job.providerAddress,
1401
+ job.evaluatorAddress,
1402
+ job.price,
1403
+ job.memos.map((memo) => {
1404
+ return new acpMemo_default(
1405
+ this,
1406
+ memo.id,
1407
+ memo.memoType,
1408
+ memo.content,
1409
+ memo.nextPhase
1410
+ );
1411
+ }),
1412
+ job.phase
1413
+ );
1414
+ } catch (error) {
1415
+ throw error;
1416
+ }
1417
+ });
1418
+ }
1419
+ getMemoById(jobId, memoId) {
1420
+ return __async(this, null, function* () {
1421
+ let url = `${this.acpUrl}/api/jobs/${jobId}/memos/${memoId}`;
1422
+ try {
1423
+ const response = yield fetch(url, {
1424
+ headers: {
1425
+ "wallet-address": this.acpContractClient.walletAddress
1426
+ }
1427
+ });
1428
+ const data = yield response.json();
1429
+ if (data.error) {
1430
+ throw new Error(data.error.message);
1431
+ }
1432
+ const memo = data.data;
1433
+ if (!memo) {
1434
+ return;
1435
+ }
1436
+ return new acpMemo_default(
1437
+ this,
1438
+ memo.id,
1439
+ memo.memoType,
1440
+ memo.content,
1441
+ memo.nextPhase
1442
+ );
1443
+ } catch (error) {
1444
+ throw error;
1445
+ }
1446
+ });
1447
+ }
1448
+ getAgent(walletAddress) {
1449
+ return __async(this, null, function* () {
1450
+ const url = `${this.acpUrl}/api/agents?filters[walletAddress]=${walletAddress}`;
1451
+ const response = yield fetch(url);
1452
+ const data = yield response.json();
1453
+ const agents = data.data || [];
1454
+ if (agents.length === 0) {
1455
+ return;
1456
+ }
1457
+ return agents[0];
1458
+ });
1459
+ }
1460
+ };
1461
+ var acpClient_default = AcpClient;
1462
+
1463
+ // src/configs.ts
1464
+ import { baseSepolia, base } from "@account-kit/infra";
1465
+ var baseSepoliaAcpConfig = {
1466
+ chain: baseSepolia,
1467
+ contractAddress: "0x2422c1c43451Eb69Ff49dfD39c4Dc8C5230fA1e6",
1468
+ virtualsTokenAddress: "0xbfAB80ccc15DF6fb7185f9498d6039317331846a",
1469
+ alchemyRpcUrl: "https://alchemy-proxy.virtuals.io/api/proxy/rpc",
1470
+ acpUrl: "https://acpx-staging.virtuals.io"
1471
+ };
1472
+
1473
+ // src/index.ts
1474
+ var index_default = acpClient_default;
1475
+ export {
1476
+ acpAbi_default as ACP_ABI,
1477
+ acpContractClient_default as AcpContractClient,
1478
+ acpJob_default as AcpJob,
1479
+ AcpJobPhases,
1480
+ acpMemo_default as AcpMemo,
1481
+ MemoType,
1482
+ baseSepoliaAcpConfig,
1483
+ index_default as default
1484
+ };