@the_ro_show/agent-ads-sdk 0.16.0 → 0.17.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/dist/index.mjs CHANGED
@@ -468,59 +468,6 @@ var AttentionMarketClient = class {
468
468
  }
469
469
  this.http = new HTTPClient(httpConfig);
470
470
  }
471
- /**
472
- * Infer taxonomy from user message using keyword matching
473
- * Returns best-guess taxonomy based on common patterns
474
- */
475
- inferTaxonomy(userMessage) {
476
- const msg = userMessage.toLowerCase();
477
- if (msg.match(/\b(ecommerce|e-commerce|online store|shopify|sell products?|product brand)\b/)) {
478
- return "business.ecommerce.platform.trial";
479
- }
480
- if (msg.match(/\b(start.*business|launch.*business|business formation|llc|incorporate)\b/)) {
481
- return "business.ecommerce.platform.trial";
482
- }
483
- if (msg.match(/\b(car insurance|auto insurance|vehicle insurance)\b/)) {
484
- return "insurance.auto.full_coverage.quote";
485
- }
486
- if (msg.match(/\b(health insurance|medical insurance)\b/)) {
487
- return "insurance.health.individual.quote";
488
- }
489
- if (msg.match(/\b(life insurance)\b/)) {
490
- return "insurance.life.term.quote";
491
- }
492
- if (msg.match(/\b(insurance)\b/)) {
493
- return "insurance.auto.full_coverage.quote";
494
- }
495
- if (msg.match(/\b(personal loan|debt consolidation|borrow money)\b/)) {
496
- return "finance.loans.personal.apply";
497
- }
498
- if (msg.match(/\b(credit card)\b/)) {
499
- return "finance.credit_cards.rewards.apply";
500
- }
501
- if (msg.match(/\b(mover?s?|moving|relocat(e|ing))\b/)) {
502
- return "home_services.moving.local.quote";
503
- }
504
- if (msg.match(/\b(plumber|plumbing|leak|pipe)\b/)) {
505
- return "home_services.plumbing.emergency.quote";
506
- }
507
- if (msg.match(/\b(electrician|electrical|wiring)\b/)) {
508
- return "home_services.electrical.repair.quote";
509
- }
510
- if (msg.match(/\b(clean(ing|er)|maid service)\b/)) {
511
- return "home_services.cleaning.regular.book";
512
- }
513
- if (msg.match(/\b(hotel|lodging|accommodation)\b/)) {
514
- return "travel.hotels.luxury.book";
515
- }
516
- if (msg.match(/\b(flight|plane ticket|airfare)\b/)) {
517
- return "travel.flights.domestic.book";
518
- }
519
- if (msg.match(/\b(lawyer|attorney|legal help)\b/)) {
520
- return "legal.general.consultation";
521
- }
522
- return "business.ecommerce.platform.trial";
523
- }
524
471
  /**
525
472
  * Validate SDK configuration for security
526
473
  */
@@ -604,7 +551,7 @@ var AttentionMarketClient = class {
604
551
  const language = params.language || "en";
605
552
  const platform = params.platform || "web";
606
553
  const placementType = params.placement || "sponsored_suggestion";
607
- const taxonomy = params.suggestedCategory || this.inferTaxonomy(params.userMessage);
554
+ const taxonomy = params.suggestedCategory || "general.query";
608
555
  if (params.minQualityScore !== void 0) {
609
556
  if (typeof params.minQualityScore !== "number" || params.minQualityScore < 0 || params.minQualityScore > 1) {
610
557
  throw new Error("minQualityScore must be a number between 0.0 and 1.0");
@@ -659,6 +606,11 @@ var AttentionMarketClient = class {
659
606
  if (params.optimizeFor && params.optimizeFor !== "revenue" && params.optimizeFor !== "relevance") {
660
607
  throw new Error('optimizeFor must be either "revenue" or "relevance"');
661
608
  }
609
+ const validFormats = ["minimal", "standard", "verbose"];
610
+ const responseFormat = params.response_format || "minimal";
611
+ if (!validFormats.includes(responseFormat)) {
612
+ throw new Error(`response_format must be one of: ${validFormats.join(", ")}. Got: ${responseFormat}`);
613
+ }
662
614
  const request = {
663
615
  request_id: generateUUID(),
664
616
  agent_id: this.agentId,
@@ -687,7 +639,7 @@ var AttentionMarketClient = class {
687
639
  context,
688
640
  user_intent: params.userMessage,
689
641
  // Use minimal response format by default for better performance
690
- response_format: "minimal",
642
+ response_format: responseFormat,
691
643
  // === Smart Context Fields (v0.15.0) ===
692
644
  // Include user context if we have any data
693
645
  ...(interests.length > 0 || recentTopics.length > 0 || purchaseIntent) && {
@@ -730,7 +682,11 @@ var AttentionMarketClient = class {
730
682
  tracking_token: response.tracking_token
731
683
  });
732
684
  } catch (error) {
733
- console.warn("[AttentionMarket] Failed to auto-track impression:", error);
685
+ console.error("[AttentionMarket] REVENUE RISK: Failed to auto-track impression. Clicks without impressions will NOT earn revenue.", {
686
+ error: error instanceof Error ? error.message : String(error),
687
+ tracking_token: response.tracking_token,
688
+ unit_id: response["_meta"]?.["unit_id"]
689
+ });
734
690
  }
735
691
  }
736
692
  const adResponse2 = {
@@ -775,7 +731,11 @@ var AttentionMarketClient = class {
775
731
  tracking_token: adUnit.tracking.token
776
732
  });
777
733
  } catch (error) {
778
- console.warn("[AttentionMarket] Failed to auto-track impression:", error);
734
+ console.error("[AttentionMarket] REVENUE RISK: Failed to auto-track impression. Clicks without impressions will NOT earn revenue.", {
735
+ error: error instanceof Error ? error.message : String(error),
736
+ tracking_token: adUnit.tracking.token,
737
+ unit_id: adUnit.unit_id
738
+ });
779
739
  }
780
740
  const adResponse = {
781
741
  request_id: response.request_id,
@@ -1125,7 +1085,7 @@ var AttentionMarketClient = class {
1125
1085
  const context = contextParts.join("\n");
1126
1086
  const country = params.context?.geo?.country || "US";
1127
1087
  const language = this.normalizeLocale(params.context?.locale);
1128
- const taxonomy = params.suggestedCategory || "unknown";
1088
+ const taxonomy = params.suggestedCategory || "general.query";
1129
1089
  const idempotencyKey = options?.idempotencyKey || generateUUID();
1130
1090
  const request = {
1131
1091
  request_id: idempotencyKey,
@@ -1385,6 +1345,7 @@ var AttentionMarketClient = class {
1385
1345
  url
1386
1346
  );
1387
1347
  }
1348
+ // TODO: Add getDeveloperMetrics() method when DeveloperMetricsResponse type is defined
1388
1349
  };
1389
1350
 
1390
1351
  // src/mock-client.ts