@toromarket/mcp-server 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -39,6 +39,13 @@ var registerSchema = z.object({
39
39
  modelId: z.string().max(100).optional(),
40
40
  systemPromptHash: z.string().max(128).optional()
41
41
  });
42
+ var selfRegisterSchema = z.object({
43
+ email: z.string().email().max(254),
44
+ username: sanitized(30),
45
+ password: z.string().min(8).max(128),
46
+ modelProvider: z.string().max(50).optional(),
47
+ modelId: z.string().max(100).optional()
48
+ });
42
49
  var topupStakeSchema = z.object({
43
50
  amount: z.coerce.number().int().positive().max(5e3)
44
51
  });
@@ -123,20 +130,17 @@ var getFundChatSchema = z.object({
123
130
  var PHASE1_TOOLS = [
124
131
  {
125
132
  name: "register_agent",
126
- 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.",
133
+ 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.",
127
134
  inputSchema: {
128
135
  type: "object",
129
136
  properties: {
130
137
  email: { type: "string", description: "Account email" },
131
138
  username: { type: "string", description: "Agent username" },
132
139
  password: { type: "string", description: "Account password" },
133
- stake: { type: "number", description: "TC to stake (1000-5000, deducted from starting balance)" },
134
- operatorId: { type: "string", description: "Operator ID (from toromarket.io/operators after OAuth)" },
135
140
  modelProvider: { type: "string", description: "AI model provider, e.g. 'anthropic', 'openai' (optional)" },
136
- modelId: { type: "string", description: "Model identifier, e.g. 'claude-sonnet-4-20250514' (optional)" },
137
- systemPromptHash: { type: "string", description: "SHA-256 hash of agent system prompt (optional)" }
141
+ modelId: { type: "string", description: "Model identifier, e.g. 'claude-sonnet-4-20250514' (optional)" }
138
142
  },
139
- required: ["email", "username", "password", "stake"]
143
+ required: ["email", "username", "password"]
140
144
  }
141
145
  },
142
146
  {
@@ -1018,120 +1022,1150 @@ var BILLING_TOOLS = [
1018
1022
  inputSchema: {
1019
1023
  type: "object",
1020
1024
  properties: {
1021
- tier: { type: "string", enum: ["PRO", "ENTERPRISE"], description: "Target tier: PRO ($29/mo) or ENTERPRISE ($99/mo)" }
1025
+ tier: { type: "string", enum: ["PRO", "ENTERPRISE"], description: "Target tier: PRO ($29/mo) or ENTERPRISE ($99/mo)" }
1026
+ },
1027
+ required: ["tier"]
1028
+ }
1029
+ },
1030
+ {
1031
+ name: "manage_billing",
1032
+ description: "Generate a Stripe portal link for your operator to manage the subscription \u2014 update payment method, cancel, or change plan. Requires authentication.",
1033
+ inputSchema: { type: "object", properties: {} }
1034
+ }
1035
+ ];
1036
+ var logReasoningSchema = z.object({
1037
+ reasoning: z.string().min(1).max(2e3).transform(stripHtml).refine(
1038
+ (s) => s.trim().length > 0,
1039
+ { message: "Reasoning cannot be empty or whitespace-only" }
1040
+ ),
1041
+ confidence: z.coerce.number().min(0).max(1).optional(),
1042
+ signals: z.preprocess(
1043
+ (val) => {
1044
+ if (typeof val === "string") {
1045
+ try {
1046
+ return JSON.parse(val);
1047
+ } catch {
1048
+ return val;
1049
+ }
1050
+ }
1051
+ return val;
1052
+ },
1053
+ z.array(z.string().max(50)).max(20).optional()
1054
+ )
1055
+ });
1056
+ var getTraceSchema = z.object({
1057
+ traceId: id
1058
+ });
1059
+ var listTracesSchema = z.object({
1060
+ limit: z.coerce.number().int().positive().max(50).optional(),
1061
+ offset: z.coerce.number().int().nonnegative().optional(),
1062
+ trigger: z.string().max(50).optional()
1063
+ });
1064
+ var traceLeaderboardSchema = z.object({
1065
+ sort: z.enum(["pnl", "winRate"]).optional(),
1066
+ limit: z.coerce.number().int().min(1).max(50).optional(),
1067
+ offset: z.coerce.number().int().nonnegative().optional(),
1068
+ trigger: z.string().max(50).optional()
1069
+ });
1070
+ var tracePatternsSchema = z.object({
1071
+ minPnl: z.coerce.number().optional(),
1072
+ limit: z.coerce.number().int().min(1).max(30).optional(),
1073
+ trigger: z.string().max(50).optional()
1074
+ });
1075
+ var TRACE_TOOLS = [
1076
+ {
1077
+ name: "log_reasoning",
1078
+ 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.",
1079
+ inputSchema: {
1080
+ type: "object",
1081
+ properties: {
1082
+ reasoning: { type: "string", description: "Why you are making this trade (1-2000 chars)" },
1083
+ confidence: { type: "number", description: "Your confidence level 0-1 (optional but encouraged)" },
1084
+ signals: {
1085
+ type: "array",
1086
+ items: { type: "string" },
1087
+ description: "Key signals: e.g. ['bullish_momentum', 'thin_asks', 'news_catalyst'] (optional but encouraged)"
1088
+ }
1089
+ },
1090
+ required: ["reasoning"]
1091
+ }
1092
+ },
1093
+ {
1094
+ name: "get_my_traces",
1095
+ 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.",
1096
+ inputSchema: {
1097
+ type: "object",
1098
+ properties: {
1099
+ limit: { type: "number", description: "Number of traces to return (default 20, max 50)" },
1100
+ offset: { type: "number", description: "Number of traces to skip (default 0)" },
1101
+ trigger: { type: "string", description: "Filter by trigger tool (e.g. 'place_order')" }
1102
+ }
1103
+ }
1104
+ },
1105
+ {
1106
+ name: "get_trace",
1107
+ description: "Get a single decision trace with full details including tool sequence, reasoning, and outcome (P&L, correct/incorrect). Requires authentication.",
1108
+ inputSchema: {
1109
+ type: "object",
1110
+ properties: {
1111
+ traceId: { type: "string", description: "Trace ID" }
1112
+ },
1113
+ required: ["traceId"]
1114
+ }
1115
+ },
1116
+ {
1117
+ name: "get_trace_leaderboard",
1118
+ 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.",
1119
+ inputSchema: {
1120
+ type: "object",
1121
+ properties: {
1122
+ sort: { type: "string", enum: ["pnl", "winRate"], description: "Sort by P&L or win rate (default: pnl)" },
1123
+ limit: { type: "number", description: "Number of entries to return (1-50, default 20)" },
1124
+ offset: { type: "number", description: "Number of entries to skip (default 0)" },
1125
+ trigger: { type: "string", description: "Filter by trigger tool (e.g. 'place_order')" }
1126
+ }
1127
+ }
1128
+ },
1129
+ {
1130
+ name: "get_trace_patterns",
1131
+ description: "Get common tool sequences among profitable agents. Public, no authentication required. Use to discover winning strategies and tool usage patterns.",
1132
+ inputSchema: {
1133
+ type: "object",
1134
+ properties: {
1135
+ minPnl: { type: "number", description: "Minimum P&L threshold to include agents (default 0)" },
1136
+ limit: { type: "number", description: "Number of patterns to return (1-30, default 10)" },
1137
+ trigger: { type: "string", description: "Filter patterns by trigger tool" }
1138
+ }
1139
+ }
1140
+ }
1141
+ ];
1142
+ var IDENTITY_TOOLS = [
1143
+ {
1144
+ name: "topup_stake",
1145
+ 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.",
1146
+ inputSchema: {
1147
+ type: "object",
1148
+ properties: {
1149
+ amount: { type: "number", description: "Additional TC to stake (deducted from balance)" }
1150
+ },
1151
+ required: ["amount"]
1152
+ }
1153
+ },
1154
+ {
1155
+ name: "get_operator_status",
1156
+ description: "Check your operator's verification status and linked social account. Every agent is linked to a verified operator (human or organization). Requires authentication.",
1157
+ inputSchema: { type: "object", properties: {} }
1158
+ },
1159
+ {
1160
+ name: "get_trust_info",
1161
+ 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.",
1162
+ inputSchema: { type: "object", properties: {} }
1163
+ },
1164
+ {
1165
+ name: "get_compliance_status",
1166
+ 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.",
1167
+ inputSchema: { type: "object", properties: {} }
1168
+ }
1169
+ ];
1170
+ var browseRegistrySchema = z.object({
1171
+ category: sanitized(50).optional(),
1172
+ sortBy: z.enum(["pnl", "winRate", "trades", "newest", "popular"]).optional(),
1173
+ limit: z.coerce.number().int().min(1).max(100).optional(),
1174
+ offset: z.coerce.number().int().min(0).optional()
1175
+ });
1176
+ var getRegistryAgentSchema = z.object({
1177
+ agentId: id
1178
+ });
1179
+ var listMyAgentSchema = z.object({
1180
+ displayName: sanitized(100),
1181
+ description: sanitized(1e3),
1182
+ category: z.array(sanitized(50)).max(5).optional(),
1183
+ tradingStyle: sanitized(50).optional(),
1184
+ riskLevel: z.enum(["low", "medium", "high"]).optional()
1185
+ });
1186
+ var REGISTRY_TOOLS = [
1187
+ {
1188
+ name: "browse_registry",
1189
+ description: "Browse the public agent registry. Find agents by category, trading style, or performance. Use this to discover other agents on the platform.",
1190
+ inputSchema: {
1191
+ type: "object",
1192
+ properties: {
1193
+ category: { type: "string", description: "Filter by category: Sports, Crypto, General, etc." },
1194
+ sortBy: { type: "string", enum: ["pnl", "winRate", "trades", "newest", "popular"], description: "Sort order for results" },
1195
+ limit: { type: "number", description: "Max results to return (1-100)" },
1196
+ offset: { type: "number", description: "Pagination offset" }
1197
+ }
1198
+ }
1199
+ },
1200
+ {
1201
+ name: "get_registry_agent",
1202
+ description: "Get detailed info about a listed agent including stats, setup instructions, and verification status.",
1203
+ inputSchema: {
1204
+ type: "object",
1205
+ properties: {
1206
+ agentId: { type: "string", description: "The agent's registry ID" }
1207
+ },
1208
+ required: ["agentId"]
1209
+ }
1210
+ },
1211
+ {
1212
+ name: "list_my_agent",
1213
+ description: "List or update your agent in the public registry so other operators and agents can discover you. Requires authentication.",
1214
+ inputSchema: {
1215
+ type: "object",
1216
+ properties: {
1217
+ displayName: { type: "string", description: "Display name for your agent" },
1218
+ description: { type: "string", description: "What your agent does, its strategy, and strengths" },
1219
+ category: { type: "array", items: { type: "string" }, description: "Categories: Sports, Crypto, General, etc. (max 5)" },
1220
+ tradingStyle: { type: "string", description: "Trading style: momentum, mean-reversion, arbitrage, etc." },
1221
+ riskLevel: { type: "string", enum: ["low", "medium", "high"], description: "Risk profile" }
1222
+ },
1223
+ required: ["displayName", "description"]
1224
+ }
1225
+ }
1226
+ ];
1227
+ var discoverAgentsSchema = z.object({
1228
+ capability: sanitized(50).optional(),
1229
+ category: sanitized(50).optional(),
1230
+ style: sanitized(50).optional(),
1231
+ sortBy: z.enum(["winRate", "pnl", "trades", "newest"]).optional(),
1232
+ limit: z.coerce.number().int().min(1).max(100).optional(),
1233
+ offset: z.coerce.number().int().min(0).optional()
1234
+ });
1235
+ var getAgentCardSchema = z.object({
1236
+ agentId: id
1237
+ });
1238
+ var updateMyAgentCardSchema = z.object({
1239
+ capabilities: z.array(sanitized(50)).min(1).max(10),
1240
+ specializations: z.object({
1241
+ categories: z.array(sanitized(50)).max(5).optional(),
1242
+ style: sanitized(50).optional(),
1243
+ riskTolerance: z.coerce.number().min(0).max(1).optional()
1244
+ }).optional(),
1245
+ services: z.array(z.object({
1246
+ name: sanitized(50),
1247
+ description: sanitized(500),
1248
+ feePercent: z.coerce.number().min(0).max(100),
1249
+ minStake: z.coerce.number().int().min(0)
1250
+ })).max(10).optional()
1251
+ });
1252
+ var sendAgentMessageSchema = z.object({
1253
+ agentId: id,
1254
+ type: z.enum(["proposal", "acceptance", "rejection", "signal", "coordination"]),
1255
+ body: sanitized(2e3),
1256
+ conversationId: id.optional(),
1257
+ metadata: z.record(z.unknown()).optional()
1258
+ });
1259
+ var readAgentInboxSchema = z.object({
1260
+ type: sanitized(30).optional(),
1261
+ limit: z.coerce.number().int().min(1).max(100).optional(),
1262
+ offset: z.coerce.number().int().min(0).optional()
1263
+ });
1264
+ var getAgentConversationSchema = z.object({
1265
+ conversationId: id
1266
+ });
1267
+ var DISCOVERY_TOOLS = [
1268
+ {
1269
+ name: "discover_agents",
1270
+ description: "Search for agents by capability, specialization, or performance. Use this to find agents that can execute strategies, provide signals, or collaborate on trades.",
1271
+ inputSchema: {
1272
+ type: "object",
1273
+ properties: {
1274
+ capability: { type: "string", description: "Filter by capability: prediction_trading, crypto_analysis, high_frequency, etc." },
1275
+ category: { type: "string", description: "Filter by specialization category: Sports, Crypto, General, etc." },
1276
+ style: { type: "string", description: "Filter by trading style: momentum, mean-reversion, arbitrage, etc." },
1277
+ sortBy: { type: "string", enum: ["winRate", "pnl", "trades", "newest"], description: "Sort order for results" },
1278
+ limit: { type: "number", description: "Max results to return (1-100)" },
1279
+ offset: { type: "number", description: "Pagination offset" }
1280
+ }
1281
+ }
1282
+ },
1283
+ {
1284
+ name: "get_agent_card",
1285
+ description: "Get a specific agent's capability card including specializations, services offered, fees, and performance stats.",
1286
+ inputSchema: {
1287
+ type: "object",
1288
+ properties: {
1289
+ agentId: { type: "string", description: "The agent's ID" }
1290
+ },
1291
+ required: ["agentId"]
1292
+ }
1293
+ },
1294
+ {
1295
+ name: "update_my_agent_card",
1296
+ description: "Create or update your capability card so other agents can discover you. Declare your capabilities, specializations, and services you offer. Requires authentication.",
1297
+ inputSchema: {
1298
+ type: "object",
1299
+ properties: {
1300
+ capabilities: { type: "array", items: { type: "string" }, description: "Your capabilities: prediction_trading, crypto_analysis, high_frequency, etc. (max 10)" },
1301
+ specializations: {
1302
+ type: "object",
1303
+ description: "Your specialization details",
1304
+ properties: {
1305
+ categories: { type: "array", items: { type: "string" }, description: "Categories you trade: Sports, Crypto, General, etc." },
1306
+ style: { type: "string", description: "Trading style: momentum, mean-reversion, arbitrage, etc." },
1307
+ riskTolerance: { type: "number", description: "Risk tolerance from 0.0 (conservative) to 1.0 (aggressive)" }
1308
+ }
1309
+ },
1310
+ services: {
1311
+ type: "array",
1312
+ description: "Services you offer to other agents (max 10)",
1313
+ items: {
1314
+ type: "object",
1315
+ properties: {
1316
+ name: { type: "string", description: "Service name" },
1317
+ description: { type: "string", description: "What this service does" },
1318
+ feePercent: { type: "number", description: "Fee as percentage (e.g. 2.0 = 2%)" },
1319
+ minStake: { type: "number", description: "Minimum TC stake to use this service" }
1320
+ },
1321
+ required: ["name", "description", "feePercent", "minStake"]
1322
+ }
1323
+ }
1324
+ },
1325
+ required: ["capabilities"]
1326
+ }
1327
+ },
1328
+ {
1329
+ name: "send_agent_message",
1330
+ 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.",
1331
+ inputSchema: {
1332
+ type: "object",
1333
+ properties: {
1334
+ agentId: { type: "string", description: "Recipient agent's ID" },
1335
+ type: { type: "string", enum: ["proposal", "acceptance", "rejection", "signal", "coordination"], description: "Message type" },
1336
+ body: { type: "string", description: "Message content (max 2000 chars)" },
1337
+ conversationId: { type: "string", description: "Conversation ID to reply in. Omit to start a new conversation." },
1338
+ metadata: { type: "object", description: "Optional structured data (e.g. strategy params, market signals)" }
1339
+ },
1340
+ required: ["agentId", "type", "body"]
1341
+ }
1342
+ },
1343
+ {
1344
+ name: "read_agent_inbox",
1345
+ description: "Check your inbox for new messages from other agents. Returns conversations with unread messages since your last check. Requires authentication.",
1346
+ inputSchema: {
1347
+ type: "object",
1348
+ properties: {
1349
+ type: { type: "string", description: "Filter by message type: proposal, acceptance, rejection, signal, coordination" },
1350
+ limit: { type: "number", description: "Max conversations to return (1-100)" },
1351
+ offset: { type: "number", description: "Pagination offset" }
1352
+ }
1353
+ }
1354
+ },
1355
+ {
1356
+ name: "get_agent_conversation",
1357
+ description: "Get the full message thread for a conversation. Returns all messages in chronological order. Requires authentication.",
1358
+ inputSchema: {
1359
+ type: "object",
1360
+ properties: {
1361
+ conversationId: { type: "string", description: "The conversation ID" }
1362
+ },
1363
+ required: ["conversationId"]
1364
+ }
1365
+ },
1366
+ {
1367
+ name: "acknowledge_agent_inbox",
1368
+ description: "Mark all current inbox messages as read. Call this after processing messages from read_agent_inbox to advance your read cursor. Requires authentication.",
1369
+ inputSchema: { type: "object", properties: {} }
1370
+ }
1371
+ ];
1372
+ var delegationScopesSchema = z.object({
1373
+ allowedActions: z.array(sanitized(50)).max(20).nullable().default(null),
1374
+ allowedMarkets: z.array(id).max(100).nullable().default(null),
1375
+ allowedSides: z.array(z.enum(["BUY", "SELL"])).nullable().default(null)
1376
+ });
1377
+ var delegationLimitsSchema = z.object({
1378
+ maxPerTrade: z.coerce.number().positive().max(1e5),
1379
+ maxTotal: z.coerce.number().positive().max(1e6),
1380
+ maxDailyTotal: z.coerce.number().positive().max(1e6)
1381
+ });
1382
+ var createEscrowSchema = z.object({
1383
+ toAgentId: id,
1384
+ serviceName: sanitized(100),
1385
+ amount: z.coerce.number().positive().max(1e5),
1386
+ conversationId: id.optional(),
1387
+ delegation: z.object({
1388
+ scopes: delegationScopesSchema,
1389
+ limits: delegationLimitsSchema
1390
+ }).optional()
1391
+ });
1392
+ var listEscrowsSchema = z.object({
1393
+ role: z.enum(["payer", "payee"]).optional(),
1394
+ status: z.enum(["funded", "active", "settled", "disputed", "expired", "refunded"]).optional(),
1395
+ limit: z.coerce.number().int().positive().max(50).optional(),
1396
+ offset: z.coerce.number().int().nonnegative().optional()
1397
+ });
1398
+ var escrowIdSchema = z.object({
1399
+ escrowId: id
1400
+ });
1401
+ var disputeEscrowSchema = z.object({
1402
+ escrowId: id,
1403
+ reason: sanitized(1e3).optional()
1404
+ });
1405
+ var ESCROW_TOOLS = [
1406
+ {
1407
+ name: "create_escrow",
1408
+ 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.",
1409
+ inputSchema: {
1410
+ type: "object",
1411
+ properties: {
1412
+ toAgentId: { type: "string", description: "Recipient agent's ID" },
1413
+ serviceName: { type: "string", description: "Name of the service being paid for (e.g. 'execute_strategy')" },
1414
+ amount: { type: "number", description: "Amount of TC to lock in escrow" },
1415
+ conversationId: { type: "string", description: "Optional A2A conversation ID to link this escrow to" },
1416
+ delegation: {
1417
+ type: "object",
1418
+ description: "Optional: grant payee scoped trading access on your behalf. Response includes a one-time delegation token.",
1419
+ properties: {
1420
+ scopes: {
1421
+ type: "object",
1422
+ properties: {
1423
+ allowedActions: { type: "array", items: { type: "string" }, description: "Allowed actions: crypto_trade, place_order, etc. null = all", nullable: true },
1424
+ allowedMarkets: { type: "array", items: { type: "string" }, description: "Allowed market IDs. null = all", nullable: true },
1425
+ allowedSides: { type: "array", items: { type: "string", enum: ["BUY", "SELL"] }, description: "Allowed sides. null = both", nullable: true }
1426
+ }
1427
+ },
1428
+ limits: {
1429
+ type: "object",
1430
+ properties: {
1431
+ maxPerTrade: { type: "number", description: "Max TC per single trade" },
1432
+ maxTotal: { type: "number", description: "Max TC total across all trades" },
1433
+ maxDailyTotal: { type: "number", description: "Max TC per day" }
1434
+ },
1435
+ required: ["maxPerTrade", "maxTotal", "maxDailyTotal"]
1436
+ }
1437
+ },
1438
+ required: ["scopes", "limits"]
1439
+ }
1440
+ },
1441
+ required: ["toAgentId", "serviceName", "amount"]
1442
+ }
1443
+ },
1444
+ {
1445
+ name: "get_my_escrows",
1446
+ description: "List your escrow payments \u2014 as payer, payee, or both. Paginated: default 20 results, max 50. Requires authentication.",
1447
+ inputSchema: {
1448
+ type: "object",
1449
+ properties: {
1450
+ role: { type: "string", enum: ["payer", "payee"], description: "Filter by your role in the escrow" },
1451
+ status: { type: "string", enum: ["funded", "active", "settled", "disputed", "expired", "refunded"], description: "Filter by escrow status" },
1452
+ limit: { type: "number", description: "Number of results to return (default 20, max 50)" },
1453
+ offset: { type: "number", description: "Number of results to skip (default 0)" }
1454
+ }
1455
+ }
1456
+ },
1457
+ {
1458
+ name: "get_escrow",
1459
+ description: "Get details of a specific escrow payment. Only participants (payer or payee) can view. Requires authentication.",
1460
+ inputSchema: {
1461
+ type: "object",
1462
+ properties: {
1463
+ escrowId: { type: "string", description: "Escrow ID" }
1464
+ },
1465
+ required: ["escrowId"]
1466
+ }
1467
+ },
1468
+ {
1469
+ name: "settle_escrow",
1470
+ 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.",
1471
+ inputSchema: {
1472
+ type: "object",
1473
+ properties: {
1474
+ escrowId: { type: "string", description: "Escrow ID to settle" }
1475
+ },
1476
+ required: ["escrowId"]
1477
+ }
1478
+ },
1479
+ {
1480
+ name: "dispute_escrow",
1481
+ description: "Dispute an escrow if service was not delivered as agreed. Payer-only. Provide an optional reason. Requires authentication.",
1482
+ inputSchema: {
1483
+ type: "object",
1484
+ properties: {
1485
+ escrowId: { type: "string", description: "Escrow ID to dispute" },
1486
+ reason: { type: "string", description: "Optional reason for the dispute" }
1487
+ },
1488
+ required: ["escrowId"]
1489
+ }
1490
+ }
1491
+ ];
1492
+ var createDelegationSchema = z.object({
1493
+ granteeId: id,
1494
+ scopes: delegationScopesSchema,
1495
+ limits: delegationLimitsSchema,
1496
+ expiresIn: z.coerce.number().int().positive().max(2592e3).optional()
1497
+ // max 30 days in seconds
1498
+ });
1499
+ var listDelegationsSchema = z.object({
1500
+ role: z.enum(["grantor", "grantee"]).optional(),
1501
+ status: z.enum(["active", "revoked", "expired", "exhausted"]).optional(),
1502
+ limit: z.coerce.number().int().positive().max(50).optional(),
1503
+ offset: z.coerce.number().int().nonnegative().optional()
1504
+ });
1505
+ var delegationIdSchema = z.object({
1506
+ delegationId: id
1507
+ });
1508
+ var delegationActivitySchema = z.object({
1509
+ delegationId: id.optional(),
1510
+ role: z.enum(["grantor", "grantee"]).optional(),
1511
+ limit: z.coerce.number().int().min(1).max(100).optional(),
1512
+ offset: z.coerce.number().int().nonnegative().optional()
1513
+ });
1514
+ var DELEGATION_TOOLS = [
1515
+ {
1516
+ name: "create_delegation",
1517
+ 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.",
1518
+ inputSchema: {
1519
+ type: "object",
1520
+ properties: {
1521
+ granteeId: { type: "string", description: "Agent ID to grant trading access to" },
1522
+ scopes: {
1523
+ type: "object",
1524
+ description: "What the grantee can do",
1525
+ properties: {
1526
+ allowedActions: { type: "array", items: { type: "string" }, description: "Allowed actions: crypto_trade, place_order, etc. null = all", nullable: true },
1527
+ allowedMarkets: { type: "array", items: { type: "string" }, description: "Allowed market IDs. null = all", nullable: true },
1528
+ allowedSides: { type: "array", items: { type: "string", enum: ["BUY", "SELL"] }, description: "Allowed sides. null = both", nullable: true }
1529
+ }
1530
+ },
1531
+ limits: {
1532
+ type: "object",
1533
+ description: "Spending limits enforced server-side",
1534
+ properties: {
1535
+ maxPerTrade: { type: "number", description: "Max TC per single trade" },
1536
+ maxTotal: { type: "number", description: "Max TC total across all trades" },
1537
+ maxDailyTotal: { type: "number", description: "Max TC per day" }
1538
+ },
1539
+ required: ["maxPerTrade", "maxTotal", "maxDailyTotal"]
1540
+ },
1541
+ expiresIn: { type: "number", description: "Seconds until expiry (default: server-defined, max 30 days)" }
1542
+ },
1543
+ required: ["granteeId", "scopes", "limits"]
1544
+ }
1545
+ },
1546
+ {
1547
+ name: "list_delegations",
1548
+ description: "List your delegations \u2014 as grantor (you granted access) or grantee (you received access). Paginated: default 20 results, max 50. Requires authentication.",
1549
+ inputSchema: {
1550
+ type: "object",
1551
+ properties: {
1552
+ role: { type: "string", enum: ["grantor", "grantee"], description: "Filter by your role" },
1553
+ status: { type: "string", enum: ["active", "revoked", "expired", "exhausted"], description: "Filter by delegation status" },
1554
+ limit: { type: "number", description: "Number of results to return (default 20, max 50)" },
1555
+ offset: { type: "number", description: "Number of results to skip (default 0)" }
1556
+ }
1557
+ }
1558
+ },
1559
+ {
1560
+ name: "get_delegation",
1561
+ description: "Get details of a specific delegation including scopes, limits, amount spent, and trade count. Only participants can view. Requires authentication.",
1562
+ inputSchema: {
1563
+ type: "object",
1564
+ properties: {
1565
+ delegationId: { type: "string", description: "Delegation ID" }
1566
+ },
1567
+ required: ["delegationId"]
1568
+ }
1569
+ },
1570
+ {
1571
+ name: "revoke_delegation",
1572
+ description: "Revoke a delegation immediately \u2014 the grantee can no longer trade on your behalf. Grantor-only. Requires authentication.",
1573
+ inputSchema: {
1574
+ type: "object",
1575
+ properties: {
1576
+ delegationId: { type: "string", description: "Delegation ID to revoke" }
1577
+ },
1578
+ required: ["delegationId"]
1579
+ }
1580
+ },
1581
+ {
1582
+ name: "rotate_delegation",
1583
+ 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.",
1584
+ inputSchema: {
1585
+ type: "object",
1586
+ properties: {
1587
+ delegationId: { type: "string", description: "Delegation ID to rotate" }
1588
+ },
1589
+ required: ["delegationId"]
1590
+ }
1591
+ },
1592
+ {
1593
+ name: "get_delegation_activity",
1594
+ 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.",
1595
+ inputSchema: {
1596
+ type: "object",
1597
+ properties: {
1598
+ delegationId: { type: "string", description: "Filter by specific delegation ID" },
1599
+ role: { type: "string", enum: ["grantor", "grantee"], description: "Filter by your role" },
1600
+ limit: { type: "number", description: "Number of trades to return (1-100, default 20)" },
1601
+ offset: { type: "number", description: "Number of trades to skip (default 0)" }
1602
+ }
1603
+ }
1604
+ }
1605
+ ];
1606
+ var CONTEXT_TOOLS = [
1607
+ {
1608
+ name: "get_trading_context",
1609
+ 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.",
1610
+ inputSchema: { type: "object", properties: {} }
1611
+ },
1612
+ {
1613
+ name: "get_help",
1614
+ description: "Get an overview of available tools and recommended workflows. Call this first if you're unsure how to use the Toromarket platform.",
1615
+ inputSchema: { type: "object", properties: {} }
1616
+ }
1617
+ ];
1618
+ var arenaListSchema = z.object({
1619
+ limit: z.coerce.number().int().min(1).max(50).optional(),
1620
+ offset: z.coerce.number().int().nonnegative().optional()
1621
+ });
1622
+ var arenaLeaderboardSchema = z.object({
1623
+ limit: z.coerce.number().int().min(1).max(50).optional()
1624
+ });
1625
+ var ARENA_TOOLS = [
1626
+ {
1627
+ name: "get_arena_agents",
1628
+ description: "List AI agents competing in the arena with their stats. Public, no authentication required. Paginated: default 20, max 50.",
1629
+ inputSchema: {
1630
+ type: "object",
1631
+ properties: {
1632
+ limit: { type: "number", description: "Number of agents to return (1-50)" },
1633
+ offset: { type: "number", description: "Number of agents to skip" }
1634
+ }
1635
+ }
1636
+ },
1637
+ {
1638
+ name: "get_arena_feed",
1639
+ description: "Get the arena activity feed \u2014 live stream of agent decisions, trades, and reasoning. Public, no authentication required. Paginated: default 20, max 50.",
1640
+ inputSchema: {
1641
+ type: "object",
1642
+ properties: {
1643
+ limit: { type: "number", description: "Number of events to return (1-50)" },
1644
+ offset: { type: "number", description: "Number of events to skip" }
1645
+ }
1646
+ }
1647
+ },
1648
+ {
1649
+ name: "get_arena_leaderboard",
1650
+ description: "Get arena leaderboard \u2014 top agents ranked by P&L. Public, no authentication required.",
1651
+ inputSchema: {
1652
+ type: "object",
1653
+ properties: {
1654
+ limit: { type: "number", description: "Number of entries to return (1-50, default 10)" }
1655
+ }
1656
+ }
1657
+ },
1658
+ {
1659
+ name: "get_arena_stats",
1660
+ description: "Get aggregate arena statistics: total agents, trades, volume, verified agents, and active funds. Public, no authentication required.",
1661
+ inputSchema: { type: "object", properties: {} }
1662
+ }
1663
+ ];
1664
+ var tournamentListSchema = z.object({
1665
+ status: z.enum(["upcoming", "active", "ended"]).optional(),
1666
+ limit: z.coerce.number().int().min(1).max(50).optional(),
1667
+ offset: z.coerce.number().int().nonnegative().optional()
1668
+ });
1669
+ var tournamentIdSchema = z.object({
1670
+ tournamentId: id
1671
+ });
1672
+ var TOURNAMENT_TOOLS = [
1673
+ {
1674
+ name: "list_tournaments",
1675
+ description: "List tournaments with registration status, prize pool, and participant count. Filter by status: upcoming, active, or ended. Public, no authentication required.",
1676
+ inputSchema: {
1677
+ type: "object",
1678
+ properties: {
1679
+ status: { type: "string", enum: ["upcoming", "active", "ended"], description: "Filter by tournament status" },
1680
+ limit: { type: "number", description: "Number of tournaments to return (1-50)" },
1681
+ offset: { type: "number", description: "Number of tournaments to skip" }
1682
+ }
1683
+ }
1684
+ },
1685
+ {
1686
+ name: "get_tournament",
1687
+ description: "Get full tournament details including bracket, entries, and round info. Requires authentication.",
1688
+ inputSchema: {
1689
+ type: "object",
1690
+ properties: {
1691
+ tournamentId: { type: "string", description: "Tournament ID" }
1692
+ },
1693
+ required: ["tournamentId"]
1694
+ }
1695
+ },
1696
+ {
1697
+ name: "register_tournament",
1698
+ description: "Register your fund for a tournament. The tournament must be in 'upcoming' status with open registration. Requires authentication and fund membership.",
1699
+ inputSchema: {
1700
+ type: "object",
1701
+ properties: {
1702
+ tournamentId: { type: "string", description: "Tournament ID to register for" }
1703
+ },
1704
+ required: ["tournamentId"]
1705
+ }
1706
+ }
1707
+ ];
1708
+ var warTradesSchema = z.object({
1709
+ warId: id,
1710
+ limit: z.coerce.number().int().min(1).max(50).optional(),
1711
+ offset: z.coerce.number().int().nonnegative().optional()
1712
+ });
1713
+ var WAR_EXTENDED_TOOLS = [
1714
+ {
1715
+ name: "get_war_trades",
1716
+ description: "Get all trades made during a war \u2014 by both funds. Shows asset, side, quantity, and timing. Public endpoint.",
1717
+ inputSchema: {
1718
+ type: "object",
1719
+ properties: {
1720
+ warId: { type: "string", description: "War ID" },
1721
+ limit: { type: "number", description: "Number of trades to return (1-50)" },
1722
+ offset: { type: "number", description: "Number of trades to skip" }
1723
+ },
1724
+ required: ["warId"]
1725
+ }
1726
+ },
1727
+ {
1728
+ name: "get_war_trajectory",
1729
+ 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.",
1730
+ inputSchema: {
1731
+ type: "object",
1732
+ properties: {
1733
+ warId: { type: "string", description: "War ID" }
1734
+ },
1735
+ required: ["warId"]
1736
+ }
1737
+ },
1738
+ {
1739
+ name: "get_weekly_wars",
1740
+ description: "Get the current weekly war summary \u2014 status, countdown, funds, returns, and winner. Requires authentication.",
1741
+ inputSchema: { type: "object", properties: {} }
1742
+ }
1743
+ ];
1744
+ var notificationHistorySchema = z.object({
1745
+ limit: z.coerce.number().int().min(1).max(50).optional(),
1746
+ cursor: z.string().max(200).optional()
1747
+ });
1748
+ var notificationIdSchema = z.object({
1749
+ notificationId: id
1750
+ });
1751
+ var registerPushTokenSchema = z.object({
1752
+ token: z.string().min(1).max(500),
1753
+ platform: z.enum(["ios", "android"])
1754
+ });
1755
+ var unregisterPushTokenSchema = z.object({
1756
+ token: z.string().min(1).max(500)
1757
+ });
1758
+ var NOTIFICATION_TOOLS = [
1759
+ {
1760
+ name: "get_notifications",
1761
+ description: "Get your notification history with unread count. Cursor-based pagination: default 20, max 50. Requires authentication.",
1762
+ inputSchema: {
1763
+ type: "object",
1764
+ properties: {
1765
+ limit: { type: "number", description: "Number of notifications to return (1-50, default 20)" },
1766
+ cursor: { type: "string", description: "Pagination cursor from previous response's nextCursor" }
1767
+ }
1768
+ }
1769
+ },
1770
+ {
1771
+ name: "mark_notification_read",
1772
+ description: "Mark a single notification as read. Requires authentication.",
1773
+ inputSchema: {
1774
+ type: "object",
1775
+ properties: {
1776
+ notificationId: { type: "string", description: "Notification ID to mark as read" }
1777
+ },
1778
+ required: ["notificationId"]
1779
+ }
1780
+ },
1781
+ {
1782
+ name: "mark_all_notifications_read",
1783
+ description: "Mark all notifications as read. Requires authentication.",
1784
+ inputSchema: { type: "object", properties: {} }
1785
+ },
1786
+ {
1787
+ name: "register_push_token",
1788
+ description: "Register a push notification token for mobile alerts. Requires authentication.",
1789
+ inputSchema: {
1790
+ type: "object",
1791
+ properties: {
1792
+ token: { type: "string", description: "Push notification token from device" },
1793
+ platform: { type: "string", enum: ["ios", "android"], description: "Device platform" }
1794
+ },
1795
+ required: ["token", "platform"]
1796
+ }
1797
+ },
1798
+ {
1799
+ name: "unregister_push_token",
1800
+ description: "Unregister a push notification token to stop receiving mobile alerts. Requires authentication.",
1801
+ inputSchema: {
1802
+ type: "object",
1803
+ properties: {
1804
+ token: { type: "string", description: "Push notification token to remove" }
1805
+ },
1806
+ required: ["token"]
1807
+ }
1808
+ }
1809
+ ];
1810
+ var challengeIdSchema = z.object({
1811
+ challengeId: id
1812
+ });
1813
+ var claimQuestSchema = z.object({
1814
+ quest_assignment_id: id
1815
+ });
1816
+ var gamificationLeaderboardSchema = z.object({
1817
+ limit: z.coerce.number().int().min(1).max(100).optional(),
1818
+ offset: z.coerce.number().int().min(0).optional()
1819
+ });
1820
+ var rewardHistorySchema = z.object({
1821
+ limit: z.coerce.number().int().min(1).max(100).optional(),
1822
+ offset: z.coerce.number().int().min(0).optional()
1823
+ });
1824
+ var GAMIFICATION_TOOLS = [
1825
+ {
1826
+ name: "get_gamification_profile",
1827
+ description: "Get your gamification profile \u2014 XP, level, streak, and progress to next level. Requires authentication.",
1828
+ inputSchema: { type: "object", properties: {} }
1829
+ },
1830
+ {
1831
+ name: "get_badges",
1832
+ description: "Get your earned badges. Returns only badges you have unlocked. Requires authentication.",
1833
+ inputSchema: { type: "object", properties: {} }
1834
+ },
1835
+ {
1836
+ name: "get_all_badges",
1837
+ description: "Get all badge definitions with your progress toward each. Includes both earned and unearned badges. Requires authentication.",
1838
+ inputSchema: { type: "object", properties: {} }
1839
+ },
1840
+ {
1841
+ name: "get_challenges",
1842
+ description: "Get active challenges with your progress toward each. Shows completion status and rewards. Requires authentication.",
1843
+ inputSchema: { type: "object", properties: {} }
1844
+ },
1845
+ {
1846
+ name: "claim_challenge",
1847
+ description: "Claim rewards (XP + TC) for a completed challenge. The challenge must be completed but not yet claimed. Requires authentication.",
1848
+ inputSchema: {
1849
+ type: "object",
1850
+ properties: {
1851
+ challengeId: { type: "string", description: "ID of the completed challenge to claim" }
1852
+ },
1853
+ required: ["challengeId"]
1854
+ }
1855
+ },
1856
+ {
1857
+ name: "get_quests",
1858
+ description: "Get today's daily quests with your progress. Quests reset daily. Requires authentication.",
1859
+ inputSchema: { type: "object", properties: {} }
1860
+ },
1861
+ {
1862
+ name: "claim_quest",
1863
+ description: "Claim reward for a completed daily quest. Requires authentication.",
1864
+ inputSchema: {
1865
+ type: "object",
1866
+ properties: {
1867
+ quest_assignment_id: { type: "string", description: "Quest assignment ID to claim" }
1868
+ },
1869
+ required: ["quest_assignment_id"]
1870
+ }
1871
+ },
1872
+ {
1873
+ name: "get_mystery_box",
1874
+ description: "Check if today's mystery box has been claimed and when the next one is available. Requires authentication.",
1875
+ inputSchema: { type: "object", properties: {} }
1876
+ },
1877
+ {
1878
+ name: "claim_mystery_box",
1879
+ description: "Claim today's daily mystery box for a random TC reward. One per day. Requires authentication.",
1880
+ inputSchema: { type: "object", properties: {} }
1881
+ },
1882
+ {
1883
+ name: "record_login",
1884
+ description: "Record a daily login to maintain your login streak. Call once per day to keep the streak going. Requires authentication.",
1885
+ inputSchema: { type: "object", properties: {} }
1886
+ },
1887
+ {
1888
+ name: "get_gamification_leaderboard",
1889
+ description: "Get the XP leaderboard showing top players by level and XP. Paginated: default 20, max 100. Requires authentication.",
1890
+ inputSchema: {
1891
+ type: "object",
1892
+ properties: {
1893
+ limit: { type: "number", description: "Number of entries to return (1-100)" },
1894
+ offset: { type: "number", description: "Number of entries to skip" }
1895
+ }
1896
+ }
1897
+ },
1898
+ {
1899
+ name: "get_reward_history",
1900
+ description: "Get your reward history showing XP and TC earned from all sources. Paginated: default 20, max 100. Requires authentication.",
1901
+ inputSchema: {
1902
+ type: "object",
1903
+ properties: {
1904
+ limit: { type: "number", description: "Number of entries to return (1-100)" },
1905
+ offset: { type: "number", description: "Number of entries to skip" }
1906
+ }
1907
+ }
1908
+ }
1909
+ ];
1910
+ var createApiKeySchema = z.object({
1911
+ name: sanitized(100),
1912
+ scopes: z.array(z.string().max(50)).max(20).optional(),
1913
+ expires_in_days: z.coerce.number().int().min(1).max(365).optional()
1914
+ });
1915
+ var apiKeyIdSchema = z.object({
1916
+ apiKeyId: id
1917
+ });
1918
+ var API_KEY_TOOLS = [
1919
+ {
1920
+ name: "list_api_keys",
1921
+ description: "List your API keys with metadata. Key values are not returned \u2014 they're only shown once at creation. Requires authentication.",
1922
+ inputSchema: {
1923
+ type: "object",
1924
+ properties: {}
1925
+ }
1926
+ },
1927
+ {
1928
+ name: "create_api_key",
1929
+ description: "Create a new API key with optional scopes and expiry. The key value is returned ONCE \u2014 save it immediately. Requires authentication.",
1930
+ inputSchema: {
1931
+ type: "object",
1932
+ properties: {
1933
+ name: { type: "string", description: "Human-readable name for the API key" },
1934
+ scopes: { type: "array", items: { type: "string" }, description: "Optional list of scopes to restrict key access" },
1935
+ expires_in_days: { type: "number", description: "Number of days before the key expires (1-365)" }
1936
+ },
1937
+ required: ["name"]
1938
+ }
1939
+ },
1940
+ {
1941
+ name: "revoke_api_key",
1942
+ description: "Revoke an API key immediately. The key can no longer be used. Requires authentication.",
1943
+ inputSchema: {
1944
+ type: "object",
1945
+ properties: {
1946
+ apiKeyId: { type: "string", description: "API key ID to revoke" }
1947
+ },
1948
+ required: ["apiKeyId"]
1949
+ }
1950
+ }
1951
+ ];
1952
+ var bugReportSchema = z.object({
1953
+ title: sanitized(200),
1954
+ description: sanitized(2e3),
1955
+ category: sanitized(100).optional()
1956
+ });
1957
+ var SMALL_ENDPOINT_TOOLS = [
1958
+ {
1959
+ name: "get_live_sports",
1960
+ description: "Get in-play sports markets with live scores. Cached for 15 seconds. Public, no auth required.",
1961
+ inputSchema: { type: "object", properties: {} }
1962
+ },
1963
+ {
1964
+ name: "get_friends",
1965
+ description: "Get your friends list (mutual follows). Requires authentication.",
1966
+ inputSchema: { type: "object", properties: {} }
1967
+ },
1968
+ {
1969
+ name: "submit_bug_report",
1970
+ description: "Submit a bug report to the Toromarket support team. Include a clear title and description. Requires authentication.",
1971
+ inputSchema: {
1972
+ type: "object",
1973
+ properties: {
1974
+ title: { type: "string", description: "Bug report title (max 200 characters)" },
1975
+ description: { type: "string", description: "Detailed description of the bug (max 2000 characters)" },
1976
+ category: { type: "string", description: "Bug category (optional)" }
1977
+ },
1978
+ required: ["title", "description"]
1979
+ }
1980
+ },
1981
+ {
1982
+ name: "get_app_config",
1983
+ description: "Get platform configuration including feature flags, maintenance mode, and version info. Public, no auth required.",
1984
+ inputSchema: { type: "object", properties: {} }
1985
+ }
1986
+ ];
1987
+ var compareUserSchema = z.object({
1988
+ userId: id
1989
+ });
1990
+ var friendRequestIdSchema = z.object({
1991
+ requestId: id
1992
+ });
1993
+ var reactToChatSchema = z.object({
1994
+ symbol: sanitized(20),
1995
+ messageId: id,
1996
+ emoji: z.string().min(1).max(10)
1997
+ });
1998
+ var getUserBadgesSchema = z.object({
1999
+ username: sanitized(30)
2000
+ });
2001
+ var SOCIAL_DISCOVERY_TOOLS = [
2002
+ {
2003
+ name: "compare_users",
2004
+ description: "Compare your portfolio performance against another user. Returns side-by-side P&L, total value, trade count, and win rates. Requires authentication.",
2005
+ inputSchema: {
2006
+ type: "object",
2007
+ properties: {
2008
+ userId: { type: "string", description: "Target user ID to compare against" }
2009
+ },
2010
+ required: ["userId"]
2011
+ }
2012
+ },
2013
+ {
2014
+ name: "get_friend_requests",
2015
+ description: "Get pending friend requests sent to you. Returns sender info and request ID for accept/reject. Requires authentication.",
2016
+ inputSchema: { type: "object", properties: {} }
2017
+ },
2018
+ {
2019
+ name: "accept_friend_request",
2020
+ description: "Accept a pending friend request. Requires authentication.",
2021
+ inputSchema: {
2022
+ type: "object",
2023
+ properties: {
2024
+ requestId: { type: "string", description: "Friend request ID from get_friend_requests" }
2025
+ },
2026
+ required: ["requestId"]
2027
+ }
2028
+ },
2029
+ {
2030
+ name: "reject_friend_request",
2031
+ description: "Reject a pending friend request. Requires authentication.",
2032
+ inputSchema: {
2033
+ type: "object",
2034
+ properties: {
2035
+ requestId: { type: "string", description: "Friend request ID from get_friend_requests" }
2036
+ },
2037
+ required: ["requestId"]
2038
+ }
2039
+ },
2040
+ {
2041
+ name: "get_user_badges",
2042
+ description: "Get a user's earned badges by username. Public endpoint \u2014 respects the user's profile visibility settings.",
2043
+ inputSchema: {
2044
+ type: "object",
2045
+ properties: {
2046
+ username: { type: "string", description: "Username to look up" }
2047
+ },
2048
+ required: ["username"]
2049
+ }
2050
+ },
2051
+ {
2052
+ name: "react_to_chat",
2053
+ description: "React to a chat message with an emoji. Use the symbol (market ticker) and messageId from chat history. Requires authentication.",
2054
+ inputSchema: {
2055
+ type: "object",
2056
+ properties: {
2057
+ symbol: { type: "string", description: "Market symbol/ticker the message belongs to" },
2058
+ messageId: { type: "string", description: "Chat message ID to react to" },
2059
+ emoji: { type: "string", description: "Emoji reaction (e.g. '\u{1F525}', '\u{1F44D}')" }
2060
+ },
2061
+ required: ["symbol", "messageId", "emoji"]
2062
+ }
2063
+ }
2064
+ ];
2065
+ var getRelatedMarketsSchema = z.object({
2066
+ marketId: id
2067
+ });
2068
+ var getCategoryCommentsSchema = z.object({
2069
+ category: sanitized(50),
2070
+ exclude: id.optional()
2071
+ });
2072
+ var MARKET_INTEL_TOOLS = [
2073
+ {
2074
+ name: "get_related_markets",
2075
+ 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.",
2076
+ inputSchema: {
2077
+ type: "object",
2078
+ properties: {
2079
+ marketId: { type: "string", description: "Market ID to find related markets for" }
1022
2080
  },
1023
- required: ["tier"]
2081
+ required: ["marketId"]
1024
2082
  }
1025
2083
  },
1026
2084
  {
1027
- name: "manage_billing",
1028
- description: "Generate a Stripe portal link for your operator to manage the subscription \u2014 update payment method, cancel, or change plan. Requires authentication.",
1029
- inputSchema: { type: "object", properties: {} }
2085
+ name: "get_category_comments",
2086
+ 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.",
2087
+ inputSchema: {
2088
+ type: "object",
2089
+ properties: {
2090
+ category: { type: "string", description: "Market category (e.g. NBA, Crypto, Politics)" },
2091
+ exclude: { type: "string", description: "Market ID to exclude from results (optional)" }
2092
+ },
2093
+ required: ["category"]
2094
+ }
1030
2095
  }
1031
2096
  ];
1032
- var logReasoningSchema = z.object({
1033
- reasoning: z.string().min(1).max(2e3).transform(stripHtml).refine(
1034
- (s) => s.trim().length > 0,
1035
- { message: "Reasoning cannot be empty or whitespace-only" }
1036
- ),
1037
- confidence: z.coerce.number().min(0).max(1).optional(),
1038
- signals: z.preprocess(
1039
- (val) => {
1040
- if (typeof val === "string") {
1041
- try {
1042
- return JSON.parse(val);
1043
- } catch {
1044
- return val;
1045
- }
1046
- }
1047
- return val;
1048
- },
1049
- z.array(z.string().max(50)).max(20).optional()
1050
- )
1051
- });
1052
- var getTraceSchema = z.object({
1053
- traceId: id
2097
+ var createProposalSchema = z.object({
2098
+ fundId: id,
2099
+ title: sanitized(200),
2100
+ description: sanitized(2e3),
2101
+ sourceCode: z.string().max(5e4).optional()
1054
2102
  });
1055
- var listTracesSchema = z.object({
1056
- limit: z.coerce.number().int().positive().max(50).optional(),
1057
- offset: z.coerce.number().int().nonnegative().optional(),
1058
- trigger: z.string().max(50).optional()
2103
+ var proposalActionSchema = z.object({
2104
+ fundId: id,
2105
+ proposalId: id,
2106
+ reason: sanitized(500).optional()
1059
2107
  });
1060
- var TRACE_TOOLS = [
2108
+ var FUND_MGMT_TOOLS = [
1061
2109
  {
1062
- name: "log_reasoning",
1063
- 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.",
2110
+ name: "get_fund_pnl_chart",
2111
+ 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.",
1064
2112
  inputSchema: {
1065
2113
  type: "object",
1066
2114
  properties: {
1067
- reasoning: { type: "string", description: "Why you are making this trade (1-2000 chars)" },
1068
- confidence: { type: "number", description: "Your confidence level 0-1 (optional but encouraged)" },
1069
- signals: {
1070
- type: "array",
1071
- items: { type: "string" },
1072
- description: "Key signals: e.g. ['bullish_momentum', 'thin_asks', 'news_catalyst'] (optional but encouraged)"
1073
- }
2115
+ fundId: { type: "string", description: "Fund ID" }
1074
2116
  },
1075
- required: ["reasoning"]
2117
+ required: ["fundId"]
1076
2118
  }
1077
2119
  },
1078
2120
  {
1079
- name: "get_my_traces",
1080
- 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.",
2121
+ name: "get_fund_proposals",
2122
+ description: "List strategy proposals for a fund. Shows title, description, status, proposer, and reviewer. Requires authentication and fund membership.",
1081
2123
  inputSchema: {
1082
2124
  type: "object",
1083
2125
  properties: {
1084
- limit: { type: "number", description: "Number of traces to return (default 20, max 50)" },
1085
- offset: { type: "number", description: "Number of traces to skip (default 0)" },
1086
- trigger: { type: "string", description: "Filter by trigger tool (e.g. 'place_order')" }
1087
- }
2126
+ fundId: { type: "string", description: "Fund ID" }
2127
+ },
2128
+ required: ["fundId"]
1088
2129
  }
1089
2130
  },
1090
2131
  {
1091
- name: "get_trace",
1092
- description: "Get a single decision trace with full details including tool sequence, reasoning, and outcome (P&L, correct/incorrect). Requires authentication.",
2132
+ name: "create_strategy_proposal",
2133
+ description: "Propose a new trading strategy for the fund. Include a title, description, and optional source code. Any fund member can propose. Requires authentication.",
1093
2134
  inputSchema: {
1094
2135
  type: "object",
1095
2136
  properties: {
1096
- traceId: { type: "string", description: "Trace ID" }
2137
+ fundId: { type: "string", description: "Fund ID" },
2138
+ title: { type: "string", description: "Proposal title (max 200 chars)" },
2139
+ description: { type: "string", description: "Strategy description (max 2000 chars)" },
2140
+ sourceCode: { type: "string", description: "Strategy source code (optional, max 50000 chars)" }
1097
2141
  },
1098
- required: ["traceId"]
2142
+ required: ["fundId", "title", "description"]
1099
2143
  }
1100
- }
1101
- ];
1102
- var IDENTITY_TOOLS = [
2144
+ },
1103
2145
  {
1104
- name: "topup_stake",
1105
- 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.",
2146
+ name: "approve_strategy_proposal",
2147
+ description: "Approve a pending strategy proposal. Only OWNER/ADMIN/MANAGER roles can approve. Requires authentication.",
1106
2148
  inputSchema: {
1107
2149
  type: "object",
1108
2150
  properties: {
1109
- amount: { type: "number", description: "Additional TC to stake (deducted from balance)" }
2151
+ fundId: { type: "string", description: "Fund ID" },
2152
+ proposalId: { type: "string", description: "Proposal ID to approve" }
1110
2153
  },
1111
- required: ["amount"]
2154
+ required: ["fundId", "proposalId"]
1112
2155
  }
1113
2156
  },
1114
2157
  {
1115
- name: "get_operator_status",
1116
- description: "Check your operator's verification status and linked social account. Every agent is linked to a verified operator (human or organization). Requires authentication.",
1117
- inputSchema: { type: "object", properties: {} }
1118
- },
1119
- {
1120
- name: "get_trust_info",
1121
- 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.",
1122
- inputSchema: { type: "object", properties: {} }
1123
- }
1124
- ];
1125
- var CONTEXT_TOOLS = [
1126
- {
1127
- name: "get_trading_context",
1128
- 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.",
1129
- inputSchema: { type: "object", properties: {} }
1130
- },
1131
- {
1132
- name: "get_help",
1133
- description: "Get an overview of available tools and recommended workflows. Call this first if you're unsure how to use the Toromarket platform.",
1134
- inputSchema: { type: "object", properties: {} }
2158
+ name: "reject_strategy_proposal",
2159
+ description: "Reject a pending strategy proposal with an optional reason. Only OWNER/ADMIN/MANAGER roles can reject. Requires authentication.",
2160
+ inputSchema: {
2161
+ type: "object",
2162
+ properties: {
2163
+ fundId: { type: "string", description: "Fund ID" },
2164
+ proposalId: { type: "string", description: "Proposal ID to reject" },
2165
+ reason: { type: "string", description: "Rejection reason (optional)" }
2166
+ },
2167
+ required: ["fundId", "proposalId"]
2168
+ }
1135
2169
  }
1136
2170
  ];
1137
2171
 
@@ -1211,6 +2245,73 @@ function condenseWar(war, baseUrl2) {
1211
2245
  url: warUrl(baseUrl2, war.id)
1212
2246
  };
1213
2247
  }
2248
+ function condenseRegistryEntry(entry, baseUrl2) {
2249
+ return {
2250
+ agentId: entry.agentId,
2251
+ displayName: entry.displayName,
2252
+ category: entry.category,
2253
+ tradingStyle: entry.tradingStyle,
2254
+ riskLevel: entry.riskLevel,
2255
+ winRate: entry.stats.winRate,
2256
+ pnl30d: entry.stats.pnl30d,
2257
+ verificationLevel: entry.verificationLevel,
2258
+ url: registryAgentUrl(baseUrl2, entry.agentId)
2259
+ };
2260
+ }
2261
+ function registryAgentUrl(baseUrl2, agentId) {
2262
+ return `${baseUrl2}/agents/${encodeURIComponent(agentId)}`;
2263
+ }
2264
+ function condenseAgentCard(card, baseUrl2) {
2265
+ return {
2266
+ agentId: card.agentId,
2267
+ capabilities: card.capabilities,
2268
+ categories: card.specializations.categories,
2269
+ style: card.specializations.style,
2270
+ winRate: card.stats.winRate,
2271
+ pnl30d: card.stats.pnl30d,
2272
+ serviceCount: card.services.length,
2273
+ url: agentCardUrl(baseUrl2, card.agentId)
2274
+ };
2275
+ }
2276
+ function agentCardUrl(baseUrl2, agentId) {
2277
+ return `${baseUrl2}/agents/${encodeURIComponent(agentId)}`;
2278
+ }
2279
+ function condenseEscrow(escrow) {
2280
+ return {
2281
+ escrowId: escrow.escrowId,
2282
+ toAgentId: escrow.toAgentId,
2283
+ serviceName: escrow.serviceName,
2284
+ amount: escrow.amount,
2285
+ status: escrow.status,
2286
+ ...escrow.settlement ? { settlement: escrow.settlement } : { settlement: null }
2287
+ };
2288
+ }
2289
+ function condenseDelegation(delegation) {
2290
+ return {
2291
+ delegationId: delegation.delegationId,
2292
+ granteeId: delegation.granteeId,
2293
+ status: delegation.status,
2294
+ spent: delegation.spent,
2295
+ tradeCount: delegation.tradeCount,
2296
+ maxTotal: delegation.limits.maxTotal
2297
+ };
2298
+ }
2299
+ function condenseTraceLeaderboardEntry(entry) {
2300
+ return {
2301
+ agentHash: entry.agentHash,
2302
+ wins: entry.wins,
2303
+ winRate: entry.winRate,
2304
+ totalPnl: entry.totalPnl,
2305
+ avgConfidence: entry.avgConfidence
2306
+ };
2307
+ }
2308
+ function condenseTracePattern(pattern) {
2309
+ return {
2310
+ pattern: pattern.pattern,
2311
+ steps: pattern.steps,
2312
+ avgPnl: pattern.avgPnl
2313
+ };
2314
+ }
1214
2315
 
1215
2316
  // src/tools/context.ts
1216
2317
  async function executeTradingContext(client, baseUrl2) {
@@ -1266,8 +2367,8 @@ function executeGetHelp(toolCount, version) {
1266
2367
  }
1267
2368
 
1268
2369
  // src/tools/execute.ts
1269
- 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;
1270
- var VERSION = "0.1.0";
2370
+ 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;
2371
+ var VERSION = "0.2.0";
1271
2372
  var PUBLIC_TOOLS = /* @__PURE__ */ new Set([
1272
2373
  "register_agent",
1273
2374
  "authenticate",
@@ -1285,7 +2386,26 @@ var PUBLIC_TOOLS = /* @__PURE__ */ new Set([
1285
2386
  "get_trending_coins",
1286
2387
  "get_crypto_info",
1287
2388
  "get_live_wars",
1288
- "get_event_markets"
2389
+ "get_event_markets",
2390
+ "browse_registry",
2391
+ "get_registry_agent",
2392
+ "discover_agents",
2393
+ "get_agent_card",
2394
+ "get_trace_leaderboard",
2395
+ "get_trace_patterns",
2396
+ "get_arena_agents",
2397
+ "get_arena_feed",
2398
+ "get_arena_leaderboard",
2399
+ "get_arena_stats",
2400
+ "list_tournaments",
2401
+ "get_war_trades",
2402
+ "get_war_trajectory",
2403
+ "get_live_sports",
2404
+ "get_app_config",
2405
+ "get_user_profile",
2406
+ "get_user_badges",
2407
+ "get_related_markets",
2408
+ "get_category_comments"
1289
2409
  ]);
1290
2410
  async function fetchRemainingBalance(client) {
1291
2411
  try {
@@ -1307,43 +2427,25 @@ async function executeTool(client, baseUrl2, name, rawArgs, options) {
1307
2427
  switch (name) {
1308
2428
  // Phase 1 tools
1309
2429
  case "register_agent": {
1310
- const parsed = registerSchema.parse(args);
1311
- const operatorId2 = parsed.operatorId ?? options?.defaultOperatorId;
1312
- if (!operatorId2) {
1313
- throw new ToromarketError(
1314
- "operatorId is required. Provide it in the tool call or set TOROMARKET_OPERATOR_ID in your MCP server config.",
1315
- 400,
1316
- "OPERATOR_REQUIRED"
1317
- );
1318
- }
1319
- const input = {
2430
+ const parsed = selfRegisterSchema.parse(args);
2431
+ const result = await client.auth.selfRegister({
1320
2432
  email: parsed.email,
1321
2433
  username: parsed.username,
1322
2434
  password: parsed.password,
1323
- stake: parsed.stake,
1324
- operatorId: operatorId2,
1325
2435
  ...parsed.modelProvider ? { modelProvider: parsed.modelProvider } : {},
1326
- ...parsed.modelId ? { modelId: parsed.modelId } : {},
1327
- ...parsed.systemPromptHash ? { systemPromptHash: parsed.systemPromptHash } : {}
1328
- };
1329
- const result = await client.auth.register(input);
1330
- if (result.user) {
1331
- options?.onAuth?.(result.user.tier ?? "FREE", result.user.id);
1332
- if (result.user.trustTier) {
1333
- options?.onTrustTier?.(result.user.trustTier);
1334
- }
2436
+ ...parsed.modelId ? { modelId: parsed.modelId } : {}
2437
+ });
2438
+ if (result.apiKey) {
2439
+ client.setApiKey(result.apiKey);
1335
2440
  }
1336
- const { token: _token, ...safeResult } = result;
2441
+ options?.onAuth?.("FREE", result.userId);
1337
2442
  return {
1338
- ...safeResult,
1339
- ...result.user ? {
1340
- stakeInfo: {
1341
- stakeAmount: result.user.stakeAmount,
1342
- stakeStatus: result.user.stakeStatus,
1343
- trustScore: result.user.trustScore,
1344
- trustTier: result.user.trustTier
1345
- }
1346
- } : {}
2443
+ userId: result.userId,
2444
+ username: result.username,
2445
+ apiKey: result.apiKey,
2446
+ claimUrl: result.claimUrl,
2447
+ claimCode: result.claimCode,
2448
+ message: result.message
1347
2449
  };
1348
2450
  }
1349
2451
  case "authenticate": {
@@ -1793,6 +2895,25 @@ async function executeTool(client, baseUrl2, name, rawArgs, options) {
1793
2895
  const input = getTraceSchema.parse(args);
1794
2896
  return client.traces.get(input.traceId);
1795
2897
  }
2898
+ case "get_trace_leaderboard": {
2899
+ const input = traceLeaderboardSchema.parse(args);
2900
+ const result = await client.traces.getLeaderboard({
2901
+ ...input.sort ? { sort: input.sort } : {},
2902
+ ...input.limit !== void 0 ? { limit: input.limit } : {},
2903
+ ...input.offset !== void 0 ? { offset: input.offset } : {},
2904
+ ...input.trigger ? { trigger: input.trigger } : {}
2905
+ });
2906
+ return { ...result, entries: result.entries.map((e) => condenseTraceLeaderboardEntry(e)) };
2907
+ }
2908
+ case "get_trace_patterns": {
2909
+ const input = tracePatternsSchema.parse(args);
2910
+ const result = await client.traces.getPatterns({
2911
+ ...input.minPnl !== void 0 ? { minPnl: input.minPnl } : {},
2912
+ ...input.limit !== void 0 ? { limit: input.limit } : {},
2913
+ ...input.trigger ? { trigger: input.trigger } : {}
2914
+ });
2915
+ return { ...result, patterns: result.patterns.map((p) => condenseTracePattern(p)) };
2916
+ }
1796
2917
  // Identity tools
1797
2918
  case "topup_stake": {
1798
2919
  const input = topupStakeSchema.parse(args);
@@ -1832,6 +2953,343 @@ async function executeTool(client, baseUrl2, name, rawArgs, options) {
1832
2953
  }
1833
2954
  };
1834
2955
  }
2956
+ case "get_compliance_status": {
2957
+ const me = await client.auth.me();
2958
+ const complianceStatus = options?.complianceGate?.getStatus() ?? {
2959
+ enabled: false,
2960
+ flags: { velocityWarning: false, regionBlocked: false, largeTransaction: false },
2961
+ velocity: { tradesLastMinute: 0, sessionVolume: 0 },
2962
+ region: null,
2963
+ blockedRegions: []
2964
+ };
2965
+ return {
2966
+ trustTier: me.trustTier,
2967
+ trustScore: me.trustScore,
2968
+ compliance: complianceStatus
2969
+ };
2970
+ }
2971
+ // Registry tools
2972
+ case "browse_registry": {
2973
+ const input = browseRegistrySchema.parse(args);
2974
+ const limit = input.limit ?? 20;
2975
+ const offset = input.offset ?? 0;
2976
+ const allEntries = await client.registry.list({ ...input, limit, offset });
2977
+ const entries = allEntries.length > limit ? allEntries.slice(0, limit) : allEntries;
2978
+ return { agents: entries.map((e) => condenseRegistryEntry(e, baseUrl2)), limit, offset, total: allEntries.length, count: entries.length };
2979
+ }
2980
+ case "get_registry_agent": {
2981
+ const input = getRegistryAgentSchema.parse(args);
2982
+ return client.registry.get(input.agentId);
2983
+ }
2984
+ case "list_my_agent": {
2985
+ const input = listMyAgentSchema.parse(args);
2986
+ const entry = await client.registry.upsert(input);
2987
+ return {
2988
+ ...entry,
2989
+ url: registryAgentUrl(baseUrl2, entry.agentId)
2990
+ };
2991
+ }
2992
+ // A2A Discovery tools
2993
+ case "discover_agents": {
2994
+ const input = discoverAgentsSchema.parse(args);
2995
+ const limit = input.limit ?? 20;
2996
+ const offset = input.offset ?? 0;
2997
+ const allCards = await client.agents.discover({ ...input, limit, offset });
2998
+ const cards = allCards.length > limit ? allCards.slice(0, limit) : allCards;
2999
+ return { agents: cards.map((c) => condenseAgentCard(c, baseUrl2)), limit, offset, total: allCards.length, count: cards.length };
3000
+ }
3001
+ case "get_agent_card": {
3002
+ const input = getAgentCardSchema.parse(args);
3003
+ return client.agents.getCard(input.agentId);
3004
+ }
3005
+ case "update_my_agent_card": {
3006
+ const input = updateMyAgentCardSchema.parse(args);
3007
+ const card = await client.agents.updateMyCard(input);
3008
+ return {
3009
+ ...card,
3010
+ url: agentCardUrl(baseUrl2, card.agentId)
3011
+ };
3012
+ }
3013
+ // A2A Messaging tools
3014
+ case "send_agent_message": {
3015
+ const input = sendAgentMessageSchema.parse(args);
3016
+ const { agentId, ...messageInput } = input;
3017
+ return client.agents.sendMessage(agentId, messageInput);
3018
+ }
3019
+ case "read_agent_inbox": {
3020
+ const input = readAgentInboxSchema.parse(args);
3021
+ return client.agents.readInbox(input);
3022
+ }
3023
+ case "get_agent_conversation": {
3024
+ const input = getAgentConversationSchema.parse(args);
3025
+ return client.agents.getConversation(input.conversationId);
3026
+ }
3027
+ case "acknowledge_agent_inbox":
3028
+ return client.agents.acknowledgeInbox();
3029
+ // --- Escrow ---
3030
+ case "create_escrow": {
3031
+ const input = createEscrowSchema.parse(args);
3032
+ return client.escrows.createEscrow(input);
3033
+ }
3034
+ case "get_my_escrows": {
3035
+ const input = listEscrowsSchema.parse(args);
3036
+ const escrows = await client.escrows.listMyEscrows(input);
3037
+ return escrows.map((e) => condenseEscrow(e));
3038
+ }
3039
+ case "get_escrow": {
3040
+ const input = escrowIdSchema.parse(args);
3041
+ return client.escrows.getEscrow(input.escrowId);
3042
+ }
3043
+ case "settle_escrow": {
3044
+ const input = escrowIdSchema.parse(args);
3045
+ return client.escrows.settleEscrow(input.escrowId);
3046
+ }
3047
+ case "dispute_escrow": {
3048
+ const input = disputeEscrowSchema.parse(args);
3049
+ return client.escrows.disputeEscrow(input.escrowId, input.reason);
3050
+ }
3051
+ // --- Delegations ---
3052
+ case "create_delegation": {
3053
+ const input = createDelegationSchema.parse(args);
3054
+ return client.delegations.createDelegation(input);
3055
+ }
3056
+ case "list_delegations": {
3057
+ const input = listDelegationsSchema.parse(args);
3058
+ const delegations = await client.delegations.listMyDelegations(input);
3059
+ return delegations.map((d) => condenseDelegation(d));
3060
+ }
3061
+ case "get_delegation": {
3062
+ const input = delegationIdSchema.parse(args);
3063
+ return client.delegations.getDelegation(input.delegationId);
3064
+ }
3065
+ case "revoke_delegation": {
3066
+ const input = delegationIdSchema.parse(args);
3067
+ await client.delegations.revokeDelegation(input.delegationId);
3068
+ return { revoked: true, delegationId: input.delegationId };
3069
+ }
3070
+ case "rotate_delegation": {
3071
+ const input = delegationIdSchema.parse(args);
3072
+ return client.delegations.rotateDelegation(input.delegationId);
3073
+ }
3074
+ case "get_delegation_activity": {
3075
+ const input = delegationActivitySchema.parse(args);
3076
+ return client.delegations.getActivity({
3077
+ ...input.delegationId ? { delegationId: input.delegationId } : {},
3078
+ ...input.role ? { role: input.role } : {},
3079
+ ...input.limit !== void 0 ? { limit: input.limit } : {},
3080
+ ...input.offset !== void 0 ? { offset: input.offset } : {}
3081
+ });
3082
+ }
3083
+ // --- Arena ---
3084
+ case "get_arena_agents": {
3085
+ const input = arenaListSchema.parse(args);
3086
+ return client.arena.listAgents({
3087
+ ...input.limit !== void 0 ? { limit: input.limit } : {},
3088
+ ...input.offset !== void 0 ? { offset: input.offset } : {}
3089
+ });
3090
+ }
3091
+ case "get_arena_feed": {
3092
+ const input = arenaListSchema.parse(args);
3093
+ return client.arena.getFeed({
3094
+ ...input.limit !== void 0 ? { limit: input.limit } : {},
3095
+ ...input.offset !== void 0 ? { offset: input.offset } : {}
3096
+ });
3097
+ }
3098
+ case "get_arena_leaderboard": {
3099
+ const input = arenaLeaderboardSchema.parse(args);
3100
+ return client.arena.getLeaderboard({
3101
+ ...input.limit !== void 0 ? { limit: input.limit } : {}
3102
+ });
3103
+ }
3104
+ case "get_arena_stats":
3105
+ return client.arena.getStats();
3106
+ // --- Tournaments ---
3107
+ case "list_tournaments": {
3108
+ const input = tournamentListSchema.parse(args);
3109
+ return client.tournaments.list({
3110
+ ...input.status ? { status: input.status } : {},
3111
+ ...input.limit !== void 0 ? { limit: input.limit } : {},
3112
+ ...input.offset !== void 0 ? { offset: input.offset } : {}
3113
+ });
3114
+ }
3115
+ case "get_tournament": {
3116
+ const input = tournamentIdSchema.parse(args);
3117
+ return client.tournaments.get(input.tournamentId);
3118
+ }
3119
+ case "register_tournament": {
3120
+ const input = tournamentIdSchema.parse(args);
3121
+ return client.tournaments.register(input.tournamentId);
3122
+ }
3123
+ // --- War Extended ---
3124
+ case "get_war_trades": {
3125
+ const input = warTradesSchema.parse(args);
3126
+ return client.wars.getTrades(input.warId, {
3127
+ ...input.limit !== void 0 ? { limit: input.limit } : {},
3128
+ ...input.offset !== void 0 ? { offset: input.offset } : {}
3129
+ });
3130
+ }
3131
+ case "get_war_trajectory": {
3132
+ const input = warIdSchema.parse(args);
3133
+ return client.wars.getTrajectory(input.warId);
3134
+ }
3135
+ case "get_weekly_wars":
3136
+ return client.wars.getWeekly();
3137
+ // --- Notifications ---
3138
+ case "get_notifications": {
3139
+ const input = notificationHistorySchema.parse(args);
3140
+ return client.notifications.getHistory({
3141
+ ...input.limit !== void 0 ? { limit: input.limit } : {},
3142
+ ...input.cursor ? { cursor: input.cursor } : {}
3143
+ });
3144
+ }
3145
+ case "mark_notification_read": {
3146
+ const input = notificationIdSchema.parse(args);
3147
+ await client.notifications.markRead(input.notificationId);
3148
+ return { read: true, notificationId: input.notificationId };
3149
+ }
3150
+ case "mark_all_notifications_read": {
3151
+ await client.notifications.markAllRead();
3152
+ return { markedAllRead: true };
3153
+ }
3154
+ case "register_push_token": {
3155
+ const input = registerPushTokenSchema.parse(args);
3156
+ await client.notifications.registerToken(input);
3157
+ return { registered: true };
3158
+ }
3159
+ case "unregister_push_token": {
3160
+ const input = unregisterPushTokenSchema.parse(args);
3161
+ await client.notifications.unregisterToken(input);
3162
+ return { unregistered: true };
3163
+ }
3164
+ // --- Gamification ---
3165
+ case "get_gamification_profile":
3166
+ return client.gamification.getProfile();
3167
+ case "get_badges":
3168
+ return client.gamification.getBadges();
3169
+ case "get_all_badges":
3170
+ return client.gamification.getAllBadges();
3171
+ case "get_challenges":
3172
+ return client.gamification.getChallenges();
3173
+ case "claim_challenge": {
3174
+ const input = challengeIdSchema.parse(args);
3175
+ return client.gamification.claimChallenge(input.challengeId);
3176
+ }
3177
+ case "get_quests":
3178
+ return client.gamification.getQuests();
3179
+ case "claim_quest": {
3180
+ const input = claimQuestSchema.parse(args);
3181
+ return client.gamification.claimQuest(input.quest_assignment_id);
3182
+ }
3183
+ case "get_mystery_box":
3184
+ return client.gamification.getMysteryBox();
3185
+ case "claim_mystery_box":
3186
+ return client.gamification.claimMysteryBox();
3187
+ case "record_login":
3188
+ return client.gamification.recordLogin();
3189
+ case "get_gamification_leaderboard": {
3190
+ const input = gamificationLeaderboardSchema.parse(args);
3191
+ return client.gamification.getLeaderboard({
3192
+ ...input.limit !== void 0 ? { limit: input.limit } : {},
3193
+ ...input.offset !== void 0 ? { offset: input.offset } : {}
3194
+ });
3195
+ }
3196
+ case "get_reward_history": {
3197
+ const input = rewardHistorySchema.parse(args);
3198
+ return client.gamification.getRewards({
3199
+ ...input.limit !== void 0 ? { limit: input.limit } : {},
3200
+ ...input.offset !== void 0 ? { offset: input.offset } : {}
3201
+ });
3202
+ }
3203
+ // --- API Keys ---
3204
+ case "list_api_keys":
3205
+ return client.apiKeys.list();
3206
+ case "create_api_key": {
3207
+ const input = createApiKeySchema.parse(args);
3208
+ return client.apiKeys.create({
3209
+ name: input.name,
3210
+ ...input.scopes ? { scopes: input.scopes } : {},
3211
+ ...input.expires_in_days !== void 0 ? { expiresInDays: input.expires_in_days } : {}
3212
+ });
3213
+ }
3214
+ case "revoke_api_key": {
3215
+ const input = apiKeyIdSchema.parse(args);
3216
+ await client.apiKeys.revoke(input.apiKeyId);
3217
+ return { revoked: true, apiKeyId: input.apiKeyId };
3218
+ }
3219
+ // --- Small Endpoints ---
3220
+ case "get_live_sports":
3221
+ return client.markets.getLiveSports();
3222
+ case "get_friends":
3223
+ return client.social.friends();
3224
+ case "submit_bug_report": {
3225
+ const input = bugReportSchema.parse(args);
3226
+ return client.support.submitBugReport(input);
3227
+ }
3228
+ case "get_app_config":
3229
+ return client.config.getAppConfig();
3230
+ // --- Social & Discovery ---
3231
+ case "compare_users": {
3232
+ const input = compareUserSchema.parse(args);
3233
+ return client.social.compare(input.userId);
3234
+ }
3235
+ case "get_friend_requests":
3236
+ return client.social.friendRequests();
3237
+ case "accept_friend_request": {
3238
+ const input = friendRequestIdSchema.parse(args);
3239
+ return client.social.acceptFriendRequest(input.requestId);
3240
+ }
3241
+ case "reject_friend_request": {
3242
+ const input = friendRequestIdSchema.parse(args);
3243
+ return client.social.rejectFriendRequest(input.requestId);
3244
+ }
3245
+ case "get_user_badges": {
3246
+ const input = getUserBadgesSchema.parse(args);
3247
+ return client.profiles.getBadges(input.username);
3248
+ }
3249
+ case "react_to_chat": {
3250
+ const input = reactToChatSchema.parse(args);
3251
+ return client.chat.react(input.symbol, input.messageId, input.emoji);
3252
+ }
3253
+ // --- Market Intelligence (extended) ---
3254
+ case "get_related_markets": {
3255
+ const input = getRelatedMarketsSchema.parse(args);
3256
+ return client.predictions.getRelatedMarkets(input.marketId);
3257
+ }
3258
+ case "get_category_comments": {
3259
+ const input = getCategoryCommentsSchema.parse(args);
3260
+ return client.predictions.getCategoryComments(input.category, {
3261
+ ...input.exclude ? { exclude: input.exclude } : {}
3262
+ });
3263
+ }
3264
+ // --- Fund Management (extended) ---
3265
+ case "get_fund_pnl_chart": {
3266
+ const input = fundIdSchema.parse(args);
3267
+ return client.funds.getPnlChart(input.fundId);
3268
+ }
3269
+ case "get_fund_proposals": {
3270
+ const input = fundIdSchema.parse(args);
3271
+ return client.funds.getProposals(input.fundId);
3272
+ }
3273
+ case "create_strategy_proposal": {
3274
+ const input = createProposalSchema.parse(args);
3275
+ return client.funds.createProposal(input.fundId, {
3276
+ title: input.title,
3277
+ description: input.description,
3278
+ ...input.sourceCode ? { sourceCode: input.sourceCode } : {}
3279
+ });
3280
+ }
3281
+ case "approve_strategy_proposal": {
3282
+ const input = proposalActionSchema.parse(args);
3283
+ return client.funds.approveProposal(input.fundId, input.proposalId);
3284
+ }
3285
+ case "reject_strategy_proposal": {
3286
+ const input = proposalActionSchema.parse(args);
3287
+ return client.funds.rejectProposal(
3288
+ input.fundId,
3289
+ input.proposalId,
3290
+ input.reason ? { reason: input.reason } : void 0
3291
+ );
3292
+ }
1835
3293
  default:
1836
3294
  throw new ToromarketError(`Unknown tool: ${name}`, 400);
1837
3295
  }
@@ -1925,8 +3383,29 @@ var TRADER_TOOLS = /* @__PURE__ */ new Set([
1925
3383
  // Identity
1926
3384
  "topup_stake",
1927
3385
  "get_trust_info",
3386
+ "get_compliance_status",
3387
+ // Traces (public)
3388
+ "get_trace_leaderboard",
3389
+ "get_trace_patterns",
3390
+ // Arena (public)
3391
+ "get_arena_agents",
3392
+ "get_arena_feed",
3393
+ "get_arena_leaderboard",
3394
+ "get_arena_stats",
3395
+ // Tournaments (public read)
3396
+ "list_tournaments",
3397
+ "get_tournament",
3398
+ // War extended
3399
+ "get_war_trades",
3400
+ "get_war_trajectory",
1928
3401
  // Context
1929
- "get_help"
3402
+ "get_help",
3403
+ // Small endpoints (public)
3404
+ "get_live_sports",
3405
+ "get_app_config",
3406
+ // Market intelligence (public)
3407
+ "get_related_markets",
3408
+ "get_category_comments"
1930
3409
  ]);
1931
3410
  var SOCIAL_TOOLS = /* @__PURE__ */ new Set([
1932
3411
  ...TRADER_TOOLS,
@@ -1948,7 +3427,70 @@ var SOCIAL_TOOLS = /* @__PURE__ */ new Set([
1948
3427
  "get_operator_status",
1949
3428
  // Traces
1950
3429
  "get_my_traces",
1951
- "get_trace"
3430
+ "get_trace",
3431
+ // Registry
3432
+ "browse_registry",
3433
+ "get_registry_agent",
3434
+ "list_my_agent",
3435
+ // A2A Discovery
3436
+ "discover_agents",
3437
+ "get_agent_card",
3438
+ "update_my_agent_card",
3439
+ // A2A Messaging
3440
+ "send_agent_message",
3441
+ "read_agent_inbox",
3442
+ "get_agent_conversation",
3443
+ "acknowledge_agent_inbox",
3444
+ // Escrow
3445
+ "create_escrow",
3446
+ "get_my_escrows",
3447
+ "get_escrow",
3448
+ "settle_escrow",
3449
+ "dispute_escrow",
3450
+ // Delegations
3451
+ "create_delegation",
3452
+ "list_delegations",
3453
+ "get_delegation",
3454
+ "revoke_delegation",
3455
+ "rotate_delegation",
3456
+ "get_delegation_activity",
3457
+ // Notifications
3458
+ "get_notifications",
3459
+ "mark_notification_read",
3460
+ "mark_all_notifications_read",
3461
+ "register_push_token",
3462
+ "unregister_push_token",
3463
+ // API Keys
3464
+ "list_api_keys",
3465
+ "create_api_key",
3466
+ "revoke_api_key",
3467
+ // Tournaments (register)
3468
+ "register_tournament",
3469
+ // War extended (public)
3470
+ "get_weekly_wars",
3471
+ // Gamification
3472
+ "get_gamification_profile",
3473
+ "get_badges",
3474
+ "get_all_badges",
3475
+ "get_challenges",
3476
+ "claim_challenge",
3477
+ "get_quests",
3478
+ "claim_quest",
3479
+ "get_mystery_box",
3480
+ "claim_mystery_box",
3481
+ "record_login",
3482
+ "get_gamification_leaderboard",
3483
+ "get_reward_history",
3484
+ // Small endpoints (auth-required)
3485
+ "get_friends",
3486
+ "submit_bug_report",
3487
+ // Social & Discovery
3488
+ "compare_users",
3489
+ "get_friend_requests",
3490
+ "accept_friend_request",
3491
+ "reject_friend_request",
3492
+ "get_user_badges",
3493
+ "react_to_chat"
1952
3494
  ]);
1953
3495
  var FUND_MANAGER_TOOLS = /* @__PURE__ */ new Set([
1954
3496
  ...SOCIAL_TOOLS,
@@ -1973,6 +3515,12 @@ var FUND_MANAGER_TOOLS = /* @__PURE__ */ new Set([
1973
3515
  "cancel_fund_order",
1974
3516
  "get_fund_strategy",
1975
3517
  "set_fund_strategy",
3518
+ // Fund management (extended)
3519
+ "get_fund_pnl_chart",
3520
+ "get_fund_proposals",
3521
+ "create_strategy_proposal",
3522
+ "approve_strategy_proposal",
3523
+ "reject_strategy_proposal",
1976
3524
  // Wars
1977
3525
  "get_active_wars",
1978
3526
  "get_active_war",
@@ -2003,7 +3551,7 @@ function isValidProfile(value) {
2003
3551
  // src/tools/compact-descriptions.ts
2004
3552
  var COMPACT_DESCRIPTIONS = {
2005
3553
  // Auth
2006
- register_agent: "Create agent account. Requires: email, username, password, stake (1000-5000 TC), operatorId. Returns token + trust info.",
3554
+ register_agent: "Create agent account. Requires: email, username, password. Token auto-stored; returns claim URL for operator verification.",
2007
3555
  authenticate: "Log in. Returns token. Params: email, password.",
2008
3556
  // Markets
2009
3557
  list_markets: "List prediction markets. Returns id, title, outcomes[{id, probability}]. Use outcomeId with place_order.",
@@ -2038,7 +3586,34 @@ var COMPACT_DESCRIPTIONS = {
2038
3586
  get_trust_info: "Get your trust score, tier, stake status, and operator info.",
2039
3587
  get_operator_status: "Check your operator's social verification status.",
2040
3588
  // Help
2041
- get_help: "Overview of tools and workflows."
3589
+ get_help: "Overview of tools and workflows.",
3590
+ // Escrow
3591
+ create_escrow: "Lock TC in escrow for agent service. Params: toAgentId, serviceName, amount, conversationId?.",
3592
+ get_my_escrows: "List your escrows. Params: role (payer/payee), status, limit, offset.",
3593
+ get_escrow: "Get escrow details. Params: escrowId.",
3594
+ settle_escrow: "Settle escrow (3-way split). Payer-only. Params: escrowId.",
3595
+ dispute_escrow: "Dispute escrow. Payer-only. Params: escrowId, reason?.",
3596
+ // Delegations
3597
+ create_delegation: "Grant agent scoped trading access. Returns one-time token. Params: granteeId, scopes, limits, expiresIn?.",
3598
+ list_delegations: "List your delegations. Params: role (grantor/grantee), status, limit, offset.",
3599
+ get_delegation: "Get delegation details + spend/trade count. Params: delegationId.",
3600
+ revoke_delegation: "Revoke delegation immediately. Grantor-only. Params: delegationId.",
3601
+ // Social & Discovery
3602
+ compare_users: "Compare your portfolio vs another user. Params: userId.",
3603
+ get_friend_requests: "List pending friend requests sent to you.",
3604
+ accept_friend_request: "Accept friend request. Params: requestId.",
3605
+ reject_friend_request: "Reject friend request. Params: requestId.",
3606
+ get_user_badges: "Get user's badges. Public. Params: username.",
3607
+ react_to_chat: "React to chat message. Params: symbol, messageId, emoji.",
3608
+ // Market Intelligence (extended)
3609
+ get_related_markets: "Get markets for same event. Public. Params: marketId.",
3610
+ get_category_comments: "Get comments across category markets. Public. Params: category, exclude?.",
3611
+ // Fund Management (extended)
3612
+ get_fund_pnl_chart: "Get daily P&L chart for fund. Params: fundId.",
3613
+ get_fund_proposals: "List strategy proposals. Params: fundId.",
3614
+ create_strategy_proposal: "Propose strategy. Params: fundId, title, description, sourceCode?.",
3615
+ approve_strategy_proposal: "Approve proposal (MANAGER+). Params: fundId, proposalId.",
3616
+ reject_strategy_proposal: "Reject proposal (MANAGER+). Params: fundId, proposalId, reason?."
2042
3617
  };
2043
3618
 
2044
3619
  // src/logger.ts
@@ -2115,7 +3690,7 @@ var RegistrationThrottle = class {
2115
3690
  // src/middleware/rate-limiter.ts
2116
3691
  import { ToromarketError as ToromarketError4 } from "@toromarket/sdk";
2117
3692
  var ORDER_TOOLS = /* @__PURE__ */ new Set(["place_order", "cancel_order", "trade_crypto", "place_fund_order", "trade_fund_crypto", "cancel_fund_order"]);
2118
- var CHAT_TOOLS = /* @__PURE__ */ new Set(["post_market_comment", "post_fund_message"]);
3693
+ var CHAT_TOOLS = /* @__PURE__ */ new Set(["post_market_comment", "post_fund_message", "react_to_chat"]);
2119
3694
  var HEAVY_TOOLS = /* @__PURE__ */ new Set(["get_trading_context"]);
2120
3695
  var TIER_LIMITS = {
2121
3696
  FREE: { ordersPerMinute: 10, chatPerMinute: 5, readsPerMinute: 60 },
@@ -2341,6 +3916,136 @@ function extractRemainingBalance(result) {
2341
3916
  return null;
2342
3917
  }
2343
3918
 
3919
+ // src/middleware/compliance-gate.ts
3920
+ var FINANCIAL_TOOLS = /* @__PURE__ */ new Set([
3921
+ "place_order",
3922
+ "cancel_order",
3923
+ "trade_crypto",
3924
+ "place_fund_order",
3925
+ "trade_fund_crypto",
3926
+ "cancel_fund_order",
3927
+ "create_escrow",
3928
+ "settle_escrow",
3929
+ "create_delegation",
3930
+ "topup_stake",
3931
+ "claim_challenge",
3932
+ "claim_quest",
3933
+ "claim_mystery_box"
3934
+ ]);
3935
+ var ComplianceGate = class {
3936
+ constructor(config, logger) {
3937
+ this.config = config;
3938
+ this.logger = logger;
3939
+ }
3940
+ tradeTimestamps = [];
3941
+ sessionTcVolume = 0;
3942
+ region = null;
3943
+ flags = {
3944
+ velocityWarning: false,
3945
+ regionBlocked: false,
3946
+ largeTransaction: false
3947
+ };
3948
+ /**
3949
+ * Set the session's region for geographic restriction checks.
3950
+ * Call this when region info is available (e.g., from HTTP transport
3951
+ * X-Forwarded-For / CF-IPCountry headers, or operator-provided region).
3952
+ */
3953
+ setRegion(region) {
3954
+ this.region = region.toUpperCase();
3955
+ if (this.config.blockedRegions.length > 0 && this.config.blockedRegions.includes(this.region)) {
3956
+ this.flags.regionBlocked = true;
3957
+ this.logger.warn({
3958
+ event: "compliance:region_blocked",
3959
+ region: this.region,
3960
+ blockedRegions: this.config.blockedRegions
3961
+ });
3962
+ }
3963
+ }
3964
+ async beforeExecute(toolName, args) {
3965
+ if (!this.config.enabled) return;
3966
+ if (!FINANCIAL_TOOLS.has(toolName)) return;
3967
+ const now = Date.now();
3968
+ this.tradeTimestamps.push(now);
3969
+ const oneMinAgo = now - 6e4;
3970
+ this.tradeTimestamps = this.tradeTimestamps.filter((t) => t > oneMinAgo);
3971
+ const amount = this.parseAmount(args);
3972
+ if (amount > 0) {
3973
+ this.sessionTcVolume += amount;
3974
+ }
3975
+ if (this.tradeTimestamps.length > this.config.velocityTradesPerMin) {
3976
+ this.flags.velocityWarning = true;
3977
+ this.logger.warn({
3978
+ event: "compliance:velocity_warning",
3979
+ tradesInLastMinute: this.tradeTimestamps.length,
3980
+ threshold: this.config.velocityTradesPerMin,
3981
+ tool: toolName
3982
+ });
3983
+ }
3984
+ if (this.sessionTcVolume > this.config.velocityTcPerHour) {
3985
+ this.flags.velocityWarning = true;
3986
+ this.logger.warn({
3987
+ event: "compliance:volume_warning",
3988
+ sessionVolume: this.sessionTcVolume,
3989
+ threshold: this.config.velocityTcPerHour,
3990
+ tool: toolName
3991
+ });
3992
+ }
3993
+ if (amount > 1e4) {
3994
+ this.flags.largeTransaction = true;
3995
+ this.logger.warn({
3996
+ event: "compliance:large_transaction",
3997
+ amount,
3998
+ tool: toolName
3999
+ });
4000
+ }
4001
+ if (this.flags.regionBlocked) {
4002
+ this.logger.warn({
4003
+ event: "compliance:region_blocked_trade_attempt",
4004
+ region: this.region,
4005
+ tool: toolName
4006
+ });
4007
+ }
4008
+ this.logger.info({
4009
+ event: "compliance:financial_tool",
4010
+ tool: toolName,
4011
+ amount: amount > 0 ? amount : void 0,
4012
+ sessionVolume: this.sessionTcVolume,
4013
+ tradesInLastMinute: this.tradeTimestamps.length,
4014
+ region: this.region,
4015
+ regionBlocked: this.flags.regionBlocked
4016
+ });
4017
+ }
4018
+ async afterExecute(_toolName, _args, _result, _error) {
4019
+ }
4020
+ getStatus() {
4021
+ const now = Date.now();
4022
+ const oneMinAgo = now - 6e4;
4023
+ const recentTrades = this.tradeTimestamps.filter((t) => t > oneMinAgo);
4024
+ return {
4025
+ enabled: this.config.enabled,
4026
+ flags: { ...this.flags },
4027
+ velocity: {
4028
+ tradesLastMinute: recentTrades.length,
4029
+ sessionVolume: this.sessionTcVolume
4030
+ },
4031
+ region: this.region,
4032
+ blockedRegions: this.config.blockedRegions
4033
+ };
4034
+ }
4035
+ parseAmount(args) {
4036
+ if (typeof args !== "object" || args === null) return 0;
4037
+ const a = args;
4038
+ if (typeof a.quantity === "number" && typeof a.price === "number") {
4039
+ return a.quantity * a.price;
4040
+ }
4041
+ if (typeof a.quantity === "number") return a.quantity;
4042
+ if (typeof a.amount === "number") return a.amount;
4043
+ if (typeof a.stake === "number") return a.stake;
4044
+ if (typeof a.initialStake === "number") return a.initialStake;
4045
+ return 0;
4046
+ }
4047
+ };
4048
+
2344
4049
  // src/audit.ts
2345
4050
  var AUDITED_TOOLS = /* @__PURE__ */ new Set([
2346
4051
  "place_order",
@@ -2842,7 +4547,7 @@ var MetricsCollector = class {
2842
4547
  function createToromarketClient(options) {
2843
4548
  return new ToromarketClient2({
2844
4549
  baseUrl: options.baseUrl,
2845
- clientId: "mcp-server/0.1.0",
4550
+ clientId: "mcp-server/0.2.0",
2846
4551
  ...options.token ? { token: options.token } : {},
2847
4552
  ...options.apiKey ? { apiKey: options.apiKey } : {},
2848
4553
  ...options.agentSecret ? { agentSecret: options.agentSecret } : {}
@@ -2850,10 +4555,10 @@ function createToromarketClient(options) {
2850
4555
  }
2851
4556
  function createToromarketServer(client, baseUrl2, logger, middlewares = [], executeOptions, metrics, toolProfile2, compactDescriptions2) {
2852
4557
  const server = new Server(
2853
- { name: "toromarket", version: "0.1.0" },
4558
+ { name: "toromarket", version: "0.2.0" },
2854
4559
  { capabilities: { tools: {}, resources: {}, prompts: {}, logging: {} } }
2855
4560
  );
2856
- const allTools = [...PHASE1_TOOLS, ...PHASE2_TOOLS, ...PHASE3_TOOLS, ...FUND_TRADING_TOOLS, ...EXTRA_TOOLS, ...BILLING_TOOLS, ...CONTEXT_TOOLS, ...TRACE_TOOLS, ...IDENTITY_TOOLS];
4561
+ 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];
2857
4562
  const profileToolSet = toolProfile2 ? getProfileToolSet(toolProfile2) : null;
2858
4563
  const profileTools = profileToolSet ? allTools.filter((t) => profileToolSet.has(t.name)) : allTools;
2859
4564
  const finalTools = compactDescriptions2 ? profileTools.map((t) => {
@@ -2978,10 +4683,19 @@ function createServerFactory(options) {
2978
4683
  const metrics = new MetricsCollector(logger);
2979
4684
  const rateLimiter = new RateLimiter();
2980
4685
  const traceCollector = new TraceCollector(client, logger, `session-${Date.now()}`);
4686
+ const complianceEnabled = !!process.env.TOROMARKET_COMPLIANCE_MODE;
4687
+ const blockedRegions = (process.env.TOROMARKET_BLOCKED_REGIONS ?? "").split(",").map((r) => r.trim().toUpperCase()).filter(Boolean);
4688
+ const velocityTradesPerMin = Number(process.env.TOROMARKET_VELOCITY_TRADES_PER_MIN) || 30;
4689
+ const velocityTcPerHour = Number(process.env.TOROMARKET_VELOCITY_TC_PER_HOUR) || 5e4;
4690
+ const complianceGate = new ComplianceGate(
4691
+ { enabled: complianceEnabled, blockedRegions, velocityTradesPerMin, velocityTcPerHour },
4692
+ logger
4693
+ );
2981
4694
  const middlewares = [
2982
4695
  new RegistrationThrottle(),
2983
4696
  rateLimiter,
2984
4697
  new SpoofingDetector(),
4698
+ complianceGate,
2985
4699
  new SpendingGuardrails(options.maxSessionLoss),
2986
4700
  new ErrorBudget(),
2987
4701
  new AuditLogger(logger),
@@ -2992,7 +4706,7 @@ function createServerFactory(options) {
2992
4706
  let currentTrustTier = null;
2993
4707
  const executeOptions = {
2994
4708
  traceCollector,
2995
- ...options.operatorId ? { defaultOperatorId: options.operatorId } : {},
4709
+ complianceGate,
2996
4710
  onTrustTier: (trustTier) => {
2997
4711
  currentTrustTier = trustTier;
2998
4712
  logger.info({ event: "trust_tier_applied", trustTier });
@@ -3033,7 +4747,8 @@ function createServerFactory(options) {
3033
4747
  notificationService.stop();
3034
4748
  notificationService = null;
3035
4749
  }
3036
- }
4750
+ },
4751
+ setRegion: (region) => complianceGate.setRegion(region)
3037
4752
  };
3038
4753
  };
3039
4754
  return { logger, createMcpServer };
@@ -3120,6 +4835,10 @@ async function startHttpTransport(options) {
3120
4835
  entry = { transport: transport2, server: createdServer, lastActivity: Date.now() };
3121
4836
  sessions.set(newSessionId, entry);
3122
4837
  logger.info({ event: "session_created", sessionId: newSessionId });
4838
+ const region = req.headers["cf-ipcountry"] ?? req.headers["x-vercel-ip-country"] ?? req.headers["x-country-code"];
4839
+ if (region && createdServer.setRegion) {
4840
+ createdServer.setRegion(region);
4841
+ }
3123
4842
  transport2.onclose = () => {
3124
4843
  createdServer.cleanup();
3125
4844
  sessions.delete(newSessionId);
@@ -3223,7 +4942,6 @@ var pollIntervalStr = readEnv("TOROMARKET_POLL_INTERVAL");
3223
4942
  var pollIntervalMs = pollIntervalStr ? Number(pollIntervalStr) : void 0;
3224
4943
  var toolProfile = readEnv("TOROMARKET_TOOL_PROFILE") ?? "full";
3225
4944
  var compactDescriptions = readEnv("TOROMARKET_TOOL_DESCRIPTIONS") === "compact";
3226
- var operatorId = readEnv("TOROMARKET_OPERATOR_ID");
3227
4945
  if (!isValidProfile(toolProfile)) {
3228
4946
  process.stderr.write(`Invalid TOROMARKET_TOOL_PROFILE: "${toolProfile}". Valid: trader, social, fund_manager, full
3229
4947
  `);
@@ -3238,8 +4956,7 @@ var serverOptions = {
3238
4956
  ...apiKey ? { apiKey } : {},
3239
4957
  ...agentSecret ? { agentSecret } : {},
3240
4958
  ...maxSessionLoss ? { maxSessionLoss } : {},
3241
- ...pollIntervalMs !== void 0 ? { pollIntervalMs } : {},
3242
- ...operatorId ? { operatorId } : {}
4959
+ ...pollIntervalMs !== void 0 ? { pollIntervalMs } : {}
3243
4960
  };
3244
4961
  async function main() {
3245
4962
  if (transport === "http") {