@the_ro_show/agent-ads-sdk 0.17.0 → 0.18.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 +30 -14
- package/dist/index.d.mts +741 -2
- package/dist/index.d.ts +741 -2
- package/dist/index.js +594 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +591 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -1
package/dist/index.mjs
CHANGED
|
@@ -50,6 +50,10 @@ var HTTPClient = class {
|
|
|
50
50
|
constructor(config) {
|
|
51
51
|
this.config = config;
|
|
52
52
|
}
|
|
53
|
+
/** Expose the API key so sub-clients can re-use it in different headers */
|
|
54
|
+
get apiKey() {
|
|
55
|
+
return this.config.apiKey;
|
|
56
|
+
}
|
|
53
57
|
async request(method, path, options = {}) {
|
|
54
58
|
const url = `${this.config.baseUrl}${path}`;
|
|
55
59
|
let lastError;
|
|
@@ -77,21 +81,26 @@ var HTTPClient = class {
|
|
|
77
81
|
"Content-Type": "application/json",
|
|
78
82
|
...options.headers
|
|
79
83
|
};
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
84
|
+
if (!options.skipDefaultAuth) {
|
|
85
|
+
if (this.config.supabaseAnonKey) {
|
|
86
|
+
headers["Authorization"] = `Bearer ${this.config.supabaseAnonKey}`;
|
|
87
|
+
}
|
|
88
|
+
if (this.config.apiKey) {
|
|
89
|
+
headers["X-AM-API-Key"] = this.config.apiKey;
|
|
90
|
+
}
|
|
85
91
|
}
|
|
86
92
|
if (options.idempotencyKey) {
|
|
87
93
|
headers["Idempotency-Key"] = options.idempotencyKey;
|
|
88
94
|
}
|
|
89
|
-
const
|
|
95
|
+
const fetchInit = {
|
|
90
96
|
method,
|
|
91
97
|
headers,
|
|
92
|
-
body: options.body ? JSON.stringify(options.body) : void 0,
|
|
93
98
|
signal: controller.signal
|
|
94
|
-
}
|
|
99
|
+
};
|
|
100
|
+
if (options.body) {
|
|
101
|
+
fetchInit.body = JSON.stringify(options.body);
|
|
102
|
+
}
|
|
103
|
+
const response = await fetch(url, fetchInit);
|
|
95
104
|
clearTimeout(timeoutId);
|
|
96
105
|
if (!response.ok) {
|
|
97
106
|
const errorBody = await response.json().catch(() => ({
|
|
@@ -445,6 +454,432 @@ function calculateMessageCount(conversationHistory) {
|
|
|
445
454
|
return (conversationHistory?.length || 0) + 1;
|
|
446
455
|
}
|
|
447
456
|
|
|
457
|
+
// src/session-client.ts
|
|
458
|
+
var SessionClient = class {
|
|
459
|
+
constructor(http) {
|
|
460
|
+
this.http = http;
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Initiate a new capability session.
|
|
464
|
+
*
|
|
465
|
+
* @example
|
|
466
|
+
* ```typescript
|
|
467
|
+
* const session = await client.sessions.initiate({
|
|
468
|
+
* capability_type: 'code_review',
|
|
469
|
+
* config: { language: 'typescript' }
|
|
470
|
+
* });
|
|
471
|
+
* console.log(session.session_id);
|
|
472
|
+
* ```
|
|
473
|
+
*/
|
|
474
|
+
async initiate(request) {
|
|
475
|
+
return this.http.request(
|
|
476
|
+
"POST",
|
|
477
|
+
"/capability-session",
|
|
478
|
+
{ body: { action: "initiate", ...request } }
|
|
479
|
+
);
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Send a message within an existing capability session.
|
|
483
|
+
*
|
|
484
|
+
* @example
|
|
485
|
+
* ```typescript
|
|
486
|
+
* const response = await client.sessions.sendMessage({
|
|
487
|
+
* session_id: 'sess_abc123',
|
|
488
|
+
* message: 'Review this function for bugs'
|
|
489
|
+
* });
|
|
490
|
+
* console.log(response.response);
|
|
491
|
+
* ```
|
|
492
|
+
*/
|
|
493
|
+
async sendMessage(request) {
|
|
494
|
+
if (!request.session_id) {
|
|
495
|
+
throw new Error("session_id is required");
|
|
496
|
+
}
|
|
497
|
+
if (!request.message) {
|
|
498
|
+
throw new Error("message is required");
|
|
499
|
+
}
|
|
500
|
+
return this.http.request(
|
|
501
|
+
"POST",
|
|
502
|
+
"/capability-session",
|
|
503
|
+
{ body: { action: "message", ...request } }
|
|
504
|
+
);
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* End a capability session.
|
|
508
|
+
*
|
|
509
|
+
* @example
|
|
510
|
+
* ```typescript
|
|
511
|
+
* const result = await client.sessions.end({
|
|
512
|
+
* session_id: 'sess_abc123',
|
|
513
|
+
* reason: 'task_completed'
|
|
514
|
+
* });
|
|
515
|
+
* ```
|
|
516
|
+
*/
|
|
517
|
+
async end(request) {
|
|
518
|
+
if (!request.session_id) {
|
|
519
|
+
throw new Error("session_id is required");
|
|
520
|
+
}
|
|
521
|
+
return this.http.request(
|
|
522
|
+
"POST",
|
|
523
|
+
"/capability-session",
|
|
524
|
+
{ body: { action: "end", ...request } }
|
|
525
|
+
);
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Connect a GitHub repository to the capability session.
|
|
529
|
+
*
|
|
530
|
+
* @example
|
|
531
|
+
* ```typescript
|
|
532
|
+
* const result = await client.sessions.connectGitHub({
|
|
533
|
+
* session_id: 'sess_abc123',
|
|
534
|
+
* repository: 'owner/repo',
|
|
535
|
+
* branch: 'main'
|
|
536
|
+
* });
|
|
537
|
+
* ```
|
|
538
|
+
*/
|
|
539
|
+
async connectGitHub(request) {
|
|
540
|
+
if (!request.session_id) {
|
|
541
|
+
throw new Error("session_id is required");
|
|
542
|
+
}
|
|
543
|
+
if (!request.repository) {
|
|
544
|
+
throw new Error("repository is required");
|
|
545
|
+
}
|
|
546
|
+
return this.http.request(
|
|
547
|
+
"POST",
|
|
548
|
+
"/capability-session",
|
|
549
|
+
{ body: { action: "connect-github", ...request } }
|
|
550
|
+
);
|
|
551
|
+
}
|
|
552
|
+
};
|
|
553
|
+
|
|
554
|
+
// src/developer-client.ts
|
|
555
|
+
var DeveloperClient = class {
|
|
556
|
+
constructor(http) {
|
|
557
|
+
this.http = http;
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Log in as a developer. Returns a session token for subsequent calls.
|
|
561
|
+
* No API key auth needed for this endpoint.
|
|
562
|
+
*
|
|
563
|
+
* @example
|
|
564
|
+
* ```typescript
|
|
565
|
+
* const session = await client.developer.login({
|
|
566
|
+
* email: 'dev@example.com',
|
|
567
|
+
* password: 'secret'
|
|
568
|
+
* });
|
|
569
|
+
* console.log(session.session_token);
|
|
570
|
+
* ```
|
|
571
|
+
*/
|
|
572
|
+
async login(request) {
|
|
573
|
+
if (!request.email) {
|
|
574
|
+
throw new Error("email is required");
|
|
575
|
+
}
|
|
576
|
+
if (!request.password) {
|
|
577
|
+
throw new Error("password is required");
|
|
578
|
+
}
|
|
579
|
+
return this.http.request(
|
|
580
|
+
"POST",
|
|
581
|
+
"/developer-login",
|
|
582
|
+
{ body: request, skipDefaultAuth: true }
|
|
583
|
+
);
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Get developer account data using a session token.
|
|
587
|
+
* No default API key auth — uses session token in body.
|
|
588
|
+
*
|
|
589
|
+
* @example
|
|
590
|
+
* ```typescript
|
|
591
|
+
* const data = await client.developer.getData('session_token_here');
|
|
592
|
+
* console.log(data.agent_name);
|
|
593
|
+
* ```
|
|
594
|
+
*/
|
|
595
|
+
async getData(sessionToken) {
|
|
596
|
+
if (!sessionToken) {
|
|
597
|
+
throw new Error("sessionToken is required");
|
|
598
|
+
}
|
|
599
|
+
return this.http.request(
|
|
600
|
+
"POST",
|
|
601
|
+
"/developer-data",
|
|
602
|
+
{ body: { session_token: sessionToken }, skipDefaultAuth: true }
|
|
603
|
+
);
|
|
604
|
+
}
|
|
605
|
+
/**
|
|
606
|
+
* Get developer earnings. Uses X-API-Key header (not X-AM-API-Key).
|
|
607
|
+
*
|
|
608
|
+
* @example
|
|
609
|
+
* ```typescript
|
|
610
|
+
* const earnings = await client.developer.getEarnings();
|
|
611
|
+
* console.log(earnings.balances.available);
|
|
612
|
+
* ```
|
|
613
|
+
*/
|
|
614
|
+
async getEarnings() {
|
|
615
|
+
const apiKey = this.http.apiKey;
|
|
616
|
+
if (!apiKey) {
|
|
617
|
+
throw new Error("API key is required for getEarnings()");
|
|
618
|
+
}
|
|
619
|
+
return this.http.request(
|
|
620
|
+
"GET",
|
|
621
|
+
"/developer-earnings",
|
|
622
|
+
{
|
|
623
|
+
skipDefaultAuth: true,
|
|
624
|
+
headers: { "X-API-Key": apiKey }
|
|
625
|
+
}
|
|
626
|
+
);
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Get developer stats. Uses standard X-AM-API-Key auth.
|
|
630
|
+
*
|
|
631
|
+
* @example
|
|
632
|
+
* ```typescript
|
|
633
|
+
* const stats = await client.developer.getStats({ period: '30d' });
|
|
634
|
+
* console.log(stats.impressions, stats.clicks);
|
|
635
|
+
* ```
|
|
636
|
+
*/
|
|
637
|
+
async getStats(params) {
|
|
638
|
+
const queryParams = new URLSearchParams();
|
|
639
|
+
if (params?.period) {
|
|
640
|
+
queryParams.append("period", params.period);
|
|
641
|
+
}
|
|
642
|
+
const qs = queryParams.toString();
|
|
643
|
+
const url = `/developer-stats${qs ? "?" + qs : ""}`;
|
|
644
|
+
return this.http.request("GET", url);
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* Get developer analytics. Uses session token in body (no default auth).
|
|
648
|
+
*
|
|
649
|
+
* @example
|
|
650
|
+
* ```typescript
|
|
651
|
+
* const analytics = await client.developer.getAnalytics('session_token', {
|
|
652
|
+
* start_date: '2026-01-01',
|
|
653
|
+
* group_by: 'week'
|
|
654
|
+
* });
|
|
655
|
+
* ```
|
|
656
|
+
*/
|
|
657
|
+
async getAnalytics(sessionToken, params) {
|
|
658
|
+
if (!sessionToken) {
|
|
659
|
+
throw new Error("sessionToken is required");
|
|
660
|
+
}
|
|
661
|
+
return this.http.request(
|
|
662
|
+
"POST",
|
|
663
|
+
"/developer-analytics",
|
|
664
|
+
{
|
|
665
|
+
body: { session_token: sessionToken, ...params },
|
|
666
|
+
skipDefaultAuth: true
|
|
667
|
+
}
|
|
668
|
+
);
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* Regenerate API keys. Uses session token in body (no default auth).
|
|
672
|
+
*
|
|
673
|
+
* @example
|
|
674
|
+
* ```typescript
|
|
675
|
+
* const newKeys = await client.developer.regenerateKeys({
|
|
676
|
+
* session_token: 'session_token_here',
|
|
677
|
+
* key_type: 'test'
|
|
678
|
+
* });
|
|
679
|
+
* console.log(newKeys.api_key_test);
|
|
680
|
+
* ```
|
|
681
|
+
*/
|
|
682
|
+
async regenerateKeys(request) {
|
|
683
|
+
if (!request.session_token) {
|
|
684
|
+
throw new Error("session_token is required");
|
|
685
|
+
}
|
|
686
|
+
if (!request.key_type) {
|
|
687
|
+
throw new Error("key_type is required");
|
|
688
|
+
}
|
|
689
|
+
return this.http.request(
|
|
690
|
+
"POST",
|
|
691
|
+
"/regenerate-keys",
|
|
692
|
+
{ body: request, skipDefaultAuth: true }
|
|
693
|
+
);
|
|
694
|
+
}
|
|
695
|
+
};
|
|
696
|
+
|
|
697
|
+
// src/advertiser-client.ts
|
|
698
|
+
var AdvertiserClient = class {
|
|
699
|
+
constructor(http) {
|
|
700
|
+
this.http = http;
|
|
701
|
+
}
|
|
702
|
+
/**
|
|
703
|
+
* Sign up as a new advertiser. No API key auth needed.
|
|
704
|
+
*
|
|
705
|
+
* @example
|
|
706
|
+
* ```typescript
|
|
707
|
+
* const account = await client.advertiser.signup({
|
|
708
|
+
* email: 'ads@company.com',
|
|
709
|
+
* password: 'secure123',
|
|
710
|
+
* company_name: 'Acme Corp'
|
|
711
|
+
* });
|
|
712
|
+
* console.log(account.advertiser_id);
|
|
713
|
+
* ```
|
|
714
|
+
*/
|
|
715
|
+
async signup(request) {
|
|
716
|
+
if (!request.email) {
|
|
717
|
+
throw new Error("email is required");
|
|
718
|
+
}
|
|
719
|
+
if (!request.password) {
|
|
720
|
+
throw new Error("password is required");
|
|
721
|
+
}
|
|
722
|
+
if (!request.company_name) {
|
|
723
|
+
throw new Error("company_name is required");
|
|
724
|
+
}
|
|
725
|
+
return this.http.request(
|
|
726
|
+
"POST",
|
|
727
|
+
"/advertiser-signup",
|
|
728
|
+
{ body: request, skipDefaultAuth: true }
|
|
729
|
+
);
|
|
730
|
+
}
|
|
731
|
+
/**
|
|
732
|
+
* Log in as an advertiser. Returns a session token.
|
|
733
|
+
* No API key auth needed.
|
|
734
|
+
*
|
|
735
|
+
* @example
|
|
736
|
+
* ```typescript
|
|
737
|
+
* const session = await client.advertiser.login({
|
|
738
|
+
* email: 'ads@company.com',
|
|
739
|
+
* password: 'secure123'
|
|
740
|
+
* });
|
|
741
|
+
* console.log(session.session_token);
|
|
742
|
+
* ```
|
|
743
|
+
*/
|
|
744
|
+
async login(request) {
|
|
745
|
+
if (!request.email) {
|
|
746
|
+
throw new Error("email is required");
|
|
747
|
+
}
|
|
748
|
+
if (!request.password) {
|
|
749
|
+
throw new Error("password is required");
|
|
750
|
+
}
|
|
751
|
+
return this.http.request(
|
|
752
|
+
"POST",
|
|
753
|
+
"/advertiser-login",
|
|
754
|
+
{ body: request, skipDefaultAuth: true }
|
|
755
|
+
);
|
|
756
|
+
}
|
|
757
|
+
/**
|
|
758
|
+
* Get advertiser stats. Uses X-Advertiser-Key header or query param.
|
|
759
|
+
*
|
|
760
|
+
* @example
|
|
761
|
+
* ```typescript
|
|
762
|
+
* const stats = await client.advertiser.getStats({
|
|
763
|
+
* advertiser_key: 'adv_key_123',
|
|
764
|
+
* period: '30d'
|
|
765
|
+
* });
|
|
766
|
+
* console.log(stats.budget.remaining);
|
|
767
|
+
* ```
|
|
768
|
+
*/
|
|
769
|
+
async getStats(params) {
|
|
770
|
+
const queryParams = new URLSearchParams();
|
|
771
|
+
if (params?.advertiser_key) {
|
|
772
|
+
queryParams.append("advertiser_key", params.advertiser_key);
|
|
773
|
+
}
|
|
774
|
+
if (params?.period) {
|
|
775
|
+
queryParams.append("period", params.period);
|
|
776
|
+
}
|
|
777
|
+
const qs = queryParams.toString();
|
|
778
|
+
const url = `/advertiser-stats${qs ? "?" + qs : ""}`;
|
|
779
|
+
const headers = {};
|
|
780
|
+
if (params?.advertiser_key) {
|
|
781
|
+
headers["X-Advertiser-Key"] = params.advertiser_key;
|
|
782
|
+
}
|
|
783
|
+
return this.http.request(
|
|
784
|
+
"GET",
|
|
785
|
+
url,
|
|
786
|
+
{ skipDefaultAuth: true, headers }
|
|
787
|
+
);
|
|
788
|
+
}
|
|
789
|
+
/**
|
|
790
|
+
* Get advertiser analytics. Uses session token in body (no default auth).
|
|
791
|
+
*
|
|
792
|
+
* @example
|
|
793
|
+
* ```typescript
|
|
794
|
+
* const analytics = await client.advertiser.getAnalytics('session_token', {
|
|
795
|
+
* start_date: '2026-01-01',
|
|
796
|
+
* group_by: 'week'
|
|
797
|
+
* });
|
|
798
|
+
* ```
|
|
799
|
+
*/
|
|
800
|
+
async getAnalytics(sessionToken, params) {
|
|
801
|
+
if (!sessionToken) {
|
|
802
|
+
throw new Error("sessionToken is required");
|
|
803
|
+
}
|
|
804
|
+
return this.http.request(
|
|
805
|
+
"POST",
|
|
806
|
+
"/advertiser-analytics",
|
|
807
|
+
{
|
|
808
|
+
body: { session_token: sessionToken, ...params },
|
|
809
|
+
skipDefaultAuth: true
|
|
810
|
+
}
|
|
811
|
+
);
|
|
812
|
+
}
|
|
813
|
+
/**
|
|
814
|
+
* Create a new campaign. Uses JWT bearer token for auth.
|
|
815
|
+
*
|
|
816
|
+
* @example
|
|
817
|
+
* ```typescript
|
|
818
|
+
* const campaign = await client.advertiser.createCampaign('jwt_token', {
|
|
819
|
+
* name: 'Summer Sale',
|
|
820
|
+
* ad_type: 'link',
|
|
821
|
+
* daily_budget: 5000,
|
|
822
|
+
* bid_amount: 100,
|
|
823
|
+
* creative: {
|
|
824
|
+
* title: 'Summer Sale - 50% Off',
|
|
825
|
+
* body: 'Limited time offer',
|
|
826
|
+
* cta: 'Shop Now',
|
|
827
|
+
* landing_url: 'https://example.com/sale'
|
|
828
|
+
* }
|
|
829
|
+
* });
|
|
830
|
+
* ```
|
|
831
|
+
*/
|
|
832
|
+
async createCampaign(jwt, request) {
|
|
833
|
+
if (!jwt) {
|
|
834
|
+
throw new Error("jwt is required for campaign creation");
|
|
835
|
+
}
|
|
836
|
+
if (!request.name) {
|
|
837
|
+
throw new Error("name is required");
|
|
838
|
+
}
|
|
839
|
+
if (!request.ad_type) {
|
|
840
|
+
throw new Error("ad_type is required");
|
|
841
|
+
}
|
|
842
|
+
if (!request.creative) {
|
|
843
|
+
throw new Error("creative is required");
|
|
844
|
+
}
|
|
845
|
+
return this.http.request(
|
|
846
|
+
"POST",
|
|
847
|
+
"/campaign-create",
|
|
848
|
+
{
|
|
849
|
+
body: request,
|
|
850
|
+
skipDefaultAuth: true,
|
|
851
|
+
headers: { "Authorization": `Bearer ${jwt}` }
|
|
852
|
+
}
|
|
853
|
+
);
|
|
854
|
+
}
|
|
855
|
+
/**
|
|
856
|
+
* Update an existing campaign. Uses session token in body (no default auth).
|
|
857
|
+
*
|
|
858
|
+
* @example
|
|
859
|
+
* ```typescript
|
|
860
|
+
* const result = await client.advertiser.updateCampaign({
|
|
861
|
+
* campaign_id: 'camp_123',
|
|
862
|
+
* session_token: 'session_token',
|
|
863
|
+
* updates: { name: 'Updated Campaign Name' },
|
|
864
|
+
* status: 'paused'
|
|
865
|
+
* });
|
|
866
|
+
* ```
|
|
867
|
+
*/
|
|
868
|
+
async updateCampaign(request) {
|
|
869
|
+
if (!request.campaign_id) {
|
|
870
|
+
throw new Error("campaign_id is required");
|
|
871
|
+
}
|
|
872
|
+
if (!request.session_token) {
|
|
873
|
+
throw new Error("session_token is required");
|
|
874
|
+
}
|
|
875
|
+
return this.http.request(
|
|
876
|
+
"POST",
|
|
877
|
+
"/campaign-update",
|
|
878
|
+
{ body: request, skipDefaultAuth: true }
|
|
879
|
+
);
|
|
880
|
+
}
|
|
881
|
+
};
|
|
882
|
+
|
|
448
883
|
// src/client.ts
|
|
449
884
|
var DEFAULT_BASE_URL = "https://peruwnbrqkvmrldhpoom.supabase.co/functions/v1";
|
|
450
885
|
var DEFAULT_TIMEOUT_MS = 4e3;
|
|
@@ -453,6 +888,12 @@ var AttentionMarketClient = class {
|
|
|
453
888
|
http;
|
|
454
889
|
agentId;
|
|
455
890
|
appId;
|
|
891
|
+
/** Capability session management (multi-turn AI sessions) */
|
|
892
|
+
sessions;
|
|
893
|
+
/** Developer portal (login, earnings, stats, analytics) */
|
|
894
|
+
developer;
|
|
895
|
+
/** Advertiser portal (signup, login, campaigns, stats) */
|
|
896
|
+
advertiser;
|
|
456
897
|
constructor(config) {
|
|
457
898
|
this.agentId = config.agentId;
|
|
458
899
|
this.appId = config.appId;
|
|
@@ -467,6 +908,9 @@ var AttentionMarketClient = class {
|
|
|
467
908
|
httpConfig.supabaseAnonKey = config.supabaseAnonKey;
|
|
468
909
|
}
|
|
469
910
|
this.http = new HTTPClient(httpConfig);
|
|
911
|
+
this.sessions = new SessionClient(this.http);
|
|
912
|
+
this.developer = new DeveloperClient(this.http);
|
|
913
|
+
this.advertiser = new AdvertiserClient(this.http);
|
|
470
914
|
}
|
|
471
915
|
/**
|
|
472
916
|
* Validate SDK configuration for security
|
|
@@ -665,7 +1109,8 @@ var AttentionMarketClient = class {
|
|
|
665
1109
|
// Developer controls (Phase 2: Revenue Optimization)
|
|
666
1110
|
...params.minCPC !== void 0 && { minCPC: params.minCPC },
|
|
667
1111
|
...params.minRelevanceScore !== void 0 && { minRelevanceScore: params.minRelevanceScore },
|
|
668
|
-
...params.optimizeFor && { optimizeFor: params.optimizeFor }
|
|
1112
|
+
...params.optimizeFor && { optimizeFor: params.optimizeFor },
|
|
1113
|
+
...params.maxWaitMs !== void 0 && { max_wait_ms: params.maxWaitMs }
|
|
669
1114
|
};
|
|
670
1115
|
const response = await this.decideRaw(request, options);
|
|
671
1116
|
if (response && response.creative) {
|
|
@@ -817,6 +1262,24 @@ var AttentionMarketClient = class {
|
|
|
817
1262
|
async sendFeedback(request) {
|
|
818
1263
|
return await this.http.request("POST", "/feedback", { body: request });
|
|
819
1264
|
}
|
|
1265
|
+
/**
|
|
1266
|
+
* Rate the delivery quality of an ad after a verified click.
|
|
1267
|
+
* Requires a prior click event for the tracking_token. Ratings feed
|
|
1268
|
+
* into quality scores (minimum 5 unique raters per campaign).
|
|
1269
|
+
*
|
|
1270
|
+
* @example
|
|
1271
|
+
* ```typescript
|
|
1272
|
+
* await client.rateBusinessDelivery({
|
|
1273
|
+
* tracking_token: ad.tracking_token,
|
|
1274
|
+
* ad_unit_id: ad._ad.unit_id,
|
|
1275
|
+
* rating: 4,
|
|
1276
|
+
* context: 'Relevant product, good landing page'
|
|
1277
|
+
* });
|
|
1278
|
+
* ```
|
|
1279
|
+
*/
|
|
1280
|
+
async rateBusinessDelivery(request) {
|
|
1281
|
+
return await this.http.request("POST", "/rate-business", { body: request });
|
|
1282
|
+
}
|
|
820
1283
|
/**
|
|
821
1284
|
* Fetch default policy constraints and formatting requirements.
|
|
822
1285
|
*/
|
|
@@ -1345,7 +1808,122 @@ var AttentionMarketClient = class {
|
|
|
1345
1808
|
url
|
|
1346
1809
|
);
|
|
1347
1810
|
}
|
|
1348
|
-
//
|
|
1811
|
+
// ==========================================================================
|
|
1812
|
+
// New Methods (v0.18.0)
|
|
1813
|
+
// ==========================================================================
|
|
1814
|
+
/**
|
|
1815
|
+
* Sign up a new agent using the v2 endpoint.
|
|
1816
|
+
* Static method — no API key needed.
|
|
1817
|
+
*
|
|
1818
|
+
* @example
|
|
1819
|
+
* ```typescript
|
|
1820
|
+
* const agent = await AttentionMarketClient.signupAgentV2({
|
|
1821
|
+
* owner_email: 'dev@example.com',
|
|
1822
|
+
* agent_name: 'My Agent',
|
|
1823
|
+
* sdk: 'typescript'
|
|
1824
|
+
* });
|
|
1825
|
+
* console.log(agent.api_key_live);
|
|
1826
|
+
* ```
|
|
1827
|
+
*/
|
|
1828
|
+
static async signupAgentV2(request, baseUrl) {
|
|
1829
|
+
if (!request.owner_email) {
|
|
1830
|
+
throw new Error("owner_email is required");
|
|
1831
|
+
}
|
|
1832
|
+
if (!request.agent_name) {
|
|
1833
|
+
throw new Error("agent_name is required");
|
|
1834
|
+
}
|
|
1835
|
+
const http = new HTTPClient({
|
|
1836
|
+
baseUrl: baseUrl ?? DEFAULT_BASE_URL,
|
|
1837
|
+
timeoutMs: DEFAULT_TIMEOUT_MS,
|
|
1838
|
+
maxRetries: DEFAULT_MAX_RETRIES
|
|
1839
|
+
});
|
|
1840
|
+
return http.request(
|
|
1841
|
+
"POST",
|
|
1842
|
+
"/agent-signup",
|
|
1843
|
+
{ body: request, skipDefaultAuth: true }
|
|
1844
|
+
);
|
|
1845
|
+
}
|
|
1846
|
+
/**
|
|
1847
|
+
* Track an agent-to-agent call using a tracking token.
|
|
1848
|
+
*
|
|
1849
|
+
* @example
|
|
1850
|
+
* ```typescript
|
|
1851
|
+
* await client.trackCall('trk_abc123', { model: 'gpt-4' });
|
|
1852
|
+
* ```
|
|
1853
|
+
*/
|
|
1854
|
+
async trackCall(token, metadata) {
|
|
1855
|
+
if (!token) {
|
|
1856
|
+
throw new Error("token is required for trackCall()");
|
|
1857
|
+
}
|
|
1858
|
+
return this.http.request(
|
|
1859
|
+
"POST",
|
|
1860
|
+
`/track-call/${encodeURIComponent(token)}`,
|
|
1861
|
+
{ body: metadata ? { metadata } : void 0 }
|
|
1862
|
+
);
|
|
1863
|
+
}
|
|
1864
|
+
/**
|
|
1865
|
+
* Scrape a website for knowledge base content.
|
|
1866
|
+
* Requires Bearer JWT and an OpenAI API key header.
|
|
1867
|
+
*
|
|
1868
|
+
* @example
|
|
1869
|
+
* ```typescript
|
|
1870
|
+
* const result = await client.scrapeSite(
|
|
1871
|
+
* { url: 'https://example.com', max_pages: 10 },
|
|
1872
|
+
* 'jwt_token',
|
|
1873
|
+
* 'sk-openai-key'
|
|
1874
|
+
* );
|
|
1875
|
+
* ```
|
|
1876
|
+
*/
|
|
1877
|
+
async scrapeSite(request, jwt, openaiKey) {
|
|
1878
|
+
if (!request.url) {
|
|
1879
|
+
throw new Error("url is required");
|
|
1880
|
+
}
|
|
1881
|
+
if (!jwt) {
|
|
1882
|
+
throw new Error("jwt is required for scrapeSite()");
|
|
1883
|
+
}
|
|
1884
|
+
if (!openaiKey) {
|
|
1885
|
+
throw new Error("openaiKey is required for scrapeSite()");
|
|
1886
|
+
}
|
|
1887
|
+
return this.http.request(
|
|
1888
|
+
"POST",
|
|
1889
|
+
"/scrape-site",
|
|
1890
|
+
{
|
|
1891
|
+
body: request,
|
|
1892
|
+
skipDefaultAuth: true,
|
|
1893
|
+
headers: {
|
|
1894
|
+
"Authorization": `Bearer ${jwt}`,
|
|
1895
|
+
"x-openai-key": openaiKey
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1898
|
+
);
|
|
1899
|
+
}
|
|
1900
|
+
/**
|
|
1901
|
+
* Train an agent with custom knowledge.
|
|
1902
|
+
* No default auth — agent ID is in the request body.
|
|
1903
|
+
*
|
|
1904
|
+
* @example
|
|
1905
|
+
* ```typescript
|
|
1906
|
+
* const result = await client.trainAgent({
|
|
1907
|
+
* agent_id: 'agt_123',
|
|
1908
|
+
* training_data: [
|
|
1909
|
+
* { type: 'document', content: 'Product FAQ...' }
|
|
1910
|
+
* ]
|
|
1911
|
+
* });
|
|
1912
|
+
* ```
|
|
1913
|
+
*/
|
|
1914
|
+
async trainAgent(request) {
|
|
1915
|
+
if (!request.agent_id) {
|
|
1916
|
+
throw new Error("agent_id is required");
|
|
1917
|
+
}
|
|
1918
|
+
if (!request.training_data || request.training_data.length === 0) {
|
|
1919
|
+
throw new Error("training_data is required and must not be empty");
|
|
1920
|
+
}
|
|
1921
|
+
return this.http.request(
|
|
1922
|
+
"POST",
|
|
1923
|
+
"/train-agent",
|
|
1924
|
+
{ body: request, skipDefaultAuth: true }
|
|
1925
|
+
);
|
|
1926
|
+
}
|
|
1349
1927
|
};
|
|
1350
1928
|
|
|
1351
1929
|
// src/mock-client.ts
|
|
@@ -1891,10 +2469,13 @@ function suggestTaxonomies(query) {
|
|
|
1891
2469
|
}
|
|
1892
2470
|
export {
|
|
1893
2471
|
APIRequestError,
|
|
2472
|
+
AdvertiserClient,
|
|
1894
2473
|
AttentionMarketClient,
|
|
1895
2474
|
AttentionMarketError,
|
|
2475
|
+
DeveloperClient,
|
|
1896
2476
|
MockAttentionMarketClient,
|
|
1897
2477
|
NetworkError,
|
|
2478
|
+
SessionClient,
|
|
1898
2479
|
TimeoutError,
|
|
1899
2480
|
buildTaxonomy,
|
|
1900
2481
|
createImpressionEvent,
|