@virtuals-protocol/acp-node 0.3.0-beta.38 → 0.3.0-beta.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -186,13 +186,15 @@ declare class AcpAccount {
186
186
  clientAddress: Address;
187
187
  providerAddress: Address;
188
188
  metadata: Record<string, any>;
189
- constructor(contractClient: BaseAcpContractClient, id: number, clientAddress: Address, providerAddress: Address, metadata: Record<string, any>);
189
+ expiryAt?: number | undefined;
190
+ constructor(contractClient: BaseAcpContractClient, id: number, clientAddress: Address, providerAddress: Address, metadata: Record<string, any>, expiryAt?: number | undefined);
190
191
  updateMetadata(metadata: Record<string, any>): Promise<OperationPayload>;
191
192
  }
192
193
 
193
194
  declare enum PriceType {
194
195
  FIXED = "fixed",
195
- PERCENTAGE = "percentage"
196
+ PERCENTAGE = "percentage",
197
+ SUBSCRIPTION = "subscription"
196
198
  }
197
199
  declare class AcpJobOffering {
198
200
  private readonly acpClient;
@@ -205,9 +207,28 @@ declare class AcpJobOffering {
205
207
  slaMinutes: number;
206
208
  requirement?: (Object | string) | undefined;
207
209
  deliverable?: (Object | string) | undefined;
210
+ subscriptionTiers: string[];
211
+ isPrivate: boolean;
208
212
  private ajv;
209
- constructor(acpClient: AcpClient, acpContractClient: BaseAcpContractClient, providerAddress: Address, name: string, price: number, priceType: PriceType, requiredFunds: boolean, slaMinutes: number, requirement?: (Object | string) | undefined, deliverable?: (Object | string) | undefined);
210
- initiateJob(serviceRequirement: Object | string, evaluatorAddress?: Address): Promise<number>;
213
+ constructor(acpClient: AcpClient, acpContractClient: BaseAcpContractClient, providerAddress: Address, name: string, price: number, priceType: PriceType | undefined, requiredFunds: boolean, slaMinutes: number, requirement?: (Object | string) | undefined, deliverable?: (Object | string) | undefined, subscriptionTiers?: string[], isPrivate?: boolean);
214
+ initiateJob(serviceRequirement: Object | string, evaluatorAddress?: Address, expiredAt?: Date, preferredSubscriptionTier?: string): Promise<number>;
215
+ private validateRequest;
216
+ private isSubscriptionRequired;
217
+ private validateSubscriptionTier;
218
+ /**
219
+ * Resolve the account to use for the job.
220
+ *
221
+ * For non-subscription jobs: returns the existing account if found.
222
+ * For subscription jobs, priority:
223
+ * 1. Valid account matching preferred tier
224
+ * 2. Any valid (non-expired) account
225
+ * 3. Expired/unactivated account (expiryAt = 0) to reuse
226
+ * 4. null — createJob will create a new one
227
+ */
228
+ private resolveAccount;
229
+ private findPreferredAccount;
230
+ private createJob;
231
+ private sendInitialMemo;
211
232
  }
212
233
 
213
234
  type AcpAgentArgs = {
@@ -220,6 +241,7 @@ type AcpAgentArgs = {
220
241
  twitterHandle?: string;
221
242
  metrics?: unknown;
222
243
  resources?: unknown;
244
+ subscriptions?: ISubscriptionTier[];
223
245
  };
224
246
  declare class AcpAgent {
225
247
  readonly id: string;
@@ -231,11 +253,12 @@ declare class AcpAgent {
231
253
  readonly twitterHandle?: string;
232
254
  readonly metrics?: unknown;
233
255
  readonly resources?: unknown;
256
+ readonly subscriptions: readonly ISubscriptionTier[];
234
257
  constructor(args: AcpAgentArgs);
235
258
  }
236
259
 
237
260
  declare class AcpMemo {
238
- private contractClient;
261
+ private acpClient;
239
262
  id: number;
240
263
  type: MemoType;
241
264
  content: string;
@@ -248,7 +271,9 @@ declare class AcpMemo {
248
271
  txHash?: `0x${string}` | undefined;
249
272
  signedTxHash?: `0x${string}` | undefined;
250
273
  state?: AcpMemoState | undefined;
251
- constructor(contractClient: BaseAcpContractClient, id: number, type: MemoType, content: string, nextPhase: AcpJobPhases, status: AcpMemoStatus, senderAddress: Address, signedReason?: string | undefined, expiry?: Date | undefined, payableDetails?: PayableDetails | undefined, txHash?: `0x${string}` | undefined, signedTxHash?: `0x${string}` | undefined, state?: AcpMemoState | undefined);
274
+ constructor(acpClient: AcpClient, id: number, type: MemoType, content: string, nextPhase: AcpJobPhases, status: AcpMemoStatus, senderAddress: Address, signedReason?: string | undefined, expiry?: Date | undefined, payableDetails?: PayableDetails | undefined, txHash?: `0x${string}` | undefined, signedTxHash?: `0x${string}` | undefined, state?: AcpMemoState | undefined);
275
+ static build(acpClient: AcpClient, id: number, type: MemoType, content: string, nextPhase: AcpJobPhases, status: AcpMemoStatus, senderAddress: Address, signedReason?: string, expiry?: Date, payableDetails?: PayableDetails, txHash?: `0x${string}`, signedTxHash?: `0x${string}`, state?: AcpMemoState): Promise<AcpMemo>;
276
+ getContent(): Promise<string>;
252
277
  create(jobId: number, isSecured?: boolean): Promise<OperationPayload>;
253
278
  sign(approved: boolean, reason?: string): Promise<{
254
279
  userOpHash: Address;
@@ -281,13 +306,13 @@ declare class AcpJob {
281
306
  phase: AcpJobPhases;
282
307
  context: Record<string, any>;
283
308
  contractAddress: Address;
284
- private _deliverable;
285
309
  netPayableAmount?: number | undefined;
286
310
  name: string | undefined;
287
311
  requirement: Record<string, any> | string | undefined;
288
312
  priceType: PriceType;
289
313
  priceValue: number;
290
- constructor(acpClient: AcpClient, id: number, clientAddress: Address, providerAddress: Address, evaluatorAddress: Address, price: number, priceTokenAddress: Address, memos: AcpMemo[], phase: AcpJobPhases, context: Record<string, any>, contractAddress: Address, _deliverable: DeliverablePayload | null, netPayableAmount?: number | undefined);
314
+ isPrivate: boolean;
315
+ constructor(acpClient: AcpClient, id: number, clientAddress: Address, providerAddress: Address, evaluatorAddress: Address, price: number, priceTokenAddress: Address, memos: AcpMemo[], phase: AcpJobPhases, context: Record<string, any>, contractAddress: Address, netPayableAmount?: number | undefined);
291
316
  get acpContractClient(): BaseAcpContractClient;
292
317
  get config(): AcpContractConfig;
293
318
  get baseFare(): Fare;
@@ -297,12 +322,17 @@ declare class AcpJob {
297
322
  get evaluatorAgent(): Promise<AcpAgent | null>;
298
323
  get account(): Promise<AcpAccount | null>;
299
324
  get latestMemo(): AcpMemo | undefined;
300
- getDeliverable(): Promise<DeliverablePayload | null>;
325
+ getDeliverable(): DeliverablePayload | null;
301
326
  createRequirement(content: string): Promise<{
302
327
  userOpHash: Address;
303
328
  txnHash: Address;
304
329
  }>;
305
- createPayableRequirement(content: string, type: MemoType.PAYABLE_REQUEST | MemoType.PAYABLE_TRANSFER_ESCROW | MemoType.PAYABLE_TRANSFER, amount: FareAmountBase, recipient: Address, expiredAt?: Date): Promise<{
330
+ acceptRequirement(memo: AcpMemo, reason?: string): Promise<{
331
+ userOpHash: Address;
332
+ txnHash: Address;
333
+ }>;
334
+ createPayableRequirement(content: string, type: MemoType.PAYABLE_REQUEST | MemoType.PAYABLE_TRANSFER_ESCROW | MemoType.PAYABLE_TRANSFER | MemoType.PAYABLE_REQUEST_SUBSCRIPTION, amount: FareAmountBase, recipient: Address, expiredAt?: Date, // 5 minutes
335
+ duration?: number): Promise<{
306
336
  userOpHash: Address;
307
337
  txnHash: Address;
308
338
  }>;
@@ -334,7 +364,14 @@ declare class AcpJob {
334
364
  userOpHash: Address;
335
365
  txnHash: Address;
336
366
  }>;
337
- evaluate(accept: boolean, reason?: string): Promise<void>;
367
+ paySubscription(reason?: string): Promise<{
368
+ userOpHash: Address;
369
+ txnHash: Address;
370
+ }>;
371
+ evaluate(accept: boolean, reason?: string): Promise<{
372
+ userOpHash: Address;
373
+ txnHash: Address;
374
+ }>;
338
375
  createNotification(content: string): Promise<{
339
376
  userOpHash: Address;
340
377
  txnHash: Address;
@@ -410,6 +447,28 @@ interface IAcpClientOptions {
410
447
  customRpcUrl?: string;
411
448
  skipSocketConnection?: boolean;
412
449
  }
450
+ type IAcpAccount = {
451
+ id: number;
452
+ clientAddress: Address;
453
+ providerAddress: Address;
454
+ metadata: Record<string, any>;
455
+ expiryAt?: number;
456
+ };
457
+ type ISubscriptionTier = {
458
+ name: string;
459
+ price: number;
460
+ duration: number;
461
+ };
462
+ type ISubscriptionCheckResponse = {
463
+ accounts: IAcpAccount[];
464
+ };
465
+ type SubscriptionPaymentRequirementResult = {
466
+ needsSubscriptionPayment: false;
467
+ action: "no_subscription_required" | "valid_subscription";
468
+ } | {
469
+ needsSubscriptionPayment: true;
470
+ tier: ISubscriptionTier;
471
+ };
413
472
  type X402Config = {
414
473
  url: string;
415
474
  };
@@ -537,7 +596,8 @@ declare enum MemoType {
537
596
  PAYABLE_TRANSFER = 7,// 7 - Direct payment transfer
538
597
  PAYABLE_TRANSFER_ESCROW = 8,// 8 - Escrowed payment transfer
539
598
  NOTIFICATION = 9,// 9 - Notification
540
- PAYABLE_NOTIFICATION = 10
599
+ PAYABLE_NOTIFICATION = 10,// 10 - Payable notification
600
+ PAYABLE_REQUEST_SUBSCRIPTION = 11
541
601
  }
542
602
  declare enum AcpJobPhases {
543
603
  REQUEST = 0,
@@ -575,11 +635,21 @@ declare abstract class BaseAcpContractClient {
575
635
  txnHash: Address;
576
636
  }>;
577
637
  abstract getJobId(createJobUserOpHash: Address, clientAddress: Address, providerAddress: Address): Promise<number>;
638
+ /**
639
+ * Returns a createAccount operation payload if the contract supports it (V2).
640
+ * Returns null for V1 or when the ABI does not include createAccount.
641
+ */
642
+ createAccount(providerAddress: Address, metadata: string): OperationPayload | null;
643
+ /**
644
+ * Returns the new account id from a createAccount user op receipt, or null if not supported.
645
+ */
646
+ getAccountIdFromUserOpHash(_userOpHash: Address): Promise<number | null>;
578
647
  get walletAddress(): `0x${string}`;
579
648
  createJobWithAccount(accountId: number, evaluatorAddress: Address, budgetBaseUnit: bigint, paymentTokenAddress: Address, expiredAt: Date, isX402Job?: boolean): OperationPayload;
580
649
  createJob(providerAddress: Address, evaluatorAddress: Address, expiredAt: Date, paymentTokenAddress: Address, budgetBaseUnit: bigint, metadata: string, isX402Job?: boolean): OperationPayload;
581
650
  approveAllowance(amountBaseUnit: bigint, paymentTokenAddress?: Address, targetAddress?: Address): OperationPayload;
582
- createPayableMemo(jobId: number, content: string, amountBaseUnit: bigint, recipient: Address, feeAmountBaseUnit: bigint, feeType: FeeType, nextPhase: AcpJobPhases, type: MemoType.PAYABLE_REQUEST | MemoType.PAYABLE_TRANSFER_ESCROW | MemoType.PAYABLE_TRANSFER | MemoType.PAYABLE_NOTIFICATION, expiredAt: Date, token?: Address, secured?: boolean): OperationPayload;
651
+ createPayableMemo(jobId: number, content: string, amountBaseUnit: bigint, recipient: Address, feeAmountBaseUnit: bigint, feeType: FeeType, nextPhase: AcpJobPhases, type: MemoType.PAYABLE_REQUEST | MemoType.PAYABLE_TRANSFER_ESCROW | MemoType.PAYABLE_TRANSFER | MemoType.PAYABLE_NOTIFICATION | MemoType.PAYABLE_REQUEST_SUBSCRIPTION, expiredAt: Date, token?: Address, secured?: boolean): OperationPayload;
652
+ createSubscriptionMemo(jobId: number, content: string, amountBaseUnit: bigint, recipient: Address, feeAmountBaseUnit: bigint, feeType: FeeType, duration: number, nextPhase: AcpJobPhases, expiredAt: Date, token?: Address): OperationPayload;
583
653
  createCrossChainPayableMemo(jobId: number, content: string, token: Address, amountBaseUnit: bigint, recipient: Address, feeAmountBaseUnit: bigint, feeType: FeeType, type: MemoType.PAYABLE_REQUEST | MemoType.PAYABLE_TRANSFER | MemoType.PAYABLE_NOTIFICATION, expiredAt: Date, nextPhase: AcpJobPhases, destinationEid: number, secured?: boolean): OperationPayload;
584
654
  createMemo(jobId: number, content: string, type: MemoType, isSecured: boolean, nextPhase: AcpJobPhases): OperationPayload;
585
655
  createMemoWithMetadata(jobId: number, content: string, type: MemoType, isSecured: boolean, nextPhase: AcpJobPhases, metadata: string): OperationPayload;
@@ -641,7 +711,7 @@ declare class AcpClient {
641
711
  private _hydrateJobs;
642
712
  private _hydrateAgent;
643
713
  browseAgents(keyword: string, options?: IAcpBrowseAgentsOptions): Promise<AcpAgent[]>;
644
- initiateJob(providerAddress: Address, serviceRequirement: Object | string, fareAmount: FareAmountBase, evaluatorAddress?: Address, expiredAt?: Date): Promise<number>;
714
+ initiateJob(providerAddress: Address, serviceRequirement: Object | string, fareAmount: FareAmountBase, evaluatorAddress?: Address, expiredAt?: Date, offeringName?: string, preferredSubscriptionTier?: string): Promise<number>;
645
715
  getActiveJobs(page?: number, pageSize?: number): Promise<AcpJob[]>;
646
716
  getPendingMemoJobs(page?: number, pageSize?: number): Promise<AcpJob[]>;
647
717
  getCompletedJobs(page?: number, pageSize?: number): Promise<AcpJob[]>;
@@ -650,7 +720,38 @@ declare class AcpClient {
650
720
  getMemoById(jobId: number, memoId: number): Promise<AcpMemo | null>;
651
721
  getAgent(walletAddress: Address, options?: IAcpGetAgentOptions): Promise<AcpAgent | null>;
652
722
  getAccountByJobId(jobId: number, acpContractClient?: BaseAcpContractClient): Promise<AcpAccount | null>;
653
- getByClientAndProvider(clientAddress: Address, providerAddress: Address, acpContractClient?: BaseAcpContractClient): Promise<AcpAccount | null>;
723
+ /**
724
+ * Gets account or subscription data for a client–provider pair.
725
+ * When offeringName is provided, the backend may return subscription tiers and accounts
726
+ * (ISubscriptionCheckResponse). When not provided, returns a single AcpAccount or null.
727
+ */
728
+ getByClientAndProvider(clientAddress: Address, providerAddress: Address, acpContractClient?: BaseAcpContractClient, offeringName?: string): Promise<AcpAccount | ISubscriptionCheckResponse | null>;
729
+ /**
730
+ * Narrows a backend response to ISubscriptionCheckResponse if it has an accounts array.
731
+ */
732
+ private _asSubscriptionCheck;
733
+ /**
734
+ * Resolve the account to use for the job.
735
+ *
736
+ * For subscription jobs, priority:
737
+ * 1. Valid account matching preferred tier
738
+ * 2. Any valid (non-expired) account
739
+ * 3. Unactivated account (expiryAt = 0) to reuse
740
+ * 4. null — createJob will create a new one
741
+ */
742
+ private _resolveSubscriptionAccount;
743
+ private _findPreferredAccount;
744
+ /**
745
+ * Returns the first subscription account with expiryAt > now, or null.
746
+ */
747
+ private _getValidSubscriptionAccountFromResponse;
748
+ /**
749
+ * Seller-facing: determines whether to create a subscription payment request memo.
750
+ * Call this when handling a new job (e.g. in REQUEST phase); then branch on
751
+ * needsSubscriptionPayment and use tier when true.
752
+ */
753
+ getSubscriptionPaymentRequirement(clientAddress: Address, providerAddress: Address, offeringName: string): Promise<SubscriptionPaymentRequirementResult>;
754
+ getValidSubscriptionAccount(providerAddress: Address, offeringName: string, clientAddress: Address, acpContractClient?: BaseAcpContractClient): Promise<AcpAccount | null>;
654
755
  createMemoContent(jobId: number, content: string): Promise<IAcpMemoContent>;
655
756
  getMemoContent(url: string): Promise<string>;
656
757
  getTokenBalances(): Promise<{
@@ -8939,7 +9040,7 @@ declare class AcpContractClient extends BaseAcpContractClient {
8939
9040
  getJobId(createJobUserOpHash: Address$1, clientAddress: Address$1, providerAddress: Address$1): Promise<number>;
8940
9041
  createJob(providerAddress: Address$1, evaluatorAddress: Address$1, expireAt: Date, paymentTokenAddress: Address$1, budgetBaseUnit: bigint, metadata: string, isX402Job?: boolean): OperationPayload;
8941
9042
  setBudgetWithPaymentToken(jobId: number, budgetBaseUnit: bigint, paymentTokenAddress?: Address$1): OperationPayload;
8942
- createPayableMemo(jobId: number, content: string, amountBaseUnit: bigint, recipient: Address$1, feeAmountBaseUnit: bigint, feeType: FeeType, nextPhase: AcpJobPhases, type: MemoType.PAYABLE_REQUEST | MemoType.PAYABLE_TRANSFER_ESCROW, expiredAt: Date, token?: Address$1, secured?: boolean): OperationPayload;
9043
+ createPayableMemo(jobId: number, content: string, amountBaseUnit: bigint, recipient: Address$1, feeAmountBaseUnit: bigint, feeType: FeeType, nextPhase: AcpJobPhases, type: MemoType.PAYABLE_REQUEST | MemoType.PAYABLE_TRANSFER_ESCROW | MemoType.PAYABLE_REQUEST_SUBSCRIPTION, expiredAt: Date, token?: Address$1, secured?: boolean): OperationPayload;
8943
9044
  createJobWithAccount(accountId: number, evaluatorAddress: Address$1, budgetBaseUnit: bigint, paymentTokenAddress: Address$1, expiredAt: Date, isX402Job?: boolean): OperationPayload;
8944
9045
  updateAccountMetadata(accountId: number, metadata: string): OperationPayload;
8945
9046
  updateJobX402Nonce(jobId: number, nonce: string): Promise<OffChainJob>;
@@ -8978,6 +9079,7 @@ declare class AcpContractClientV2 extends BaseAcpContractClient {
8978
9079
  txnHash: Address$1;
8979
9080
  }>;
8980
9081
  getJobId(createJobUserOpHash: Address$1, clientAddress: Address$1, providerAddress: Address$1): Promise<number>;
9082
+ getAccountIdFromUserOpHash(userOpHash: Address$1): Promise<number | null>;
8981
9083
  updateJobX402Nonce(jobId: number, nonce: string): Promise<OffChainJob>;
8982
9084
  generateX402Payment(payableRequest: X402PayableRequest, requirements: X402PayableRequirements): Promise<X402Payment>;
8983
9085
  performX402Request(url: string, version: string, budget?: string, signature?: string): Promise<X402PaymentResponse>;
@@ -8989,4 +9091,4 @@ declare class AcpContractClientV2 extends BaseAcpContractClient {
8989
9091
  sendTransaction(request: TransactionRequest): Promise<Hex>;
8990
9092
  }
8991
9093
 
8992
- export { ACP_ABI, AcpAgent, AcpAgentSort, AcpContractClient, AcpContractClientV2, AcpContractConfig, AcpError, AcpGraduationStatus, AcpJob, AcpJobPhases, AcpMemo, AcpMemoState, AcpMemoStatus, AcpOnlineStatus, BaseAcpContractClient, type DeliverablePayload, Fare, FareAmount, FareBigInt, MemoType, baseAcpConfig, baseAcpConfigV2, baseAcpX402Config, baseAcpX402ConfigV2, baseSepoliaAcpConfig, baseSepoliaAcpConfigV2, baseSepoliaAcpX402ConfigV2, AcpClient as default, ethFare, preparePayload, wethFare };
9094
+ export { ACP_ABI, AcpAccount, AcpAgent, AcpAgentSort, AcpContractClient, AcpContractClientV2, AcpContractConfig, AcpError, AcpGraduationStatus, AcpJob, AcpJobPhases, AcpMemo, AcpMemoState, AcpMemoStatus, AcpOnlineStatus, BaseAcpContractClient, type DeliverablePayload, Fare, FareAmount, FareBigInt, type IAcpAccount, type ISubscriptionCheckResponse, type ISubscriptionTier, MemoType, PriceType, type SubscriptionPaymentRequirementResult, baseAcpConfig, baseAcpConfigV2, baseAcpX402Config, baseAcpX402ConfigV2, baseSepoliaAcpConfig, baseSepoliaAcpConfigV2, baseSepoliaAcpX402ConfigV2, AcpClient as default, ethFare, preparePayload, wethFare };
package/dist/index.d.ts CHANGED
@@ -186,13 +186,15 @@ declare class AcpAccount {
186
186
  clientAddress: Address;
187
187
  providerAddress: Address;
188
188
  metadata: Record<string, any>;
189
- constructor(contractClient: BaseAcpContractClient, id: number, clientAddress: Address, providerAddress: Address, metadata: Record<string, any>);
189
+ expiryAt?: number | undefined;
190
+ constructor(contractClient: BaseAcpContractClient, id: number, clientAddress: Address, providerAddress: Address, metadata: Record<string, any>, expiryAt?: number | undefined);
190
191
  updateMetadata(metadata: Record<string, any>): Promise<OperationPayload>;
191
192
  }
192
193
 
193
194
  declare enum PriceType {
194
195
  FIXED = "fixed",
195
- PERCENTAGE = "percentage"
196
+ PERCENTAGE = "percentage",
197
+ SUBSCRIPTION = "subscription"
196
198
  }
197
199
  declare class AcpJobOffering {
198
200
  private readonly acpClient;
@@ -205,9 +207,28 @@ declare class AcpJobOffering {
205
207
  slaMinutes: number;
206
208
  requirement?: (Object | string) | undefined;
207
209
  deliverable?: (Object | string) | undefined;
210
+ subscriptionTiers: string[];
211
+ isPrivate: boolean;
208
212
  private ajv;
209
- constructor(acpClient: AcpClient, acpContractClient: BaseAcpContractClient, providerAddress: Address, name: string, price: number, priceType: PriceType, requiredFunds: boolean, slaMinutes: number, requirement?: (Object | string) | undefined, deliverable?: (Object | string) | undefined);
210
- initiateJob(serviceRequirement: Object | string, evaluatorAddress?: Address): Promise<number>;
213
+ constructor(acpClient: AcpClient, acpContractClient: BaseAcpContractClient, providerAddress: Address, name: string, price: number, priceType: PriceType | undefined, requiredFunds: boolean, slaMinutes: number, requirement?: (Object | string) | undefined, deliverable?: (Object | string) | undefined, subscriptionTiers?: string[], isPrivate?: boolean);
214
+ initiateJob(serviceRequirement: Object | string, evaluatorAddress?: Address, expiredAt?: Date, preferredSubscriptionTier?: string): Promise<number>;
215
+ private validateRequest;
216
+ private isSubscriptionRequired;
217
+ private validateSubscriptionTier;
218
+ /**
219
+ * Resolve the account to use for the job.
220
+ *
221
+ * For non-subscription jobs: returns the existing account if found.
222
+ * For subscription jobs, priority:
223
+ * 1. Valid account matching preferred tier
224
+ * 2. Any valid (non-expired) account
225
+ * 3. Expired/unactivated account (expiryAt = 0) to reuse
226
+ * 4. null — createJob will create a new one
227
+ */
228
+ private resolveAccount;
229
+ private findPreferredAccount;
230
+ private createJob;
231
+ private sendInitialMemo;
211
232
  }
212
233
 
213
234
  type AcpAgentArgs = {
@@ -220,6 +241,7 @@ type AcpAgentArgs = {
220
241
  twitterHandle?: string;
221
242
  metrics?: unknown;
222
243
  resources?: unknown;
244
+ subscriptions?: ISubscriptionTier[];
223
245
  };
224
246
  declare class AcpAgent {
225
247
  readonly id: string;
@@ -231,11 +253,12 @@ declare class AcpAgent {
231
253
  readonly twitterHandle?: string;
232
254
  readonly metrics?: unknown;
233
255
  readonly resources?: unknown;
256
+ readonly subscriptions: readonly ISubscriptionTier[];
234
257
  constructor(args: AcpAgentArgs);
235
258
  }
236
259
 
237
260
  declare class AcpMemo {
238
- private contractClient;
261
+ private acpClient;
239
262
  id: number;
240
263
  type: MemoType;
241
264
  content: string;
@@ -248,7 +271,9 @@ declare class AcpMemo {
248
271
  txHash?: `0x${string}` | undefined;
249
272
  signedTxHash?: `0x${string}` | undefined;
250
273
  state?: AcpMemoState | undefined;
251
- constructor(contractClient: BaseAcpContractClient, id: number, type: MemoType, content: string, nextPhase: AcpJobPhases, status: AcpMemoStatus, senderAddress: Address, signedReason?: string | undefined, expiry?: Date | undefined, payableDetails?: PayableDetails | undefined, txHash?: `0x${string}` | undefined, signedTxHash?: `0x${string}` | undefined, state?: AcpMemoState | undefined);
274
+ constructor(acpClient: AcpClient, id: number, type: MemoType, content: string, nextPhase: AcpJobPhases, status: AcpMemoStatus, senderAddress: Address, signedReason?: string | undefined, expiry?: Date | undefined, payableDetails?: PayableDetails | undefined, txHash?: `0x${string}` | undefined, signedTxHash?: `0x${string}` | undefined, state?: AcpMemoState | undefined);
275
+ static build(acpClient: AcpClient, id: number, type: MemoType, content: string, nextPhase: AcpJobPhases, status: AcpMemoStatus, senderAddress: Address, signedReason?: string, expiry?: Date, payableDetails?: PayableDetails, txHash?: `0x${string}`, signedTxHash?: `0x${string}`, state?: AcpMemoState): Promise<AcpMemo>;
276
+ getContent(): Promise<string>;
252
277
  create(jobId: number, isSecured?: boolean): Promise<OperationPayload>;
253
278
  sign(approved: boolean, reason?: string): Promise<{
254
279
  userOpHash: Address;
@@ -281,13 +306,13 @@ declare class AcpJob {
281
306
  phase: AcpJobPhases;
282
307
  context: Record<string, any>;
283
308
  contractAddress: Address;
284
- private _deliverable;
285
309
  netPayableAmount?: number | undefined;
286
310
  name: string | undefined;
287
311
  requirement: Record<string, any> | string | undefined;
288
312
  priceType: PriceType;
289
313
  priceValue: number;
290
- constructor(acpClient: AcpClient, id: number, clientAddress: Address, providerAddress: Address, evaluatorAddress: Address, price: number, priceTokenAddress: Address, memos: AcpMemo[], phase: AcpJobPhases, context: Record<string, any>, contractAddress: Address, _deliverable: DeliverablePayload | null, netPayableAmount?: number | undefined);
314
+ isPrivate: boolean;
315
+ constructor(acpClient: AcpClient, id: number, clientAddress: Address, providerAddress: Address, evaluatorAddress: Address, price: number, priceTokenAddress: Address, memos: AcpMemo[], phase: AcpJobPhases, context: Record<string, any>, contractAddress: Address, netPayableAmount?: number | undefined);
291
316
  get acpContractClient(): BaseAcpContractClient;
292
317
  get config(): AcpContractConfig;
293
318
  get baseFare(): Fare;
@@ -297,12 +322,17 @@ declare class AcpJob {
297
322
  get evaluatorAgent(): Promise<AcpAgent | null>;
298
323
  get account(): Promise<AcpAccount | null>;
299
324
  get latestMemo(): AcpMemo | undefined;
300
- getDeliverable(): Promise<DeliverablePayload | null>;
325
+ getDeliverable(): DeliverablePayload | null;
301
326
  createRequirement(content: string): Promise<{
302
327
  userOpHash: Address;
303
328
  txnHash: Address;
304
329
  }>;
305
- createPayableRequirement(content: string, type: MemoType.PAYABLE_REQUEST | MemoType.PAYABLE_TRANSFER_ESCROW | MemoType.PAYABLE_TRANSFER, amount: FareAmountBase, recipient: Address, expiredAt?: Date): Promise<{
330
+ acceptRequirement(memo: AcpMemo, reason?: string): Promise<{
331
+ userOpHash: Address;
332
+ txnHash: Address;
333
+ }>;
334
+ createPayableRequirement(content: string, type: MemoType.PAYABLE_REQUEST | MemoType.PAYABLE_TRANSFER_ESCROW | MemoType.PAYABLE_TRANSFER | MemoType.PAYABLE_REQUEST_SUBSCRIPTION, amount: FareAmountBase, recipient: Address, expiredAt?: Date, // 5 minutes
335
+ duration?: number): Promise<{
306
336
  userOpHash: Address;
307
337
  txnHash: Address;
308
338
  }>;
@@ -334,7 +364,14 @@ declare class AcpJob {
334
364
  userOpHash: Address;
335
365
  txnHash: Address;
336
366
  }>;
337
- evaluate(accept: boolean, reason?: string): Promise<void>;
367
+ paySubscription(reason?: string): Promise<{
368
+ userOpHash: Address;
369
+ txnHash: Address;
370
+ }>;
371
+ evaluate(accept: boolean, reason?: string): Promise<{
372
+ userOpHash: Address;
373
+ txnHash: Address;
374
+ }>;
338
375
  createNotification(content: string): Promise<{
339
376
  userOpHash: Address;
340
377
  txnHash: Address;
@@ -410,6 +447,28 @@ interface IAcpClientOptions {
410
447
  customRpcUrl?: string;
411
448
  skipSocketConnection?: boolean;
412
449
  }
450
+ type IAcpAccount = {
451
+ id: number;
452
+ clientAddress: Address;
453
+ providerAddress: Address;
454
+ metadata: Record<string, any>;
455
+ expiryAt?: number;
456
+ };
457
+ type ISubscriptionTier = {
458
+ name: string;
459
+ price: number;
460
+ duration: number;
461
+ };
462
+ type ISubscriptionCheckResponse = {
463
+ accounts: IAcpAccount[];
464
+ };
465
+ type SubscriptionPaymentRequirementResult = {
466
+ needsSubscriptionPayment: false;
467
+ action: "no_subscription_required" | "valid_subscription";
468
+ } | {
469
+ needsSubscriptionPayment: true;
470
+ tier: ISubscriptionTier;
471
+ };
413
472
  type X402Config = {
414
473
  url: string;
415
474
  };
@@ -537,7 +596,8 @@ declare enum MemoType {
537
596
  PAYABLE_TRANSFER = 7,// 7 - Direct payment transfer
538
597
  PAYABLE_TRANSFER_ESCROW = 8,// 8 - Escrowed payment transfer
539
598
  NOTIFICATION = 9,// 9 - Notification
540
- PAYABLE_NOTIFICATION = 10
599
+ PAYABLE_NOTIFICATION = 10,// 10 - Payable notification
600
+ PAYABLE_REQUEST_SUBSCRIPTION = 11
541
601
  }
542
602
  declare enum AcpJobPhases {
543
603
  REQUEST = 0,
@@ -575,11 +635,21 @@ declare abstract class BaseAcpContractClient {
575
635
  txnHash: Address;
576
636
  }>;
577
637
  abstract getJobId(createJobUserOpHash: Address, clientAddress: Address, providerAddress: Address): Promise<number>;
638
+ /**
639
+ * Returns a createAccount operation payload if the contract supports it (V2).
640
+ * Returns null for V1 or when the ABI does not include createAccount.
641
+ */
642
+ createAccount(providerAddress: Address, metadata: string): OperationPayload | null;
643
+ /**
644
+ * Returns the new account id from a createAccount user op receipt, or null if not supported.
645
+ */
646
+ getAccountIdFromUserOpHash(_userOpHash: Address): Promise<number | null>;
578
647
  get walletAddress(): `0x${string}`;
579
648
  createJobWithAccount(accountId: number, evaluatorAddress: Address, budgetBaseUnit: bigint, paymentTokenAddress: Address, expiredAt: Date, isX402Job?: boolean): OperationPayload;
580
649
  createJob(providerAddress: Address, evaluatorAddress: Address, expiredAt: Date, paymentTokenAddress: Address, budgetBaseUnit: bigint, metadata: string, isX402Job?: boolean): OperationPayload;
581
650
  approveAllowance(amountBaseUnit: bigint, paymentTokenAddress?: Address, targetAddress?: Address): OperationPayload;
582
- createPayableMemo(jobId: number, content: string, amountBaseUnit: bigint, recipient: Address, feeAmountBaseUnit: bigint, feeType: FeeType, nextPhase: AcpJobPhases, type: MemoType.PAYABLE_REQUEST | MemoType.PAYABLE_TRANSFER_ESCROW | MemoType.PAYABLE_TRANSFER | MemoType.PAYABLE_NOTIFICATION, expiredAt: Date, token?: Address, secured?: boolean): OperationPayload;
651
+ createPayableMemo(jobId: number, content: string, amountBaseUnit: bigint, recipient: Address, feeAmountBaseUnit: bigint, feeType: FeeType, nextPhase: AcpJobPhases, type: MemoType.PAYABLE_REQUEST | MemoType.PAYABLE_TRANSFER_ESCROW | MemoType.PAYABLE_TRANSFER | MemoType.PAYABLE_NOTIFICATION | MemoType.PAYABLE_REQUEST_SUBSCRIPTION, expiredAt: Date, token?: Address, secured?: boolean): OperationPayload;
652
+ createSubscriptionMemo(jobId: number, content: string, amountBaseUnit: bigint, recipient: Address, feeAmountBaseUnit: bigint, feeType: FeeType, duration: number, nextPhase: AcpJobPhases, expiredAt: Date, token?: Address): OperationPayload;
583
653
  createCrossChainPayableMemo(jobId: number, content: string, token: Address, amountBaseUnit: bigint, recipient: Address, feeAmountBaseUnit: bigint, feeType: FeeType, type: MemoType.PAYABLE_REQUEST | MemoType.PAYABLE_TRANSFER | MemoType.PAYABLE_NOTIFICATION, expiredAt: Date, nextPhase: AcpJobPhases, destinationEid: number, secured?: boolean): OperationPayload;
584
654
  createMemo(jobId: number, content: string, type: MemoType, isSecured: boolean, nextPhase: AcpJobPhases): OperationPayload;
585
655
  createMemoWithMetadata(jobId: number, content: string, type: MemoType, isSecured: boolean, nextPhase: AcpJobPhases, metadata: string): OperationPayload;
@@ -641,7 +711,7 @@ declare class AcpClient {
641
711
  private _hydrateJobs;
642
712
  private _hydrateAgent;
643
713
  browseAgents(keyword: string, options?: IAcpBrowseAgentsOptions): Promise<AcpAgent[]>;
644
- initiateJob(providerAddress: Address, serviceRequirement: Object | string, fareAmount: FareAmountBase, evaluatorAddress?: Address, expiredAt?: Date): Promise<number>;
714
+ initiateJob(providerAddress: Address, serviceRequirement: Object | string, fareAmount: FareAmountBase, evaluatorAddress?: Address, expiredAt?: Date, offeringName?: string, preferredSubscriptionTier?: string): Promise<number>;
645
715
  getActiveJobs(page?: number, pageSize?: number): Promise<AcpJob[]>;
646
716
  getPendingMemoJobs(page?: number, pageSize?: number): Promise<AcpJob[]>;
647
717
  getCompletedJobs(page?: number, pageSize?: number): Promise<AcpJob[]>;
@@ -650,7 +720,38 @@ declare class AcpClient {
650
720
  getMemoById(jobId: number, memoId: number): Promise<AcpMemo | null>;
651
721
  getAgent(walletAddress: Address, options?: IAcpGetAgentOptions): Promise<AcpAgent | null>;
652
722
  getAccountByJobId(jobId: number, acpContractClient?: BaseAcpContractClient): Promise<AcpAccount | null>;
653
- getByClientAndProvider(clientAddress: Address, providerAddress: Address, acpContractClient?: BaseAcpContractClient): Promise<AcpAccount | null>;
723
+ /**
724
+ * Gets account or subscription data for a client–provider pair.
725
+ * When offeringName is provided, the backend may return subscription tiers and accounts
726
+ * (ISubscriptionCheckResponse). When not provided, returns a single AcpAccount or null.
727
+ */
728
+ getByClientAndProvider(clientAddress: Address, providerAddress: Address, acpContractClient?: BaseAcpContractClient, offeringName?: string): Promise<AcpAccount | ISubscriptionCheckResponse | null>;
729
+ /**
730
+ * Narrows a backend response to ISubscriptionCheckResponse if it has an accounts array.
731
+ */
732
+ private _asSubscriptionCheck;
733
+ /**
734
+ * Resolve the account to use for the job.
735
+ *
736
+ * For subscription jobs, priority:
737
+ * 1. Valid account matching preferred tier
738
+ * 2. Any valid (non-expired) account
739
+ * 3. Unactivated account (expiryAt = 0) to reuse
740
+ * 4. null — createJob will create a new one
741
+ */
742
+ private _resolveSubscriptionAccount;
743
+ private _findPreferredAccount;
744
+ /**
745
+ * Returns the first subscription account with expiryAt > now, or null.
746
+ */
747
+ private _getValidSubscriptionAccountFromResponse;
748
+ /**
749
+ * Seller-facing: determines whether to create a subscription payment request memo.
750
+ * Call this when handling a new job (e.g. in REQUEST phase); then branch on
751
+ * needsSubscriptionPayment and use tier when true.
752
+ */
753
+ getSubscriptionPaymentRequirement(clientAddress: Address, providerAddress: Address, offeringName: string): Promise<SubscriptionPaymentRequirementResult>;
754
+ getValidSubscriptionAccount(providerAddress: Address, offeringName: string, clientAddress: Address, acpContractClient?: BaseAcpContractClient): Promise<AcpAccount | null>;
654
755
  createMemoContent(jobId: number, content: string): Promise<IAcpMemoContent>;
655
756
  getMemoContent(url: string): Promise<string>;
656
757
  getTokenBalances(): Promise<{
@@ -8939,7 +9040,7 @@ declare class AcpContractClient extends BaseAcpContractClient {
8939
9040
  getJobId(createJobUserOpHash: Address$1, clientAddress: Address$1, providerAddress: Address$1): Promise<number>;
8940
9041
  createJob(providerAddress: Address$1, evaluatorAddress: Address$1, expireAt: Date, paymentTokenAddress: Address$1, budgetBaseUnit: bigint, metadata: string, isX402Job?: boolean): OperationPayload;
8941
9042
  setBudgetWithPaymentToken(jobId: number, budgetBaseUnit: bigint, paymentTokenAddress?: Address$1): OperationPayload;
8942
- createPayableMemo(jobId: number, content: string, amountBaseUnit: bigint, recipient: Address$1, feeAmountBaseUnit: bigint, feeType: FeeType, nextPhase: AcpJobPhases, type: MemoType.PAYABLE_REQUEST | MemoType.PAYABLE_TRANSFER_ESCROW, expiredAt: Date, token?: Address$1, secured?: boolean): OperationPayload;
9043
+ createPayableMemo(jobId: number, content: string, amountBaseUnit: bigint, recipient: Address$1, feeAmountBaseUnit: bigint, feeType: FeeType, nextPhase: AcpJobPhases, type: MemoType.PAYABLE_REQUEST | MemoType.PAYABLE_TRANSFER_ESCROW | MemoType.PAYABLE_REQUEST_SUBSCRIPTION, expiredAt: Date, token?: Address$1, secured?: boolean): OperationPayload;
8943
9044
  createJobWithAccount(accountId: number, evaluatorAddress: Address$1, budgetBaseUnit: bigint, paymentTokenAddress: Address$1, expiredAt: Date, isX402Job?: boolean): OperationPayload;
8944
9045
  updateAccountMetadata(accountId: number, metadata: string): OperationPayload;
8945
9046
  updateJobX402Nonce(jobId: number, nonce: string): Promise<OffChainJob>;
@@ -8978,6 +9079,7 @@ declare class AcpContractClientV2 extends BaseAcpContractClient {
8978
9079
  txnHash: Address$1;
8979
9080
  }>;
8980
9081
  getJobId(createJobUserOpHash: Address$1, clientAddress: Address$1, providerAddress: Address$1): Promise<number>;
9082
+ getAccountIdFromUserOpHash(userOpHash: Address$1): Promise<number | null>;
8981
9083
  updateJobX402Nonce(jobId: number, nonce: string): Promise<OffChainJob>;
8982
9084
  generateX402Payment(payableRequest: X402PayableRequest, requirements: X402PayableRequirements): Promise<X402Payment>;
8983
9085
  performX402Request(url: string, version: string, budget?: string, signature?: string): Promise<X402PaymentResponse>;
@@ -8989,4 +9091,4 @@ declare class AcpContractClientV2 extends BaseAcpContractClient {
8989
9091
  sendTransaction(request: TransactionRequest): Promise<Hex>;
8990
9092
  }
8991
9093
 
8992
- export { ACP_ABI, AcpAgent, AcpAgentSort, AcpContractClient, AcpContractClientV2, AcpContractConfig, AcpError, AcpGraduationStatus, AcpJob, AcpJobPhases, AcpMemo, AcpMemoState, AcpMemoStatus, AcpOnlineStatus, BaseAcpContractClient, type DeliverablePayload, Fare, FareAmount, FareBigInt, MemoType, baseAcpConfig, baseAcpConfigV2, baseAcpX402Config, baseAcpX402ConfigV2, baseSepoliaAcpConfig, baseSepoliaAcpConfigV2, baseSepoliaAcpX402ConfigV2, AcpClient as default, ethFare, preparePayload, wethFare };
9094
+ export { ACP_ABI, AcpAccount, AcpAgent, AcpAgentSort, AcpContractClient, AcpContractClientV2, AcpContractConfig, AcpError, AcpGraduationStatus, AcpJob, AcpJobPhases, AcpMemo, AcpMemoState, AcpMemoStatus, AcpOnlineStatus, BaseAcpContractClient, type DeliverablePayload, Fare, FareAmount, FareBigInt, type IAcpAccount, type ISubscriptionCheckResponse, type ISubscriptionTier, MemoType, PriceType, type SubscriptionPaymentRequirementResult, baseAcpConfig, baseAcpConfigV2, baseAcpX402Config, baseAcpX402ConfigV2, baseSepoliaAcpConfig, baseSepoliaAcpConfigV2, baseSepoliaAcpX402ConfigV2, AcpClient as default, ethFare, preparePayload, wethFare };