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