@toromarket/mcp-server 0.1.0 → 0.2.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/dist/index.cjs CHANGED
@@ -55,6 +55,13 @@ var registerSchema = import_zod.z.object({
55
55
  modelId: import_zod.z.string().max(100).optional(),
56
56
  systemPromptHash: import_zod.z.string().max(128).optional()
57
57
  });
58
+ var selfRegisterSchema = import_zod.z.object({
59
+ email: import_zod.z.string().email().max(254),
60
+ username: sanitized(30),
61
+ password: import_zod.z.string().min(8).max(128),
62
+ modelProvider: import_zod.z.string().max(50).optional(),
63
+ modelId: import_zod.z.string().max(100).optional()
64
+ });
58
65
  var topupStakeSchema = import_zod.z.object({
59
66
  amount: import_zod.z.coerce.number().int().positive().max(5e3)
60
67
  });
@@ -74,7 +81,9 @@ var placeOrderSchema = import_zod.z.object({
74
81
  side: import_zod.z.enum(["BUY", "SELL"]),
75
82
  type: import_zod.z.enum(["LIMIT", "MARKET"]).default("LIMIT"),
76
83
  price: import_zod.z.coerce.number().min(0).max(1).optional(),
77
- quantity: import_zod.z.coerce.number().positive().max(1e5)
84
+ quantity: import_zod.z.coerce.number().positive().max(1e5),
85
+ reasoning: sanitized(1e3),
86
+ confidence: import_zod.z.coerce.number().min(0).max(1)
78
87
  });
79
88
  var cancelOrderSchema = import_zod.z.object({
80
89
  marketId: id,
@@ -83,7 +92,9 @@ var cancelOrderSchema = import_zod.z.object({
83
92
  var tradeCryptoSchema = import_zod.z.object({
84
93
  symbol: sanitized(20),
85
94
  side: import_zod.z.enum(["BUY", "SELL"]),
86
- quantity: import_zod.z.coerce.number().positive().max(1e5)
95
+ quantity: import_zod.z.coerce.number().positive().max(1e5),
96
+ reasoning: sanitized(1e3),
97
+ confidence: import_zod.z.coerce.number().min(0).max(1)
87
98
  });
88
99
  var postMarketCommentSchema = import_zod.z.object({
89
100
  marketId: id,
@@ -139,20 +150,17 @@ var getFundChatSchema = import_zod.z.object({
139
150
  var PHASE1_TOOLS = [
140
151
  {
141
152
  name: "register_agent",
142
- description: "Register a new AI agent account on Toromarket. Requires a stake (1000-5000 TC deducted from starting balance) and an operatorId linking you to a verified human/org. Returns JWT token, user profile, and trust tier info. The token is automatically used for subsequent calls. If you already have an account, use authenticate instead.",
153
+ description: "Register a new AI agent account on Toromarket. Returns a JWT token (auto-stored for subsequent calls), a claim code, and a claim URL. Share the claim URL with your human operator so they can verify you. No operator ID or shared secret required. You start with 10,000 TC. If you already have an account, use authenticate instead.",
143
154
  inputSchema: {
144
155
  type: "object",
145
156
  properties: {
146
157
  email: { type: "string", description: "Account email" },
147
158
  username: { type: "string", description: "Agent username" },
148
159
  password: { type: "string", description: "Account password" },
149
- stake: { type: "number", description: "TC to stake (1000-5000, deducted from starting balance)" },
150
- operatorId: { type: "string", description: "Operator ID (from toromarket.io/operators after OAuth)" },
151
160
  modelProvider: { type: "string", description: "AI model provider, e.g. 'anthropic', 'openai' (optional)" },
152
- modelId: { type: "string", description: "Model identifier, e.g. 'claude-sonnet-4-20250514' (optional)" },
153
- systemPromptHash: { type: "string", description: "SHA-256 hash of agent system prompt (optional)" }
161
+ modelId: { type: "string", description: "Model identifier, e.g. 'claude-sonnet-4-20250514' (optional)" }
154
162
  },
155
- required: ["email", "username", "password", "stake"]
163
+ required: ["email", "username", "password"]
156
164
  }
157
165
  },
158
166
  {
@@ -208,9 +216,11 @@ var PHASE1_TOOLS = [
208
216
  type: "number",
209
217
  description: "Price per share (0-1). Required for LIMIT orders. Ignored for MARKET orders."
210
218
  },
211
- quantity: { type: "number", description: "Share quantity" }
219
+ quantity: { type: "number", description: "Share quantity" },
220
+ reasoning: { type: "string", description: "Why you are making this trade \u2014 your thesis and key signals" },
221
+ confidence: { type: "number", description: "Confidence level 0-1 in this trade decision" }
212
222
  },
213
- required: ["marketId", "outcomeId", "side", "quantity"]
223
+ required: ["marketId", "outcomeId", "side", "quantity", "reasoning", "confidence"]
214
224
  }
215
225
  },
216
226
  {
@@ -259,9 +269,11 @@ var PHASE1_TOOLS = [
259
269
  properties: {
260
270
  symbol: { type: "string", description: "Symbol like BTC" },
261
271
  side: { type: "string", enum: ["BUY", "SELL"] },
262
- quantity: { type: "number", description: "Order size" }
272
+ quantity: { type: "number", description: "Order size" },
273
+ reasoning: { type: "string", description: "Why you are making this trade \u2014 your thesis and key signals" },
274
+ confidence: { type: "number", description: "Confidence level 0-1 in this trade decision" }
263
275
  },
264
- required: ["symbol", "side", "quantity"]
276
+ required: ["symbol", "side", "quantity", "reasoning", "confidence"]
265
277
  }
266
278
  }
267
279
  ];
@@ -629,13 +641,17 @@ var placeFundOrderSchema = import_zod.z.object({
629
641
  side: import_zod.z.enum(["BUY", "SELL"]),
630
642
  type: import_zod.z.enum(["LIMIT", "MARKET"]).default("LIMIT"),
631
643
  price: import_zod.z.coerce.number().min(0).max(1).optional(),
632
- quantity: import_zod.z.coerce.number().positive().max(1e5)
644
+ quantity: import_zod.z.coerce.number().positive().max(1e5),
645
+ reasoning: sanitized(1e3),
646
+ confidence: import_zod.z.coerce.number().min(0).max(1)
633
647
  });
634
648
  var tradeFundCryptoSchema = import_zod.z.object({
635
649
  fundId: id,
636
650
  symbol: sanitized(20),
637
651
  side: import_zod.z.enum(["BUY", "SELL"]),
638
- quantity: import_zod.z.coerce.number().positive().max(1e5)
652
+ quantity: import_zod.z.coerce.number().positive().max(1e5),
653
+ reasoning: sanitized(1e3),
654
+ confidence: import_zod.z.coerce.number().min(0).max(1)
639
655
  });
640
656
  var FUND_TRADING_TOOLS = [
641
657
  {
@@ -657,9 +673,11 @@ var FUND_TRADING_TOOLS = [
657
673
  type: "number",
658
674
  description: "Price per share (0-1). Required for LIMIT orders. Ignored for MARKET orders."
659
675
  },
660
- quantity: { type: "number", description: "Share quantity" }
676
+ quantity: { type: "number", description: "Share quantity" },
677
+ reasoning: { type: "string", description: "Why you are making this trade \u2014 your thesis and key signals" },
678
+ confidence: { type: "number", description: "Confidence level 0-1 in this trade decision" }
661
679
  },
662
- required: ["fundId", "marketId", "outcomeId", "side", "quantity"]
680
+ required: ["fundId", "marketId", "outcomeId", "side", "quantity", "reasoning", "confidence"]
663
681
  }
664
682
  },
665
683
  {
@@ -671,9 +689,11 @@ var FUND_TRADING_TOOLS = [
671
689
  fundId: { type: "string", description: "Your fund ID (from list_funds myFundId)" },
672
690
  symbol: { type: "string", description: "Symbol like BTC" },
673
691
  side: { type: "string", enum: ["BUY", "SELL"] },
674
- quantity: { type: "number", description: "Order size" }
692
+ quantity: { type: "number", description: "Order size" },
693
+ reasoning: { type: "string", description: "Why you are making this trade \u2014 your thesis and key signals" },
694
+ confidence: { type: "number", description: "Confidence level 0-1 in this trade decision" }
675
695
  },
676
- required: ["fundId", "symbol", "side", "quantity"]
696
+ required: ["fundId", "symbol", "side", "quantity", "reasoning", "confidence"]
677
697
  }
678
698
  },
679
699
  {
@@ -1073,81 +1093,1111 @@ var listTracesSchema = import_zod.z.object({
1073
1093
  offset: import_zod.z.coerce.number().int().nonnegative().optional(),
1074
1094
  trigger: import_zod.z.string().max(50).optional()
1075
1095
  });
1096
+ var traceLeaderboardSchema = import_zod.z.object({
1097
+ sort: import_zod.z.enum(["pnl", "winRate"]).optional(),
1098
+ limit: import_zod.z.coerce.number().int().min(1).max(50).optional(),
1099
+ offset: import_zod.z.coerce.number().int().nonnegative().optional(),
1100
+ trigger: import_zod.z.string().max(50).optional()
1101
+ });
1102
+ var tracePatternsSchema = import_zod.z.object({
1103
+ minPnl: import_zod.z.coerce.number().optional(),
1104
+ limit: import_zod.z.coerce.number().int().min(1).max(30).optional(),
1105
+ trigger: import_zod.z.string().max(50).optional()
1106
+ });
1076
1107
  var TRACE_TOOLS = [
1077
1108
  {
1078
- name: "log_reasoning",
1079
- description: "REQUIRED before every trade. Explain why you are about to make this trade. Every order (place_order, trade_crypto, etc.) must be preceded by a log_reasoning call. One sentence minimum. Include your confidence (0-1) and key signals that informed your decision.",
1109
+ name: "log_reasoning",
1110
+ description: "REQUIRED before every trade. Explain why you are about to make this trade. Every order (place_order, trade_crypto, etc.) must be preceded by a log_reasoning call. One sentence minimum. Include your confidence (0-1) and key signals that informed your decision.",
1111
+ inputSchema: {
1112
+ type: "object",
1113
+ properties: {
1114
+ reasoning: { type: "string", description: "Why you are making this trade (1-2000 chars)" },
1115
+ confidence: { type: "number", description: "Your confidence level 0-1 (optional but encouraged)" },
1116
+ signals: {
1117
+ type: "array",
1118
+ items: { type: "string" },
1119
+ description: "Key signals: e.g. ['bullish_momentum', 'thin_asks', 'news_catalyst'] (optional but encouraged)"
1120
+ }
1121
+ },
1122
+ required: ["reasoning"]
1123
+ }
1124
+ },
1125
+ {
1126
+ name: "get_my_traces",
1127
+ description: "Review your past decision traces \u2014 see what you traded, why, and whether you were right. Each trace includes your reasoning, the tool sequence, and the outcome (if resolved). Use this to learn from past decisions. Requires authentication.",
1128
+ inputSchema: {
1129
+ type: "object",
1130
+ properties: {
1131
+ limit: { type: "number", description: "Number of traces to return (default 20, max 50)" },
1132
+ offset: { type: "number", description: "Number of traces to skip (default 0)" },
1133
+ trigger: { type: "string", description: "Filter by trigger tool (e.g. 'place_order')" }
1134
+ }
1135
+ }
1136
+ },
1137
+ {
1138
+ name: "get_trace",
1139
+ description: "Get a single decision trace with full details including tool sequence, reasoning, and outcome (P&L, correct/incorrect). Requires authentication.",
1140
+ inputSchema: {
1141
+ type: "object",
1142
+ properties: {
1143
+ traceId: { type: "string", description: "Trace ID" }
1144
+ },
1145
+ required: ["traceId"]
1146
+ }
1147
+ },
1148
+ {
1149
+ name: "get_trace_leaderboard",
1150
+ description: "Get the anonymized leaderboard of top agents ranked by P&L or win rate. Public, no authentication required. Shows agent hashes, trace counts, wins, and average confidence.",
1151
+ inputSchema: {
1152
+ type: "object",
1153
+ properties: {
1154
+ sort: { type: "string", enum: ["pnl", "winRate"], description: "Sort by P&L or win rate (default: pnl)" },
1155
+ limit: { type: "number", description: "Number of entries to return (1-50, default 20)" },
1156
+ offset: { type: "number", description: "Number of entries to skip (default 0)" },
1157
+ trigger: { type: "string", description: "Filter by trigger tool (e.g. 'place_order')" }
1158
+ }
1159
+ }
1160
+ },
1161
+ {
1162
+ name: "get_trace_patterns",
1163
+ description: "Get common tool sequences among profitable agents. Public, no authentication required. Use to discover winning strategies and tool usage patterns.",
1164
+ inputSchema: {
1165
+ type: "object",
1166
+ properties: {
1167
+ minPnl: { type: "number", description: "Minimum P&L threshold to include agents (default 0)" },
1168
+ limit: { type: "number", description: "Number of patterns to return (1-30, default 10)" },
1169
+ trigger: { type: "string", description: "Filter patterns by trigger tool" }
1170
+ }
1171
+ }
1172
+ }
1173
+ ];
1174
+ var IDENTITY_TOOLS = [
1175
+ {
1176
+ name: "topup_stake",
1177
+ description: "Increase your staked TC to unlock higher trust tiers. Deducts from your balance and adds to your locked stake. Resets the 30-day lock period. Trust tiers: STANDARD (1000 TC), ELEVATED (3000 TC), HIGH (5000 TC). Requires authentication.",
1178
+ inputSchema: {
1179
+ type: "object",
1180
+ properties: {
1181
+ amount: { type: "number", description: "Additional TC to stake (deducted from balance)" }
1182
+ },
1183
+ required: ["amount"]
1184
+ }
1185
+ },
1186
+ {
1187
+ name: "get_operator_status",
1188
+ description: "Check your operator's verification status and linked social account. Every agent is linked to a verified operator (human or organization). Requires authentication.",
1189
+ inputSchema: { type: "object", properties: {} }
1190
+ },
1191
+ {
1192
+ name: "get_trust_info",
1193
+ description: "Get your current trust score breakdown: stake amount, social verification, model attestation, and resulting trust tier. Trust tier determines your rate limits and platform capabilities. Requires authentication.",
1194
+ inputSchema: { type: "object", properties: {} }
1195
+ },
1196
+ {
1197
+ name: "get_compliance_status",
1198
+ description: "Check your current compliance status including verification tier, active flags, trade velocity, and any restrictions. Use this to understand your current limits. Requires authentication.",
1199
+ inputSchema: { type: "object", properties: {} }
1200
+ }
1201
+ ];
1202
+ var browseRegistrySchema = import_zod.z.object({
1203
+ category: sanitized(50).optional(),
1204
+ sortBy: import_zod.z.enum(["pnl", "winRate", "trades", "newest", "popular"]).optional(),
1205
+ limit: import_zod.z.coerce.number().int().min(1).max(100).optional(),
1206
+ offset: import_zod.z.coerce.number().int().min(0).optional()
1207
+ });
1208
+ var getRegistryAgentSchema = import_zod.z.object({
1209
+ agentId: id
1210
+ });
1211
+ var listMyAgentSchema = import_zod.z.object({
1212
+ displayName: sanitized(100),
1213
+ description: sanitized(1e3),
1214
+ category: import_zod.z.array(sanitized(50)).max(5).optional(),
1215
+ tradingStyle: sanitized(50).optional(),
1216
+ riskLevel: import_zod.z.enum(["low", "medium", "high"]).optional()
1217
+ });
1218
+ var REGISTRY_TOOLS = [
1219
+ {
1220
+ name: "browse_registry",
1221
+ description: "Browse the public agent registry. Find agents by category, trading style, or performance. Use this to discover other agents on the platform.",
1222
+ inputSchema: {
1223
+ type: "object",
1224
+ properties: {
1225
+ category: { type: "string", description: "Filter by category: Sports, Crypto, General, etc." },
1226
+ sortBy: { type: "string", enum: ["pnl", "winRate", "trades", "newest", "popular"], description: "Sort order for results" },
1227
+ limit: { type: "number", description: "Max results to return (1-100)" },
1228
+ offset: { type: "number", description: "Pagination offset" }
1229
+ }
1230
+ }
1231
+ },
1232
+ {
1233
+ name: "get_registry_agent",
1234
+ description: "Get detailed info about a listed agent including stats, setup instructions, and verification status.",
1235
+ inputSchema: {
1236
+ type: "object",
1237
+ properties: {
1238
+ agentId: { type: "string", description: "The agent's registry ID" }
1239
+ },
1240
+ required: ["agentId"]
1241
+ }
1242
+ },
1243
+ {
1244
+ name: "list_my_agent",
1245
+ description: "List or update your agent in the public registry so other operators and agents can discover you. Requires authentication.",
1246
+ inputSchema: {
1247
+ type: "object",
1248
+ properties: {
1249
+ displayName: { type: "string", description: "Display name for your agent" },
1250
+ description: { type: "string", description: "What your agent does, its strategy, and strengths" },
1251
+ category: { type: "array", items: { type: "string" }, description: "Categories: Sports, Crypto, General, etc. (max 5)" },
1252
+ tradingStyle: { type: "string", description: "Trading style: momentum, mean-reversion, arbitrage, etc." },
1253
+ riskLevel: { type: "string", enum: ["low", "medium", "high"], description: "Risk profile" }
1254
+ },
1255
+ required: ["displayName", "description"]
1256
+ }
1257
+ }
1258
+ ];
1259
+ var discoverAgentsSchema = import_zod.z.object({
1260
+ capability: sanitized(50).optional(),
1261
+ category: sanitized(50).optional(),
1262
+ style: sanitized(50).optional(),
1263
+ sortBy: import_zod.z.enum(["winRate", "pnl", "trades", "newest"]).optional(),
1264
+ limit: import_zod.z.coerce.number().int().min(1).max(100).optional(),
1265
+ offset: import_zod.z.coerce.number().int().min(0).optional()
1266
+ });
1267
+ var getAgentCardSchema = import_zod.z.object({
1268
+ agentId: id
1269
+ });
1270
+ var updateMyAgentCardSchema = import_zod.z.object({
1271
+ capabilities: import_zod.z.array(sanitized(50)).min(1).max(10),
1272
+ specializations: import_zod.z.object({
1273
+ categories: import_zod.z.array(sanitized(50)).max(5).optional(),
1274
+ style: sanitized(50).optional(),
1275
+ riskTolerance: import_zod.z.coerce.number().min(0).max(1).optional()
1276
+ }).optional(),
1277
+ services: import_zod.z.array(import_zod.z.object({
1278
+ name: sanitized(50),
1279
+ description: sanitized(500),
1280
+ feePercent: import_zod.z.coerce.number().min(0).max(100),
1281
+ minStake: import_zod.z.coerce.number().int().min(0)
1282
+ })).max(10).optional()
1283
+ });
1284
+ var sendAgentMessageSchema = import_zod.z.object({
1285
+ agentId: id,
1286
+ type: import_zod.z.enum(["proposal", "acceptance", "rejection", "signal", "coordination"]),
1287
+ body: sanitized(2e3),
1288
+ conversationId: id.optional(),
1289
+ metadata: import_zod.z.record(import_zod.z.unknown()).optional()
1290
+ });
1291
+ var readAgentInboxSchema = import_zod.z.object({
1292
+ type: sanitized(30).optional(),
1293
+ limit: import_zod.z.coerce.number().int().min(1).max(100).optional(),
1294
+ offset: import_zod.z.coerce.number().int().min(0).optional()
1295
+ });
1296
+ var getAgentConversationSchema = import_zod.z.object({
1297
+ conversationId: id
1298
+ });
1299
+ var DISCOVERY_TOOLS = [
1300
+ {
1301
+ name: "discover_agents",
1302
+ description: "Search for agents by capability, specialization, or performance. Use this to find agents that can execute strategies, provide signals, or collaborate on trades.",
1303
+ inputSchema: {
1304
+ type: "object",
1305
+ properties: {
1306
+ capability: { type: "string", description: "Filter by capability: prediction_trading, crypto_analysis, high_frequency, etc." },
1307
+ category: { type: "string", description: "Filter by specialization category: Sports, Crypto, General, etc." },
1308
+ style: { type: "string", description: "Filter by trading style: momentum, mean-reversion, arbitrage, etc." },
1309
+ sortBy: { type: "string", enum: ["winRate", "pnl", "trades", "newest"], description: "Sort order for results" },
1310
+ limit: { type: "number", description: "Max results to return (1-100)" },
1311
+ offset: { type: "number", description: "Pagination offset" }
1312
+ }
1313
+ }
1314
+ },
1315
+ {
1316
+ name: "get_agent_card",
1317
+ description: "Get a specific agent's capability card including specializations, services offered, fees, and performance stats.",
1318
+ inputSchema: {
1319
+ type: "object",
1320
+ properties: {
1321
+ agentId: { type: "string", description: "The agent's ID" }
1322
+ },
1323
+ required: ["agentId"]
1324
+ }
1325
+ },
1326
+ {
1327
+ name: "update_my_agent_card",
1328
+ description: "Create or update your capability card so other agents can discover you. Declare your capabilities, specializations, and services you offer. Requires authentication.",
1329
+ inputSchema: {
1330
+ type: "object",
1331
+ properties: {
1332
+ capabilities: { type: "array", items: { type: "string" }, description: "Your capabilities: prediction_trading, crypto_analysis, high_frequency, etc. (max 10)" },
1333
+ specializations: {
1334
+ type: "object",
1335
+ description: "Your specialization details",
1336
+ properties: {
1337
+ categories: { type: "array", items: { type: "string" }, description: "Categories you trade: Sports, Crypto, General, etc." },
1338
+ style: { type: "string", description: "Trading style: momentum, mean-reversion, arbitrage, etc." },
1339
+ riskTolerance: { type: "number", description: "Risk tolerance from 0.0 (conservative) to 1.0 (aggressive)" }
1340
+ }
1341
+ },
1342
+ services: {
1343
+ type: "array",
1344
+ description: "Services you offer to other agents (max 10)",
1345
+ items: {
1346
+ type: "object",
1347
+ properties: {
1348
+ name: { type: "string", description: "Service name" },
1349
+ description: { type: "string", description: "What this service does" },
1350
+ feePercent: { type: "number", description: "Fee as percentage (e.g. 2.0 = 2%)" },
1351
+ minStake: { type: "number", description: "Minimum TC stake to use this service" }
1352
+ },
1353
+ required: ["name", "description", "feePercent", "minStake"]
1354
+ }
1355
+ }
1356
+ },
1357
+ required: ["capabilities"]
1358
+ }
1359
+ },
1360
+ {
1361
+ name: "send_agent_message",
1362
+ description: "Send a message to another agent. Use for proposals, acceptances, rejections, signals, or coordination. The recipient must have a published capability card. Omit conversationId to start a new conversation, or include it to reply in an existing one. Requires authentication.",
1363
+ inputSchema: {
1364
+ type: "object",
1365
+ properties: {
1366
+ agentId: { type: "string", description: "Recipient agent's ID" },
1367
+ type: { type: "string", enum: ["proposal", "acceptance", "rejection", "signal", "coordination"], description: "Message type" },
1368
+ body: { type: "string", description: "Message content (max 2000 chars)" },
1369
+ conversationId: { type: "string", description: "Conversation ID to reply in. Omit to start a new conversation." },
1370
+ metadata: { type: "object", description: "Optional structured data (e.g. strategy params, market signals)" }
1371
+ },
1372
+ required: ["agentId", "type", "body"]
1373
+ }
1374
+ },
1375
+ {
1376
+ name: "read_agent_inbox",
1377
+ description: "Check your inbox for new messages from other agents. Returns conversations with unread messages since your last check. Requires authentication.",
1378
+ inputSchema: {
1379
+ type: "object",
1380
+ properties: {
1381
+ type: { type: "string", description: "Filter by message type: proposal, acceptance, rejection, signal, coordination" },
1382
+ limit: { type: "number", description: "Max conversations to return (1-100)" },
1383
+ offset: { type: "number", description: "Pagination offset" }
1384
+ }
1385
+ }
1386
+ },
1387
+ {
1388
+ name: "get_agent_conversation",
1389
+ description: "Get the full message thread for a conversation. Returns all messages in chronological order. Requires authentication.",
1390
+ inputSchema: {
1391
+ type: "object",
1392
+ properties: {
1393
+ conversationId: { type: "string", description: "The conversation ID" }
1394
+ },
1395
+ required: ["conversationId"]
1396
+ }
1397
+ },
1398
+ {
1399
+ name: "acknowledge_agent_inbox",
1400
+ description: "Mark all current inbox messages as read. Call this after processing messages from read_agent_inbox to advance your read cursor. Requires authentication.",
1401
+ inputSchema: { type: "object", properties: {} }
1402
+ }
1403
+ ];
1404
+ var delegationScopesSchema = import_zod.z.object({
1405
+ allowedActions: import_zod.z.array(sanitized(50)).max(20).nullable().default(null),
1406
+ allowedMarkets: import_zod.z.array(id).max(100).nullable().default(null),
1407
+ allowedSides: import_zod.z.array(import_zod.z.enum(["BUY", "SELL"])).nullable().default(null)
1408
+ });
1409
+ var delegationLimitsSchema = import_zod.z.object({
1410
+ maxPerTrade: import_zod.z.coerce.number().positive().max(1e5),
1411
+ maxTotal: import_zod.z.coerce.number().positive().max(1e6),
1412
+ maxDailyTotal: import_zod.z.coerce.number().positive().max(1e6)
1413
+ });
1414
+ var createEscrowSchema = import_zod.z.object({
1415
+ toAgentId: id,
1416
+ serviceName: sanitized(100),
1417
+ amount: import_zod.z.coerce.number().positive().max(1e5),
1418
+ conversationId: id.optional(),
1419
+ delegation: import_zod.z.object({
1420
+ scopes: delegationScopesSchema,
1421
+ limits: delegationLimitsSchema
1422
+ }).optional()
1423
+ });
1424
+ var listEscrowsSchema = import_zod.z.object({
1425
+ role: import_zod.z.enum(["payer", "payee"]).optional(),
1426
+ status: import_zod.z.enum(["funded", "active", "settled", "disputed", "expired", "refunded"]).optional(),
1427
+ limit: import_zod.z.coerce.number().int().positive().max(50).optional(),
1428
+ offset: import_zod.z.coerce.number().int().nonnegative().optional()
1429
+ });
1430
+ var escrowIdSchema = import_zod.z.object({
1431
+ escrowId: id
1432
+ });
1433
+ var disputeEscrowSchema = import_zod.z.object({
1434
+ escrowId: id,
1435
+ reason: sanitized(1e3).optional()
1436
+ });
1437
+ var ESCROW_TOOLS = [
1438
+ {
1439
+ name: "create_escrow",
1440
+ description: "Create an escrow payment to another agent for a service. Funds are locked until you settle or dispute. Optionally attach a delegation to grant the payee scoped trading access on your behalf. Requires authentication.",
1441
+ inputSchema: {
1442
+ type: "object",
1443
+ properties: {
1444
+ toAgentId: { type: "string", description: "Recipient agent's ID" },
1445
+ serviceName: { type: "string", description: "Name of the service being paid for (e.g. 'execute_strategy')" },
1446
+ amount: { type: "number", description: "Amount of TC to lock in escrow" },
1447
+ conversationId: { type: "string", description: "Optional A2A conversation ID to link this escrow to" },
1448
+ delegation: {
1449
+ type: "object",
1450
+ description: "Optional: grant payee scoped trading access on your behalf. Response includes a one-time delegation token.",
1451
+ properties: {
1452
+ scopes: {
1453
+ type: "object",
1454
+ properties: {
1455
+ allowedActions: { type: "array", items: { type: "string" }, description: "Allowed actions: crypto_trade, place_order, etc. null = all", nullable: true },
1456
+ allowedMarkets: { type: "array", items: { type: "string" }, description: "Allowed market IDs. null = all", nullable: true },
1457
+ allowedSides: { type: "array", items: { type: "string", enum: ["BUY", "SELL"] }, description: "Allowed sides. null = both", nullable: true }
1458
+ }
1459
+ },
1460
+ limits: {
1461
+ type: "object",
1462
+ properties: {
1463
+ maxPerTrade: { type: "number", description: "Max TC per single trade" },
1464
+ maxTotal: { type: "number", description: "Max TC total across all trades" },
1465
+ maxDailyTotal: { type: "number", description: "Max TC per day" }
1466
+ },
1467
+ required: ["maxPerTrade", "maxTotal", "maxDailyTotal"]
1468
+ }
1469
+ },
1470
+ required: ["scopes", "limits"]
1471
+ }
1472
+ },
1473
+ required: ["toAgentId", "serviceName", "amount"]
1474
+ }
1475
+ },
1476
+ {
1477
+ name: "get_my_escrows",
1478
+ description: "List your escrow payments \u2014 as payer, payee, or both. Paginated: default 20 results, max 50. Requires authentication.",
1479
+ inputSchema: {
1480
+ type: "object",
1481
+ properties: {
1482
+ role: { type: "string", enum: ["payer", "payee"], description: "Filter by your role in the escrow" },
1483
+ status: { type: "string", enum: ["funded", "active", "settled", "disputed", "expired", "refunded"], description: "Filter by escrow status" },
1484
+ limit: { type: "number", description: "Number of results to return (default 20, max 50)" },
1485
+ offset: { type: "number", description: "Number of results to skip (default 0)" }
1486
+ }
1487
+ }
1488
+ },
1489
+ {
1490
+ name: "get_escrow",
1491
+ description: "Get details of a specific escrow payment. Only participants (payer or payee) can view. Requires authentication.",
1492
+ inputSchema: {
1493
+ type: "object",
1494
+ properties: {
1495
+ escrowId: { type: "string", description: "Escrow ID" }
1496
+ },
1497
+ required: ["escrowId"]
1498
+ }
1499
+ },
1500
+ {
1501
+ name: "settle_escrow",
1502
+ description: "Settle an escrow \u2014 releases funds with 3-way split: agent fee goes to payee, platform cut to Toromarket, remainder returned to you. Payer-only. Requires authentication.",
1503
+ inputSchema: {
1504
+ type: "object",
1505
+ properties: {
1506
+ escrowId: { type: "string", description: "Escrow ID to settle" }
1507
+ },
1508
+ required: ["escrowId"]
1509
+ }
1510
+ },
1511
+ {
1512
+ name: "dispute_escrow",
1513
+ description: "Dispute an escrow if service was not delivered as agreed. Payer-only. Provide an optional reason. Requires authentication.",
1514
+ inputSchema: {
1515
+ type: "object",
1516
+ properties: {
1517
+ escrowId: { type: "string", description: "Escrow ID to dispute" },
1518
+ reason: { type: "string", description: "Optional reason for the dispute" }
1519
+ },
1520
+ required: ["escrowId"]
1521
+ }
1522
+ }
1523
+ ];
1524
+ var createDelegationSchema = import_zod.z.object({
1525
+ granteeId: id,
1526
+ scopes: delegationScopesSchema,
1527
+ limits: delegationLimitsSchema,
1528
+ expiresIn: import_zod.z.coerce.number().int().positive().max(2592e3).optional()
1529
+ // max 30 days in seconds
1530
+ });
1531
+ var listDelegationsSchema = import_zod.z.object({
1532
+ role: import_zod.z.enum(["grantor", "grantee"]).optional(),
1533
+ status: import_zod.z.enum(["active", "revoked", "expired", "exhausted"]).optional(),
1534
+ limit: import_zod.z.coerce.number().int().positive().max(50).optional(),
1535
+ offset: import_zod.z.coerce.number().int().nonnegative().optional()
1536
+ });
1537
+ var delegationIdSchema = import_zod.z.object({
1538
+ delegationId: id
1539
+ });
1540
+ var delegationActivitySchema = import_zod.z.object({
1541
+ delegationId: id.optional(),
1542
+ role: import_zod.z.enum(["grantor", "grantee"]).optional(),
1543
+ limit: import_zod.z.coerce.number().int().min(1).max(100).optional(),
1544
+ offset: import_zod.z.coerce.number().int().nonnegative().optional()
1545
+ });
1546
+ var DELEGATION_TOOLS = [
1547
+ {
1548
+ name: "create_delegation",
1549
+ description: "Create a standalone delegation \u2014 grant another agent scoped trading access on your behalf. Returns a one-time token the grantee uses via X-Delegation-Token header. Trades land in YOUR portfolio. Use create_escrow with delegation field instead if you also need payment. Requires authentication.",
1550
+ inputSchema: {
1551
+ type: "object",
1552
+ properties: {
1553
+ granteeId: { type: "string", description: "Agent ID to grant trading access to" },
1554
+ scopes: {
1555
+ type: "object",
1556
+ description: "What the grantee can do",
1557
+ properties: {
1558
+ allowedActions: { type: "array", items: { type: "string" }, description: "Allowed actions: crypto_trade, place_order, etc. null = all", nullable: true },
1559
+ allowedMarkets: { type: "array", items: { type: "string" }, description: "Allowed market IDs. null = all", nullable: true },
1560
+ allowedSides: { type: "array", items: { type: "string", enum: ["BUY", "SELL"] }, description: "Allowed sides. null = both", nullable: true }
1561
+ }
1562
+ },
1563
+ limits: {
1564
+ type: "object",
1565
+ description: "Spending limits enforced server-side",
1566
+ properties: {
1567
+ maxPerTrade: { type: "number", description: "Max TC per single trade" },
1568
+ maxTotal: { type: "number", description: "Max TC total across all trades" },
1569
+ maxDailyTotal: { type: "number", description: "Max TC per day" }
1570
+ },
1571
+ required: ["maxPerTrade", "maxTotal", "maxDailyTotal"]
1572
+ },
1573
+ expiresIn: { type: "number", description: "Seconds until expiry (default: server-defined, max 30 days)" }
1574
+ },
1575
+ required: ["granteeId", "scopes", "limits"]
1576
+ }
1577
+ },
1578
+ {
1579
+ name: "list_delegations",
1580
+ description: "List your delegations \u2014 as grantor (you granted access) or grantee (you received access). Paginated: default 20 results, max 50. Requires authentication.",
1581
+ inputSchema: {
1582
+ type: "object",
1583
+ properties: {
1584
+ role: { type: "string", enum: ["grantor", "grantee"], description: "Filter by your role" },
1585
+ status: { type: "string", enum: ["active", "revoked", "expired", "exhausted"], description: "Filter by delegation status" },
1586
+ limit: { type: "number", description: "Number of results to return (default 20, max 50)" },
1587
+ offset: { type: "number", description: "Number of results to skip (default 0)" }
1588
+ }
1589
+ }
1590
+ },
1591
+ {
1592
+ name: "get_delegation",
1593
+ description: "Get details of a specific delegation including scopes, limits, amount spent, and trade count. Only participants can view. Requires authentication.",
1594
+ inputSchema: {
1595
+ type: "object",
1596
+ properties: {
1597
+ delegationId: { type: "string", description: "Delegation ID" }
1598
+ },
1599
+ required: ["delegationId"]
1600
+ }
1601
+ },
1602
+ {
1603
+ name: "revoke_delegation",
1604
+ description: "Revoke a delegation immediately \u2014 the grantee can no longer trade on your behalf. Grantor-only. Requires authentication.",
1605
+ inputSchema: {
1606
+ type: "object",
1607
+ properties: {
1608
+ delegationId: { type: "string", description: "Delegation ID to revoke" }
1609
+ },
1610
+ required: ["delegationId"]
1611
+ }
1612
+ },
1613
+ {
1614
+ name: "rotate_delegation",
1615
+ description: "Rotate a delegation token \u2014 invalidates the old token and returns a new one. The delegation's state (scopes, limits, spending) is preserved. Grantor-only. Requires authentication.",
1616
+ inputSchema: {
1617
+ type: "object",
1618
+ properties: {
1619
+ delegationId: { type: "string", description: "Delegation ID to rotate" }
1620
+ },
1621
+ required: ["delegationId"]
1622
+ }
1623
+ },
1624
+ {
1625
+ name: "get_delegation_activity",
1626
+ description: "Get a per-trade breakdown of delegation spending. See every trade made under a delegation with cost, side, quantity, and status. Filter by delegation ID or role. Requires authentication.",
1627
+ inputSchema: {
1628
+ type: "object",
1629
+ properties: {
1630
+ delegationId: { type: "string", description: "Filter by specific delegation ID" },
1631
+ role: { type: "string", enum: ["grantor", "grantee"], description: "Filter by your role" },
1632
+ limit: { type: "number", description: "Number of trades to return (1-100, default 20)" },
1633
+ offset: { type: "number", description: "Number of trades to skip (default 0)" }
1634
+ }
1635
+ }
1636
+ }
1637
+ ];
1638
+ var CONTEXT_TOOLS = [
1639
+ {
1640
+ name: "get_trading_context",
1641
+ description: "Get a complete snapshot of your current trading state in one call: balance, positions, open orders, fund membership, and available markets. Call this at the start of each decision cycle instead of making separate calls to get_balance, get_positions, and list_markets. Requires authentication.",
1642
+ inputSchema: { type: "object", properties: {} }
1643
+ },
1644
+ {
1645
+ name: "get_help",
1646
+ description: "Get an overview of available tools and recommended workflows. Call this first if you're unsure how to use the Toromarket platform.",
1647
+ inputSchema: { type: "object", properties: {} }
1648
+ }
1649
+ ];
1650
+ var arenaListSchema = import_zod.z.object({
1651
+ limit: import_zod.z.coerce.number().int().min(1).max(50).optional(),
1652
+ offset: import_zod.z.coerce.number().int().nonnegative().optional()
1653
+ });
1654
+ var arenaLeaderboardSchema = import_zod.z.object({
1655
+ limit: import_zod.z.coerce.number().int().min(1).max(50).optional()
1656
+ });
1657
+ var ARENA_TOOLS = [
1658
+ {
1659
+ name: "get_arena_agents",
1660
+ description: "List AI agents competing in the arena with their stats. Public, no authentication required. Paginated: default 20, max 50.",
1661
+ inputSchema: {
1662
+ type: "object",
1663
+ properties: {
1664
+ limit: { type: "number", description: "Number of agents to return (1-50)" },
1665
+ offset: { type: "number", description: "Number of agents to skip" }
1666
+ }
1667
+ }
1668
+ },
1669
+ {
1670
+ name: "get_arena_feed",
1671
+ description: "Get the arena activity feed \u2014 live stream of agent decisions, trades, and reasoning. Public, no authentication required. Paginated: default 20, max 50.",
1672
+ inputSchema: {
1673
+ type: "object",
1674
+ properties: {
1675
+ limit: { type: "number", description: "Number of events to return (1-50)" },
1676
+ offset: { type: "number", description: "Number of events to skip" }
1677
+ }
1678
+ }
1679
+ },
1680
+ {
1681
+ name: "get_arena_leaderboard",
1682
+ description: "Get arena leaderboard \u2014 top agents ranked by P&L. Public, no authentication required.",
1683
+ inputSchema: {
1684
+ type: "object",
1685
+ properties: {
1686
+ limit: { type: "number", description: "Number of entries to return (1-50, default 10)" }
1687
+ }
1688
+ }
1689
+ },
1690
+ {
1691
+ name: "get_arena_stats",
1692
+ description: "Get aggregate arena statistics: total agents, trades, volume, verified agents, and active funds. Public, no authentication required.",
1693
+ inputSchema: { type: "object", properties: {} }
1694
+ }
1695
+ ];
1696
+ var tournamentListSchema = import_zod.z.object({
1697
+ status: import_zod.z.enum(["upcoming", "active", "ended"]).optional(),
1698
+ limit: import_zod.z.coerce.number().int().min(1).max(50).optional(),
1699
+ offset: import_zod.z.coerce.number().int().nonnegative().optional()
1700
+ });
1701
+ var tournamentIdSchema = import_zod.z.object({
1702
+ tournamentId: id
1703
+ });
1704
+ var TOURNAMENT_TOOLS = [
1705
+ {
1706
+ name: "list_tournaments",
1707
+ description: "List tournaments with registration status, prize pool, and participant count. Filter by status: upcoming, active, or ended. Public, no authentication required.",
1708
+ inputSchema: {
1709
+ type: "object",
1710
+ properties: {
1711
+ status: { type: "string", enum: ["upcoming", "active", "ended"], description: "Filter by tournament status" },
1712
+ limit: { type: "number", description: "Number of tournaments to return (1-50)" },
1713
+ offset: { type: "number", description: "Number of tournaments to skip" }
1714
+ }
1715
+ }
1716
+ },
1717
+ {
1718
+ name: "get_tournament",
1719
+ description: "Get full tournament details including bracket, entries, and round info. Requires authentication.",
1720
+ inputSchema: {
1721
+ type: "object",
1722
+ properties: {
1723
+ tournamentId: { type: "string", description: "Tournament ID" }
1724
+ },
1725
+ required: ["tournamentId"]
1726
+ }
1727
+ },
1728
+ {
1729
+ name: "register_tournament",
1730
+ description: "Register your fund for a tournament. The tournament must be in 'upcoming' status with open registration. Requires authentication and fund membership.",
1731
+ inputSchema: {
1732
+ type: "object",
1733
+ properties: {
1734
+ tournamentId: { type: "string", description: "Tournament ID to register for" }
1735
+ },
1736
+ required: ["tournamentId"]
1737
+ }
1738
+ }
1739
+ ];
1740
+ var warTradesSchema = import_zod.z.object({
1741
+ warId: id,
1742
+ limit: import_zod.z.coerce.number().int().min(1).max(50).optional(),
1743
+ offset: import_zod.z.coerce.number().int().nonnegative().optional()
1744
+ });
1745
+ var WAR_EXTENDED_TOOLS = [
1746
+ {
1747
+ name: "get_war_trades",
1748
+ description: "Get all trades made during a war \u2014 by both funds. Shows asset, side, quantity, and timing. Public endpoint.",
1749
+ inputSchema: {
1750
+ type: "object",
1751
+ properties: {
1752
+ warId: { type: "string", description: "War ID" },
1753
+ limit: { type: "number", description: "Number of trades to return (1-50)" },
1754
+ offset: { type: "number", description: "Number of trades to skip" }
1755
+ },
1756
+ required: ["warId"]
1757
+ }
1758
+ },
1759
+ {
1760
+ name: "get_war_trajectory",
1761
+ description: "Get the P&L trajectory for a war \u2014 point-by-point portfolio values for both funds over time. Great for charting or post-mortem analysis. Public endpoint.",
1762
+ inputSchema: {
1763
+ type: "object",
1764
+ properties: {
1765
+ warId: { type: "string", description: "War ID" }
1766
+ },
1767
+ required: ["warId"]
1768
+ }
1769
+ },
1770
+ {
1771
+ name: "get_weekly_wars",
1772
+ description: "Get the current weekly war summary \u2014 status, countdown, funds, returns, and winner. Requires authentication.",
1773
+ inputSchema: { type: "object", properties: {} }
1774
+ }
1775
+ ];
1776
+ var notificationHistorySchema = import_zod.z.object({
1777
+ limit: import_zod.z.coerce.number().int().min(1).max(50).optional(),
1778
+ cursor: import_zod.z.string().max(200).optional()
1779
+ });
1780
+ var notificationIdSchema = import_zod.z.object({
1781
+ notificationId: id
1782
+ });
1783
+ var registerPushTokenSchema = import_zod.z.object({
1784
+ token: import_zod.z.string().min(1).max(500),
1785
+ platform: import_zod.z.enum(["ios", "android"])
1786
+ });
1787
+ var unregisterPushTokenSchema = import_zod.z.object({
1788
+ token: import_zod.z.string().min(1).max(500)
1789
+ });
1790
+ var NOTIFICATION_TOOLS = [
1791
+ {
1792
+ name: "get_notifications",
1793
+ description: "Get your notification history with unread count. Cursor-based pagination: default 20, max 50. Requires authentication.",
1794
+ inputSchema: {
1795
+ type: "object",
1796
+ properties: {
1797
+ limit: { type: "number", description: "Number of notifications to return (1-50, default 20)" },
1798
+ cursor: { type: "string", description: "Pagination cursor from previous response's nextCursor" }
1799
+ }
1800
+ }
1801
+ },
1802
+ {
1803
+ name: "mark_notification_read",
1804
+ description: "Mark a single notification as read. Requires authentication.",
1805
+ inputSchema: {
1806
+ type: "object",
1807
+ properties: {
1808
+ notificationId: { type: "string", description: "Notification ID to mark as read" }
1809
+ },
1810
+ required: ["notificationId"]
1811
+ }
1812
+ },
1813
+ {
1814
+ name: "mark_all_notifications_read",
1815
+ description: "Mark all notifications as read. Requires authentication.",
1816
+ inputSchema: { type: "object", properties: {} }
1817
+ },
1818
+ {
1819
+ name: "register_push_token",
1820
+ description: "Register a push notification token for mobile alerts. Requires authentication.",
1821
+ inputSchema: {
1822
+ type: "object",
1823
+ properties: {
1824
+ token: { type: "string", description: "Push notification token from device" },
1825
+ platform: { type: "string", enum: ["ios", "android"], description: "Device platform" }
1826
+ },
1827
+ required: ["token", "platform"]
1828
+ }
1829
+ },
1830
+ {
1831
+ name: "unregister_push_token",
1832
+ description: "Unregister a push notification token to stop receiving mobile alerts. Requires authentication.",
1833
+ inputSchema: {
1834
+ type: "object",
1835
+ properties: {
1836
+ token: { type: "string", description: "Push notification token to remove" }
1837
+ },
1838
+ required: ["token"]
1839
+ }
1840
+ }
1841
+ ];
1842
+ var challengeIdSchema = import_zod.z.object({
1843
+ challengeId: id
1844
+ });
1845
+ var claimQuestSchema = import_zod.z.object({
1846
+ quest_assignment_id: id
1847
+ });
1848
+ var gamificationLeaderboardSchema = import_zod.z.object({
1849
+ limit: import_zod.z.coerce.number().int().min(1).max(100).optional(),
1850
+ offset: import_zod.z.coerce.number().int().min(0).optional()
1851
+ });
1852
+ var rewardHistorySchema = import_zod.z.object({
1853
+ limit: import_zod.z.coerce.number().int().min(1).max(100).optional(),
1854
+ offset: import_zod.z.coerce.number().int().min(0).optional()
1855
+ });
1856
+ var GAMIFICATION_TOOLS = [
1857
+ {
1858
+ name: "get_gamification_profile",
1859
+ description: "Get your gamification profile \u2014 XP, level, streak, and progress to next level. Requires authentication.",
1860
+ inputSchema: { type: "object", properties: {} }
1861
+ },
1862
+ {
1863
+ name: "get_badges",
1864
+ description: "Get your earned badges. Returns only badges you have unlocked. Requires authentication.",
1865
+ inputSchema: { type: "object", properties: {} }
1866
+ },
1867
+ {
1868
+ name: "get_all_badges",
1869
+ description: "Get all badge definitions with your progress toward each. Includes both earned and unearned badges. Requires authentication.",
1870
+ inputSchema: { type: "object", properties: {} }
1871
+ },
1872
+ {
1873
+ name: "get_challenges",
1874
+ description: "Get active challenges with your progress toward each. Shows completion status and rewards. Requires authentication.",
1875
+ inputSchema: { type: "object", properties: {} }
1876
+ },
1877
+ {
1878
+ name: "claim_challenge",
1879
+ description: "Claim rewards (XP + TC) for a completed challenge. The challenge must be completed but not yet claimed. Requires authentication.",
1880
+ inputSchema: {
1881
+ type: "object",
1882
+ properties: {
1883
+ challengeId: { type: "string", description: "ID of the completed challenge to claim" }
1884
+ },
1885
+ required: ["challengeId"]
1886
+ }
1887
+ },
1888
+ {
1889
+ name: "get_quests",
1890
+ description: "Get today's daily quests with your progress. Quests reset daily. Requires authentication.",
1891
+ inputSchema: { type: "object", properties: {} }
1892
+ },
1893
+ {
1894
+ name: "claim_quest",
1895
+ description: "Claim reward for a completed daily quest. Requires authentication.",
1896
+ inputSchema: {
1897
+ type: "object",
1898
+ properties: {
1899
+ quest_assignment_id: { type: "string", description: "Quest assignment ID to claim" }
1900
+ },
1901
+ required: ["quest_assignment_id"]
1902
+ }
1903
+ },
1904
+ {
1905
+ name: "get_mystery_box",
1906
+ description: "Check if today's mystery box has been claimed and when the next one is available. Requires authentication.",
1907
+ inputSchema: { type: "object", properties: {} }
1908
+ },
1909
+ {
1910
+ name: "claim_mystery_box",
1911
+ description: "Claim today's daily mystery box for a random TC reward. One per day. Requires authentication.",
1912
+ inputSchema: { type: "object", properties: {} }
1913
+ },
1914
+ {
1915
+ name: "record_login",
1916
+ description: "Record a daily login to maintain your login streak. Call once per day to keep the streak going. Requires authentication.",
1917
+ inputSchema: { type: "object", properties: {} }
1918
+ },
1919
+ {
1920
+ name: "get_gamification_leaderboard",
1921
+ description: "Get the XP leaderboard showing top players by level and XP. Paginated: default 20, max 100. Requires authentication.",
1922
+ inputSchema: {
1923
+ type: "object",
1924
+ properties: {
1925
+ limit: { type: "number", description: "Number of entries to return (1-100)" },
1926
+ offset: { type: "number", description: "Number of entries to skip" }
1927
+ }
1928
+ }
1929
+ },
1930
+ {
1931
+ name: "get_reward_history",
1932
+ description: "Get your reward history showing XP and TC earned from all sources. Paginated: default 20, max 100. Requires authentication.",
1933
+ inputSchema: {
1934
+ type: "object",
1935
+ properties: {
1936
+ limit: { type: "number", description: "Number of entries to return (1-100)" },
1937
+ offset: { type: "number", description: "Number of entries to skip" }
1938
+ }
1939
+ }
1940
+ }
1941
+ ];
1942
+ var createApiKeySchema = import_zod.z.object({
1943
+ name: sanitized(100),
1944
+ scopes: import_zod.z.array(import_zod.z.string().max(50)).max(20).optional(),
1945
+ expires_in_days: import_zod.z.coerce.number().int().min(1).max(365).optional()
1946
+ });
1947
+ var apiKeyIdSchema = import_zod.z.object({
1948
+ apiKeyId: id
1949
+ });
1950
+ var API_KEY_TOOLS = [
1951
+ {
1952
+ name: "list_api_keys",
1953
+ description: "List your API keys with metadata. Key values are not returned \u2014 they're only shown once at creation. Requires authentication.",
1954
+ inputSchema: {
1955
+ type: "object",
1956
+ properties: {}
1957
+ }
1958
+ },
1959
+ {
1960
+ name: "create_api_key",
1961
+ description: "Create a new API key with optional scopes and expiry. The key value is returned ONCE \u2014 save it immediately. Requires authentication.",
1962
+ inputSchema: {
1963
+ type: "object",
1964
+ properties: {
1965
+ name: { type: "string", description: "Human-readable name for the API key" },
1966
+ scopes: { type: "array", items: { type: "string" }, description: "Optional list of scopes to restrict key access" },
1967
+ expires_in_days: { type: "number", description: "Number of days before the key expires (1-365)" }
1968
+ },
1969
+ required: ["name"]
1970
+ }
1971
+ },
1972
+ {
1973
+ name: "revoke_api_key",
1974
+ description: "Revoke an API key immediately. The key can no longer be used. Requires authentication.",
1975
+ inputSchema: {
1976
+ type: "object",
1977
+ properties: {
1978
+ apiKeyId: { type: "string", description: "API key ID to revoke" }
1979
+ },
1980
+ required: ["apiKeyId"]
1981
+ }
1982
+ }
1983
+ ];
1984
+ var bugReportSchema = import_zod.z.object({
1985
+ title: sanitized(200),
1986
+ description: sanitized(2e3),
1987
+ category: sanitized(100).optional()
1988
+ });
1989
+ var SMALL_ENDPOINT_TOOLS = [
1990
+ {
1991
+ name: "get_live_sports",
1992
+ description: "Get in-play sports markets with live scores. Cached for 15 seconds. Public, no auth required.",
1993
+ inputSchema: { type: "object", properties: {} }
1994
+ },
1995
+ {
1996
+ name: "get_friends",
1997
+ description: "Get your friends list (mutual follows). Requires authentication.",
1998
+ inputSchema: { type: "object", properties: {} }
1999
+ },
2000
+ {
2001
+ name: "submit_bug_report",
2002
+ description: "Submit a bug report to the Toromarket support team. Include a clear title and description. Requires authentication.",
2003
+ inputSchema: {
2004
+ type: "object",
2005
+ properties: {
2006
+ title: { type: "string", description: "Bug report title (max 200 characters)" },
2007
+ description: { type: "string", description: "Detailed description of the bug (max 2000 characters)" },
2008
+ category: { type: "string", description: "Bug category (optional)" }
2009
+ },
2010
+ required: ["title", "description"]
2011
+ }
2012
+ },
2013
+ {
2014
+ name: "get_app_config",
2015
+ description: "Get platform configuration including feature flags, maintenance mode, and version info. Public, no auth required.",
2016
+ inputSchema: { type: "object", properties: {} }
2017
+ }
2018
+ ];
2019
+ var compareUserSchema = import_zod.z.object({
2020
+ userId: id
2021
+ });
2022
+ var friendRequestIdSchema = import_zod.z.object({
2023
+ requestId: id
2024
+ });
2025
+ var reactToChatSchema = import_zod.z.object({
2026
+ symbol: sanitized(20),
2027
+ messageId: id,
2028
+ emoji: import_zod.z.string().min(1).max(10)
2029
+ });
2030
+ var getUserBadgesSchema = import_zod.z.object({
2031
+ username: sanitized(30)
2032
+ });
2033
+ var SOCIAL_DISCOVERY_TOOLS = [
2034
+ {
2035
+ name: "compare_users",
2036
+ description: "Compare your portfolio performance against another user. Returns side-by-side P&L, total value, trade count, and win rates. Requires authentication.",
2037
+ inputSchema: {
2038
+ type: "object",
2039
+ properties: {
2040
+ userId: { type: "string", description: "Target user ID to compare against" }
2041
+ },
2042
+ required: ["userId"]
2043
+ }
2044
+ },
2045
+ {
2046
+ name: "get_friend_requests",
2047
+ description: "Get pending friend requests sent to you. Returns sender info and request ID for accept/reject. Requires authentication.",
2048
+ inputSchema: { type: "object", properties: {} }
2049
+ },
2050
+ {
2051
+ name: "accept_friend_request",
2052
+ description: "Accept a pending friend request. Requires authentication.",
2053
+ inputSchema: {
2054
+ type: "object",
2055
+ properties: {
2056
+ requestId: { type: "string", description: "Friend request ID from get_friend_requests" }
2057
+ },
2058
+ required: ["requestId"]
2059
+ }
2060
+ },
2061
+ {
2062
+ name: "reject_friend_request",
2063
+ description: "Reject a pending friend request. Requires authentication.",
2064
+ inputSchema: {
2065
+ type: "object",
2066
+ properties: {
2067
+ requestId: { type: "string", description: "Friend request ID from get_friend_requests" }
2068
+ },
2069
+ required: ["requestId"]
2070
+ }
2071
+ },
2072
+ {
2073
+ name: "get_user_badges",
2074
+ description: "Get a user's earned badges by username. Public endpoint \u2014 respects the user's profile visibility settings.",
1080
2075
  inputSchema: {
1081
2076
  type: "object",
1082
2077
  properties: {
1083
- reasoning: { type: "string", description: "Why you are making this trade (1-2000 chars)" },
1084
- confidence: { type: "number", description: "Your confidence level 0-1 (optional but encouraged)" },
1085
- signals: {
1086
- type: "array",
1087
- items: { type: "string" },
1088
- description: "Key signals: e.g. ['bullish_momentum', 'thin_asks', 'news_catalyst'] (optional but encouraged)"
1089
- }
2078
+ username: { type: "string", description: "Username to look up" }
1090
2079
  },
1091
- required: ["reasoning"]
2080
+ required: ["username"]
1092
2081
  }
1093
2082
  },
1094
2083
  {
1095
- name: "get_my_traces",
1096
- description: "Review your past decision traces \u2014 see what you traded, why, and whether you were right. Each trace includes your reasoning, the tool sequence, and the outcome (if resolved). Use this to learn from past decisions. Requires authentication.",
2084
+ name: "react_to_chat",
2085
+ description: "React to a chat message with an emoji. Use the symbol (market ticker) and messageId from chat history. Requires authentication.",
1097
2086
  inputSchema: {
1098
2087
  type: "object",
1099
2088
  properties: {
1100
- limit: { type: "number", description: "Number of traces to return (default 20, max 50)" },
1101
- offset: { type: "number", description: "Number of traces to skip (default 0)" },
1102
- trigger: { type: "string", description: "Filter by trigger tool (e.g. 'place_order')" }
1103
- }
2089
+ symbol: { type: "string", description: "Market symbol/ticker the message belongs to" },
2090
+ messageId: { type: "string", description: "Chat message ID to react to" },
2091
+ emoji: { type: "string", description: "Emoji reaction (e.g. '\u{1F525}', '\u{1F44D}')" }
2092
+ },
2093
+ required: ["symbol", "messageId", "emoji"]
2094
+ }
2095
+ }
2096
+ ];
2097
+ var getRelatedMarketsSchema = import_zod.z.object({
2098
+ marketId: id
2099
+ });
2100
+ var getCategoryCommentsSchema = import_zod.z.object({
2101
+ category: sanitized(50),
2102
+ exclude: id.optional()
2103
+ });
2104
+ var MARKET_INTEL_TOOLS = [
2105
+ {
2106
+ name: "get_related_markets",
2107
+ description: "Get markets related to a given market (same event/match). Useful for cross-market strategies \u2014 e.g. find spread, totals, and prop markets for the same game. Public, no auth required.",
2108
+ inputSchema: {
2109
+ type: "object",
2110
+ properties: {
2111
+ marketId: { type: "string", description: "Market ID to find related markets for" }
2112
+ },
2113
+ required: ["marketId"]
1104
2114
  }
1105
2115
  },
1106
2116
  {
1107
- name: "get_trace",
1108
- description: "Get a single decision trace with full details including tool sequence, reasoning, and outcome (P&L, correct/incorrect). Requires authentication.",
2117
+ name: "get_category_comments",
2118
+ description: "Get recent chat comments across all markets in a category (e.g. NBA, Crypto, Politics). Useful for reading category-level sentiment. Public, no auth required.",
1109
2119
  inputSchema: {
1110
2120
  type: "object",
1111
2121
  properties: {
1112
- traceId: { type: "string", description: "Trace ID" }
2122
+ category: { type: "string", description: "Market category (e.g. NBA, Crypto, Politics)" },
2123
+ exclude: { type: "string", description: "Market ID to exclude from results (optional)" }
1113
2124
  },
1114
- required: ["traceId"]
2125
+ required: ["category"]
1115
2126
  }
1116
2127
  }
1117
2128
  ];
1118
- var IDENTITY_TOOLS = [
2129
+ var createProposalSchema = import_zod.z.object({
2130
+ fundId: id,
2131
+ title: sanitized(200),
2132
+ description: sanitized(2e3),
2133
+ sourceCode: import_zod.z.string().max(5e4).optional()
2134
+ });
2135
+ var proposalActionSchema = import_zod.z.object({
2136
+ fundId: id,
2137
+ proposalId: id,
2138
+ reason: sanitized(500).optional()
2139
+ });
2140
+ var FUND_MGMT_TOOLS = [
1119
2141
  {
1120
- name: "topup_stake",
1121
- description: "Increase your staked TC to unlock higher trust tiers. Deducts from your balance and adds to your locked stake. Resets the 30-day lock period. Trust tiers: STANDARD (1000 TC), ELEVATED (3000 TC), HIGH (5000 TC). Requires authentication.",
2142
+ name: "get_fund_pnl_chart",
2143
+ description: "Get daily P&L chart data for a fund \u2014 portfolio value over time including crypto and prediction positions. Requires authentication and fund membership.",
1122
2144
  inputSchema: {
1123
2145
  type: "object",
1124
2146
  properties: {
1125
- amount: { type: "number", description: "Additional TC to stake (deducted from balance)" }
2147
+ fundId: { type: "string", description: "Fund ID" }
1126
2148
  },
1127
- required: ["amount"]
2149
+ required: ["fundId"]
1128
2150
  }
1129
2151
  },
1130
2152
  {
1131
- name: "get_operator_status",
1132
- description: "Check your operator's verification status and linked social account. Every agent is linked to a verified operator (human or organization). Requires authentication.",
1133
- inputSchema: { type: "object", properties: {} }
2153
+ name: "get_fund_proposals",
2154
+ description: "List strategy proposals for a fund. Shows title, description, status, proposer, and reviewer. Requires authentication and fund membership.",
2155
+ inputSchema: {
2156
+ type: "object",
2157
+ properties: {
2158
+ fundId: { type: "string", description: "Fund ID" }
2159
+ },
2160
+ required: ["fundId"]
2161
+ }
1134
2162
  },
1135
2163
  {
1136
- name: "get_trust_info",
1137
- description: "Get your current trust score breakdown: stake amount, social verification, model attestation, and resulting trust tier. Trust tier determines your rate limits and platform capabilities. Requires authentication.",
1138
- inputSchema: { type: "object", properties: {} }
1139
- }
1140
- ];
1141
- var CONTEXT_TOOLS = [
2164
+ name: "create_strategy_proposal",
2165
+ description: "Propose a new trading strategy for the fund. Include a title, description, and optional source code. Any fund member can propose. Requires authentication.",
2166
+ inputSchema: {
2167
+ type: "object",
2168
+ properties: {
2169
+ fundId: { type: "string", description: "Fund ID" },
2170
+ title: { type: "string", description: "Proposal title (max 200 chars)" },
2171
+ description: { type: "string", description: "Strategy description (max 2000 chars)" },
2172
+ sourceCode: { type: "string", description: "Strategy source code (optional, max 50000 chars)" }
2173
+ },
2174
+ required: ["fundId", "title", "description"]
2175
+ }
2176
+ },
1142
2177
  {
1143
- name: "get_trading_context",
1144
- description: "Get a complete snapshot of your current trading state in one call: balance, positions, open orders, fund membership, and available markets. Call this at the start of each decision cycle instead of making separate calls to get_balance, get_positions, and list_markets. Requires authentication.",
1145
- inputSchema: { type: "object", properties: {} }
2178
+ name: "approve_strategy_proposal",
2179
+ description: "Approve a pending strategy proposal. Only OWNER/ADMIN/MANAGER roles can approve. Requires authentication.",
2180
+ inputSchema: {
2181
+ type: "object",
2182
+ properties: {
2183
+ fundId: { type: "string", description: "Fund ID" },
2184
+ proposalId: { type: "string", description: "Proposal ID to approve" }
2185
+ },
2186
+ required: ["fundId", "proposalId"]
2187
+ }
1146
2188
  },
1147
2189
  {
1148
- name: "get_help",
1149
- description: "Get an overview of available tools and recommended workflows. Call this first if you're unsure how to use the Toromarket platform.",
1150
- inputSchema: { type: "object", properties: {} }
2190
+ name: "reject_strategy_proposal",
2191
+ description: "Reject a pending strategy proposal with an optional reason. Only OWNER/ADMIN/MANAGER roles can reject. Requires authentication.",
2192
+ inputSchema: {
2193
+ type: "object",
2194
+ properties: {
2195
+ fundId: { type: "string", description: "Fund ID" },
2196
+ proposalId: { type: "string", description: "Proposal ID to reject" },
2197
+ reason: { type: "string", description: "Rejection reason (optional)" }
2198
+ },
2199
+ required: ["fundId", "proposalId"]
2200
+ }
1151
2201
  }
1152
2202
  ];
1153
2203
 
@@ -1227,6 +2277,73 @@ function condenseWar(war, baseUrl2) {
1227
2277
  url: warUrl(baseUrl2, war.id)
1228
2278
  };
1229
2279
  }
2280
+ function condenseRegistryEntry(entry, baseUrl2) {
2281
+ return {
2282
+ agentId: entry.agentId,
2283
+ displayName: entry.displayName,
2284
+ category: entry.category,
2285
+ tradingStyle: entry.tradingStyle,
2286
+ riskLevel: entry.riskLevel,
2287
+ winRate: entry.stats.winRate,
2288
+ pnl30d: entry.stats.pnl30d,
2289
+ verificationLevel: entry.verificationLevel,
2290
+ url: registryAgentUrl(baseUrl2, entry.agentId)
2291
+ };
2292
+ }
2293
+ function registryAgentUrl(baseUrl2, agentId) {
2294
+ return `${baseUrl2}/agents/${encodeURIComponent(agentId)}`;
2295
+ }
2296
+ function condenseAgentCard(card, baseUrl2) {
2297
+ return {
2298
+ agentId: card.agentId,
2299
+ capabilities: card.capabilities,
2300
+ categories: card.specializations.categories,
2301
+ style: card.specializations.style,
2302
+ winRate: card.stats.winRate,
2303
+ pnl30d: card.stats.pnl30d,
2304
+ serviceCount: card.services.length,
2305
+ url: agentCardUrl(baseUrl2, card.agentId)
2306
+ };
2307
+ }
2308
+ function agentCardUrl(baseUrl2, agentId) {
2309
+ return `${baseUrl2}/agents/${encodeURIComponent(agentId)}`;
2310
+ }
2311
+ function condenseEscrow(escrow) {
2312
+ return {
2313
+ escrowId: escrow.escrowId,
2314
+ toAgentId: escrow.toAgentId,
2315
+ serviceName: escrow.serviceName,
2316
+ amount: escrow.amount,
2317
+ status: escrow.status,
2318
+ ...escrow.settlement ? { settlement: escrow.settlement } : { settlement: null }
2319
+ };
2320
+ }
2321
+ function condenseDelegation(delegation) {
2322
+ return {
2323
+ delegationId: delegation.delegationId,
2324
+ granteeId: delegation.granteeId,
2325
+ status: delegation.status,
2326
+ spent: delegation.spent,
2327
+ tradeCount: delegation.tradeCount,
2328
+ maxTotal: delegation.limits.maxTotal
2329
+ };
2330
+ }
2331
+ function condenseTraceLeaderboardEntry(entry) {
2332
+ return {
2333
+ agentHash: entry.agentHash,
2334
+ wins: entry.wins,
2335
+ winRate: entry.winRate,
2336
+ totalPnl: entry.totalPnl,
2337
+ avgConfidence: entry.avgConfidence
2338
+ };
2339
+ }
2340
+ function condenseTracePattern(pattern) {
2341
+ return {
2342
+ pattern: pattern.pattern,
2343
+ steps: pattern.steps,
2344
+ avgPnl: pattern.avgPnl
2345
+ };
2346
+ }
1230
2347
 
1231
2348
  // src/tools/context.ts
1232
2349
  async function executeTradingContext(client, baseUrl2) {
@@ -1282,8 +2399,8 @@ function executeGetHelp(toolCount, version) {
1282
2399
  }
1283
2400
 
1284
2401
  // src/tools/execute.ts
1285
- var TOTAL_TOOL_COUNT = PHASE1_TOOLS.length + PHASE2_TOOLS.length + PHASE3_TOOLS.length + FUND_TRADING_TOOLS.length + EXTRA_TOOLS.length + BILLING_TOOLS.length + CONTEXT_TOOLS.length + TRACE_TOOLS.length + IDENTITY_TOOLS.length;
1286
- var VERSION = "0.1.0";
2402
+ var TOTAL_TOOL_COUNT = PHASE1_TOOLS.length + PHASE2_TOOLS.length + PHASE3_TOOLS.length + FUND_TRADING_TOOLS.length + EXTRA_TOOLS.length + BILLING_TOOLS.length + CONTEXT_TOOLS.length + TRACE_TOOLS.length + IDENTITY_TOOLS.length + REGISTRY_TOOLS.length + DISCOVERY_TOOLS.length + ESCROW_TOOLS.length + DELEGATION_TOOLS.length + ARENA_TOOLS.length + TOURNAMENT_TOOLS.length + WAR_EXTENDED_TOOLS.length + NOTIFICATION_TOOLS.length + GAMIFICATION_TOOLS.length + API_KEY_TOOLS.length + SMALL_ENDPOINT_TOOLS.length + SOCIAL_DISCOVERY_TOOLS.length + MARKET_INTEL_TOOLS.length + FUND_MGMT_TOOLS.length;
2403
+ var VERSION = "0.2.0";
1287
2404
  var PUBLIC_TOOLS = /* @__PURE__ */ new Set([
1288
2405
  "register_agent",
1289
2406
  "authenticate",
@@ -1301,7 +2418,26 @@ var PUBLIC_TOOLS = /* @__PURE__ */ new Set([
1301
2418
  "get_trending_coins",
1302
2419
  "get_crypto_info",
1303
2420
  "get_live_wars",
1304
- "get_event_markets"
2421
+ "get_event_markets",
2422
+ "browse_registry",
2423
+ "get_registry_agent",
2424
+ "discover_agents",
2425
+ "get_agent_card",
2426
+ "get_trace_leaderboard",
2427
+ "get_trace_patterns",
2428
+ "get_arena_agents",
2429
+ "get_arena_feed",
2430
+ "get_arena_leaderboard",
2431
+ "get_arena_stats",
2432
+ "list_tournaments",
2433
+ "get_war_trades",
2434
+ "get_war_trajectory",
2435
+ "get_live_sports",
2436
+ "get_app_config",
2437
+ "get_user_profile",
2438
+ "get_user_badges",
2439
+ "get_related_markets",
2440
+ "get_category_comments"
1305
2441
  ]);
1306
2442
  async function fetchRemainingBalance(client) {
1307
2443
  try {
@@ -1323,43 +2459,25 @@ async function executeTool(client, baseUrl2, name, rawArgs, options) {
1323
2459
  switch (name) {
1324
2460
  // Phase 1 tools
1325
2461
  case "register_agent": {
1326
- const parsed = registerSchema.parse(args);
1327
- const operatorId2 = parsed.operatorId ?? options?.defaultOperatorId;
1328
- if (!operatorId2) {
1329
- throw new import_sdk.ToromarketError(
1330
- "operatorId is required. Provide it in the tool call or set TOROMARKET_OPERATOR_ID in your MCP server config.",
1331
- 400,
1332
- "OPERATOR_REQUIRED"
1333
- );
1334
- }
1335
- const input = {
2462
+ const parsed = selfRegisterSchema.parse(args);
2463
+ const result = await client.auth.selfRegister({
1336
2464
  email: parsed.email,
1337
2465
  username: parsed.username,
1338
2466
  password: parsed.password,
1339
- stake: parsed.stake,
1340
- operatorId: operatorId2,
1341
2467
  ...parsed.modelProvider ? { modelProvider: parsed.modelProvider } : {},
1342
- ...parsed.modelId ? { modelId: parsed.modelId } : {},
1343
- ...parsed.systemPromptHash ? { systemPromptHash: parsed.systemPromptHash } : {}
1344
- };
1345
- const result = await client.auth.register(input);
1346
- if (result.user) {
1347
- options?.onAuth?.(result.user.tier ?? "FREE", result.user.id);
1348
- if (result.user.trustTier) {
1349
- options?.onTrustTier?.(result.user.trustTier);
1350
- }
2468
+ ...parsed.modelId ? { modelId: parsed.modelId } : {}
2469
+ });
2470
+ if (result.apiKey) {
2471
+ client.setApiKey(result.apiKey);
1351
2472
  }
1352
- const { token: _token, ...safeResult } = result;
2473
+ options?.onAuth?.("FREE", result.userId);
1353
2474
  return {
1354
- ...safeResult,
1355
- ...result.user ? {
1356
- stakeInfo: {
1357
- stakeAmount: result.user.stakeAmount,
1358
- stakeStatus: result.user.stakeStatus,
1359
- trustScore: result.user.trustScore,
1360
- trustTier: result.user.trustTier
1361
- }
1362
- } : {}
2475
+ userId: result.userId,
2476
+ username: result.username,
2477
+ apiKey: result.apiKey,
2478
+ claimUrl: result.claimUrl,
2479
+ claimCode: result.claimCode,
2480
+ message: result.message
1363
2481
  };
1364
2482
  }
1365
2483
  case "authenticate": {
@@ -1402,7 +2520,9 @@ async function executeTool(client, baseUrl2, name, rawArgs, options) {
1402
2520
  side: input.side,
1403
2521
  type: input.type,
1404
2522
  price: Number(price),
1405
- quantity: Number(input.quantity)
2523
+ quantity: Number(input.quantity),
2524
+ reasoning: input.reasoning,
2525
+ confidence: input.confidence
1406
2526
  });
1407
2527
  const remainingBalance = await fetchRemainingBalance(client);
1408
2528
  return { ...result, remainingBalance };
@@ -1429,7 +2549,13 @@ async function executeTool(client, baseUrl2, name, rawArgs, options) {
1429
2549
  }
1430
2550
  case "trade_crypto": {
1431
2551
  const input = tradeCryptoSchema.parse(args);
1432
- const result = await client.portfolio.trade(input);
2552
+ const result = await client.portfolio.trade({
2553
+ symbol: input.symbol,
2554
+ side: input.side,
2555
+ quantity: input.quantity,
2556
+ reasoning: input.reasoning,
2557
+ confidence: input.confidence
2558
+ });
1433
2559
  const remainingBalance = await fetchRemainingBalance(client);
1434
2560
  return { ...result, remainingBalance };
1435
2561
  }
@@ -1623,7 +2749,9 @@ async function executeTool(client, baseUrl2, name, rawArgs, options) {
1623
2749
  side: input.side,
1624
2750
  type: input.type,
1625
2751
  price,
1626
- quantity: input.quantity
2752
+ quantity: input.quantity,
2753
+ reasoning: input.reasoning,
2754
+ confidence: input.confidence
1627
2755
  });
1628
2756
  const fundOrderBalance = await fetchRemainingBalance(client);
1629
2757
  return { ...fundOrderResult, remainingBalance: fundOrderBalance };
@@ -1633,7 +2761,9 @@ async function executeTool(client, baseUrl2, name, rawArgs, options) {
1633
2761
  const fundTradeResult = await client.funds.tradeCrypto(input.fundId, {
1634
2762
  symbol: input.symbol,
1635
2763
  side: input.side,
1636
- quantity: input.quantity
2764
+ quantity: input.quantity,
2765
+ reasoning: input.reasoning,
2766
+ confidence: input.confidence
1637
2767
  });
1638
2768
  const fundTradeBalance = await fetchRemainingBalance(client);
1639
2769
  return { ...fundTradeResult, remainingBalance: fundTradeBalance };
@@ -1809,6 +2939,25 @@ async function executeTool(client, baseUrl2, name, rawArgs, options) {
1809
2939
  const input = getTraceSchema.parse(args);
1810
2940
  return client.traces.get(input.traceId);
1811
2941
  }
2942
+ case "get_trace_leaderboard": {
2943
+ const input = traceLeaderboardSchema.parse(args);
2944
+ const result = await client.traces.getLeaderboard({
2945
+ ...input.sort ? { sort: input.sort } : {},
2946
+ ...input.limit !== void 0 ? { limit: input.limit } : {},
2947
+ ...input.offset !== void 0 ? { offset: input.offset } : {},
2948
+ ...input.trigger ? { trigger: input.trigger } : {}
2949
+ });
2950
+ return { ...result, entries: result.entries.map((e) => condenseTraceLeaderboardEntry(e)) };
2951
+ }
2952
+ case "get_trace_patterns": {
2953
+ const input = tracePatternsSchema.parse(args);
2954
+ const result = await client.traces.getPatterns({
2955
+ ...input.minPnl !== void 0 ? { minPnl: input.minPnl } : {},
2956
+ ...input.limit !== void 0 ? { limit: input.limit } : {},
2957
+ ...input.trigger ? { trigger: input.trigger } : {}
2958
+ });
2959
+ return { ...result, patterns: result.patterns.map((p) => condenseTracePattern(p)) };
2960
+ }
1812
2961
  // Identity tools
1813
2962
  case "topup_stake": {
1814
2963
  const input = topupStakeSchema.parse(args);
@@ -1848,6 +2997,343 @@ async function executeTool(client, baseUrl2, name, rawArgs, options) {
1848
2997
  }
1849
2998
  };
1850
2999
  }
3000
+ case "get_compliance_status": {
3001
+ const me = await client.auth.me();
3002
+ const complianceStatus = options?.complianceGate?.getStatus() ?? {
3003
+ enabled: false,
3004
+ flags: { velocityWarning: false, regionBlocked: false, largeTransaction: false },
3005
+ velocity: { tradesLastMinute: 0, sessionVolume: 0 },
3006
+ region: null,
3007
+ blockedRegions: []
3008
+ };
3009
+ return {
3010
+ trustTier: me.trustTier,
3011
+ trustScore: me.trustScore,
3012
+ compliance: complianceStatus
3013
+ };
3014
+ }
3015
+ // Registry tools
3016
+ case "browse_registry": {
3017
+ const input = browseRegistrySchema.parse(args);
3018
+ const limit = input.limit ?? 20;
3019
+ const offset = input.offset ?? 0;
3020
+ const allEntries = await client.registry.list({ ...input, limit, offset });
3021
+ const entries = allEntries.length > limit ? allEntries.slice(0, limit) : allEntries;
3022
+ return { agents: entries.map((e) => condenseRegistryEntry(e, baseUrl2)), limit, offset, total: allEntries.length, count: entries.length };
3023
+ }
3024
+ case "get_registry_agent": {
3025
+ const input = getRegistryAgentSchema.parse(args);
3026
+ return client.registry.get(input.agentId);
3027
+ }
3028
+ case "list_my_agent": {
3029
+ const input = listMyAgentSchema.parse(args);
3030
+ const entry = await client.registry.upsert(input);
3031
+ return {
3032
+ ...entry,
3033
+ url: registryAgentUrl(baseUrl2, entry.agentId)
3034
+ };
3035
+ }
3036
+ // A2A Discovery tools
3037
+ case "discover_agents": {
3038
+ const input = discoverAgentsSchema.parse(args);
3039
+ const limit = input.limit ?? 20;
3040
+ const offset = input.offset ?? 0;
3041
+ const allCards = await client.agents.discover({ ...input, limit, offset });
3042
+ const cards = allCards.length > limit ? allCards.slice(0, limit) : allCards;
3043
+ return { agents: cards.map((c) => condenseAgentCard(c, baseUrl2)), limit, offset, total: allCards.length, count: cards.length };
3044
+ }
3045
+ case "get_agent_card": {
3046
+ const input = getAgentCardSchema.parse(args);
3047
+ return client.agents.getCard(input.agentId);
3048
+ }
3049
+ case "update_my_agent_card": {
3050
+ const input = updateMyAgentCardSchema.parse(args);
3051
+ const card = await client.agents.updateMyCard(input);
3052
+ return {
3053
+ ...card,
3054
+ url: agentCardUrl(baseUrl2, card.agentId)
3055
+ };
3056
+ }
3057
+ // A2A Messaging tools
3058
+ case "send_agent_message": {
3059
+ const input = sendAgentMessageSchema.parse(args);
3060
+ const { agentId, ...messageInput } = input;
3061
+ return client.agents.sendMessage(agentId, messageInput);
3062
+ }
3063
+ case "read_agent_inbox": {
3064
+ const input = readAgentInboxSchema.parse(args);
3065
+ return client.agents.readInbox(input);
3066
+ }
3067
+ case "get_agent_conversation": {
3068
+ const input = getAgentConversationSchema.parse(args);
3069
+ return client.agents.getConversation(input.conversationId);
3070
+ }
3071
+ case "acknowledge_agent_inbox":
3072
+ return client.agents.acknowledgeInbox();
3073
+ // --- Escrow ---
3074
+ case "create_escrow": {
3075
+ const input = createEscrowSchema.parse(args);
3076
+ return client.escrows.createEscrow(input);
3077
+ }
3078
+ case "get_my_escrows": {
3079
+ const input = listEscrowsSchema.parse(args);
3080
+ const escrows = await client.escrows.listMyEscrows(input);
3081
+ return escrows.map((e) => condenseEscrow(e));
3082
+ }
3083
+ case "get_escrow": {
3084
+ const input = escrowIdSchema.parse(args);
3085
+ return client.escrows.getEscrow(input.escrowId);
3086
+ }
3087
+ case "settle_escrow": {
3088
+ const input = escrowIdSchema.parse(args);
3089
+ return client.escrows.settleEscrow(input.escrowId);
3090
+ }
3091
+ case "dispute_escrow": {
3092
+ const input = disputeEscrowSchema.parse(args);
3093
+ return client.escrows.disputeEscrow(input.escrowId, input.reason);
3094
+ }
3095
+ // --- Delegations ---
3096
+ case "create_delegation": {
3097
+ const input = createDelegationSchema.parse(args);
3098
+ return client.delegations.createDelegation(input);
3099
+ }
3100
+ case "list_delegations": {
3101
+ const input = listDelegationsSchema.parse(args);
3102
+ const delegations = await client.delegations.listMyDelegations(input);
3103
+ return delegations.map((d) => condenseDelegation(d));
3104
+ }
3105
+ case "get_delegation": {
3106
+ const input = delegationIdSchema.parse(args);
3107
+ return client.delegations.getDelegation(input.delegationId);
3108
+ }
3109
+ case "revoke_delegation": {
3110
+ const input = delegationIdSchema.parse(args);
3111
+ await client.delegations.revokeDelegation(input.delegationId);
3112
+ return { revoked: true, delegationId: input.delegationId };
3113
+ }
3114
+ case "rotate_delegation": {
3115
+ const input = delegationIdSchema.parse(args);
3116
+ return client.delegations.rotateDelegation(input.delegationId);
3117
+ }
3118
+ case "get_delegation_activity": {
3119
+ const input = delegationActivitySchema.parse(args);
3120
+ return client.delegations.getActivity({
3121
+ ...input.delegationId ? { delegationId: input.delegationId } : {},
3122
+ ...input.role ? { role: input.role } : {},
3123
+ ...input.limit !== void 0 ? { limit: input.limit } : {},
3124
+ ...input.offset !== void 0 ? { offset: input.offset } : {}
3125
+ });
3126
+ }
3127
+ // --- Arena ---
3128
+ case "get_arena_agents": {
3129
+ const input = arenaListSchema.parse(args);
3130
+ return client.arena.listAgents({
3131
+ ...input.limit !== void 0 ? { limit: input.limit } : {},
3132
+ ...input.offset !== void 0 ? { offset: input.offset } : {}
3133
+ });
3134
+ }
3135
+ case "get_arena_feed": {
3136
+ const input = arenaListSchema.parse(args);
3137
+ return client.arena.getFeed({
3138
+ ...input.limit !== void 0 ? { limit: input.limit } : {},
3139
+ ...input.offset !== void 0 ? { offset: input.offset } : {}
3140
+ });
3141
+ }
3142
+ case "get_arena_leaderboard": {
3143
+ const input = arenaLeaderboardSchema.parse(args);
3144
+ return client.arena.getLeaderboard({
3145
+ ...input.limit !== void 0 ? { limit: input.limit } : {}
3146
+ });
3147
+ }
3148
+ case "get_arena_stats":
3149
+ return client.arena.getStats();
3150
+ // --- Tournaments ---
3151
+ case "list_tournaments": {
3152
+ const input = tournamentListSchema.parse(args);
3153
+ return client.tournaments.list({
3154
+ ...input.status ? { status: input.status } : {},
3155
+ ...input.limit !== void 0 ? { limit: input.limit } : {},
3156
+ ...input.offset !== void 0 ? { offset: input.offset } : {}
3157
+ });
3158
+ }
3159
+ case "get_tournament": {
3160
+ const input = tournamentIdSchema.parse(args);
3161
+ return client.tournaments.get(input.tournamentId);
3162
+ }
3163
+ case "register_tournament": {
3164
+ const input = tournamentIdSchema.parse(args);
3165
+ return client.tournaments.register(input.tournamentId);
3166
+ }
3167
+ // --- War Extended ---
3168
+ case "get_war_trades": {
3169
+ const input = warTradesSchema.parse(args);
3170
+ return client.wars.getTrades(input.warId, {
3171
+ ...input.limit !== void 0 ? { limit: input.limit } : {},
3172
+ ...input.offset !== void 0 ? { offset: input.offset } : {}
3173
+ });
3174
+ }
3175
+ case "get_war_trajectory": {
3176
+ const input = warIdSchema.parse(args);
3177
+ return client.wars.getTrajectory(input.warId);
3178
+ }
3179
+ case "get_weekly_wars":
3180
+ return client.wars.getWeekly();
3181
+ // --- Notifications ---
3182
+ case "get_notifications": {
3183
+ const input = notificationHistorySchema.parse(args);
3184
+ return client.notifications.getHistory({
3185
+ ...input.limit !== void 0 ? { limit: input.limit } : {},
3186
+ ...input.cursor ? { cursor: input.cursor } : {}
3187
+ });
3188
+ }
3189
+ case "mark_notification_read": {
3190
+ const input = notificationIdSchema.parse(args);
3191
+ await client.notifications.markRead(input.notificationId);
3192
+ return { read: true, notificationId: input.notificationId };
3193
+ }
3194
+ case "mark_all_notifications_read": {
3195
+ await client.notifications.markAllRead();
3196
+ return { markedAllRead: true };
3197
+ }
3198
+ case "register_push_token": {
3199
+ const input = registerPushTokenSchema.parse(args);
3200
+ await client.notifications.registerToken(input);
3201
+ return { registered: true };
3202
+ }
3203
+ case "unregister_push_token": {
3204
+ const input = unregisterPushTokenSchema.parse(args);
3205
+ await client.notifications.unregisterToken(input);
3206
+ return { unregistered: true };
3207
+ }
3208
+ // --- Gamification ---
3209
+ case "get_gamification_profile":
3210
+ return client.gamification.getProfile();
3211
+ case "get_badges":
3212
+ return client.gamification.getBadges();
3213
+ case "get_all_badges":
3214
+ return client.gamification.getAllBadges();
3215
+ case "get_challenges":
3216
+ return client.gamification.getChallenges();
3217
+ case "claim_challenge": {
3218
+ const input = challengeIdSchema.parse(args);
3219
+ return client.gamification.claimChallenge(input.challengeId);
3220
+ }
3221
+ case "get_quests":
3222
+ return client.gamification.getQuests();
3223
+ case "claim_quest": {
3224
+ const input = claimQuestSchema.parse(args);
3225
+ return client.gamification.claimQuest(input.quest_assignment_id);
3226
+ }
3227
+ case "get_mystery_box":
3228
+ return client.gamification.getMysteryBox();
3229
+ case "claim_mystery_box":
3230
+ return client.gamification.claimMysteryBox();
3231
+ case "record_login":
3232
+ return client.gamification.recordLogin();
3233
+ case "get_gamification_leaderboard": {
3234
+ const input = gamificationLeaderboardSchema.parse(args);
3235
+ return client.gamification.getLeaderboard({
3236
+ ...input.limit !== void 0 ? { limit: input.limit } : {},
3237
+ ...input.offset !== void 0 ? { offset: input.offset } : {}
3238
+ });
3239
+ }
3240
+ case "get_reward_history": {
3241
+ const input = rewardHistorySchema.parse(args);
3242
+ return client.gamification.getRewards({
3243
+ ...input.limit !== void 0 ? { limit: input.limit } : {},
3244
+ ...input.offset !== void 0 ? { offset: input.offset } : {}
3245
+ });
3246
+ }
3247
+ // --- API Keys ---
3248
+ case "list_api_keys":
3249
+ return client.apiKeys.list();
3250
+ case "create_api_key": {
3251
+ const input = createApiKeySchema.parse(args);
3252
+ return client.apiKeys.create({
3253
+ name: input.name,
3254
+ ...input.scopes ? { scopes: input.scopes } : {},
3255
+ ...input.expires_in_days !== void 0 ? { expiresInDays: input.expires_in_days } : {}
3256
+ });
3257
+ }
3258
+ case "revoke_api_key": {
3259
+ const input = apiKeyIdSchema.parse(args);
3260
+ await client.apiKeys.revoke(input.apiKeyId);
3261
+ return { revoked: true, apiKeyId: input.apiKeyId };
3262
+ }
3263
+ // --- Small Endpoints ---
3264
+ case "get_live_sports":
3265
+ return client.markets.getLiveSports();
3266
+ case "get_friends":
3267
+ return client.social.friends();
3268
+ case "submit_bug_report": {
3269
+ const input = bugReportSchema.parse(args);
3270
+ return client.support.submitBugReport(input);
3271
+ }
3272
+ case "get_app_config":
3273
+ return client.config.getAppConfig();
3274
+ // --- Social & Discovery ---
3275
+ case "compare_users": {
3276
+ const input = compareUserSchema.parse(args);
3277
+ return client.social.compare(input.userId);
3278
+ }
3279
+ case "get_friend_requests":
3280
+ return client.social.friendRequests();
3281
+ case "accept_friend_request": {
3282
+ const input = friendRequestIdSchema.parse(args);
3283
+ return client.social.acceptFriendRequest(input.requestId);
3284
+ }
3285
+ case "reject_friend_request": {
3286
+ const input = friendRequestIdSchema.parse(args);
3287
+ return client.social.rejectFriendRequest(input.requestId);
3288
+ }
3289
+ case "get_user_badges": {
3290
+ const input = getUserBadgesSchema.parse(args);
3291
+ return client.profiles.getBadges(input.username);
3292
+ }
3293
+ case "react_to_chat": {
3294
+ const input = reactToChatSchema.parse(args);
3295
+ return client.chat.react(input.symbol, input.messageId, input.emoji);
3296
+ }
3297
+ // --- Market Intelligence (extended) ---
3298
+ case "get_related_markets": {
3299
+ const input = getRelatedMarketsSchema.parse(args);
3300
+ return client.predictions.getRelatedMarkets(input.marketId);
3301
+ }
3302
+ case "get_category_comments": {
3303
+ const input = getCategoryCommentsSchema.parse(args);
3304
+ return client.predictions.getCategoryComments(input.category, {
3305
+ ...input.exclude ? { exclude: input.exclude } : {}
3306
+ });
3307
+ }
3308
+ // --- Fund Management (extended) ---
3309
+ case "get_fund_pnl_chart": {
3310
+ const input = fundIdSchema.parse(args);
3311
+ return client.funds.getPnlChart(input.fundId);
3312
+ }
3313
+ case "get_fund_proposals": {
3314
+ const input = fundIdSchema.parse(args);
3315
+ return client.funds.getProposals(input.fundId);
3316
+ }
3317
+ case "create_strategy_proposal": {
3318
+ const input = createProposalSchema.parse(args);
3319
+ return client.funds.createProposal(input.fundId, {
3320
+ title: input.title,
3321
+ description: input.description,
3322
+ ...input.sourceCode ? { sourceCode: input.sourceCode } : {}
3323
+ });
3324
+ }
3325
+ case "approve_strategy_proposal": {
3326
+ const input = proposalActionSchema.parse(args);
3327
+ return client.funds.approveProposal(input.fundId, input.proposalId);
3328
+ }
3329
+ case "reject_strategy_proposal": {
3330
+ const input = proposalActionSchema.parse(args);
3331
+ return client.funds.rejectProposal(
3332
+ input.fundId,
3333
+ input.proposalId,
3334
+ input.reason ? { reason: input.reason } : void 0
3335
+ );
3336
+ }
1851
3337
  default:
1852
3338
  throw new import_sdk.ToromarketError(`Unknown tool: ${name}`, 400);
1853
3339
  }
@@ -1941,8 +3427,29 @@ var TRADER_TOOLS = /* @__PURE__ */ new Set([
1941
3427
  // Identity
1942
3428
  "topup_stake",
1943
3429
  "get_trust_info",
3430
+ "get_compliance_status",
3431
+ // Traces (public)
3432
+ "get_trace_leaderboard",
3433
+ "get_trace_patterns",
3434
+ // Arena (public)
3435
+ "get_arena_agents",
3436
+ "get_arena_feed",
3437
+ "get_arena_leaderboard",
3438
+ "get_arena_stats",
3439
+ // Tournaments (public read)
3440
+ "list_tournaments",
3441
+ "get_tournament",
3442
+ // War extended
3443
+ "get_war_trades",
3444
+ "get_war_trajectory",
1944
3445
  // Context
1945
- "get_help"
3446
+ "get_help",
3447
+ // Small endpoints (public)
3448
+ "get_live_sports",
3449
+ "get_app_config",
3450
+ // Market intelligence (public)
3451
+ "get_related_markets",
3452
+ "get_category_comments"
1946
3453
  ]);
1947
3454
  var SOCIAL_TOOLS = /* @__PURE__ */ new Set([
1948
3455
  ...TRADER_TOOLS,
@@ -1964,7 +3471,70 @@ var SOCIAL_TOOLS = /* @__PURE__ */ new Set([
1964
3471
  "get_operator_status",
1965
3472
  // Traces
1966
3473
  "get_my_traces",
1967
- "get_trace"
3474
+ "get_trace",
3475
+ // Registry
3476
+ "browse_registry",
3477
+ "get_registry_agent",
3478
+ "list_my_agent",
3479
+ // A2A Discovery
3480
+ "discover_agents",
3481
+ "get_agent_card",
3482
+ "update_my_agent_card",
3483
+ // A2A Messaging
3484
+ "send_agent_message",
3485
+ "read_agent_inbox",
3486
+ "get_agent_conversation",
3487
+ "acknowledge_agent_inbox",
3488
+ // Escrow
3489
+ "create_escrow",
3490
+ "get_my_escrows",
3491
+ "get_escrow",
3492
+ "settle_escrow",
3493
+ "dispute_escrow",
3494
+ // Delegations
3495
+ "create_delegation",
3496
+ "list_delegations",
3497
+ "get_delegation",
3498
+ "revoke_delegation",
3499
+ "rotate_delegation",
3500
+ "get_delegation_activity",
3501
+ // Notifications
3502
+ "get_notifications",
3503
+ "mark_notification_read",
3504
+ "mark_all_notifications_read",
3505
+ "register_push_token",
3506
+ "unregister_push_token",
3507
+ // API Keys
3508
+ "list_api_keys",
3509
+ "create_api_key",
3510
+ "revoke_api_key",
3511
+ // Tournaments (register)
3512
+ "register_tournament",
3513
+ // War extended (public)
3514
+ "get_weekly_wars",
3515
+ // Gamification
3516
+ "get_gamification_profile",
3517
+ "get_badges",
3518
+ "get_all_badges",
3519
+ "get_challenges",
3520
+ "claim_challenge",
3521
+ "get_quests",
3522
+ "claim_quest",
3523
+ "get_mystery_box",
3524
+ "claim_mystery_box",
3525
+ "record_login",
3526
+ "get_gamification_leaderboard",
3527
+ "get_reward_history",
3528
+ // Small endpoints (auth-required)
3529
+ "get_friends",
3530
+ "submit_bug_report",
3531
+ // Social & Discovery
3532
+ "compare_users",
3533
+ "get_friend_requests",
3534
+ "accept_friend_request",
3535
+ "reject_friend_request",
3536
+ "get_user_badges",
3537
+ "react_to_chat"
1968
3538
  ]);
1969
3539
  var FUND_MANAGER_TOOLS = /* @__PURE__ */ new Set([
1970
3540
  ...SOCIAL_TOOLS,
@@ -1989,6 +3559,12 @@ var FUND_MANAGER_TOOLS = /* @__PURE__ */ new Set([
1989
3559
  "cancel_fund_order",
1990
3560
  "get_fund_strategy",
1991
3561
  "set_fund_strategy",
3562
+ // Fund management (extended)
3563
+ "get_fund_pnl_chart",
3564
+ "get_fund_proposals",
3565
+ "create_strategy_proposal",
3566
+ "approve_strategy_proposal",
3567
+ "reject_strategy_proposal",
1992
3568
  // Wars
1993
3569
  "get_active_wars",
1994
3570
  "get_active_war",
@@ -2019,7 +3595,7 @@ function isValidProfile(value) {
2019
3595
  // src/tools/compact-descriptions.ts
2020
3596
  var COMPACT_DESCRIPTIONS = {
2021
3597
  // Auth
2022
- register_agent: "Create agent account. Requires: email, username, password, stake (1000-5000 TC), operatorId. Returns token + trust info.",
3598
+ register_agent: "Create agent account. Requires: email, username, password. Token auto-stored; returns claim URL for operator verification.",
2023
3599
  authenticate: "Log in. Returns token. Params: email, password.",
2024
3600
  // Markets
2025
3601
  list_markets: "List prediction markets. Returns id, title, outcomes[{id, probability}]. Use outcomeId with place_order.",
@@ -2054,7 +3630,34 @@ var COMPACT_DESCRIPTIONS = {
2054
3630
  get_trust_info: "Get your trust score, tier, stake status, and operator info.",
2055
3631
  get_operator_status: "Check your operator's social verification status.",
2056
3632
  // Help
2057
- get_help: "Overview of tools and workflows."
3633
+ get_help: "Overview of tools and workflows.",
3634
+ // Escrow
3635
+ create_escrow: "Lock TC in escrow for agent service. Params: toAgentId, serviceName, amount, conversationId?.",
3636
+ get_my_escrows: "List your escrows. Params: role (payer/payee), status, limit, offset.",
3637
+ get_escrow: "Get escrow details. Params: escrowId.",
3638
+ settle_escrow: "Settle escrow (3-way split). Payer-only. Params: escrowId.",
3639
+ dispute_escrow: "Dispute escrow. Payer-only. Params: escrowId, reason?.",
3640
+ // Delegations
3641
+ create_delegation: "Grant agent scoped trading access. Returns one-time token. Params: granteeId, scopes, limits, expiresIn?.",
3642
+ list_delegations: "List your delegations. Params: role (grantor/grantee), status, limit, offset.",
3643
+ get_delegation: "Get delegation details + spend/trade count. Params: delegationId.",
3644
+ revoke_delegation: "Revoke delegation immediately. Grantor-only. Params: delegationId.",
3645
+ // Social & Discovery
3646
+ compare_users: "Compare your portfolio vs another user. Params: userId.",
3647
+ get_friend_requests: "List pending friend requests sent to you.",
3648
+ accept_friend_request: "Accept friend request. Params: requestId.",
3649
+ reject_friend_request: "Reject friend request. Params: requestId.",
3650
+ get_user_badges: "Get user's badges. Public. Params: username.",
3651
+ react_to_chat: "React to chat message. Params: symbol, messageId, emoji.",
3652
+ // Market Intelligence (extended)
3653
+ get_related_markets: "Get markets for same event. Public. Params: marketId.",
3654
+ get_category_comments: "Get comments across category markets. Public. Params: category, exclude?.",
3655
+ // Fund Management (extended)
3656
+ get_fund_pnl_chart: "Get daily P&L chart for fund. Params: fundId.",
3657
+ get_fund_proposals: "List strategy proposals. Params: fundId.",
3658
+ create_strategy_proposal: "Propose strategy. Params: fundId, title, description, sourceCode?.",
3659
+ approve_strategy_proposal: "Approve proposal (MANAGER+). Params: fundId, proposalId.",
3660
+ reject_strategy_proposal: "Reject proposal (MANAGER+). Params: fundId, proposalId, reason?."
2058
3661
  };
2059
3662
 
2060
3663
  // src/logger.ts
@@ -2131,7 +3734,7 @@ var RegistrationThrottle = class {
2131
3734
  // src/middleware/rate-limiter.ts
2132
3735
  var import_sdk4 = require("@toromarket/sdk");
2133
3736
  var ORDER_TOOLS = /* @__PURE__ */ new Set(["place_order", "cancel_order", "trade_crypto", "place_fund_order", "trade_fund_crypto", "cancel_fund_order"]);
2134
- var CHAT_TOOLS = /* @__PURE__ */ new Set(["post_market_comment", "post_fund_message"]);
3737
+ var CHAT_TOOLS = /* @__PURE__ */ new Set(["post_market_comment", "post_fund_message", "react_to_chat"]);
2135
3738
  var HEAVY_TOOLS = /* @__PURE__ */ new Set(["get_trading_context"]);
2136
3739
  var TIER_LIMITS = {
2137
3740
  FREE: { ordersPerMinute: 10, chatPerMinute: 5, readsPerMinute: 60 },
@@ -2357,6 +3960,136 @@ function extractRemainingBalance(result) {
2357
3960
  return null;
2358
3961
  }
2359
3962
 
3963
+ // src/middleware/compliance-gate.ts
3964
+ var FINANCIAL_TOOLS = /* @__PURE__ */ new Set([
3965
+ "place_order",
3966
+ "cancel_order",
3967
+ "trade_crypto",
3968
+ "place_fund_order",
3969
+ "trade_fund_crypto",
3970
+ "cancel_fund_order",
3971
+ "create_escrow",
3972
+ "settle_escrow",
3973
+ "create_delegation",
3974
+ "topup_stake",
3975
+ "claim_challenge",
3976
+ "claim_quest",
3977
+ "claim_mystery_box"
3978
+ ]);
3979
+ var ComplianceGate = class {
3980
+ constructor(config, logger) {
3981
+ this.config = config;
3982
+ this.logger = logger;
3983
+ }
3984
+ tradeTimestamps = [];
3985
+ sessionTcVolume = 0;
3986
+ region = null;
3987
+ flags = {
3988
+ velocityWarning: false,
3989
+ regionBlocked: false,
3990
+ largeTransaction: false
3991
+ };
3992
+ /**
3993
+ * Set the session's region for geographic restriction checks.
3994
+ * Call this when region info is available (e.g., from HTTP transport
3995
+ * X-Forwarded-For / CF-IPCountry headers, or operator-provided region).
3996
+ */
3997
+ setRegion(region) {
3998
+ this.region = region.toUpperCase();
3999
+ if (this.config.blockedRegions.length > 0 && this.config.blockedRegions.includes(this.region)) {
4000
+ this.flags.regionBlocked = true;
4001
+ this.logger.warn({
4002
+ event: "compliance:region_blocked",
4003
+ region: this.region,
4004
+ blockedRegions: this.config.blockedRegions
4005
+ });
4006
+ }
4007
+ }
4008
+ async beforeExecute(toolName, args) {
4009
+ if (!this.config.enabled) return;
4010
+ if (!FINANCIAL_TOOLS.has(toolName)) return;
4011
+ const now = Date.now();
4012
+ this.tradeTimestamps.push(now);
4013
+ const oneMinAgo = now - 6e4;
4014
+ this.tradeTimestamps = this.tradeTimestamps.filter((t) => t > oneMinAgo);
4015
+ const amount = this.parseAmount(args);
4016
+ if (amount > 0) {
4017
+ this.sessionTcVolume += amount;
4018
+ }
4019
+ if (this.tradeTimestamps.length > this.config.velocityTradesPerMin) {
4020
+ this.flags.velocityWarning = true;
4021
+ this.logger.warn({
4022
+ event: "compliance:velocity_warning",
4023
+ tradesInLastMinute: this.tradeTimestamps.length,
4024
+ threshold: this.config.velocityTradesPerMin,
4025
+ tool: toolName
4026
+ });
4027
+ }
4028
+ if (this.sessionTcVolume > this.config.velocityTcPerHour) {
4029
+ this.flags.velocityWarning = true;
4030
+ this.logger.warn({
4031
+ event: "compliance:volume_warning",
4032
+ sessionVolume: this.sessionTcVolume,
4033
+ threshold: this.config.velocityTcPerHour,
4034
+ tool: toolName
4035
+ });
4036
+ }
4037
+ if (amount > 1e4) {
4038
+ this.flags.largeTransaction = true;
4039
+ this.logger.warn({
4040
+ event: "compliance:large_transaction",
4041
+ amount,
4042
+ tool: toolName
4043
+ });
4044
+ }
4045
+ if (this.flags.regionBlocked) {
4046
+ this.logger.warn({
4047
+ event: "compliance:region_blocked_trade_attempt",
4048
+ region: this.region,
4049
+ tool: toolName
4050
+ });
4051
+ }
4052
+ this.logger.info({
4053
+ event: "compliance:financial_tool",
4054
+ tool: toolName,
4055
+ amount: amount > 0 ? amount : void 0,
4056
+ sessionVolume: this.sessionTcVolume,
4057
+ tradesInLastMinute: this.tradeTimestamps.length,
4058
+ region: this.region,
4059
+ regionBlocked: this.flags.regionBlocked
4060
+ });
4061
+ }
4062
+ async afterExecute(_toolName, _args, _result, _error) {
4063
+ }
4064
+ getStatus() {
4065
+ const now = Date.now();
4066
+ const oneMinAgo = now - 6e4;
4067
+ const recentTrades = this.tradeTimestamps.filter((t) => t > oneMinAgo);
4068
+ return {
4069
+ enabled: this.config.enabled,
4070
+ flags: { ...this.flags },
4071
+ velocity: {
4072
+ tradesLastMinute: recentTrades.length,
4073
+ sessionVolume: this.sessionTcVolume
4074
+ },
4075
+ region: this.region,
4076
+ blockedRegions: this.config.blockedRegions
4077
+ };
4078
+ }
4079
+ parseAmount(args) {
4080
+ if (typeof args !== "object" || args === null) return 0;
4081
+ const a = args;
4082
+ if (typeof a.quantity === "number" && typeof a.price === "number") {
4083
+ return a.quantity * a.price;
4084
+ }
4085
+ if (typeof a.quantity === "number") return a.quantity;
4086
+ if (typeof a.amount === "number") return a.amount;
4087
+ if (typeof a.stake === "number") return a.stake;
4088
+ if (typeof a.initialStake === "number") return a.initialStake;
4089
+ return 0;
4090
+ }
4091
+ };
4092
+
2360
4093
  // src/audit.ts
2361
4094
  var AUDITED_TOOLS = /* @__PURE__ */ new Set([
2362
4095
  "place_order",
@@ -2444,8 +4177,18 @@ var TraceCollector = class {
2444
4177
  ...signals !== void 0 ? { signals } : {}
2445
4178
  };
2446
4179
  }
2447
- async beforeExecute(toolName) {
2448
- if (STATE_CHANGING_TOOLS.has(toolName) && !this.pendingReasoning) {
4180
+ async beforeExecute(toolName, args) {
4181
+ if (!STATE_CHANGING_TOOLS.has(toolName)) return;
4182
+ if (!this.pendingReasoning && args && typeof args === "object") {
4183
+ const a = args;
4184
+ if (typeof a.reasoning === "string" && a.reasoning.length > 0) {
4185
+ this.setReasoning(
4186
+ a.reasoning,
4187
+ typeof a.confidence === "number" ? a.confidence : void 0
4188
+ );
4189
+ }
4190
+ }
4191
+ if (!this.pendingReasoning) {
2449
4192
  throw new import_sdk8.ToromarketError(
2450
4193
  "Call log_reasoning before trading. Every trade requires a reasoning explanation.",
2451
4194
  400,
@@ -2858,7 +4601,7 @@ var MetricsCollector = class {
2858
4601
  function createToromarketClient(options) {
2859
4602
  return new import_sdk9.ToromarketClient({
2860
4603
  baseUrl: options.baseUrl,
2861
- clientId: "mcp-server/0.1.0",
4604
+ clientId: "mcp-server/0.2.0",
2862
4605
  ...options.token ? { token: options.token } : {},
2863
4606
  ...options.apiKey ? { apiKey: options.apiKey } : {},
2864
4607
  ...options.agentSecret ? { agentSecret: options.agentSecret } : {}
@@ -2866,10 +4609,10 @@ function createToromarketClient(options) {
2866
4609
  }
2867
4610
  function createToromarketServer(client, baseUrl2, logger, middlewares = [], executeOptions, metrics, toolProfile2, compactDescriptions2) {
2868
4611
  const server = new import_server.Server(
2869
- { name: "toromarket", version: "0.1.0" },
4612
+ { name: "toromarket", version: "0.2.0" },
2870
4613
  { capabilities: { tools: {}, resources: {}, prompts: {}, logging: {} } }
2871
4614
  );
2872
- const allTools = [...PHASE1_TOOLS, ...PHASE2_TOOLS, ...PHASE3_TOOLS, ...FUND_TRADING_TOOLS, ...EXTRA_TOOLS, ...BILLING_TOOLS, ...CONTEXT_TOOLS, ...TRACE_TOOLS, ...IDENTITY_TOOLS];
4615
+ const allTools = [...PHASE1_TOOLS, ...PHASE2_TOOLS, ...PHASE3_TOOLS, ...FUND_TRADING_TOOLS, ...EXTRA_TOOLS, ...BILLING_TOOLS, ...CONTEXT_TOOLS, ...TRACE_TOOLS, ...IDENTITY_TOOLS, ...REGISTRY_TOOLS, ...DISCOVERY_TOOLS, ...ESCROW_TOOLS, ...DELEGATION_TOOLS, ...ARENA_TOOLS, ...TOURNAMENT_TOOLS, ...WAR_EXTENDED_TOOLS, ...NOTIFICATION_TOOLS, ...GAMIFICATION_TOOLS, ...API_KEY_TOOLS, ...SMALL_ENDPOINT_TOOLS, ...SOCIAL_DISCOVERY_TOOLS, ...MARKET_INTEL_TOOLS, ...FUND_MGMT_TOOLS];
2873
4616
  const profileToolSet = toolProfile2 ? getProfileToolSet(toolProfile2) : null;
2874
4617
  const profileTools = profileToolSet ? allTools.filter((t) => profileToolSet.has(t.name)) : allTools;
2875
4618
  const finalTools = compactDescriptions2 ? profileTools.map((t) => {
@@ -2994,10 +4737,19 @@ function createServerFactory(options) {
2994
4737
  const metrics = new MetricsCollector(logger);
2995
4738
  const rateLimiter = new RateLimiter();
2996
4739
  const traceCollector = new TraceCollector(client, logger, `session-${Date.now()}`);
4740
+ const complianceEnabled = !!process.env.TOROMARKET_COMPLIANCE_MODE;
4741
+ const blockedRegions = (process.env.TOROMARKET_BLOCKED_REGIONS ?? "").split(",").map((r) => r.trim().toUpperCase()).filter(Boolean);
4742
+ const velocityTradesPerMin = Number(process.env.TOROMARKET_VELOCITY_TRADES_PER_MIN) || 30;
4743
+ const velocityTcPerHour = Number(process.env.TOROMARKET_VELOCITY_TC_PER_HOUR) || 5e4;
4744
+ const complianceGate = new ComplianceGate(
4745
+ { enabled: complianceEnabled, blockedRegions, velocityTradesPerMin, velocityTcPerHour },
4746
+ logger
4747
+ );
2997
4748
  const middlewares = [
2998
4749
  new RegistrationThrottle(),
2999
4750
  rateLimiter,
3000
4751
  new SpoofingDetector(),
4752
+ complianceGate,
3001
4753
  new SpendingGuardrails(options.maxSessionLoss),
3002
4754
  new ErrorBudget(),
3003
4755
  new AuditLogger(logger),
@@ -3008,7 +4760,7 @@ function createServerFactory(options) {
3008
4760
  let currentTrustTier = null;
3009
4761
  const executeOptions = {
3010
4762
  traceCollector,
3011
- ...options.operatorId ? { defaultOperatorId: options.operatorId } : {},
4763
+ complianceGate,
3012
4764
  onTrustTier: (trustTier) => {
3013
4765
  currentTrustTier = trustTier;
3014
4766
  logger.info({ event: "trust_tier_applied", trustTier });
@@ -3049,7 +4801,8 @@ function createServerFactory(options) {
3049
4801
  notificationService.stop();
3050
4802
  notificationService = null;
3051
4803
  }
3052
- }
4804
+ },
4805
+ setRegion: (region) => complianceGate.setRegion(region)
3053
4806
  };
3054
4807
  };
3055
4808
  return { logger, createMcpServer };
@@ -3136,6 +4889,10 @@ async function startHttpTransport(options) {
3136
4889
  entry = { transport: transport2, server: createdServer, lastActivity: Date.now() };
3137
4890
  sessions.set(newSessionId, entry);
3138
4891
  logger.info({ event: "session_created", sessionId: newSessionId });
4892
+ const region = req.headers["cf-ipcountry"] ?? req.headers["x-vercel-ip-country"] ?? req.headers["x-country-code"];
4893
+ if (region && createdServer.setRegion) {
4894
+ createdServer.setRegion(region);
4895
+ }
3139
4896
  transport2.onclose = () => {
3140
4897
  createdServer.cleanup();
3141
4898
  sessions.delete(newSessionId);
@@ -3239,7 +4996,6 @@ var pollIntervalStr = readEnv("TOROMARKET_POLL_INTERVAL");
3239
4996
  var pollIntervalMs = pollIntervalStr ? Number(pollIntervalStr) : void 0;
3240
4997
  var toolProfile = readEnv("TOROMARKET_TOOL_PROFILE") ?? "full";
3241
4998
  var compactDescriptions = readEnv("TOROMARKET_TOOL_DESCRIPTIONS") === "compact";
3242
- var operatorId = readEnv("TOROMARKET_OPERATOR_ID");
3243
4999
  if (!isValidProfile(toolProfile)) {
3244
5000
  process.stderr.write(`Invalid TOROMARKET_TOOL_PROFILE: "${toolProfile}". Valid: trader, social, fund_manager, full
3245
5001
  `);
@@ -3254,8 +5010,7 @@ var serverOptions = {
3254
5010
  ...apiKey ? { apiKey } : {},
3255
5011
  ...agentSecret ? { agentSecret } : {},
3256
5012
  ...maxSessionLoss ? { maxSessionLoss } : {},
3257
- ...pollIntervalMs !== void 0 ? { pollIntervalMs } : {},
3258
- ...operatorId ? { operatorId } : {}
5013
+ ...pollIntervalMs !== void 0 ? { pollIntervalMs } : {}
3259
5014
  };
3260
5015
  async function main() {
3261
5016
  if (transport === "http") {