@the_ro_show/agent-ads-sdk 0.17.0 → 0.18.0

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/README.md CHANGED
@@ -495,16 +495,16 @@ The SDK automatically uses an optimized minimal payload format that reduces resp
495
495
 
496
496
  #### Response Formats
497
497
 
498
- The SDK supports three response formats:
498
+ The SDK supports three response formats that control both detail level and the number of ads returned:
499
499
 
500
500
  ```typescript
501
- // Minimal format (default, ~520B) - Essentials + relevance
501
+ // Minimal format (default) - 1 ad, essentials + relevance
502
502
  const ad = await client.decideFromContext({
503
503
  userMessage: "I need car insurance",
504
504
  response_format: 'minimal' // Optional, this is the default
505
505
  });
506
506
 
507
- // Returns:
507
+ // Returns a single ad object:
508
508
  {
509
509
  creative: { title, body, cta },
510
510
  click_url: string,
@@ -515,31 +515,47 @@ const ad = await client.decideFromContext({
515
515
  }
516
516
  ```
517
517
 
518
- For advanced use cases, you can request more detailed responses:
518
+ For multi-ad or detailed responses, use the `standard` or `verbose` formats:
519
519
 
520
520
  ```typescript
521
- // Standard format (645B) - Includes disclosure info
522
- const ad = await client.decide({
521
+ // Standard format up to 3 ads, includes disclosure info
522
+ const result = await client.decide({
523
523
  response_format: 'standard',
524
524
  // ... other params
525
525
  });
526
526
 
527
- // Verbose format (3.1KB) - Full response with all metadata
528
- const ad = await client.decide({
527
+ // Response wraps ads in an `ads` array:
528
+ // { ads: [{ creative, click_url, tracking_token, payout, disclosure, ... }] }
529
+ result.ads.forEach(ad => {
530
+ console.log(`${ad.creative.title} (relevance: ${ad.relevance_score})`);
531
+ });
532
+ ```
533
+
534
+ ```typescript
535
+ // Verbose format — up to 10 ads, adds auction + category metadata
536
+ const debug = await client.decide({
529
537
  response_format: 'verbose',
530
538
  // ... other params
531
539
  });
540
+
541
+ // Response wraps ads in a `units` array:
542
+ // { units: [{ ...all standard fields, campaign_id, auction_clearing_price, matched_categories }] }
543
+ debug.units.forEach(unit => {
544
+ console.log(`${unit.creative.title} — clearing price: ${unit.auction_clearing_price}`);
545
+ });
532
546
  ```
533
547
 
548
+ > **Tip:** All formats may return fewer ads than the maximum if fewer qualify after auction filtering. Always iterate the array rather than assuming a fixed count.
549
+
534
550
  #### Format Comparison
535
551
 
536
- | Format | Size | Use Case | Auto-impression |
537
- |--------|------|----------|-----------------|
538
- | **minimal** | ~520B | Production apps (default, includes relevance) | ✅ Yes |
539
- | **standard** | ~645B | Apps needing disclosure details | ❌ Manual |
540
- | **verbose** | ~3.1KB | Debugging, analytics | ❌ Manual |
552
+ | Format | Max Ads | Response Key | Size | Best For | Auto-impression |
553
+ |--------|---------|-------------|------|----------|-----------------|
554
+ | **minimal** | 1 | `ad` (object) | ~520B | Production apps (default) | ✅ Yes |
555
+ | **standard** | 3 | `ads` (array) | ~645B/ad | Showing multiple options, disclosure compliance | ❌ Manual |
556
+ | **verbose** | 10 | `units` (array) | ~3.1KB/ad | Debugging, analytics, auction inspection | ❌ Manual |
541
557
 
542
- **Note:** The minimal format automatically tracks impressions for you. When using standard or verbose formats with the raw `decide()` API, you must manually track impressions.
558
+ **Note:** The minimal format automatically tracks impressions. When using standard or verbose formats with the raw `decide()` API, you must track impressions manually.
543
559
 
544
560
  ## Advanced Features
545
561