agentmall 0.1.18 → 0.1.19

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/cli.js CHANGED
@@ -73,6 +73,7 @@ var AgentMall = class {
73
73
  purchases;
74
74
  payments;
75
75
  refunds;
76
+ managedAccounts;
76
77
  constructor(config = {}) {
77
78
  this.baseUrl = (config.baseUrl ?? BASE_URL).replace(/\/$/, "");
78
79
  this.apiSecret = config.apiSecret;
@@ -81,6 +82,7 @@ var AgentMall = class {
81
82
  this.purchases = new AgentMallPurchases(this);
82
83
  this.payments = new AgentMallPayments(this);
83
84
  this.refunds = new AgentMallRefunds(this);
85
+ this.managedAccounts = new AgentMallManagedAccounts(this);
84
86
  }
85
87
  /** @internal */
86
88
  hasApiSecret() {
@@ -132,6 +134,9 @@ var AgentMall = class {
132
134
  }
133
135
  throw new AgentMallError(response.status, body);
134
136
  }
137
+ if (response.status === 204) {
138
+ return void 0;
139
+ }
135
140
  return await response.json();
136
141
  }
137
142
  };
@@ -263,6 +268,58 @@ var AgentMallRefunds = class {
263
268
  return result.refunds;
264
269
  }
265
270
  };
271
+ var AgentMallManagedAccounts = class {
272
+ constructor(client) {
273
+ this.client = client;
274
+ }
275
+ async walletHeaders(account) {
276
+ const challenge = await this.client.request(
277
+ "POST",
278
+ "/api/managed-accounts/challenge",
279
+ {
280
+ body: {
281
+ address: account.address
282
+ }
283
+ }
284
+ );
285
+ const signature = await account.signMessage({
286
+ message: challenge.message
287
+ });
288
+ return {
289
+ "X-AgentMall-Wallet-Address": account.address,
290
+ "X-AgentMall-Auth-Challenge": challenge.challenge,
291
+ "X-AgentMall-Auth-Signature": signature
292
+ };
293
+ }
294
+ /** List managed retailer accounts. Requires either apiSecret or a wallet signer. */
295
+ async list(options) {
296
+ const result = await this.client.request("GET", "/api/managed-accounts", {
297
+ ...options?.account ? { headers: await this.walletHeaders(options.account) } : { auth: true }
298
+ });
299
+ return result.credentials;
300
+ }
301
+ /** Create a managed retailer account. Requires either apiSecret or a wallet signer. */
302
+ async create(body, options) {
303
+ return this.client.request("POST", "/api/managed-accounts", {
304
+ ...options?.account ? { headers: await this.walletHeaders(options.account) } : { auth: true },
305
+ body
306
+ });
307
+ }
308
+ /** Update a managed retailer account. Requires either apiSecret or a wallet signer. */
309
+ async update(body, options) {
310
+ return this.client.request("PUT", "/api/managed-accounts", {
311
+ ...options?.account ? { headers: await this.walletHeaders(options.account) } : { auth: true },
312
+ body
313
+ });
314
+ }
315
+ /** Delete a managed retailer account. Requires either apiSecret or a wallet signer. */
316
+ async delete(shortId, options) {
317
+ await this.client.request("DELETE", "/api/managed-accounts", {
318
+ ...options?.account ? { headers: await this.walletHeaders(options.account) } : { auth: true },
319
+ params: { short_id: shortId }
320
+ });
321
+ }
322
+ };
266
323
 
267
324
  // src/cli/ui.ts
268
325
  var c = {
@@ -423,6 +480,16 @@ function normalizeTrackingCarrier(carrier, trackingNumber) {
423
480
  }
424
481
  return carrierValue;
425
482
  }
483
+ function isAmazonStyleTracking(carrier, trackingNumber) {
484
+ return normalizeTrackingCarrier(carrier, trackingNumber) === "amazon";
485
+ }
486
+ function displayTrackingCarrier(carrier, trackingNumber) {
487
+ if (!carrier && !trackingNumber) return null;
488
+ if (isAmazonStyleTracking(carrier, trackingNumber)) {
489
+ return "Amazon Logistics";
490
+ }
491
+ return carrier;
492
+ }
426
493
  function trackingUrlForCarrier(carrier, trackingNumber) {
427
494
  if (!trackingNumber) return null;
428
495
  switch (normalizeTrackingCarrier(carrier, trackingNumber)) {
@@ -432,14 +499,47 @@ function trackingUrlForCarrier(carrier, trackingNumber) {
432
499
  return `https://www.fedex.com/fedextrack/?trknbr=${encodeURIComponent(trackingNumber)}`;
433
500
  case "usps":
434
501
  return `https://tools.usps.com/go/TrackConfirmAction?tLabels=${encodeURIComponent(trackingNumber)}`;
435
- case "amazon":
436
- return `https://www.amazon.com/progress-tracker/package/?trackingId=${encodeURIComponent(trackingNumber)}`;
437
502
  case "dhl":
438
503
  return `https://www.dhl.com/us-en/home/tracking.html?tracking-id=${encodeURIComponent(trackingNumber)}`;
439
504
  default:
440
505
  return null;
441
506
  }
442
507
  }
508
+ function isBuyerUsableTrackingUrl(url) {
509
+ if (!url) return false;
510
+ try {
511
+ const parsed = new URL(url);
512
+ const hostname = parsed.hostname.toLowerCase();
513
+ const path = parsed.pathname.toLowerCase();
514
+ if ((hostname === "amazon.com" || hostname === "www.amazon.com") && path.includes("/progress-tracker/")) {
515
+ return false;
516
+ }
517
+ } catch {
518
+ if (/amazon\.com\/progress-tracker\//i.test(url)) {
519
+ return false;
520
+ }
521
+ }
522
+ return true;
523
+ }
524
+ function hasAmazonTracking(tracking) {
525
+ const direct = compactTrackingValue(tracking);
526
+ if (direct) return direct.trim().toUpperCase().startsWith("TBA");
527
+ if (Array.isArray(tracking)) {
528
+ return tracking.some((entry) => hasAmazonTracking(entry));
529
+ }
530
+ if (!tracking || typeof tracking !== "object") {
531
+ return false;
532
+ }
533
+ const record = tracking;
534
+ const carrierRaw = compactTrackingValue(record.carrier) ?? compactTrackingValue(record.provider) ?? compactTrackingValue(record.shipper);
535
+ const number = compactTrackingValue(record.tracking_number) ?? compactTrackingValue(record.trackingNumber) ?? compactTrackingValue(record.number) ?? compactTrackingValue(record.code);
536
+ if (isAmazonStyleTracking(carrierRaw, number)) {
537
+ return true;
538
+ }
539
+ return ["shipments", "tracking_numbers", "trackingNumbers", "numbers"].some(
540
+ (nestedKey) => nestedKey in record && hasAmazonTracking(record[nestedKey])
541
+ );
542
+ }
443
543
  function trackingLines(tracking) {
444
544
  const direct = compactTrackingValue(tracking);
445
545
  if (direct) return [direct];
@@ -453,14 +553,22 @@ function trackingLines(tracking) {
453
553
  const carrierRaw = compactTrackingValue(record.carrier) ?? compactTrackingValue(record.provider) ?? compactTrackingValue(record.shipper);
454
554
  const number = compactTrackingValue(record.tracking_number) ?? compactTrackingValue(record.trackingNumber) ?? compactTrackingValue(record.number) ?? compactTrackingValue(record.code);
455
555
  const carrier = normalizeTrackingCarrier(carrierRaw, number);
456
- const url = compactTrackingValue(record.tracking_url) ?? compactTrackingValue(record.trackingUrl) ?? compactTrackingValue(record.url) ?? trackingUrlForCarrier(carrier, number);
556
+ const carrierLabel = displayTrackingCarrier(carrierRaw, number);
557
+ const urlCandidates = [
558
+ compactTrackingValue(record.tracking_url) ?? compactTrackingValue(record.trackingUrl),
559
+ compactTrackingValue(record.url),
560
+ compactTrackingValue(record.retailer_tracking_url),
561
+ compactTrackingValue(record.retailerTrackingUrl),
562
+ trackingUrlForCarrier(carrier, number)
563
+ ];
564
+ const url = urlCandidates.find((candidate) => isBuyerUsableTrackingUrl(candidate)) ?? null;
457
565
  const lines = [];
458
- if (carrier && number) {
459
- lines.push(`${carrier}: ${number}`);
566
+ if (carrierLabel && number) {
567
+ lines.push(`${carrierLabel}: ${number}`);
460
568
  } else if (number) {
461
569
  lines.push(number);
462
- } else if (carrier) {
463
- lines.push(carrier);
570
+ } else if (carrierLabel) {
571
+ lines.push(carrierLabel);
464
572
  }
465
573
  if (url) lines.push(url);
466
574
  for (const nestedKey of ["shipments", "tracking_numbers", "trackingNumbers", "numbers"]) {
@@ -639,6 +747,11 @@ function displayStatus(purchase) {
639
747
  for (const extra of tracking.slice(1)) {
640
748
  kv("", extra, { dim: true });
641
749
  }
750
+ if (hasAmazonTracking(purchase.tracking)) {
751
+ kv("", "Detailed tracking may appear once the package is in transit.", {
752
+ dim: true
753
+ });
754
+ }
642
755
  }
643
756
  kv("Created", new Date(purchase.createdAt).toLocaleString(), { dim: true });
644
757
  gap();
@@ -791,8 +904,9 @@ import { dirname, join } from "path";
791
904
  var STORE_PATH = join(homedir(), ".agentmall", "tokens.json");
792
905
  function emptyStore() {
793
906
  return {
794
- version: 1,
795
- purchases: {}
907
+ version: 2,
908
+ purchases: {},
909
+ preferredManagedAccounts: {}
796
910
  };
797
911
  }
798
912
  async function readStore() {
@@ -800,8 +914,9 @@ async function readStore() {
800
914
  const raw = await readFile(STORE_PATH, "utf8");
801
915
  const parsed = JSON.parse(raw);
802
916
  return {
803
- version: 1,
804
- purchases: parsed.purchases ?? {}
917
+ version: 2,
918
+ purchases: parsed.purchases ?? {},
919
+ preferredManagedAccounts: parsed.preferredManagedAccounts ?? {}
805
920
  };
806
921
  } catch {
807
922
  return emptyStore();
package/dist/index.cjs CHANGED
@@ -113,6 +113,7 @@ var AgentMall = class {
113
113
  purchases;
114
114
  payments;
115
115
  refunds;
116
+ managedAccounts;
116
117
  constructor(config = {}) {
117
118
  this.baseUrl = (config.baseUrl ?? BASE_URL).replace(/\/$/, "");
118
119
  this.apiSecret = config.apiSecret;
@@ -121,6 +122,7 @@ var AgentMall = class {
121
122
  this.purchases = new AgentMallPurchases(this);
122
123
  this.payments = new AgentMallPayments(this);
123
124
  this.refunds = new AgentMallRefunds(this);
125
+ this.managedAccounts = new AgentMallManagedAccounts(this);
124
126
  }
125
127
  /** @internal */
126
128
  hasApiSecret() {
@@ -172,6 +174,9 @@ var AgentMall = class {
172
174
  }
173
175
  throw new AgentMallError(response.status, body);
174
176
  }
177
+ if (response.status === 204) {
178
+ return void 0;
179
+ }
175
180
  return await response.json();
176
181
  }
177
182
  };
@@ -303,6 +308,58 @@ var AgentMallRefunds = class {
303
308
  return result.refunds;
304
309
  }
305
310
  };
311
+ var AgentMallManagedAccounts = class {
312
+ constructor(client) {
313
+ this.client = client;
314
+ }
315
+ async walletHeaders(account) {
316
+ const challenge = await this.client.request(
317
+ "POST",
318
+ "/api/managed-accounts/challenge",
319
+ {
320
+ body: {
321
+ address: account.address
322
+ }
323
+ }
324
+ );
325
+ const signature = await account.signMessage({
326
+ message: challenge.message
327
+ });
328
+ return {
329
+ "X-AgentMall-Wallet-Address": account.address,
330
+ "X-AgentMall-Auth-Challenge": challenge.challenge,
331
+ "X-AgentMall-Auth-Signature": signature
332
+ };
333
+ }
334
+ /** List managed retailer accounts. Requires either apiSecret or a wallet signer. */
335
+ async list(options) {
336
+ const result = await this.client.request("GET", "/api/managed-accounts", {
337
+ ...options?.account ? { headers: await this.walletHeaders(options.account) } : { auth: true }
338
+ });
339
+ return result.credentials;
340
+ }
341
+ /** Create a managed retailer account. Requires either apiSecret or a wallet signer. */
342
+ async create(body, options) {
343
+ return this.client.request("POST", "/api/managed-accounts", {
344
+ ...options?.account ? { headers: await this.walletHeaders(options.account) } : { auth: true },
345
+ body
346
+ });
347
+ }
348
+ /** Update a managed retailer account. Requires either apiSecret or a wallet signer. */
349
+ async update(body, options) {
350
+ return this.client.request("PUT", "/api/managed-accounts", {
351
+ ...options?.account ? { headers: await this.walletHeaders(options.account) } : { auth: true },
352
+ body
353
+ });
354
+ }
355
+ /** Delete a managed retailer account. Requires either apiSecret or a wallet signer. */
356
+ async delete(shortId, options) {
357
+ await this.client.request("DELETE", "/api/managed-accounts", {
358
+ ...options?.account ? { headers: await this.walletHeaders(options.account) } : { auth: true },
359
+ params: { short_id: shortId }
360
+ });
361
+ }
362
+ };
306
363
 
307
364
  // src/purchase.ts
308
365
  async function purchase(config) {
package/dist/index.d.cts CHANGED
@@ -62,6 +62,7 @@ type CreatePurchaseRequest = {
62
62
  delivery_address: DeliveryAddress;
63
63
  max_budget: number;
64
64
  buyer_email: string;
65
+ retailer_credentials_id?: string;
65
66
  idempotency_key?: string;
66
67
  metadata?: unknown;
67
68
  };
@@ -91,6 +92,7 @@ type Purchase = {
91
92
  items: PurchaseItem[];
92
93
  deliveryMethod?: string;
93
94
  tracking?: unknown;
95
+ retailerCredentialsId?: string;
94
96
  maxBudget: number;
95
97
  finalTotal?: number;
96
98
  merchantReferences?: string[];
@@ -141,6 +143,38 @@ type RefundFilters = {
141
143
  purchase_id?: string;
142
144
  status?: string;
143
145
  };
146
+ type ManagedAccount = {
147
+ id: string;
148
+ short_id: string;
149
+ email: string;
150
+ retailer: string | null;
151
+ has_totp?: boolean;
152
+ has_forwarding?: boolean;
153
+ retailer_config?: Record<string, unknown> | null;
154
+ forwarding_email: string;
155
+ created_at: string;
156
+ updated_at: string;
157
+ };
158
+ type ManagedAccountAuthChallenge = {
159
+ challenge: string;
160
+ message: string;
161
+ expiresAt: number;
162
+ };
163
+ type CreateManagedAccountRequest = {
164
+ email: string;
165
+ password?: string | null;
166
+ retailer?: string | null;
167
+ totp_secret?: string | null;
168
+ retailer_config?: Record<string, unknown> | null;
169
+ };
170
+ type UpdateManagedAccountRequest = {
171
+ short_id: string;
172
+ email?: string | null;
173
+ password?: string | null;
174
+ retailer?: string | null;
175
+ totp_secret?: string | null;
176
+ retailer_config?: Record<string, unknown> | null;
177
+ };
144
178
 
145
179
  declare class AgentMall {
146
180
  private baseUrl;
@@ -150,6 +184,7 @@ declare class AgentMall {
150
184
  purchases: AgentMallPurchases;
151
185
  payments: AgentMallPayments;
152
186
  refunds: AgentMallRefunds;
187
+ managedAccounts: AgentMallManagedAccounts;
153
188
  constructor(config?: AgentMallConfig);
154
189
  /** @internal */
155
190
  hasApiSecret(): boolean;
@@ -202,6 +237,27 @@ declare class AgentMallRefunds {
202
237
  /** List refunds. Requires apiSecret. */
203
238
  list(filters?: RefundFilters): Promise<Refund[]>;
204
239
  }
240
+ declare class AgentMallManagedAccounts {
241
+ private client;
242
+ constructor(client: AgentMall);
243
+ private walletHeaders;
244
+ /** List managed retailer accounts. Requires either apiSecret or a wallet signer. */
245
+ list(options?: {
246
+ account?: WalletAccount;
247
+ }): Promise<ManagedAccount[]>;
248
+ /** Create a managed retailer account. Requires either apiSecret or a wallet signer. */
249
+ create(body: CreateManagedAccountRequest, options?: {
250
+ account?: WalletAccount;
251
+ }): Promise<ManagedAccount>;
252
+ /** Update a managed retailer account. Requires either apiSecret or a wallet signer. */
253
+ update(body: UpdateManagedAccountRequest, options?: {
254
+ account?: WalletAccount;
255
+ }): Promise<ManagedAccount>;
256
+ /** Delete a managed retailer account. Requires either apiSecret or a wallet signer. */
257
+ delete(shortId: string, options?: {
258
+ account?: WalletAccount;
259
+ }): Promise<void>;
260
+ }
205
261
 
206
262
  type PurchaseConfig = CreatePurchaseRequest & {
207
263
  /** viem Account for MPP payment (from privateKeyToAccount or mppx resolveAccount). */
@@ -252,4 +308,4 @@ declare const BASE_URL = "https://api.agentmall.sh";
252
308
  declare const SERVICE_FEE_CENTS = 150;
253
309
  declare const SUPPORTED_RETAILERS: readonly ["amazon.com", "walmart.com", "target.com", "bestbuy.com", "homedepot.com", "ebay.com", "lowes.com", "wayfair.com", "acehardware.com", "1800flowers.com", "pokemoncenter.com"];
254
310
 
255
- export { AgentMall, type AgentMallConfig, AgentMallError, BASE_URL, ConflictError, type CreatePurchaseRequest, type CreatePurchaseResponse, type DeliveryAddress, type Payment, type PaymentFilters, PaymentRequiredError, type ProductLookup, type ProductVariant, type Purchase, type PurchaseFilters, type PurchaseItem, type PurchaseItemInput, type PurchaseLifecycleStatus, type PurchaseStatusChallenge, RateLimitError, type Refund, type RefundFilters, type RefundStatusChallenge, SERVICE_FEE_CENTS, SUPPORTED_RETAILERS, ValidationError, type VariantSelection, type WalletAccount, purchase };
311
+ export { AgentMall, type AgentMallConfig, AgentMallError, BASE_URL, ConflictError, type CreateManagedAccountRequest, type CreatePurchaseRequest, type CreatePurchaseResponse, type DeliveryAddress, type ManagedAccount, type ManagedAccountAuthChallenge, type Payment, type PaymentFilters, PaymentRequiredError, type ProductLookup, type ProductVariant, type Purchase, type PurchaseFilters, type PurchaseItem, type PurchaseItemInput, type PurchaseLifecycleStatus, type PurchaseStatusChallenge, RateLimitError, type Refund, type RefundFilters, type RefundStatusChallenge, SERVICE_FEE_CENTS, SUPPORTED_RETAILERS, type UpdateManagedAccountRequest, ValidationError, type VariantSelection, type WalletAccount, purchase };
package/dist/index.d.ts CHANGED
@@ -62,6 +62,7 @@ type CreatePurchaseRequest = {
62
62
  delivery_address: DeliveryAddress;
63
63
  max_budget: number;
64
64
  buyer_email: string;
65
+ retailer_credentials_id?: string;
65
66
  idempotency_key?: string;
66
67
  metadata?: unknown;
67
68
  };
@@ -91,6 +92,7 @@ type Purchase = {
91
92
  items: PurchaseItem[];
92
93
  deliveryMethod?: string;
93
94
  tracking?: unknown;
95
+ retailerCredentialsId?: string;
94
96
  maxBudget: number;
95
97
  finalTotal?: number;
96
98
  merchantReferences?: string[];
@@ -141,6 +143,38 @@ type RefundFilters = {
141
143
  purchase_id?: string;
142
144
  status?: string;
143
145
  };
146
+ type ManagedAccount = {
147
+ id: string;
148
+ short_id: string;
149
+ email: string;
150
+ retailer: string | null;
151
+ has_totp?: boolean;
152
+ has_forwarding?: boolean;
153
+ retailer_config?: Record<string, unknown> | null;
154
+ forwarding_email: string;
155
+ created_at: string;
156
+ updated_at: string;
157
+ };
158
+ type ManagedAccountAuthChallenge = {
159
+ challenge: string;
160
+ message: string;
161
+ expiresAt: number;
162
+ };
163
+ type CreateManagedAccountRequest = {
164
+ email: string;
165
+ password?: string | null;
166
+ retailer?: string | null;
167
+ totp_secret?: string | null;
168
+ retailer_config?: Record<string, unknown> | null;
169
+ };
170
+ type UpdateManagedAccountRequest = {
171
+ short_id: string;
172
+ email?: string | null;
173
+ password?: string | null;
174
+ retailer?: string | null;
175
+ totp_secret?: string | null;
176
+ retailer_config?: Record<string, unknown> | null;
177
+ };
144
178
 
145
179
  declare class AgentMall {
146
180
  private baseUrl;
@@ -150,6 +184,7 @@ declare class AgentMall {
150
184
  purchases: AgentMallPurchases;
151
185
  payments: AgentMallPayments;
152
186
  refunds: AgentMallRefunds;
187
+ managedAccounts: AgentMallManagedAccounts;
153
188
  constructor(config?: AgentMallConfig);
154
189
  /** @internal */
155
190
  hasApiSecret(): boolean;
@@ -202,6 +237,27 @@ declare class AgentMallRefunds {
202
237
  /** List refunds. Requires apiSecret. */
203
238
  list(filters?: RefundFilters): Promise<Refund[]>;
204
239
  }
240
+ declare class AgentMallManagedAccounts {
241
+ private client;
242
+ constructor(client: AgentMall);
243
+ private walletHeaders;
244
+ /** List managed retailer accounts. Requires either apiSecret or a wallet signer. */
245
+ list(options?: {
246
+ account?: WalletAccount;
247
+ }): Promise<ManagedAccount[]>;
248
+ /** Create a managed retailer account. Requires either apiSecret or a wallet signer. */
249
+ create(body: CreateManagedAccountRequest, options?: {
250
+ account?: WalletAccount;
251
+ }): Promise<ManagedAccount>;
252
+ /** Update a managed retailer account. Requires either apiSecret or a wallet signer. */
253
+ update(body: UpdateManagedAccountRequest, options?: {
254
+ account?: WalletAccount;
255
+ }): Promise<ManagedAccount>;
256
+ /** Delete a managed retailer account. Requires either apiSecret or a wallet signer. */
257
+ delete(shortId: string, options?: {
258
+ account?: WalletAccount;
259
+ }): Promise<void>;
260
+ }
205
261
 
206
262
  type PurchaseConfig = CreatePurchaseRequest & {
207
263
  /** viem Account for MPP payment (from privateKeyToAccount or mppx resolveAccount). */
@@ -252,4 +308,4 @@ declare const BASE_URL = "https://api.agentmall.sh";
252
308
  declare const SERVICE_FEE_CENTS = 150;
253
309
  declare const SUPPORTED_RETAILERS: readonly ["amazon.com", "walmart.com", "target.com", "bestbuy.com", "homedepot.com", "ebay.com", "lowes.com", "wayfair.com", "acehardware.com", "1800flowers.com", "pokemoncenter.com"];
254
310
 
255
- export { AgentMall, type AgentMallConfig, AgentMallError, BASE_URL, ConflictError, type CreatePurchaseRequest, type CreatePurchaseResponse, type DeliveryAddress, type Payment, type PaymentFilters, PaymentRequiredError, type ProductLookup, type ProductVariant, type Purchase, type PurchaseFilters, type PurchaseItem, type PurchaseItemInput, type PurchaseLifecycleStatus, type PurchaseStatusChallenge, RateLimitError, type Refund, type RefundFilters, type RefundStatusChallenge, SERVICE_FEE_CENTS, SUPPORTED_RETAILERS, ValidationError, type VariantSelection, type WalletAccount, purchase };
311
+ export { AgentMall, type AgentMallConfig, AgentMallError, BASE_URL, ConflictError, type CreateManagedAccountRequest, type CreatePurchaseRequest, type CreatePurchaseResponse, type DeliveryAddress, type ManagedAccount, type ManagedAccountAuthChallenge, type Payment, type PaymentFilters, PaymentRequiredError, type ProductLookup, type ProductVariant, type Purchase, type PurchaseFilters, type PurchaseItem, type PurchaseItemInput, type PurchaseLifecycleStatus, type PurchaseStatusChallenge, RateLimitError, type Refund, type RefundFilters, type RefundStatusChallenge, SERVICE_FEE_CENTS, SUPPORTED_RETAILERS, type UpdateManagedAccountRequest, ValidationError, type VariantSelection, type WalletAccount, purchase };
package/dist/index.js CHANGED
@@ -68,6 +68,7 @@ var AgentMall = class {
68
68
  purchases;
69
69
  payments;
70
70
  refunds;
71
+ managedAccounts;
71
72
  constructor(config = {}) {
72
73
  this.baseUrl = (config.baseUrl ?? BASE_URL).replace(/\/$/, "");
73
74
  this.apiSecret = config.apiSecret;
@@ -76,6 +77,7 @@ var AgentMall = class {
76
77
  this.purchases = new AgentMallPurchases(this);
77
78
  this.payments = new AgentMallPayments(this);
78
79
  this.refunds = new AgentMallRefunds(this);
80
+ this.managedAccounts = new AgentMallManagedAccounts(this);
79
81
  }
80
82
  /** @internal */
81
83
  hasApiSecret() {
@@ -127,6 +129,9 @@ var AgentMall = class {
127
129
  }
128
130
  throw new AgentMallError(response.status, body);
129
131
  }
132
+ if (response.status === 204) {
133
+ return void 0;
134
+ }
130
135
  return await response.json();
131
136
  }
132
137
  };
@@ -258,6 +263,58 @@ var AgentMallRefunds = class {
258
263
  return result.refunds;
259
264
  }
260
265
  };
266
+ var AgentMallManagedAccounts = class {
267
+ constructor(client) {
268
+ this.client = client;
269
+ }
270
+ async walletHeaders(account) {
271
+ const challenge = await this.client.request(
272
+ "POST",
273
+ "/api/managed-accounts/challenge",
274
+ {
275
+ body: {
276
+ address: account.address
277
+ }
278
+ }
279
+ );
280
+ const signature = await account.signMessage({
281
+ message: challenge.message
282
+ });
283
+ return {
284
+ "X-AgentMall-Wallet-Address": account.address,
285
+ "X-AgentMall-Auth-Challenge": challenge.challenge,
286
+ "X-AgentMall-Auth-Signature": signature
287
+ };
288
+ }
289
+ /** List managed retailer accounts. Requires either apiSecret or a wallet signer. */
290
+ async list(options) {
291
+ const result = await this.client.request("GET", "/api/managed-accounts", {
292
+ ...options?.account ? { headers: await this.walletHeaders(options.account) } : { auth: true }
293
+ });
294
+ return result.credentials;
295
+ }
296
+ /** Create a managed retailer account. Requires either apiSecret or a wallet signer. */
297
+ async create(body, options) {
298
+ return this.client.request("POST", "/api/managed-accounts", {
299
+ ...options?.account ? { headers: await this.walletHeaders(options.account) } : { auth: true },
300
+ body
301
+ });
302
+ }
303
+ /** Update a managed retailer account. Requires either apiSecret or a wallet signer. */
304
+ async update(body, options) {
305
+ return this.client.request("PUT", "/api/managed-accounts", {
306
+ ...options?.account ? { headers: await this.walletHeaders(options.account) } : { auth: true },
307
+ body
308
+ });
309
+ }
310
+ /** Delete a managed retailer account. Requires either apiSecret or a wallet signer. */
311
+ async delete(shortId, options) {
312
+ await this.client.request("DELETE", "/api/managed-accounts", {
313
+ ...options?.account ? { headers: await this.walletHeaders(options.account) } : { auth: true },
314
+ params: { short_id: shortId }
315
+ });
316
+ }
317
+ };
261
318
 
262
319
  // src/purchase.ts
263
320
  async function purchase(config) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentmall",
3
- "version": "0.1.18",
3
+ "version": "0.1.19",
4
4
  "description": "SDK and CLI for the AgentMall API — let AI agents buy physical products from US retailers",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",