@the_ro_show/agent-ads-sdk 0.13.2 → 0.14.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 +2 -1
- package/dist/index.d.mts +24 -5
- package/dist/index.d.ts +24 -5
- package/dist/index.js +55 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +55 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -408,7 +408,7 @@ var AttentionMarketClient = class {
|
|
|
408
408
|
if (options?.idempotencyKey !== void 0) {
|
|
409
409
|
requestOptions.idempotencyKey = options.idempotencyKey;
|
|
410
410
|
}
|
|
411
|
-
return await this.http.request("POST", "/
|
|
411
|
+
return await this.http.request("POST", "/decide", requestOptions);
|
|
412
412
|
}
|
|
413
413
|
/**
|
|
414
414
|
* Convenience wrapper around decideRaw().
|
|
@@ -419,7 +419,7 @@ var AttentionMarketClient = class {
|
|
|
419
419
|
if (response.status === "no_fill") {
|
|
420
420
|
return null;
|
|
421
421
|
}
|
|
422
|
-
return response.units[0] ?? null;
|
|
422
|
+
return response.units?.[0] ?? null;
|
|
423
423
|
}
|
|
424
424
|
/**
|
|
425
425
|
* Simplified ad matching using conversation context and semantic search.
|
|
@@ -535,6 +535,8 @@ var AttentionMarketClient = class {
|
|
|
535
535
|
},
|
|
536
536
|
context,
|
|
537
537
|
user_intent: params.userMessage,
|
|
538
|
+
// Use minimal response format by default for better performance
|
|
539
|
+
response_format: "minimal",
|
|
538
540
|
// Developer controls (Phase 1: Quality & Brand Safety)
|
|
539
541
|
...params.minQualityScore !== void 0 && { minQualityScore: params.minQualityScore },
|
|
540
542
|
...params.allowedCategories && { allowedCategories: params.allowedCategories },
|
|
@@ -546,7 +548,43 @@ var AttentionMarketClient = class {
|
|
|
546
548
|
...params.optimizeFor && { optimizeFor: params.optimizeFor }
|
|
547
549
|
};
|
|
548
550
|
const response = await this.decideRaw(request, options);
|
|
549
|
-
if (response.
|
|
551
|
+
if (response.creative) {
|
|
552
|
+
try {
|
|
553
|
+
await this.track({
|
|
554
|
+
event_id: `evt_${generateUUID()}`,
|
|
555
|
+
event_type: "impression",
|
|
556
|
+
occurred_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
557
|
+
agent_id: this.agentId,
|
|
558
|
+
tracking_token: response.tracking_token
|
|
559
|
+
});
|
|
560
|
+
} catch (error) {
|
|
561
|
+
console.warn("[AttentionMarket] Failed to auto-track impression:", error);
|
|
562
|
+
}
|
|
563
|
+
const adResponse2 = {
|
|
564
|
+
request_id: request.request_id,
|
|
565
|
+
decision_id: `dec_${generateUUID()}`,
|
|
566
|
+
advertiser_id: response.advertiser_id || "",
|
|
567
|
+
ad_type: "link",
|
|
568
|
+
payout: response.payout || 0,
|
|
569
|
+
creative: response.creative,
|
|
570
|
+
click_url: response.click_url || "",
|
|
571
|
+
tracking_url: response.click_url || "",
|
|
572
|
+
// Same as click_url
|
|
573
|
+
tracking_token: response.tracking_token || "",
|
|
574
|
+
disclosure: response.disclosure || {
|
|
575
|
+
label: "Sponsored",
|
|
576
|
+
explanation: "This is a paid advertisement",
|
|
577
|
+
sponsor_name: "Advertiser"
|
|
578
|
+
},
|
|
579
|
+
// Internal fields preserved for backward compatibility
|
|
580
|
+
_ad: {
|
|
581
|
+
unit_id: "",
|
|
582
|
+
tracking: { token: response.tracking_token || "" }
|
|
583
|
+
}
|
|
584
|
+
};
|
|
585
|
+
return adResponse2;
|
|
586
|
+
}
|
|
587
|
+
if (response.status === "no_fill" || !response.units || response.units.length === 0) {
|
|
550
588
|
return null;
|
|
551
589
|
}
|
|
552
590
|
const adUnit = response.units[0];
|
|
@@ -599,7 +637,7 @@ var AttentionMarketClient = class {
|
|
|
599
637
|
* Report an event (impression, click, action, conversion, feedback).
|
|
600
638
|
*/
|
|
601
639
|
async track(event) {
|
|
602
|
-
return await this.http.request("POST", "/
|
|
640
|
+
return await this.http.request("POST", "/event", {
|
|
603
641
|
body: event
|
|
604
642
|
});
|
|
605
643
|
}
|
|
@@ -689,13 +727,13 @@ var AttentionMarketClient = class {
|
|
|
689
727
|
* ```
|
|
690
728
|
*/
|
|
691
729
|
async sendFeedback(request) {
|
|
692
|
-
return await this.http.request("POST", "/
|
|
730
|
+
return await this.http.request("POST", "/feedback", { body: request });
|
|
693
731
|
}
|
|
694
732
|
/**
|
|
695
733
|
* Fetch default policy constraints and formatting requirements.
|
|
696
734
|
*/
|
|
697
735
|
async getPolicy() {
|
|
698
|
-
return await this.http.request("GET", "/
|
|
736
|
+
return await this.http.request("GET", "/policy");
|
|
699
737
|
}
|
|
700
738
|
/**
|
|
701
739
|
* Create or register an agent (optional helper).
|
|
@@ -707,7 +745,7 @@ var AttentionMarketClient = class {
|
|
|
707
745
|
timeoutMs: DEFAULT_TIMEOUT_MS,
|
|
708
746
|
maxRetries: DEFAULT_MAX_RETRIES
|
|
709
747
|
});
|
|
710
|
-
return await http.request("POST", "/
|
|
748
|
+
return await http.request("POST", "/agent-signup", {
|
|
711
749
|
body: request
|
|
712
750
|
});
|
|
713
751
|
}
|
|
@@ -859,7 +897,7 @@ var AttentionMarketClient = class {
|
|
|
859
897
|
user_intent: params.intentKey
|
|
860
898
|
};
|
|
861
899
|
const response = await this.decideRaw(request, { idempotencyKey });
|
|
862
|
-
if (response.status === "no_fill" || response.units.length === 0) {
|
|
900
|
+
if (response.status === "no_fill" || !response.units || response.units.length === 0) {
|
|
863
901
|
return null;
|
|
864
902
|
}
|
|
865
903
|
const adUnit = response.units[0];
|
|
@@ -870,7 +908,7 @@ var AttentionMarketClient = class {
|
|
|
870
908
|
const matchMethod = semanticContext ? "hybrid" : "semantic";
|
|
871
909
|
return {
|
|
872
910
|
offer_id: adUnit.unit_id,
|
|
873
|
-
request_id: response.request_id,
|
|
911
|
+
request_id: response.request_id || "",
|
|
874
912
|
impression_id: impressionId,
|
|
875
913
|
// LIMITATION: Backend doesn't return campaign_id yet - use unit_id as placeholder
|
|
876
914
|
campaign_id: adUnit.unit_id,
|
|
@@ -901,7 +939,7 @@ var AttentionMarketClient = class {
|
|
|
901
939
|
...params.revenueSharePct !== void 0 ? { source_agent_pct: params.revenueSharePct } : {}
|
|
902
940
|
}
|
|
903
941
|
} : {},
|
|
904
|
-
ttl_ms: response.ttl_ms
|
|
942
|
+
ttl_ms: response.ttl_ms || 3e5
|
|
905
943
|
};
|
|
906
944
|
}
|
|
907
945
|
/**
|
|
@@ -992,7 +1030,7 @@ var AttentionMarketClient = class {
|
|
|
992
1030
|
user_intent: params.userMessage
|
|
993
1031
|
};
|
|
994
1032
|
const response = await this.decideRaw(request, { idempotencyKey });
|
|
995
|
-
if (response.status === "no_fill" || response.units.length === 0) {
|
|
1033
|
+
if (response.status === "no_fill" || !response.units || response.units.length === 0) {
|
|
996
1034
|
return null;
|
|
997
1035
|
}
|
|
998
1036
|
const adUnit = response.units[0];
|
|
@@ -1003,7 +1041,7 @@ var AttentionMarketClient = class {
|
|
|
1003
1041
|
const similarity = adUnit._score?.relevance;
|
|
1004
1042
|
return {
|
|
1005
1043
|
offer_id: adUnit.unit_id,
|
|
1006
|
-
request_id: response.request_id,
|
|
1044
|
+
request_id: response.request_id || "",
|
|
1007
1045
|
impression_id: impressionId,
|
|
1008
1046
|
// LIMITATION: Backend doesn't return campaign_id yet - use unit_id as placeholder
|
|
1009
1047
|
campaign_id: adUnit.unit_id,
|
|
@@ -1034,7 +1072,7 @@ var AttentionMarketClient = class {
|
|
|
1034
1072
|
...params.revenueSharePct !== void 0 ? { source_agent_pct: params.revenueSharePct } : {}
|
|
1035
1073
|
}
|
|
1036
1074
|
} : {},
|
|
1037
|
-
ttl_ms: response.ttl_ms
|
|
1075
|
+
ttl_ms: response.ttl_ms || 3e5
|
|
1038
1076
|
};
|
|
1039
1077
|
}
|
|
1040
1078
|
// ============================================================================
|
|
@@ -1120,7 +1158,7 @@ var AttentionMarketClient = class {
|
|
|
1120
1158
|
user_intent: params.taskDescription
|
|
1121
1159
|
};
|
|
1122
1160
|
const response = await this.decideRaw(request);
|
|
1123
|
-
if (response.status === "no_fill" || response.units.length === 0) {
|
|
1161
|
+
if (response.status === "no_fill" || !response.units || response.units.length === 0) {
|
|
1124
1162
|
return null;
|
|
1125
1163
|
}
|
|
1126
1164
|
const adUnit = response.units[0];
|
|
@@ -1166,7 +1204,7 @@ var AttentionMarketClient = class {
|
|
|
1166
1204
|
async logServiceResult(params) {
|
|
1167
1205
|
return await this.http.request(
|
|
1168
1206
|
"POST",
|
|
1169
|
-
"/
|
|
1207
|
+
"/service-result",
|
|
1170
1208
|
{ body: params }
|
|
1171
1209
|
);
|
|
1172
1210
|
}
|
|
@@ -1213,7 +1251,7 @@ var AttentionMarketClient = class {
|
|
|
1213
1251
|
if (params?.search) {
|
|
1214
1252
|
queryParams.append("search", params.search);
|
|
1215
1253
|
}
|
|
1216
|
-
const url = `/
|
|
1254
|
+
const url = `/categories${queryParams.toString() ? "?" + queryParams.toString() : ""}`;
|
|
1217
1255
|
return await this.http.request(
|
|
1218
1256
|
"GET",
|
|
1219
1257
|
url
|
|
@@ -1381,7 +1419,7 @@ var MockAttentionMarketClient = class {
|
|
|
1381
1419
|
*/
|
|
1382
1420
|
async decide(request) {
|
|
1383
1421
|
const response = await this.decideRaw(request);
|
|
1384
|
-
if (response.status === "filled" && response.units.length > 0) {
|
|
1422
|
+
if (response.status === "filled" && response.units && response.units.length > 0) {
|
|
1385
1423
|
return response.units[0] || null;
|
|
1386
1424
|
}
|
|
1387
1425
|
return null;
|