@the_ro_show/agent-ads-sdk 0.14.0 → 0.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -368,6 +368,65 @@ const ad = await client.decideFromContext({
368
368
  });
369
369
  ```
370
370
 
371
+ ## Performance Optimization
372
+
373
+ ### Payload Optimization (v0.14.0+)
374
+
375
+ The SDK automatically uses an optimized minimal payload format that reduces response size by **84%** (from 3.2KB to ~520B) while maintaining all essential functionality including relevance scores. This improves:
376
+
377
+ - **Network efficiency:** 6x less data transfer
378
+ - **Response speed:** Faster parsing and processing
379
+ - **Mobile performance:** Lower bandwidth usage
380
+ - **Cost savings:** Reduced data transfer costs
381
+
382
+ #### Response Formats
383
+
384
+ The SDK supports three response formats:
385
+
386
+ ```typescript
387
+ // Minimal format (default, ~520B) - Essentials + relevance
388
+ const ad = await client.decideFromContext({
389
+ userMessage: "I need car insurance",
390
+ response_format: 'minimal' // Optional, this is the default
391
+ });
392
+
393
+ // Returns:
394
+ {
395
+ creative: { title, body, cta },
396
+ click_url: string,
397
+ tracking_token: string,
398
+ advertiser_id: string,
399
+ payout: number,
400
+ relevance_score: number // 0.0-1.0 for frontend filtering
401
+ }
402
+ ```
403
+
404
+ For advanced use cases, you can request more detailed responses:
405
+
406
+ ```typescript
407
+ // Standard format (645B) - Includes disclosure info
408
+ const ad = await client.decide({
409
+ response_format: 'standard',
410
+ // ... other params
411
+ });
412
+
413
+ // Verbose format (3.1KB) - Full response with all metadata
414
+ const ad = await client.decide({
415
+ response_format: 'verbose',
416
+ // ... other params
417
+ });
418
+ ```
419
+
420
+ #### Format Comparison
421
+
422
+ | Format | Size | Use Case | Auto-impression |
423
+ |--------|------|----------|-----------------|
424
+ | **minimal** | ~520B | Production apps (default, includes relevance) | ✅ Yes |
425
+ | **standard** | ~645B | Apps needing disclosure details | ❌ Manual |
426
+ | **verbose** | ~3.1KB | Debugging, analytics | ❌ Manual |
427
+
428
+ **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.
429
+
371
430
  ## Advanced Features
372
431
 
373
432
  ### Multi-Turn Conversations
@@ -497,6 +556,38 @@ Use test API keys (`am_test_...`) for development and testing. Test keys:
497
556
 
498
557
  Switch to live keys (`am_live_...`) when deploying to production.
499
558
 
559
+ ## 🤖 Claude Code Integration
560
+
561
+ Building with Claude Code? We've created ready-to-use prompts for seamless integration.
562
+
563
+ ### Quick Start (One Line)
564
+
565
+ ```
566
+ I want to add AttentionMarket ads to my AI app. Credentials:
567
+ - API Key: am_test_YOUR_KEY
568
+ - Agent ID: agt_YOUR_ID
569
+ Create a simple getRelevantAd(message) function that returns ads only when relevant (score>0.7).
570
+ ```
571
+
572
+ ### Full Integration Guide
573
+
574
+ 📖 **[Claude Code Integration Guide](CLAUDE_CODE_INTEGRATION.md)** — Copy-paste prompts for:
575
+ - Natural conversation integration
576
+ - Advanced filtering & brand safety
577
+ - Testing & analytics setup
578
+ - Mobile app integration
579
+ - Common patterns & best practices
580
+
581
+ ### Performance Metrics
582
+
583
+ | Metric | Expected Performance |
584
+ |--------|---------------------|
585
+ | **CTR** | 5-12% average |
586
+ | **Revenue/Click** | $0.50 - $15.00 |
587
+ | **Fill Rate** | 40-60% |
588
+ | **API Latency** | < 100ms p95 |
589
+ | **Payload Size** | ~520 bytes |
590
+
500
591
  ## Support
501
592
 
502
593
  - **Documentation:** [docs.attentionmarket.ai](https://docs.attentionmarket.ai)
package/dist/index.d.mts CHANGED
@@ -550,6 +550,8 @@ interface AdResponse {
550
550
  tracking_url?: string;
551
551
  /** Tracking token for event tracking */
552
552
  tracking_token: string;
553
+ /** Relevance score (0.0-1.0) for frontend rendering decisions */
554
+ relevance_score?: number;
553
555
  /** Disclosure information */
554
556
  disclosure: Disclosure;
555
557
  /** Full ad unit (for advanced usage) */
package/dist/index.d.ts CHANGED
@@ -550,6 +550,8 @@ interface AdResponse {
550
550
  tracking_url?: string;
551
551
  /** Tracking token for event tracking */
552
552
  tracking_token: string;
553
+ /** Relevance score (0.0-1.0) for frontend rendering decisions */
554
+ relevance_score?: number;
553
555
  /** Disclosure information */
554
556
  disclosure: Disclosure;
555
557
  /** Full ad unit (for advanced usage) */
package/dist/index.js CHANGED
@@ -597,17 +597,22 @@ var AttentionMarketClient = class {
597
597
  ...params.optimizeFor && { optimizeFor: params.optimizeFor }
598
598
  };
599
599
  const response = await this.decideRaw(request, options);
600
- if (response.creative) {
601
- try {
602
- await this.track({
603
- event_id: `evt_${generateUUID()}`,
604
- event_type: "impression",
605
- occurred_at: (/* @__PURE__ */ new Date()).toISOString(),
606
- agent_id: this.agentId,
607
- tracking_token: response.tracking_token
608
- });
609
- } catch (error) {
610
- console.warn("[AttentionMarket] Failed to auto-track impression:", error);
600
+ if (response && response.creative) {
601
+ if (response["_meta"]) {
602
+ try {
603
+ await this.track({
604
+ event_id: `evt_${generateUUID()}`,
605
+ event_type: "impression",
606
+ occurred_at: (/* @__PURE__ */ new Date()).toISOString(),
607
+ agent_id: this.agentId,
608
+ request_id: response["_meta"]["request_id"],
609
+ decision_id: response["_meta"]["decision_id"],
610
+ unit_id: response["_meta"]["unit_id"],
611
+ tracking_token: response.tracking_token
612
+ });
613
+ } catch (error) {
614
+ console.warn("[AttentionMarket] Failed to auto-track impression:", error);
615
+ }
611
616
  }
612
617
  const adResponse2 = {
613
618
  request_id: request.request_id,
@@ -620,6 +625,7 @@ var AttentionMarketClient = class {
620
625
  tracking_url: response.click_url || "",
621
626
  // Same as click_url
622
627
  tracking_token: response.tracking_token || "",
628
+ ...response.relevance_score !== void 0 && { relevance_score: response.relevance_score },
623
629
  disclosure: response.disclosure || {
624
630
  label: "Sponsored",
625
631
  explanation: "This is a paid advertisement",
@@ -633,7 +639,7 @@ var AttentionMarketClient = class {
633
639
  };
634
640
  return adResponse2;
635
641
  }
636
- if (response.status === "no_fill" || !response.units || response.units.length === 0) {
642
+ if (!response || response.status === "no_fill" || !response.units || response.units.length === 0) {
637
643
  return null;
638
644
  }
639
645
  const adUnit = response.units[0];