@the_ro_show/agent-ads-sdk 0.17.0 → 0.17.1
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 +30 -14
- package/dist/index.d.mts +46 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -1
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
|
|
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
|
|
518
|
+
For multi-ad or detailed responses, use the `standard` or `verbose` formats:
|
|
519
519
|
|
|
520
520
|
```typescript
|
|
521
|
-
// Standard format
|
|
522
|
-
const
|
|
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
|
-
//
|
|
528
|
-
|
|
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 |
|
|
537
|
-
|
|
538
|
-
| **minimal** | ~520B | Production apps (default
|
|
539
|
-
| **standard** | ~645B |
|
|
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
|
|
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
|
|
package/dist/index.d.mts
CHANGED
|
@@ -381,6 +381,36 @@ interface FeedbackResponse {
|
|
|
381
381
|
*/
|
|
382
382
|
analysis_mode?: 'auto' | 'fallback';
|
|
383
383
|
}
|
|
384
|
+
/**
|
|
385
|
+
* Rate the delivery quality of an ad after a verified click.
|
|
386
|
+
*
|
|
387
|
+
* @example
|
|
388
|
+
* ```typescript
|
|
389
|
+
* await client.rateBusinessDelivery({
|
|
390
|
+
* tracking_token: ad.tracking_token,
|
|
391
|
+
* ad_unit_id: ad._ad.unit_id,
|
|
392
|
+
* rating: 4,
|
|
393
|
+
* context: 'Relevant product, good landing page'
|
|
394
|
+
* });
|
|
395
|
+
* ```
|
|
396
|
+
*/
|
|
397
|
+
interface BusinessRatingRequest {
|
|
398
|
+
/** Tracking token from the ad (required) */
|
|
399
|
+
tracking_token: string;
|
|
400
|
+
/** Ad unit ID from the ad response (required) */
|
|
401
|
+
ad_unit_id: string;
|
|
402
|
+
/** Delivery quality rating: 1 (poor) to 5 (excellent) */
|
|
403
|
+
rating: 1 | 2 | 3 | 4 | 5;
|
|
404
|
+
/** Optional context about the rating (max 500 chars) */
|
|
405
|
+
context?: string;
|
|
406
|
+
/** Idempotency key for safe retries (optional) */
|
|
407
|
+
idempotency_key?: string;
|
|
408
|
+
}
|
|
409
|
+
interface BusinessRatingResponse {
|
|
410
|
+
status: 'received';
|
|
411
|
+
rating_id: string;
|
|
412
|
+
campaign_id: string;
|
|
413
|
+
}
|
|
384
414
|
interface PolicyResponse {
|
|
385
415
|
version: string;
|
|
386
416
|
disclosure: {
|
|
@@ -960,6 +990,22 @@ declare class AttentionMarketClient {
|
|
|
960
990
|
* ```
|
|
961
991
|
*/
|
|
962
992
|
sendFeedback(request: FeedbackRequest): Promise<FeedbackResponse>;
|
|
993
|
+
/**
|
|
994
|
+
* Rate the delivery quality of an ad after a verified click.
|
|
995
|
+
* Requires a prior click event for the tracking_token. Ratings feed
|
|
996
|
+
* into quality scores (minimum 5 unique raters per campaign).
|
|
997
|
+
*
|
|
998
|
+
* @example
|
|
999
|
+
* ```typescript
|
|
1000
|
+
* await client.rateBusinessDelivery({
|
|
1001
|
+
* tracking_token: ad.tracking_token,
|
|
1002
|
+
* ad_unit_id: ad._ad.unit_id,
|
|
1003
|
+
* rating: 4,
|
|
1004
|
+
* context: 'Relevant product, good landing page'
|
|
1005
|
+
* });
|
|
1006
|
+
* ```
|
|
1007
|
+
*/
|
|
1008
|
+
rateBusinessDelivery(request: BusinessRatingRequest): Promise<BusinessRatingResponse>;
|
|
963
1009
|
/**
|
|
964
1010
|
* Fetch default policy constraints and formatting requirements.
|
|
965
1011
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -381,6 +381,36 @@ interface FeedbackResponse {
|
|
|
381
381
|
*/
|
|
382
382
|
analysis_mode?: 'auto' | 'fallback';
|
|
383
383
|
}
|
|
384
|
+
/**
|
|
385
|
+
* Rate the delivery quality of an ad after a verified click.
|
|
386
|
+
*
|
|
387
|
+
* @example
|
|
388
|
+
* ```typescript
|
|
389
|
+
* await client.rateBusinessDelivery({
|
|
390
|
+
* tracking_token: ad.tracking_token,
|
|
391
|
+
* ad_unit_id: ad._ad.unit_id,
|
|
392
|
+
* rating: 4,
|
|
393
|
+
* context: 'Relevant product, good landing page'
|
|
394
|
+
* });
|
|
395
|
+
* ```
|
|
396
|
+
*/
|
|
397
|
+
interface BusinessRatingRequest {
|
|
398
|
+
/** Tracking token from the ad (required) */
|
|
399
|
+
tracking_token: string;
|
|
400
|
+
/** Ad unit ID from the ad response (required) */
|
|
401
|
+
ad_unit_id: string;
|
|
402
|
+
/** Delivery quality rating: 1 (poor) to 5 (excellent) */
|
|
403
|
+
rating: 1 | 2 | 3 | 4 | 5;
|
|
404
|
+
/** Optional context about the rating (max 500 chars) */
|
|
405
|
+
context?: string;
|
|
406
|
+
/** Idempotency key for safe retries (optional) */
|
|
407
|
+
idempotency_key?: string;
|
|
408
|
+
}
|
|
409
|
+
interface BusinessRatingResponse {
|
|
410
|
+
status: 'received';
|
|
411
|
+
rating_id: string;
|
|
412
|
+
campaign_id: string;
|
|
413
|
+
}
|
|
384
414
|
interface PolicyResponse {
|
|
385
415
|
version: string;
|
|
386
416
|
disclosure: {
|
|
@@ -960,6 +990,22 @@ declare class AttentionMarketClient {
|
|
|
960
990
|
* ```
|
|
961
991
|
*/
|
|
962
992
|
sendFeedback(request: FeedbackRequest): Promise<FeedbackResponse>;
|
|
993
|
+
/**
|
|
994
|
+
* Rate the delivery quality of an ad after a verified click.
|
|
995
|
+
* Requires a prior click event for the tracking_token. Ratings feed
|
|
996
|
+
* into quality scores (minimum 5 unique raters per campaign).
|
|
997
|
+
*
|
|
998
|
+
* @example
|
|
999
|
+
* ```typescript
|
|
1000
|
+
* await client.rateBusinessDelivery({
|
|
1001
|
+
* tracking_token: ad.tracking_token,
|
|
1002
|
+
* ad_unit_id: ad._ad.unit_id,
|
|
1003
|
+
* rating: 4,
|
|
1004
|
+
* context: 'Relevant product, good landing page'
|
|
1005
|
+
* });
|
|
1006
|
+
* ```
|
|
1007
|
+
*/
|
|
1008
|
+
rateBusinessDelivery(request: BusinessRatingRequest): Promise<BusinessRatingResponse>;
|
|
963
1009
|
/**
|
|
964
1010
|
* Fetch default policy constraints and formatting requirements.
|
|
965
1011
|
*/
|
package/dist/index.js
CHANGED
|
@@ -865,6 +865,24 @@ var AttentionMarketClient = class {
|
|
|
865
865
|
async sendFeedback(request) {
|
|
866
866
|
return await this.http.request("POST", "/feedback", { body: request });
|
|
867
867
|
}
|
|
868
|
+
/**
|
|
869
|
+
* Rate the delivery quality of an ad after a verified click.
|
|
870
|
+
* Requires a prior click event for the tracking_token. Ratings feed
|
|
871
|
+
* into quality scores (minimum 5 unique raters per campaign).
|
|
872
|
+
*
|
|
873
|
+
* @example
|
|
874
|
+
* ```typescript
|
|
875
|
+
* await client.rateBusinessDelivery({
|
|
876
|
+
* tracking_token: ad.tracking_token,
|
|
877
|
+
* ad_unit_id: ad._ad.unit_id,
|
|
878
|
+
* rating: 4,
|
|
879
|
+
* context: 'Relevant product, good landing page'
|
|
880
|
+
* });
|
|
881
|
+
* ```
|
|
882
|
+
*/
|
|
883
|
+
async rateBusinessDelivery(request) {
|
|
884
|
+
return await this.http.request("POST", "/rate-business", { body: request });
|
|
885
|
+
}
|
|
868
886
|
/**
|
|
869
887
|
* Fetch default policy constraints and formatting requirements.
|
|
870
888
|
*/
|