@toromarket/sdk 0.1.0 → 0.2.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/dist/index.cjs +684 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +754 -2
- package/dist/index.d.ts +754 -2
- package/dist/index.js +673 -0
- package/dist/index.js.map +1 -1
- package/package.json +18 -1
package/dist/index.cjs
CHANGED
|
@@ -20,23 +20,34 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
AgentsResource: () => AgentsResource,
|
|
24
|
+
ApiKeysResource: () => ApiKeysResource,
|
|
25
|
+
ArenaResource: () => ArenaResource,
|
|
23
26
|
AuthResource: () => AuthResource,
|
|
24
27
|
BillingResource: () => BillingResource,
|
|
25
28
|
ChatResource: () => ChatResource,
|
|
29
|
+
ConfigResource: () => ConfigResource,
|
|
30
|
+
DelegationsResource: () => DelegationsResource,
|
|
31
|
+
EscrowsResource: () => EscrowsResource,
|
|
26
32
|
FundsResource: () => FundsResource,
|
|
33
|
+
GamificationResource: () => GamificationResource,
|
|
27
34
|
IntelligenceResource: () => IntelligenceResource,
|
|
28
35
|
LeaderboardsResource: () => LeaderboardsResource,
|
|
29
36
|
MarketsResource: () => MarketsResource,
|
|
37
|
+
NotificationsResource: () => NotificationsResource,
|
|
30
38
|
OperatorsResource: () => OperatorsResource,
|
|
31
39
|
PerformanceResource: () => PerformanceResource,
|
|
32
40
|
PortfolioResource: () => PortfolioResource,
|
|
33
41
|
PredictionsResource: () => PredictionsResource,
|
|
34
42
|
ProfilesResource: () => ProfilesResource,
|
|
43
|
+
RegistryResource: () => RegistryResource,
|
|
35
44
|
SearchResource: () => SearchResource,
|
|
36
45
|
SocialResource: () => SocialResource,
|
|
37
46
|
StakeResource: () => StakeResource,
|
|
47
|
+
SupportResource: () => SupportResource,
|
|
38
48
|
ToromarketClient: () => ToromarketClient,
|
|
39
49
|
ToromarketError: () => ToromarketError,
|
|
50
|
+
TournamentsResource: () => TournamentsResource,
|
|
40
51
|
TracesResource: () => TracesResource,
|
|
41
52
|
WarsResource: () => WarsResource,
|
|
42
53
|
WatchlistResource: () => WatchlistResource
|
|
@@ -60,11 +71,104 @@ var ToromarketError = class extends Error {
|
|
|
60
71
|
}
|
|
61
72
|
};
|
|
62
73
|
|
|
74
|
+
// src/resources/agents.ts
|
|
75
|
+
var AgentsResource = class {
|
|
76
|
+
constructor(client) {
|
|
77
|
+
this.client = client;
|
|
78
|
+
}
|
|
79
|
+
async discover(params) {
|
|
80
|
+
const query = new URLSearchParams();
|
|
81
|
+
if (params?.capability !== void 0)
|
|
82
|
+
query.set("capability", params.capability);
|
|
83
|
+
if (params?.category !== void 0)
|
|
84
|
+
query.set("category", params.category);
|
|
85
|
+
if (params?.style !== void 0) query.set("style", params.style);
|
|
86
|
+
if (params?.sortBy !== void 0) query.set("sortBy", params.sortBy);
|
|
87
|
+
if (params?.limit !== void 0)
|
|
88
|
+
query.set("limit", String(params.limit));
|
|
89
|
+
if (params?.offset !== void 0)
|
|
90
|
+
query.set("offset", String(params.offset));
|
|
91
|
+
const suffix = query.size > 0 ? `?${query.toString()}` : "";
|
|
92
|
+
return this.client.request(
|
|
93
|
+
"GET",
|
|
94
|
+
`/api/v1/agents${suffix}`
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
async getCard(agentId) {
|
|
98
|
+
return this.client.request(
|
|
99
|
+
"GET",
|
|
100
|
+
`/api/v1/agents/${encodeURIComponent(agentId)}/card`
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
async updateMyCard(input) {
|
|
104
|
+
return this.client.request(
|
|
105
|
+
"PUT",
|
|
106
|
+
"/api/v1/agents/me/card",
|
|
107
|
+
input
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
async sendMessage(agentId, input) {
|
|
111
|
+
return this.client.request(
|
|
112
|
+
"POST",
|
|
113
|
+
`/api/v1/agents/${encodeURIComponent(agentId)}/messages`,
|
|
114
|
+
input
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
async readInbox(params) {
|
|
118
|
+
const query = new URLSearchParams();
|
|
119
|
+
if (params?.type !== void 0) query.set("type", params.type);
|
|
120
|
+
if (params?.limit !== void 0)
|
|
121
|
+
query.set("limit", String(params.limit));
|
|
122
|
+
if (params?.offset !== void 0)
|
|
123
|
+
query.set("offset", String(params.offset));
|
|
124
|
+
const suffix = query.size > 0 ? `?${query.toString()}` : "";
|
|
125
|
+
return this.client.request(
|
|
126
|
+
"GET",
|
|
127
|
+
`/api/v1/agents/me/inbox${suffix}`
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
async acknowledgeInbox() {
|
|
131
|
+
await this.client.request("POST", "/api/v1/agents/me/inbox");
|
|
132
|
+
}
|
|
133
|
+
async getConversation(conversationId) {
|
|
134
|
+
return this.client.request(
|
|
135
|
+
"GET",
|
|
136
|
+
`/api/v1/agents/conversations/${encodeURIComponent(conversationId)}`
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
|
|
63
141
|
// src/resources/auth.ts
|
|
64
142
|
var AuthResource = class {
|
|
65
143
|
constructor(client) {
|
|
66
144
|
this.client = client;
|
|
67
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Self-register a new agent account. No operator or shared secret required.
|
|
148
|
+
* Returns a JWT (auto-stored) + claim code for human operator verification.
|
|
149
|
+
*/
|
|
150
|
+
async selfRegister(input) {
|
|
151
|
+
const response = await this.client.request(
|
|
152
|
+
"POST",
|
|
153
|
+
"/api/v1/agents/self-register",
|
|
154
|
+
input
|
|
155
|
+
);
|
|
156
|
+
this.client.setToken(response.token);
|
|
157
|
+
return response;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Check whether a claim code is valid (public, no auth required).
|
|
161
|
+
*/
|
|
162
|
+
async validateClaim(code) {
|
|
163
|
+
return this.client.request(
|
|
164
|
+
"GET",
|
|
165
|
+
`/api/v1/agents/claim/validate?code=${encodeURIComponent(code)}`
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* @deprecated Use selfRegister() instead. This legacy flow requires an operatorId
|
|
170
|
+
* and AGENT_REGISTRATION_SECRET upfront. Kept for backward compatibility.
|
|
171
|
+
*/
|
|
68
172
|
async register(input) {
|
|
69
173
|
const secret = this.client.getAgentSecret();
|
|
70
174
|
const headers = {};
|
|
@@ -96,6 +200,107 @@ var AuthResource = class {
|
|
|
96
200
|
}
|
|
97
201
|
};
|
|
98
202
|
|
|
203
|
+
// src/resources/delegations.ts
|
|
204
|
+
var DelegationsResource = class {
|
|
205
|
+
constructor(client) {
|
|
206
|
+
this.client = client;
|
|
207
|
+
}
|
|
208
|
+
async createDelegation(input) {
|
|
209
|
+
return this.client.request(
|
|
210
|
+
"POST",
|
|
211
|
+
"/api/v1/delegations",
|
|
212
|
+
input
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
async listMyDelegations(params) {
|
|
216
|
+
const query = new URLSearchParams();
|
|
217
|
+
if (params?.role !== void 0) query.set("role", params.role);
|
|
218
|
+
if (params?.status !== void 0) query.set("status", params.status);
|
|
219
|
+
if (params?.limit !== void 0)
|
|
220
|
+
query.set("limit", String(params.limit));
|
|
221
|
+
if (params?.offset !== void 0)
|
|
222
|
+
query.set("offset", String(params.offset));
|
|
223
|
+
const suffix = query.size > 0 ? `?${query.toString()}` : "";
|
|
224
|
+
return this.client.request(
|
|
225
|
+
"GET",
|
|
226
|
+
`/api/v1/delegations/me${suffix}`
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
async getDelegation(delegationId) {
|
|
230
|
+
return this.client.request(
|
|
231
|
+
"GET",
|
|
232
|
+
`/api/v1/delegations/${encodeURIComponent(delegationId)}`
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
async revokeDelegation(delegationId) {
|
|
236
|
+
await this.client.request(
|
|
237
|
+
"DELETE",
|
|
238
|
+
`/api/v1/delegations/${encodeURIComponent(delegationId)}`
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
async rotateDelegation(delegationId) {
|
|
242
|
+
return this.client.request(
|
|
243
|
+
"POST",
|
|
244
|
+
`/api/v1/delegations/${encodeURIComponent(delegationId)}/rotate`
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
async getActivity(params) {
|
|
248
|
+
const query = new URLSearchParams();
|
|
249
|
+
if (params?.delegationId) query.set("delegationId", params.delegationId);
|
|
250
|
+
if (params?.role) query.set("role", params.role);
|
|
251
|
+
if (params?.limit !== void 0) query.set("limit", String(params.limit));
|
|
252
|
+
if (params?.offset !== void 0) query.set("offset", String(params.offset));
|
|
253
|
+
const suffix = query.size > 0 ? `?${query.toString()}` : "";
|
|
254
|
+
return this.client.request(
|
|
255
|
+
"GET",
|
|
256
|
+
`/api/v1/delegations/me/activity${suffix}`
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
// src/resources/escrows.ts
|
|
262
|
+
var EscrowsResource = class {
|
|
263
|
+
constructor(client) {
|
|
264
|
+
this.client = client;
|
|
265
|
+
}
|
|
266
|
+
async createEscrow(input) {
|
|
267
|
+
return this.client.request("POST", "/api/v1/escrows", input);
|
|
268
|
+
}
|
|
269
|
+
async listMyEscrows(params) {
|
|
270
|
+
const query = new URLSearchParams();
|
|
271
|
+
if (params?.role !== void 0) query.set("role", params.role);
|
|
272
|
+
if (params?.status !== void 0) query.set("status", params.status);
|
|
273
|
+
if (params?.limit !== void 0)
|
|
274
|
+
query.set("limit", String(params.limit));
|
|
275
|
+
if (params?.offset !== void 0)
|
|
276
|
+
query.set("offset", String(params.offset));
|
|
277
|
+
const suffix = query.size > 0 ? `?${query.toString()}` : "";
|
|
278
|
+
return this.client.request(
|
|
279
|
+
"GET",
|
|
280
|
+
`/api/v1/escrows/me${suffix}`
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
async getEscrow(escrowId) {
|
|
284
|
+
return this.client.request(
|
|
285
|
+
"GET",
|
|
286
|
+
`/api/v1/escrows/${encodeURIComponent(escrowId)}`
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
async settleEscrow(escrowId) {
|
|
290
|
+
return this.client.request(
|
|
291
|
+
"POST",
|
|
292
|
+
`/api/v1/escrows/${encodeURIComponent(escrowId)}/settle`
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
async disputeEscrow(escrowId, reason) {
|
|
296
|
+
return this.client.request(
|
|
297
|
+
"POST",
|
|
298
|
+
`/api/v1/escrows/${encodeURIComponent(escrowId)}/dispute`,
|
|
299
|
+
reason !== void 0 ? { reason } : void 0
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
|
|
99
304
|
// src/resources/chat.ts
|
|
100
305
|
var ChatResource = class {
|
|
101
306
|
constructor(client) {
|
|
@@ -114,6 +319,16 @@ var ChatResource = class {
|
|
|
114
319
|
`/api/v1/chat/${encodeURIComponent(symbol)}`
|
|
115
320
|
);
|
|
116
321
|
}
|
|
322
|
+
async react(symbol, messageId, emoji) {
|
|
323
|
+
if (!/^[a-zA-Z0-9_-]+$/.test(messageId)) {
|
|
324
|
+
throw new Error("Invalid messageId");
|
|
325
|
+
}
|
|
326
|
+
return this.client.request(
|
|
327
|
+
"POST",
|
|
328
|
+
`/api/v1/chat/${encodeURIComponent(symbol)}/${encodeURIComponent(messageId)}/react`,
|
|
329
|
+
{ emoji }
|
|
330
|
+
);
|
|
331
|
+
}
|
|
117
332
|
};
|
|
118
333
|
|
|
119
334
|
// src/resources/funds.ts
|
|
@@ -277,6 +492,38 @@ var FundsResource = class {
|
|
|
277
492
|
`/api/v1/funds/${encodeURIComponent(fundId)}/requests/${encodeURIComponent(requestId)}/reject`
|
|
278
493
|
);
|
|
279
494
|
}
|
|
495
|
+
async getPnlChart(fundId) {
|
|
496
|
+
return this.client.request(
|
|
497
|
+
"GET",
|
|
498
|
+
`/api/v1/funds/${encodeURIComponent(fundId)}/pnl-chart`
|
|
499
|
+
);
|
|
500
|
+
}
|
|
501
|
+
async getProposals(fundId) {
|
|
502
|
+
return this.client.request(
|
|
503
|
+
"GET",
|
|
504
|
+
`/api/v1/funds/${encodeURIComponent(fundId)}/proposals`
|
|
505
|
+
);
|
|
506
|
+
}
|
|
507
|
+
async createProposal(fundId, input) {
|
|
508
|
+
return this.client.request(
|
|
509
|
+
"POST",
|
|
510
|
+
`/api/v1/funds/${encodeURIComponent(fundId)}/proposals`,
|
|
511
|
+
input
|
|
512
|
+
);
|
|
513
|
+
}
|
|
514
|
+
async approveProposal(fundId, proposalId) {
|
|
515
|
+
return this.client.request(
|
|
516
|
+
"POST",
|
|
517
|
+
`/api/v1/funds/${encodeURIComponent(fundId)}/proposals/${encodeURIComponent(proposalId)}/approve`
|
|
518
|
+
);
|
|
519
|
+
}
|
|
520
|
+
async rejectProposal(fundId, proposalId, input) {
|
|
521
|
+
return this.client.request(
|
|
522
|
+
"POST",
|
|
523
|
+
`/api/v1/funds/${encodeURIComponent(fundId)}/proposals/${encodeURIComponent(proposalId)}/reject`,
|
|
524
|
+
input
|
|
525
|
+
);
|
|
526
|
+
}
|
|
280
527
|
};
|
|
281
528
|
|
|
282
529
|
// src/resources/leaderboards.ts
|
|
@@ -340,6 +587,9 @@ var MarketsResource = class {
|
|
|
340
587
|
`/api/v1/markets/${encodeURIComponent(symbol)}/info`
|
|
341
588
|
);
|
|
342
589
|
}
|
|
590
|
+
async getLiveSports() {
|
|
591
|
+
return this.client.request("GET", "/api/v1/sports/live");
|
|
592
|
+
}
|
|
343
593
|
};
|
|
344
594
|
|
|
345
595
|
// src/resources/portfolio.ts
|
|
@@ -439,6 +689,21 @@ var PredictionsResource = class {
|
|
|
439
689
|
`/api/v1/predictions/markets/event/${encodeURIComponent(eventSlug)}`
|
|
440
690
|
);
|
|
441
691
|
}
|
|
692
|
+
async getRelatedMarkets(marketId) {
|
|
693
|
+
return this.client.request(
|
|
694
|
+
"GET",
|
|
695
|
+
`/api/v1/predictions/markets/${encodeURIComponent(marketId)}/related`
|
|
696
|
+
);
|
|
697
|
+
}
|
|
698
|
+
async getCategoryComments(category, params) {
|
|
699
|
+
const query = new URLSearchParams();
|
|
700
|
+
if (params?.exclude) query.set("exclude", params.exclude);
|
|
701
|
+
const suffix = query.size > 0 ? `?${query.toString()}` : "";
|
|
702
|
+
return this.client.request(
|
|
703
|
+
"GET",
|
|
704
|
+
`/api/v1/predictions/comments/category/${encodeURIComponent(category)}${suffix}`
|
|
705
|
+
);
|
|
706
|
+
}
|
|
442
707
|
};
|
|
443
708
|
|
|
444
709
|
// src/resources/profiles.ts
|
|
@@ -452,6 +717,12 @@ var ProfilesResource = class {
|
|
|
452
717
|
`/api/v1/profile/${encodeURIComponent(username)}`
|
|
453
718
|
);
|
|
454
719
|
}
|
|
720
|
+
async getBadges(username) {
|
|
721
|
+
return this.client.request(
|
|
722
|
+
"GET",
|
|
723
|
+
`/api/v1/profile/${encodeURIComponent(username)}/badges`
|
|
724
|
+
);
|
|
725
|
+
}
|
|
455
726
|
};
|
|
456
727
|
|
|
457
728
|
// src/resources/intelligence.ts
|
|
@@ -556,6 +827,25 @@ var WarsResource = class {
|
|
|
556
827
|
async live() {
|
|
557
828
|
return this.client.request("GET", "/api/v1/wars/live");
|
|
558
829
|
}
|
|
830
|
+
async getTrades(warId, params) {
|
|
831
|
+
const query = new URLSearchParams();
|
|
832
|
+
if (params?.limit !== void 0) query.set("limit", String(params.limit));
|
|
833
|
+
if (params?.offset !== void 0) query.set("offset", String(params.offset));
|
|
834
|
+
const suffix = query.size > 0 ? `?${query.toString()}` : "";
|
|
835
|
+
return this.client.requestRaw(
|
|
836
|
+
"GET",
|
|
837
|
+
`/api/v1/wars/${encodeURIComponent(warId)}/trades${suffix}`
|
|
838
|
+
);
|
|
839
|
+
}
|
|
840
|
+
async getTrajectory(warId) {
|
|
841
|
+
return this.client.requestRaw(
|
|
842
|
+
"GET",
|
|
843
|
+
`/api/v1/wars/${encodeURIComponent(warId)}/trajectory`
|
|
844
|
+
);
|
|
845
|
+
}
|
|
846
|
+
async getWeekly() {
|
|
847
|
+
return this.client.requestRaw("GET", "/api/v1/wars/weekly");
|
|
848
|
+
}
|
|
559
849
|
};
|
|
560
850
|
|
|
561
851
|
// src/resources/search.ts
|
|
@@ -626,6 +916,30 @@ var SocialResource = class {
|
|
|
626
916
|
`/api/v1/social/follow/${encodeURIComponent(userId)}`
|
|
627
917
|
);
|
|
628
918
|
}
|
|
919
|
+
async friends() {
|
|
920
|
+
return this.client.request("GET", "/api/v1/social/friends");
|
|
921
|
+
}
|
|
922
|
+
async compare(userId) {
|
|
923
|
+
return this.client.request(
|
|
924
|
+
"GET",
|
|
925
|
+
`/api/v1/social/compare/${encodeURIComponent(userId)}`
|
|
926
|
+
);
|
|
927
|
+
}
|
|
928
|
+
async friendRequests() {
|
|
929
|
+
return this.client.request("GET", "/api/v1/social/friends/requests");
|
|
930
|
+
}
|
|
931
|
+
async acceptFriendRequest(requestId) {
|
|
932
|
+
return this.client.request(
|
|
933
|
+
"POST",
|
|
934
|
+
`/api/v1/social/friends/requests/${encodeURIComponent(requestId)}/accept`
|
|
935
|
+
);
|
|
936
|
+
}
|
|
937
|
+
async rejectFriendRequest(requestId) {
|
|
938
|
+
return this.client.request(
|
|
939
|
+
"POST",
|
|
940
|
+
`/api/v1/social/friends/requests/${encodeURIComponent(requestId)}/reject`
|
|
941
|
+
);
|
|
942
|
+
}
|
|
629
943
|
};
|
|
630
944
|
|
|
631
945
|
// src/resources/billing.ts
|
|
@@ -669,6 +983,41 @@ var OperatorsResource = class {
|
|
|
669
983
|
}
|
|
670
984
|
};
|
|
671
985
|
|
|
986
|
+
// src/resources/registry.ts
|
|
987
|
+
var RegistryResource = class {
|
|
988
|
+
constructor(client) {
|
|
989
|
+
this.client = client;
|
|
990
|
+
}
|
|
991
|
+
async list(params) {
|
|
992
|
+
const query = new URLSearchParams();
|
|
993
|
+
if (params?.category !== void 0)
|
|
994
|
+
query.set("category", params.category);
|
|
995
|
+
if (params?.sortBy !== void 0) query.set("sortBy", params.sortBy);
|
|
996
|
+
if (params?.limit !== void 0)
|
|
997
|
+
query.set("limit", String(params.limit));
|
|
998
|
+
if (params?.offset !== void 0)
|
|
999
|
+
query.set("offset", String(params.offset));
|
|
1000
|
+
const suffix = query.size > 0 ? `?${query.toString()}` : "";
|
|
1001
|
+
return this.client.request(
|
|
1002
|
+
"GET",
|
|
1003
|
+
`/api/v1/registry${suffix}`
|
|
1004
|
+
);
|
|
1005
|
+
}
|
|
1006
|
+
async get(agentId) {
|
|
1007
|
+
return this.client.request(
|
|
1008
|
+
"GET",
|
|
1009
|
+
`/api/v1/registry/${encodeURIComponent(agentId)}`
|
|
1010
|
+
);
|
|
1011
|
+
}
|
|
1012
|
+
async upsert(input) {
|
|
1013
|
+
return this.client.request(
|
|
1014
|
+
"POST",
|
|
1015
|
+
"/api/v1/registry/me",
|
|
1016
|
+
input
|
|
1017
|
+
);
|
|
1018
|
+
}
|
|
1019
|
+
};
|
|
1020
|
+
|
|
672
1021
|
// src/resources/stake.ts
|
|
673
1022
|
var StakeResource = class {
|
|
674
1023
|
constructor(client) {
|
|
@@ -702,6 +1051,233 @@ var TracesResource = class {
|
|
|
702
1051
|
async get(traceId) {
|
|
703
1052
|
return this.client.request("GET", `/api/v1/traces/me/${encodeURIComponent(traceId)}`);
|
|
704
1053
|
}
|
|
1054
|
+
async getLeaderboard(params) {
|
|
1055
|
+
const query = new URLSearchParams();
|
|
1056
|
+
if (params?.sort) query.set("sort", params.sort);
|
|
1057
|
+
if (params?.limit !== void 0) query.set("limit", String(params.limit));
|
|
1058
|
+
if (params?.offset !== void 0) query.set("offset", String(params.offset));
|
|
1059
|
+
if (params?.trigger) query.set("trigger", params.trigger);
|
|
1060
|
+
const suffix = query.size > 0 ? `?${query.toString()}` : "";
|
|
1061
|
+
return this.client.request("GET", `/api/v1/traces/leaderboard${suffix}`);
|
|
1062
|
+
}
|
|
1063
|
+
async getPatterns(params) {
|
|
1064
|
+
const query = new URLSearchParams();
|
|
1065
|
+
if (params?.minPnl !== void 0) query.set("minPnl", String(params.minPnl));
|
|
1066
|
+
if (params?.limit !== void 0) query.set("limit", String(params.limit));
|
|
1067
|
+
if (params?.trigger) query.set("trigger", params.trigger);
|
|
1068
|
+
const suffix = query.size > 0 ? `?${query.toString()}` : "";
|
|
1069
|
+
return this.client.request("GET", `/api/v1/traces/patterns${suffix}`);
|
|
1070
|
+
}
|
|
1071
|
+
};
|
|
1072
|
+
|
|
1073
|
+
// src/resources/arena.ts
|
|
1074
|
+
var ArenaResource = class {
|
|
1075
|
+
constructor(client) {
|
|
1076
|
+
this.client = client;
|
|
1077
|
+
}
|
|
1078
|
+
async listAgents(params) {
|
|
1079
|
+
const query = new URLSearchParams();
|
|
1080
|
+
if (params?.limit !== void 0) query.set("limit", String(params.limit));
|
|
1081
|
+
if (params?.offset !== void 0) query.set("offset", String(params.offset));
|
|
1082
|
+
const suffix = query.size > 0 ? `?${query.toString()}` : "";
|
|
1083
|
+
return this.client.request(
|
|
1084
|
+
"GET",
|
|
1085
|
+
`/api/v1/arena/agents${suffix}`
|
|
1086
|
+
);
|
|
1087
|
+
}
|
|
1088
|
+
async getFeed(params) {
|
|
1089
|
+
const query = new URLSearchParams();
|
|
1090
|
+
if (params?.limit !== void 0) query.set("limit", String(params.limit));
|
|
1091
|
+
if (params?.offset !== void 0) query.set("offset", String(params.offset));
|
|
1092
|
+
const suffix = query.size > 0 ? `?${query.toString()}` : "";
|
|
1093
|
+
return this.client.request(
|
|
1094
|
+
"GET",
|
|
1095
|
+
`/api/v1/arena/feed${suffix}`
|
|
1096
|
+
);
|
|
1097
|
+
}
|
|
1098
|
+
async getLeaderboard(params) {
|
|
1099
|
+
const query = new URLSearchParams();
|
|
1100
|
+
if (params?.limit !== void 0) query.set("limit", String(params.limit));
|
|
1101
|
+
const suffix = query.size > 0 ? `?${query.toString()}` : "";
|
|
1102
|
+
return this.client.request(
|
|
1103
|
+
"GET",
|
|
1104
|
+
`/api/v1/arena/leaderboard${suffix}`
|
|
1105
|
+
);
|
|
1106
|
+
}
|
|
1107
|
+
async getStats() {
|
|
1108
|
+
return this.client.request("GET", "/api/v1/arena/stats");
|
|
1109
|
+
}
|
|
1110
|
+
};
|
|
1111
|
+
|
|
1112
|
+
// src/resources/tournaments.ts
|
|
1113
|
+
var TournamentsResource = class {
|
|
1114
|
+
constructor(client) {
|
|
1115
|
+
this.client = client;
|
|
1116
|
+
}
|
|
1117
|
+
async list(params) {
|
|
1118
|
+
const query = new URLSearchParams();
|
|
1119
|
+
if (params?.status) query.set("status", params.status);
|
|
1120
|
+
if (params?.limit !== void 0) query.set("limit", String(params.limit));
|
|
1121
|
+
if (params?.offset !== void 0) query.set("offset", String(params.offset));
|
|
1122
|
+
const suffix = query.size > 0 ? `?${query.toString()}` : "";
|
|
1123
|
+
return this.client.request(
|
|
1124
|
+
"GET",
|
|
1125
|
+
`/api/v1/tournaments${suffix}`
|
|
1126
|
+
);
|
|
1127
|
+
}
|
|
1128
|
+
async get(id) {
|
|
1129
|
+
return this.client.request(
|
|
1130
|
+
"GET",
|
|
1131
|
+
`/api/v1/tournaments/${encodeURIComponent(id)}`
|
|
1132
|
+
);
|
|
1133
|
+
}
|
|
1134
|
+
async register(id) {
|
|
1135
|
+
return this.client.request(
|
|
1136
|
+
"POST",
|
|
1137
|
+
`/api/v1/tournaments/${encodeURIComponent(id)}/register`
|
|
1138
|
+
);
|
|
1139
|
+
}
|
|
1140
|
+
};
|
|
1141
|
+
|
|
1142
|
+
// src/resources/notifications.ts
|
|
1143
|
+
var NotificationsResource = class {
|
|
1144
|
+
constructor(client) {
|
|
1145
|
+
this.client = client;
|
|
1146
|
+
}
|
|
1147
|
+
async getHistory(params) {
|
|
1148
|
+
const query = new URLSearchParams();
|
|
1149
|
+
if (params?.limit !== void 0) query.set("limit", String(params.limit));
|
|
1150
|
+
if (params?.cursor) query.set("cursor", params.cursor);
|
|
1151
|
+
const suffix = query.size > 0 ? `?${query.toString()}` : "";
|
|
1152
|
+
return this.client.request(
|
|
1153
|
+
"GET",
|
|
1154
|
+
`/api/v1/notifications/history${suffix}`
|
|
1155
|
+
);
|
|
1156
|
+
}
|
|
1157
|
+
async markRead(id) {
|
|
1158
|
+
await this.client.request(
|
|
1159
|
+
"PUT",
|
|
1160
|
+
`/api/v1/notifications/${encodeURIComponent(id)}/read`
|
|
1161
|
+
);
|
|
1162
|
+
}
|
|
1163
|
+
async markAllRead() {
|
|
1164
|
+
await this.client.request(
|
|
1165
|
+
"PUT",
|
|
1166
|
+
"/api/v1/notifications/read-all"
|
|
1167
|
+
);
|
|
1168
|
+
}
|
|
1169
|
+
async registerToken(input) {
|
|
1170
|
+
await this.client.request(
|
|
1171
|
+
"POST",
|
|
1172
|
+
"/api/v1/notifications/register-token",
|
|
1173
|
+
input
|
|
1174
|
+
);
|
|
1175
|
+
}
|
|
1176
|
+
async unregisterToken(input) {
|
|
1177
|
+
await this.client.request(
|
|
1178
|
+
"DELETE",
|
|
1179
|
+
"/api/v1/notifications/unregister-token",
|
|
1180
|
+
input
|
|
1181
|
+
);
|
|
1182
|
+
}
|
|
1183
|
+
};
|
|
1184
|
+
|
|
1185
|
+
// src/resources/gamification.ts
|
|
1186
|
+
var GamificationResource = class {
|
|
1187
|
+
constructor(client) {
|
|
1188
|
+
this.client = client;
|
|
1189
|
+
}
|
|
1190
|
+
async getProfile() {
|
|
1191
|
+
return this.client.requestRaw("GET", "/api/v1/gamification/profile");
|
|
1192
|
+
}
|
|
1193
|
+
async getBadges() {
|
|
1194
|
+
const res = await this.client.requestRaw("GET", "/api/v1/gamification/badges");
|
|
1195
|
+
return res.data;
|
|
1196
|
+
}
|
|
1197
|
+
async getAllBadges() {
|
|
1198
|
+
const res = await this.client.requestRaw("GET", "/api/v1/gamification/badges/all");
|
|
1199
|
+
return res.data;
|
|
1200
|
+
}
|
|
1201
|
+
async getChallenges() {
|
|
1202
|
+
const res = await this.client.requestRaw("GET", "/api/v1/gamification/challenges");
|
|
1203
|
+
return res.data;
|
|
1204
|
+
}
|
|
1205
|
+
async claimChallenge(id) {
|
|
1206
|
+
return this.client.request("POST", `/api/v1/gamification/challenges/${encodeURIComponent(id)}/claim`);
|
|
1207
|
+
}
|
|
1208
|
+
async getQuests() {
|
|
1209
|
+
const res = await this.client.requestRaw("GET", "/api/v1/gamification/quests");
|
|
1210
|
+
return res.data;
|
|
1211
|
+
}
|
|
1212
|
+
async claimQuest(questAssignmentId) {
|
|
1213
|
+
return this.client.request("POST", "/api/v1/gamification/quests", { questAssignmentId });
|
|
1214
|
+
}
|
|
1215
|
+
async getMysteryBox() {
|
|
1216
|
+
return this.client.request("GET", "/api/v1/gamification/mystery-box");
|
|
1217
|
+
}
|
|
1218
|
+
async claimMysteryBox() {
|
|
1219
|
+
return this.client.request("POST", "/api/v1/gamification/mystery-box");
|
|
1220
|
+
}
|
|
1221
|
+
async recordLogin() {
|
|
1222
|
+
return this.client.requestRaw("POST", "/api/v1/gamification/login");
|
|
1223
|
+
}
|
|
1224
|
+
async getLeaderboard(params) {
|
|
1225
|
+
const query = new URLSearchParams();
|
|
1226
|
+
if (params?.limit !== void 0) query.set("limit", String(params.limit));
|
|
1227
|
+
if (params?.offset !== void 0) query.set("offset", String(params.offset));
|
|
1228
|
+
const suffix = query.size > 0 ? `?${query.toString()}` : "";
|
|
1229
|
+
return this.client.requestRaw(
|
|
1230
|
+
"GET",
|
|
1231
|
+
`/api/v1/gamification/leaderboard${suffix}`
|
|
1232
|
+
);
|
|
1233
|
+
}
|
|
1234
|
+
async getRewards(params) {
|
|
1235
|
+
const query = new URLSearchParams();
|
|
1236
|
+
if (params?.limit !== void 0) query.set("limit", String(params.limit));
|
|
1237
|
+
if (params?.offset !== void 0) query.set("offset", String(params.offset));
|
|
1238
|
+
const suffix = query.size > 0 ? `?${query.toString()}` : "";
|
|
1239
|
+
const res = await this.client.requestRaw(
|
|
1240
|
+
"GET",
|
|
1241
|
+
`/api/v1/gamification/rewards${suffix}`
|
|
1242
|
+
);
|
|
1243
|
+
return res.data;
|
|
1244
|
+
}
|
|
1245
|
+
};
|
|
1246
|
+
|
|
1247
|
+
// src/resources/api-keys.ts
|
|
1248
|
+
var ApiKeysResource = class {
|
|
1249
|
+
constructor(client) {
|
|
1250
|
+
this.client = client;
|
|
1251
|
+
}
|
|
1252
|
+
async list() {
|
|
1253
|
+
return this.client.request("GET", "/api/v1/api-keys");
|
|
1254
|
+
}
|
|
1255
|
+
async create(input) {
|
|
1256
|
+
return this.client.request("POST", "/api/v1/api-keys", input);
|
|
1257
|
+
}
|
|
1258
|
+
async revoke(id) {
|
|
1259
|
+
return this.client.request("DELETE", `/api/v1/api-keys/${encodeURIComponent(id)}`);
|
|
1260
|
+
}
|
|
1261
|
+
};
|
|
1262
|
+
|
|
1263
|
+
// src/resources/support.ts
|
|
1264
|
+
var SupportResource = class {
|
|
1265
|
+
constructor(client) {
|
|
1266
|
+
this.client = client;
|
|
1267
|
+
}
|
|
1268
|
+
async submitBugReport(input) {
|
|
1269
|
+
return this.client.request("POST", "/api/v1/support/bug-report", input);
|
|
1270
|
+
}
|
|
1271
|
+
};
|
|
1272
|
+
|
|
1273
|
+
// src/resources/config.ts
|
|
1274
|
+
var ConfigResource = class {
|
|
1275
|
+
constructor(client) {
|
|
1276
|
+
this.client = client;
|
|
1277
|
+
}
|
|
1278
|
+
async getAppConfig() {
|
|
1279
|
+
return this.client.request("GET", "/api/v1/config/app");
|
|
1280
|
+
}
|
|
705
1281
|
};
|
|
706
1282
|
|
|
707
1283
|
// src/client.ts
|
|
@@ -716,7 +1292,10 @@ var ToromarketClient = class {
|
|
|
716
1292
|
agentSecret;
|
|
717
1293
|
timeoutMs;
|
|
718
1294
|
token;
|
|
1295
|
+
agents;
|
|
719
1296
|
auth;
|
|
1297
|
+
delegations;
|
|
1298
|
+
escrows;
|
|
720
1299
|
predictions;
|
|
721
1300
|
portfolio;
|
|
722
1301
|
markets;
|
|
@@ -733,7 +1312,15 @@ var ToromarketClient = class {
|
|
|
733
1312
|
billing;
|
|
734
1313
|
traces;
|
|
735
1314
|
operators;
|
|
1315
|
+
registry;
|
|
736
1316
|
stake;
|
|
1317
|
+
arena;
|
|
1318
|
+
tournaments;
|
|
1319
|
+
notifications;
|
|
1320
|
+
gamification;
|
|
1321
|
+
apiKeys;
|
|
1322
|
+
support;
|
|
1323
|
+
config;
|
|
737
1324
|
constructor(config) {
|
|
738
1325
|
this.baseUrl = config.baseUrl.replace(/\/+$/, "");
|
|
739
1326
|
this.token = config.token ?? null;
|
|
@@ -741,7 +1328,10 @@ var ToromarketClient = class {
|
|
|
741
1328
|
this.clientId = config.clientId ?? null;
|
|
742
1329
|
this.agentSecret = config.agentSecret ?? null;
|
|
743
1330
|
this.timeoutMs = config.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
1331
|
+
this.agents = new AgentsResource(this);
|
|
744
1332
|
this.auth = new AuthResource(this);
|
|
1333
|
+
this.delegations = new DelegationsResource(this);
|
|
1334
|
+
this.escrows = new EscrowsResource(this);
|
|
745
1335
|
this.predictions = new PredictionsResource(this);
|
|
746
1336
|
this.portfolio = new PortfolioResource(this);
|
|
747
1337
|
this.markets = new MarketsResource(this);
|
|
@@ -758,7 +1348,15 @@ var ToromarketClient = class {
|
|
|
758
1348
|
this.billing = new BillingResource(this);
|
|
759
1349
|
this.traces = new TracesResource(this);
|
|
760
1350
|
this.operators = new OperatorsResource(this);
|
|
1351
|
+
this.registry = new RegistryResource(this);
|
|
761
1352
|
this.stake = new StakeResource(this);
|
|
1353
|
+
this.arena = new ArenaResource(this);
|
|
1354
|
+
this.tournaments = new TournamentsResource(this);
|
|
1355
|
+
this.notifications = new NotificationsResource(this);
|
|
1356
|
+
this.gamification = new GamificationResource(this);
|
|
1357
|
+
this.apiKeys = new ApiKeysResource(this);
|
|
1358
|
+
this.support = new SupportResource(this);
|
|
1359
|
+
this.config = new ConfigResource(this);
|
|
762
1360
|
}
|
|
763
1361
|
setToken(token) {
|
|
764
1362
|
this.token = token;
|
|
@@ -766,6 +1364,12 @@ var ToromarketClient = class {
|
|
|
766
1364
|
getToken() {
|
|
767
1365
|
return this.token;
|
|
768
1366
|
}
|
|
1367
|
+
setApiKey(apiKey) {
|
|
1368
|
+
this.apiKey = apiKey;
|
|
1369
|
+
}
|
|
1370
|
+
getApiKey() {
|
|
1371
|
+
return this.apiKey;
|
|
1372
|
+
}
|
|
769
1373
|
getAgentSecret() {
|
|
770
1374
|
return this.agentSecret;
|
|
771
1375
|
}
|
|
@@ -868,26 +1472,106 @@ var ToromarketClient = class {
|
|
|
868
1472
|
}
|
|
869
1473
|
throw new ToromarketError("Max retries exceeded", 500);
|
|
870
1474
|
}
|
|
1475
|
+
/**
|
|
1476
|
+
* Like request(), but returns the raw parsed JSON without envelope unwrapping.
|
|
1477
|
+
* Use for endpoints that return raw JSON (not wrapped in { success, data }).
|
|
1478
|
+
*/
|
|
1479
|
+
async requestRaw(method, path, body, options) {
|
|
1480
|
+
const upperMethod = method.toUpperCase();
|
|
1481
|
+
const idempotencyKey = MUTATING_METHODS.has(upperMethod) ? (0, import_node_crypto.randomUUID)() : void 0;
|
|
1482
|
+
for (let attempt = 0; attempt < MAX_RETRY_ATTEMPTS; attempt++) {
|
|
1483
|
+
const isLastAttempt = attempt === MAX_RETRY_ATTEMPTS - 1;
|
|
1484
|
+
const controller = new AbortController();
|
|
1485
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
1486
|
+
const init = {
|
|
1487
|
+
method,
|
|
1488
|
+
headers: {
|
|
1489
|
+
"Content-Type": "application/json",
|
|
1490
|
+
...this.clientId ? { "x-toromarket-client": this.clientId } : {},
|
|
1491
|
+
...this.apiKey ? { "X-API-Key": this.apiKey } : {},
|
|
1492
|
+
...this.token ? { Authorization: `Bearer ${this.token}` } : {},
|
|
1493
|
+
...idempotencyKey ? { "Idempotency-Key": idempotencyKey } : {},
|
|
1494
|
+
...options?.headers
|
|
1495
|
+
},
|
|
1496
|
+
signal: controller.signal
|
|
1497
|
+
};
|
|
1498
|
+
if (body !== void 0) {
|
|
1499
|
+
init.body = JSON.stringify(body);
|
|
1500
|
+
}
|
|
1501
|
+
let response;
|
|
1502
|
+
try {
|
|
1503
|
+
response = await fetch(`${this.baseUrl}${path}`, init);
|
|
1504
|
+
} catch (fetchError) {
|
|
1505
|
+
clearTimeout(timeoutId);
|
|
1506
|
+
if (!isLastAttempt) {
|
|
1507
|
+
if (fetchError instanceof TypeError || fetchError instanceof DOMException && fetchError.name === "AbortError") {
|
|
1508
|
+
await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY_MS));
|
|
1509
|
+
continue;
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
if (fetchError instanceof DOMException && fetchError.name === "AbortError") {
|
|
1513
|
+
throw new ToromarketError("Request timed out", 408, "TIMEOUT");
|
|
1514
|
+
}
|
|
1515
|
+
if (fetchError instanceof TypeError) {
|
|
1516
|
+
throw new ToromarketError(`Network error: ${fetchError.message}`, 0, "NETWORK_ERROR");
|
|
1517
|
+
}
|
|
1518
|
+
throw fetchError;
|
|
1519
|
+
}
|
|
1520
|
+
clearTimeout(timeoutId);
|
|
1521
|
+
if (this.isRetryableStatus(response.status) && !isLastAttempt) {
|
|
1522
|
+
await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY_MS));
|
|
1523
|
+
continue;
|
|
1524
|
+
}
|
|
1525
|
+
if (!response.ok) {
|
|
1526
|
+
let parsedBody;
|
|
1527
|
+
try {
|
|
1528
|
+
parsedBody = await response.json();
|
|
1529
|
+
} catch {
|
|
1530
|
+
throw new ToromarketError(`HTTP ${response.status} with non-JSON response`, response.status);
|
|
1531
|
+
}
|
|
1532
|
+
const raw = parsedBody;
|
|
1533
|
+
const code = typeof raw === "object" && raw !== null && typeof raw.code === "string" ? raw.code : void 0;
|
|
1534
|
+
throw new ToromarketError(`HTTP ${response.status}`, response.status, code, parsedBody);
|
|
1535
|
+
}
|
|
1536
|
+
try {
|
|
1537
|
+
return await response.json();
|
|
1538
|
+
} catch {
|
|
1539
|
+
return void 0;
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
throw new ToromarketError("Max retries exceeded", 500);
|
|
1543
|
+
}
|
|
871
1544
|
};
|
|
872
1545
|
// Annotate the CommonJS export names for ESM import in node:
|
|
873
1546
|
0 && (module.exports = {
|
|
1547
|
+
AgentsResource,
|
|
1548
|
+
ApiKeysResource,
|
|
1549
|
+
ArenaResource,
|
|
874
1550
|
AuthResource,
|
|
875
1551
|
BillingResource,
|
|
876
1552
|
ChatResource,
|
|
1553
|
+
ConfigResource,
|
|
1554
|
+
DelegationsResource,
|
|
1555
|
+
EscrowsResource,
|
|
877
1556
|
FundsResource,
|
|
1557
|
+
GamificationResource,
|
|
878
1558
|
IntelligenceResource,
|
|
879
1559
|
LeaderboardsResource,
|
|
880
1560
|
MarketsResource,
|
|
1561
|
+
NotificationsResource,
|
|
881
1562
|
OperatorsResource,
|
|
882
1563
|
PerformanceResource,
|
|
883
1564
|
PortfolioResource,
|
|
884
1565
|
PredictionsResource,
|
|
885
1566
|
ProfilesResource,
|
|
1567
|
+
RegistryResource,
|
|
886
1568
|
SearchResource,
|
|
887
1569
|
SocialResource,
|
|
888
1570
|
StakeResource,
|
|
1571
|
+
SupportResource,
|
|
889
1572
|
ToromarketClient,
|
|
890
1573
|
ToromarketError,
|
|
1574
|
+
TournamentsResource,
|
|
891
1575
|
TracesResource,
|
|
892
1576
|
WarsResource,
|
|
893
1577
|
WatchlistResource
|