agent-hustle-demo 1.0.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.
Files changed (60) hide show
  1. package/README.md +429 -0
  2. package/dist/HustleChat-BC9wvWVA.d.ts +90 -0
  3. package/dist/HustleChat-BcrKkkyn.d.cts +90 -0
  4. package/dist/browser/hustle-react.js +14854 -0
  5. package/dist/browser/hustle-react.js.map +1 -0
  6. package/dist/components/index.cjs +3141 -0
  7. package/dist/components/index.cjs.map +1 -0
  8. package/dist/components/index.d.cts +20 -0
  9. package/dist/components/index.d.ts +20 -0
  10. package/dist/components/index.js +3112 -0
  11. package/dist/components/index.js.map +1 -0
  12. package/dist/hooks/index.cjs +845 -0
  13. package/dist/hooks/index.cjs.map +1 -0
  14. package/dist/hooks/index.d.cts +6 -0
  15. package/dist/hooks/index.d.ts +6 -0
  16. package/dist/hooks/index.js +838 -0
  17. package/dist/hooks/index.js.map +1 -0
  18. package/dist/hustle-Kj0X8qXC.d.cts +193 -0
  19. package/dist/hustle-Kj0X8qXC.d.ts +193 -0
  20. package/dist/index-ChUsRBwL.d.ts +152 -0
  21. package/dist/index-DE1N7C3W.d.cts +152 -0
  22. package/dist/index-DuPFrMZy.d.cts +214 -0
  23. package/dist/index-kFIdHjNw.d.ts +214 -0
  24. package/dist/index.cjs +3746 -0
  25. package/dist/index.cjs.map +1 -0
  26. package/dist/index.d.cts +271 -0
  27. package/dist/index.d.ts +271 -0
  28. package/dist/index.js +3697 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/providers/index.cjs +844 -0
  31. package/dist/providers/index.cjs.map +1 -0
  32. package/dist/providers/index.d.cts +5 -0
  33. package/dist/providers/index.d.ts +5 -0
  34. package/dist/providers/index.js +838 -0
  35. package/dist/providers/index.js.map +1 -0
  36. package/package.json +80 -0
  37. package/src/components/AuthStatus.tsx +352 -0
  38. package/src/components/ConnectButton.tsx +421 -0
  39. package/src/components/HustleChat.tsx +1273 -0
  40. package/src/components/MarkdownContent.tsx +431 -0
  41. package/src/components/index.ts +15 -0
  42. package/src/hooks/index.ts +40 -0
  43. package/src/hooks/useEmblemAuth.ts +27 -0
  44. package/src/hooks/useHustle.ts +36 -0
  45. package/src/hooks/usePlugins.ts +135 -0
  46. package/src/index.ts +142 -0
  47. package/src/plugins/index.ts +48 -0
  48. package/src/plugins/migrateFun.ts +211 -0
  49. package/src/plugins/predictionMarket.ts +411 -0
  50. package/src/providers/EmblemAuthProvider.tsx +319 -0
  51. package/src/providers/HustleProvider.tsx +540 -0
  52. package/src/providers/index.ts +6 -0
  53. package/src/styles/index.ts +2 -0
  54. package/src/styles/tokens.ts +447 -0
  55. package/src/types/auth.ts +85 -0
  56. package/src/types/hustle.ts +217 -0
  57. package/src/types/index.ts +49 -0
  58. package/src/types/plugin.ts +180 -0
  59. package/src/utils/index.ts +122 -0
  60. package/src/utils/pluginRegistry.ts +375 -0
@@ -0,0 +1,411 @@
1
+ /**
2
+ * Prediction Market Alpha Plugin
3
+ *
4
+ * Provides AI tools for searching and analyzing prediction markets
5
+ * using the Dome API (https://api.domeapi.io)
6
+ *
7
+ * Supported platforms: Polymarket, Kalshi
8
+ *
9
+ * Get specific market details:
10
+ * - "Get details on the [market-slug] market"
11
+ * - "Tell me more about that Bitcoin prediction market"
12
+ *
13
+ * Get prices/odds:
14
+ * - "What are the current odds on [market]?"
15
+ * - "What's the probability showing for [market]?"
16
+ *
17
+ * Get trading activity:
18
+ * - "Show me recent trades on that market"
19
+ * - "What's the trading activity like?"
20
+ * - "What prediction market platforms are supported?"
21
+ * - "Search Kalshi for markets about crypto"
22
+ * - "Show me prediction markets on Polymarket about politics"
23
+ * - "Get details on [ticker] from Kalshi"
24
+ */
25
+
26
+ import type { HustlePlugin } from '../types';
27
+
28
+ const DOME_API_BASE = 'https://api.domeapi.io/v1';
29
+
30
+ /**
31
+ * Supported prediction market platforms
32
+ */
33
+ type Platform = 'polymarket' | 'kalshi';
34
+
35
+ /**
36
+ * Prediction Market Alpha Plugin
37
+ *
38
+ * Tools:
39
+ * - get_supported_platforms: List supported prediction market platforms
40
+ * - search_prediction_markets: Search for markets on Polymarket or Kalshi
41
+ * - get_market_details: Get detailed info about a specific market
42
+ * - get_market_prices: Get current prices/odds for a market
43
+ * - get_market_trades: Get recent trading activity
44
+ */
45
+ export const predictionMarketPlugin: HustlePlugin = {
46
+ name: 'prediction-market-alpha',
47
+ version: '1.1.0',
48
+ description: 'Search and analyze prediction markets on Polymarket and Kalshi',
49
+
50
+ tools: [
51
+ {
52
+ name: 'get_supported_platforms',
53
+ description:
54
+ 'Get a list of supported prediction market platforms. Call this first to know which platforms are available for querying.',
55
+ parameters: {
56
+ type: 'object',
57
+ properties: {},
58
+ },
59
+ },
60
+ {
61
+ name: 'search_prediction_markets',
62
+ description:
63
+ 'Search for prediction markets. Find markets about politics, crypto, sports, and more. Returns market titles, current odds, volume, and status. You MUST provide tags to filter results.',
64
+ parameters: {
65
+ type: 'object',
66
+ properties: {
67
+ platform: {
68
+ type: 'string',
69
+ enum: ['polymarket', 'kalshi'],
70
+ description: 'The prediction market platform to search (default: polymarket)',
71
+ },
72
+ tags: {
73
+ type: 'array',
74
+ items: { type: 'string' },
75
+ description: 'REQUIRED: Single word categories or tags to identify a market segment (e.g., "politics", "crypto", "sports", "finance", "entertainment", "ai")',
76
+ },
77
+ status: {
78
+ type: 'string',
79
+ enum: ['open', 'closed'],
80
+ description: 'Filter by market status',
81
+ },
82
+ limit: {
83
+ type: 'number',
84
+ description: 'Number of results (1-100)',
85
+ default: 10,
86
+ },
87
+ },
88
+ required: ['tags'],
89
+ },
90
+ },
91
+ {
92
+ name: 'get_market_details',
93
+ description:
94
+ 'Get detailed information about a specific prediction market including current prices, trading history, and resolution source.',
95
+ parameters: {
96
+ type: 'object',
97
+ properties: {
98
+ platform: {
99
+ type: 'string',
100
+ enum: ['polymarket', 'kalshi'],
101
+ description: 'The prediction market platform (default: polymarket)',
102
+ },
103
+ market_slug: {
104
+ type: 'string',
105
+ description: 'The market slug/identifier (ticker for Kalshi)',
106
+ },
107
+ },
108
+ required: ['market_slug'],
109
+ },
110
+ },
111
+ {
112
+ name: 'get_market_prices',
113
+ description:
114
+ 'Get current prices/odds for a prediction market. Shows probability for each outcome.',
115
+ parameters: {
116
+ type: 'object',
117
+ properties: {
118
+ platform: {
119
+ type: 'string',
120
+ enum: ['polymarket', 'kalshi'],
121
+ description: 'The prediction market platform (default: polymarket)',
122
+ },
123
+ market_slug: {
124
+ type: 'string',
125
+ description: 'The market slug/identifier (ticker for Kalshi)',
126
+ },
127
+ },
128
+ required: ['market_slug'],
129
+ },
130
+ },
131
+ {
132
+ name: 'get_market_trades',
133
+ description: 'Get recent orders/trading activity for a prediction market.',
134
+ parameters: {
135
+ type: 'object',
136
+ properties: {
137
+ platform: {
138
+ type: 'string',
139
+ enum: ['polymarket', 'kalshi'],
140
+ description: 'The prediction market platform (default: polymarket)',
141
+ },
142
+ market_slug: {
143
+ type: 'string',
144
+ description: 'The market slug/identifier (ticker for Kalshi)',
145
+ },
146
+ limit: {
147
+ type: 'number',
148
+ description: 'Number of orders to return (max 100)',
149
+ default: 20,
150
+ },
151
+ },
152
+ required: ['market_slug'],
153
+ },
154
+ },
155
+ ],
156
+
157
+ executors: {
158
+ get_supported_platforms: async () => {
159
+ return {
160
+ platforms: [
161
+ {
162
+ id: 'polymarket',
163
+ name: 'Polymarket',
164
+ description: 'Decentralized prediction market on Polygon',
165
+ features: ['tags', 'volume_filtering'],
166
+ },
167
+ {
168
+ id: 'kalshi',
169
+ name: 'Kalshi',
170
+ description: 'CFTC-regulated prediction market exchange',
171
+ features: ['regulated', 'event_based'],
172
+ },
173
+ ],
174
+ };
175
+ },
176
+
177
+ search_prediction_markets: async (args) => {
178
+ const platform = (args.platform as Platform) || 'polymarket';
179
+ const params = new URLSearchParams();
180
+
181
+ if (args.limit) params.append('limit', String(args.limit));
182
+
183
+ if (platform === 'polymarket') {
184
+ if (args.tags) params.append('tags', (args.tags as string[]).join(','));
185
+ if (args.status) params.append('status', args.status as string);
186
+
187
+ const response = await fetch(`${DOME_API_BASE}/polymarket/markets?${params}`);
188
+
189
+ if (!response.ok) {
190
+ throw new Error(`Dome API error: ${response.status} ${response.statusText}`);
191
+ }
192
+
193
+ const data = await response.json();
194
+
195
+ return {
196
+ platform: 'polymarket',
197
+ markets: data.markets?.map((m: Record<string, unknown>) => ({
198
+ slug: m.market_slug,
199
+ title: m.title,
200
+ status: m.status,
201
+ volume: m.volume_total,
202
+ tags: m.tags,
203
+ outcomes: [
204
+ { label: (m.side_a as Record<string, unknown>)?.label, id: (m.side_a as Record<string, unknown>)?.id },
205
+ { label: (m.side_b as Record<string, unknown>)?.label, id: (m.side_b as Record<string, unknown>)?.id },
206
+ ],
207
+ winner: m.winning_side,
208
+ })) || [],
209
+ total: data.pagination?.total || 0,
210
+ hasMore: data.pagination?.has_more || false,
211
+ };
212
+ } else if (platform === 'kalshi') {
213
+ if (args.status) params.append('status', args.status as string);
214
+
215
+ const response = await fetch(`${DOME_API_BASE}/kalshi/markets?${params}`);
216
+
217
+ if (!response.ok) {
218
+ throw new Error(`Dome API error: ${response.status} ${response.statusText}`);
219
+ }
220
+
221
+ const data = await response.json();
222
+
223
+ return {
224
+ platform: 'kalshi',
225
+ markets: data.markets?.map((m: Record<string, unknown>) => ({
226
+ ticker: m.ticker,
227
+ title: m.title,
228
+ status: m.status,
229
+ category: m.category,
230
+ subtitle: m.subtitle,
231
+ yesAsk: m.yes_ask,
232
+ yesBid: m.yes_bid,
233
+ volume: m.volume,
234
+ })) || [],
235
+ total: data.pagination?.total || 0,
236
+ hasMore: data.pagination?.has_more || false,
237
+ };
238
+ }
239
+
240
+ throw new Error(`Unsupported platform: ${platform}`);
241
+ },
242
+
243
+ get_market_details: async (args) => {
244
+ const platform = (args.platform as Platform) || 'polymarket';
245
+
246
+ if (platform === 'polymarket') {
247
+ const response = await fetch(
248
+ `${DOME_API_BASE}/polymarket/markets?market_slug=${args.market_slug}`
249
+ );
250
+
251
+ if (!response.ok) {
252
+ throw new Error(`Dome API error: ${response.status} ${response.statusText}`);
253
+ }
254
+
255
+ const data = await response.json();
256
+ const market = data.markets?.[0];
257
+
258
+ if (!market) {
259
+ throw new Error(`Market not found: ${args.market_slug}`);
260
+ }
261
+
262
+ return {
263
+ platform: 'polymarket',
264
+ slug: market.market_slug,
265
+ title: market.title,
266
+ status: market.status,
267
+ startTime: market.start_time
268
+ ? new Date(market.start_time * 1000).toISOString()
269
+ : null,
270
+ endTime: market.end_time
271
+ ? new Date(market.end_time * 1000).toISOString()
272
+ : null,
273
+ volume: {
274
+ total: market.volume_total,
275
+ week: market.volume_1_week,
276
+ month: market.volume_1_month,
277
+ },
278
+ resolutionSource: market.resolution_source,
279
+ outcomes: [
280
+ { label: market.side_a?.label, id: market.side_a?.id },
281
+ { label: market.side_b?.label, id: market.side_b?.id },
282
+ ],
283
+ winner: market.winning_side,
284
+ tags: market.tags,
285
+ };
286
+ } else if (platform === 'kalshi') {
287
+ const response = await fetch(
288
+ `${DOME_API_BASE}/kalshi/markets?ticker=${args.market_slug}`
289
+ );
290
+
291
+ if (!response.ok) {
292
+ throw new Error(`Dome API error: ${response.status} ${response.statusText}`);
293
+ }
294
+
295
+ const data = await response.json();
296
+ const market = data.markets?.[0];
297
+
298
+ if (!market) {
299
+ throw new Error(`Market not found: ${args.market_slug}`);
300
+ }
301
+
302
+ return {
303
+ platform: 'kalshi',
304
+ ticker: market.ticker,
305
+ title: market.title,
306
+ subtitle: market.subtitle,
307
+ status: market.status,
308
+ category: market.category,
309
+ yesAsk: market.yes_ask,
310
+ yesBid: market.yes_bid,
311
+ volume: market.volume,
312
+ openInterest: market.open_interest,
313
+ };
314
+ }
315
+
316
+ throw new Error(`Unsupported platform: ${platform}`);
317
+ },
318
+
319
+ get_market_prices: async (args) => {
320
+ const platform = (args.platform as Platform) || 'polymarket';
321
+
322
+ if (platform === 'polymarket') {
323
+ const response = await fetch(
324
+ `${DOME_API_BASE}/polymarket/market-price?market_slug=${args.market_slug}`
325
+ );
326
+
327
+ if (!response.ok) {
328
+ throw new Error(`Dome API error: ${response.status} ${response.statusText}`);
329
+ }
330
+
331
+ const data = await response.json();
332
+ return { platform: 'polymarket', ...data };
333
+ } else if (platform === 'kalshi') {
334
+ // Kalshi prices are included in the market details
335
+ const response = await fetch(
336
+ `${DOME_API_BASE}/kalshi/markets?ticker=${args.market_slug}`
337
+ );
338
+
339
+ if (!response.ok) {
340
+ throw new Error(`Dome API error: ${response.status} ${response.statusText}`);
341
+ }
342
+
343
+ const data = await response.json();
344
+ const market = data.markets?.[0];
345
+
346
+ if (!market) {
347
+ throw new Error(`Market not found: ${args.market_slug}`);
348
+ }
349
+
350
+ return {
351
+ platform: 'kalshi',
352
+ ticker: market.ticker,
353
+ yesAsk: market.yes_ask,
354
+ yesBid: market.yes_bid,
355
+ lastPrice: market.last_price,
356
+ };
357
+ }
358
+
359
+ throw new Error(`Unsupported platform: ${platform}`);
360
+ },
361
+
362
+ get_market_trades: async (args) => {
363
+ const platform = (args.platform as Platform) || 'polymarket';
364
+ const limit = String(args.limit || 20);
365
+
366
+ if (platform === 'polymarket') {
367
+ const params = new URLSearchParams({
368
+ market_slug: args.market_slug as string,
369
+ limit,
370
+ });
371
+
372
+ const response = await fetch(
373
+ `${DOME_API_BASE}/polymarket/orders?${params}`
374
+ );
375
+
376
+ if (!response.ok) {
377
+ throw new Error(`Dome API error: ${response.status} ${response.statusText}`);
378
+ }
379
+
380
+ const data = await response.json();
381
+ return { platform: 'polymarket', ...data };
382
+ } else if (platform === 'kalshi') {
383
+ const params = new URLSearchParams({
384
+ ticker: args.market_slug as string,
385
+ limit,
386
+ });
387
+
388
+ const response = await fetch(
389
+ `${DOME_API_BASE}/kalshi/trades?${params}`
390
+ );
391
+
392
+ if (!response.ok) {
393
+ throw new Error(`Dome API error: ${response.status} ${response.statusText}`);
394
+ }
395
+
396
+ const data = await response.json();
397
+ return { platform: 'kalshi', ...data };
398
+ }
399
+
400
+ throw new Error(`Unsupported platform: ${platform}`);
401
+ },
402
+ },
403
+
404
+ hooks: {
405
+ onRegister: () => {
406
+ console.log('[Plugin] Prediction Market Alpha v1.1.0 registered (Polymarket + Kalshi)');
407
+ },
408
+ },
409
+ };
410
+
411
+ export default predictionMarketPlugin;