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