@the_ro_show/agent-ads-sdk 0.13.0 → 0.13.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 +328 -529
- package/dist/index.d.mts +29 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +60 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +60 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -96,6 +96,35 @@ interface DecideFromContextRequest {
|
|
|
96
96
|
* blockedAdvertisers: ['adv_abc123', 'adv_xyz789']
|
|
97
97
|
*/
|
|
98
98
|
blockedAdvertisers?: string[];
|
|
99
|
+
/**
|
|
100
|
+
* Minimum cost-per-click threshold in cents.
|
|
101
|
+
* Only return ads with bids at or above this value.
|
|
102
|
+
* Higher values = more revenue per ad but lower fill rate.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* minCPC: 50 // Only show ads bidding $0.50 or more per click
|
|
106
|
+
*/
|
|
107
|
+
minCPC?: number;
|
|
108
|
+
/**
|
|
109
|
+
* Minimum semantic relevance score threshold (0.0 - 1.0).
|
|
110
|
+
* Only return ads with relevance scores at or above this value.
|
|
111
|
+
* Higher values = more relevant ads but lower fill rate.
|
|
112
|
+
* Default backend threshold: 0.25
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* minRelevanceScore: 0.8 // Only show highly relevant ads
|
|
116
|
+
*/
|
|
117
|
+
minRelevanceScore?: number;
|
|
118
|
+
/**
|
|
119
|
+
* Ad ranking strategy.
|
|
120
|
+
* - 'revenue': Rank by bid amount (highest bid wins)
|
|
121
|
+
* - 'relevance': Rank by semantic similarity (best match wins)
|
|
122
|
+
* Default: 'revenue'
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* optimizeFor: 'relevance' // Prioritize best semantic match over highest bid
|
|
126
|
+
*/
|
|
127
|
+
optimizeFor?: 'revenue' | 'relevance';
|
|
99
128
|
}
|
|
100
129
|
interface DecideResponse {
|
|
101
130
|
request_id: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -96,6 +96,35 @@ interface DecideFromContextRequest {
|
|
|
96
96
|
* blockedAdvertisers: ['adv_abc123', 'adv_xyz789']
|
|
97
97
|
*/
|
|
98
98
|
blockedAdvertisers?: string[];
|
|
99
|
+
/**
|
|
100
|
+
* Minimum cost-per-click threshold in cents.
|
|
101
|
+
* Only return ads with bids at or above this value.
|
|
102
|
+
* Higher values = more revenue per ad but lower fill rate.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* minCPC: 50 // Only show ads bidding $0.50 or more per click
|
|
106
|
+
*/
|
|
107
|
+
minCPC?: number;
|
|
108
|
+
/**
|
|
109
|
+
* Minimum semantic relevance score threshold (0.0 - 1.0).
|
|
110
|
+
* Only return ads with relevance scores at or above this value.
|
|
111
|
+
* Higher values = more relevant ads but lower fill rate.
|
|
112
|
+
* Default backend threshold: 0.25
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* minRelevanceScore: 0.8 // Only show highly relevant ads
|
|
116
|
+
*/
|
|
117
|
+
minRelevanceScore?: number;
|
|
118
|
+
/**
|
|
119
|
+
* Ad ranking strategy.
|
|
120
|
+
* - 'revenue': Rank by bid amount (highest bid wins)
|
|
121
|
+
* - 'relevance': Rank by semantic similarity (best match wins)
|
|
122
|
+
* Default: 'revenue'
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* optimizeFor: 'relevance' // Prioritize best semantic match over highest bid
|
|
126
|
+
*/
|
|
127
|
+
optimizeFor?: 'revenue' | 'relevance';
|
|
99
128
|
}
|
|
100
129
|
interface DecideResponse {
|
|
101
130
|
request_id: string;
|
package/dist/index.js
CHANGED
|
@@ -354,7 +354,7 @@ function sanitizeURL(url, options) {
|
|
|
354
354
|
}
|
|
355
355
|
|
|
356
356
|
// src/client.ts
|
|
357
|
-
var DEFAULT_BASE_URL = "https://
|
|
357
|
+
var DEFAULT_BASE_URL = "https://peruwnbrqkvmrldhpoom.supabase.co/functions/v1";
|
|
358
358
|
var DEFAULT_TIMEOUT_MS = 4e3;
|
|
359
359
|
var DEFAULT_MAX_RETRIES = 2;
|
|
360
360
|
var AttentionMarketClient = class {
|
|
@@ -503,6 +503,60 @@ var AttentionMarketClient = class {
|
|
|
503
503
|
const platform = params.platform || "web";
|
|
504
504
|
const placementType = params.placement || "sponsored_suggestion";
|
|
505
505
|
const taxonomy = params.suggestedCategory || this.inferTaxonomy(params.userMessage);
|
|
506
|
+
if (params.minQualityScore !== void 0) {
|
|
507
|
+
if (typeof params.minQualityScore !== "number" || params.minQualityScore < 0 || params.minQualityScore > 1) {
|
|
508
|
+
throw new Error("minQualityScore must be a number between 0.0 and 1.0");
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
if (params.allowedCategories !== void 0) {
|
|
512
|
+
if (!Array.isArray(params.allowedCategories)) {
|
|
513
|
+
throw new Error("allowedCategories must be an array");
|
|
514
|
+
}
|
|
515
|
+
if (params.allowedCategories.length === 0) {
|
|
516
|
+
throw new Error("allowedCategories cannot be empty (would block all ads). Use blockedCategories to exclude specific categories, or omit to allow all.");
|
|
517
|
+
}
|
|
518
|
+
for (const cat of params.allowedCategories) {
|
|
519
|
+
if (typeof cat !== "string" && typeof cat !== "number") {
|
|
520
|
+
throw new Error(`allowedCategories must contain strings or numbers, found: ${typeof cat}`);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
if (params.blockedCategories !== void 0) {
|
|
525
|
+
if (!Array.isArray(params.blockedCategories)) {
|
|
526
|
+
throw new Error("blockedCategories must be an array");
|
|
527
|
+
}
|
|
528
|
+
for (const cat of params.blockedCategories) {
|
|
529
|
+
if (typeof cat !== "string" && typeof cat !== "number") {
|
|
530
|
+
throw new Error(`blockedCategories must contain strings or numbers, found: ${typeof cat}`);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
if (params.allowedCategories && params.allowedCategories.length > 0) {
|
|
534
|
+
console.warn("[AttentionMarket] Both allowedCategories and blockedCategories specified. blockedCategories will be ignored.");
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
if (params.blockedAdvertisers !== void 0) {
|
|
538
|
+
if (!Array.isArray(params.blockedAdvertisers)) {
|
|
539
|
+
throw new Error("blockedAdvertisers must be an array");
|
|
540
|
+
}
|
|
541
|
+
for (const id of params.blockedAdvertisers) {
|
|
542
|
+
if (typeof id !== "string" || id.trim().length === 0) {
|
|
543
|
+
throw new Error("blockedAdvertisers must contain non-empty strings (advertiser IDs)");
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
if (params.minCPC !== void 0) {
|
|
548
|
+
if (typeof params.minCPC !== "number" || params.minCPC < 0) {
|
|
549
|
+
throw new Error("minCPC must be a non-negative number (cost-per-click in cents)");
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
if (params.minRelevanceScore !== void 0) {
|
|
553
|
+
if (typeof params.minRelevanceScore !== "number" || params.minRelevanceScore < 0 || params.minRelevanceScore > 1) {
|
|
554
|
+
throw new Error("minRelevanceScore must be a number between 0.0 and 1.0");
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
if (params.optimizeFor && params.optimizeFor !== "revenue" && params.optimizeFor !== "relevance") {
|
|
558
|
+
throw new Error('optimizeFor must be either "revenue" or "relevance"');
|
|
559
|
+
}
|
|
506
560
|
const request = {
|
|
507
561
|
request_id: generateUUID(),
|
|
508
562
|
agent_id: this.agentId,
|
|
@@ -534,7 +588,11 @@ var AttentionMarketClient = class {
|
|
|
534
588
|
...params.minQualityScore !== void 0 && { minQualityScore: params.minQualityScore },
|
|
535
589
|
...params.allowedCategories && { allowedCategories: params.allowedCategories },
|
|
536
590
|
...params.blockedCategories && { blockedCategories: params.blockedCategories },
|
|
537
|
-
...params.blockedAdvertisers && { blockedAdvertisers: params.blockedAdvertisers }
|
|
591
|
+
...params.blockedAdvertisers && { blockedAdvertisers: params.blockedAdvertisers },
|
|
592
|
+
// Developer controls (Phase 2: Revenue Optimization)
|
|
593
|
+
...params.minCPC !== void 0 && { minCPC: params.minCPC },
|
|
594
|
+
...params.minRelevanceScore !== void 0 && { minRelevanceScore: params.minRelevanceScore },
|
|
595
|
+
...params.optimizeFor && { optimizeFor: params.optimizeFor }
|
|
538
596
|
};
|
|
539
597
|
const response = await this.decideRaw(request, options);
|
|
540
598
|
if (response.status === "no_fill" || response.units.length === 0) {
|