@emblemvault/hustle-react 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +225 -0
  2. package/dist/browser/hustle-react.js +14705 -0
  3. package/dist/browser/hustle-react.js.map +1 -0
  4. package/dist/components/index.cjs +3170 -0
  5. package/dist/components/index.cjs.map +1 -0
  6. package/dist/components/index.d.cts +58 -0
  7. package/dist/components/index.d.ts +58 -0
  8. package/dist/components/index.js +3143 -0
  9. package/dist/components/index.js.map +1 -0
  10. package/dist/hooks/index.cjs +695 -0
  11. package/dist/hooks/index.cjs.map +1 -0
  12. package/dist/hooks/index.d.cts +46 -0
  13. package/dist/hooks/index.d.ts +46 -0
  14. package/dist/hooks/index.js +691 -0
  15. package/dist/hooks/index.js.map +1 -0
  16. package/dist/hustle-S48t4lTZ.d.cts +222 -0
  17. package/dist/hustle-S48t4lTZ.d.ts +222 -0
  18. package/dist/index.cjs +3588 -0
  19. package/dist/index.cjs.map +1 -0
  20. package/dist/index.d.cts +229 -0
  21. package/dist/index.d.ts +229 -0
  22. package/dist/index.js +3547 -0
  23. package/dist/index.js.map +1 -0
  24. package/dist/plugin-BUg7vMxe.d.cts +172 -0
  25. package/dist/plugin-BUg7vMxe.d.ts +172 -0
  26. package/dist/plugins/index.cjs +1235 -0
  27. package/dist/plugins/index.cjs.map +1 -0
  28. package/dist/plugins/index.d.cts +192 -0
  29. package/dist/plugins/index.d.ts +192 -0
  30. package/dist/plugins/index.js +1225 -0
  31. package/dist/plugins/index.js.map +1 -0
  32. package/dist/providers/index.cjs +694 -0
  33. package/dist/providers/index.cjs.map +1 -0
  34. package/dist/providers/index.d.cts +46 -0
  35. package/dist/providers/index.d.ts +46 -0
  36. package/dist/providers/index.js +691 -0
  37. package/dist/providers/index.js.map +1 -0
  38. package/package.json +87 -0
@@ -0,0 +1,1225 @@
1
+ // src/plugins/predictionMarket.ts
2
+ var DOME_API_BASE = "https://api.domeapi.io/v1";
3
+ var predictionMarketPlugin = {
4
+ name: "prediction-market-alpha",
5
+ version: "1.1.0",
6
+ description: "Search and analyze prediction markets on Polymarket and Kalshi",
7
+ tools: [
8
+ {
9
+ name: "get_supported_platforms",
10
+ description: "Get a list of supported prediction market platforms. Call this first to know which platforms are available for querying.",
11
+ parameters: {
12
+ type: "object",
13
+ properties: {}
14
+ }
15
+ },
16
+ {
17
+ name: "search_prediction_markets",
18
+ description: "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.",
19
+ parameters: {
20
+ type: "object",
21
+ properties: {
22
+ platform: {
23
+ type: "string",
24
+ enum: ["polymarket", "kalshi"],
25
+ description: "The prediction market platform to search (default: polymarket)"
26
+ },
27
+ tags: {
28
+ type: "array",
29
+ items: { type: "string" },
30
+ description: 'REQUIRED: Single word categories or tags to identify a market segment (e.g., "politics", "crypto", "sports", "finance", "entertainment", "ai")'
31
+ },
32
+ status: {
33
+ type: "string",
34
+ enum: ["open", "closed"],
35
+ description: "Filter by market status"
36
+ },
37
+ limit: {
38
+ type: "number",
39
+ description: "Number of results (1-100)",
40
+ default: 10
41
+ }
42
+ },
43
+ required: ["tags"]
44
+ }
45
+ },
46
+ {
47
+ name: "get_market_details",
48
+ description: "Get detailed information about a specific prediction market including current prices, trading history, and resolution source.",
49
+ parameters: {
50
+ type: "object",
51
+ properties: {
52
+ platform: {
53
+ type: "string",
54
+ enum: ["polymarket", "kalshi"],
55
+ description: "The prediction market platform (default: polymarket)"
56
+ },
57
+ market_slug: {
58
+ type: "string",
59
+ description: "The market slug/identifier (ticker for Kalshi)"
60
+ }
61
+ },
62
+ required: ["market_slug"]
63
+ }
64
+ },
65
+ {
66
+ name: "get_market_prices",
67
+ description: "Get current prices/odds for a prediction market. Shows probability for each outcome.",
68
+ parameters: {
69
+ type: "object",
70
+ properties: {
71
+ platform: {
72
+ type: "string",
73
+ enum: ["polymarket", "kalshi"],
74
+ description: "The prediction market platform (default: polymarket)"
75
+ },
76
+ market_slug: {
77
+ type: "string",
78
+ description: "The market slug/identifier (ticker for Kalshi)"
79
+ }
80
+ },
81
+ required: ["market_slug"]
82
+ }
83
+ },
84
+ {
85
+ name: "get_market_trades",
86
+ description: "Get recent orders/trading activity for a prediction market.",
87
+ parameters: {
88
+ type: "object",
89
+ properties: {
90
+ platform: {
91
+ type: "string",
92
+ enum: ["polymarket", "kalshi"],
93
+ description: "The prediction market platform (default: polymarket)"
94
+ },
95
+ market_slug: {
96
+ type: "string",
97
+ description: "The market slug/identifier (ticker for Kalshi)"
98
+ },
99
+ limit: {
100
+ type: "number",
101
+ description: "Number of orders to return (max 100)",
102
+ default: 20
103
+ }
104
+ },
105
+ required: ["market_slug"]
106
+ }
107
+ }
108
+ ],
109
+ executors: {
110
+ get_supported_platforms: async () => {
111
+ return {
112
+ platforms: [
113
+ {
114
+ id: "polymarket",
115
+ name: "Polymarket",
116
+ description: "Decentralized prediction market on Polygon",
117
+ features: ["tags", "volume_filtering"]
118
+ },
119
+ {
120
+ id: "kalshi",
121
+ name: "Kalshi",
122
+ description: "CFTC-regulated prediction market exchange",
123
+ features: ["regulated", "event_based"]
124
+ }
125
+ ]
126
+ };
127
+ },
128
+ search_prediction_markets: async (args2) => {
129
+ const platform = args2.platform || "polymarket";
130
+ const params = new URLSearchParams();
131
+ if (args2.limit) params.append("limit", String(args2.limit));
132
+ if (platform === "polymarket") {
133
+ if (args2.tags) params.append("tags", args2.tags.join(","));
134
+ if (args2.status) params.append("status", args2.status);
135
+ const response = await fetch(`${DOME_API_BASE}/polymarket/markets?${params}`);
136
+ if (!response.ok) {
137
+ throw new Error(`Dome API error: ${response.status} ${response.statusText}`);
138
+ }
139
+ const data = await response.json();
140
+ return {
141
+ platform: "polymarket",
142
+ markets: data.markets?.map((m) => ({
143
+ slug: m.market_slug,
144
+ title: m.title,
145
+ status: m.status,
146
+ volume: m.volume_total,
147
+ tags: m.tags,
148
+ outcomes: [
149
+ { label: m.side_a?.label, id: m.side_a?.id },
150
+ { label: m.side_b?.label, id: m.side_b?.id }
151
+ ],
152
+ winner: m.winning_side
153
+ })) || [],
154
+ total: data.pagination?.total || 0,
155
+ hasMore: data.pagination?.has_more || false
156
+ };
157
+ } else if (platform === "kalshi") {
158
+ if (args2.status) params.append("status", args2.status);
159
+ const response = await fetch(`${DOME_API_BASE}/kalshi/markets?${params}`);
160
+ if (!response.ok) {
161
+ throw new Error(`Dome API error: ${response.status} ${response.statusText}`);
162
+ }
163
+ const data = await response.json();
164
+ return {
165
+ platform: "kalshi",
166
+ markets: data.markets?.map((m) => ({
167
+ ticker: m.ticker,
168
+ title: m.title,
169
+ status: m.status,
170
+ category: m.category,
171
+ subtitle: m.subtitle,
172
+ yesAsk: m.yes_ask,
173
+ yesBid: m.yes_bid,
174
+ volume: m.volume
175
+ })) || [],
176
+ total: data.pagination?.total || 0,
177
+ hasMore: data.pagination?.has_more || false
178
+ };
179
+ }
180
+ throw new Error(`Unsupported platform: ${platform}`);
181
+ },
182
+ get_market_details: async (args2) => {
183
+ const platform = args2.platform || "polymarket";
184
+ if (platform === "polymarket") {
185
+ const response = await fetch(
186
+ `${DOME_API_BASE}/polymarket/markets?market_slug=${args2.market_slug}`
187
+ );
188
+ if (!response.ok) {
189
+ throw new Error(`Dome API error: ${response.status} ${response.statusText}`);
190
+ }
191
+ const data = await response.json();
192
+ const market = data.markets?.[0];
193
+ if (!market) {
194
+ throw new Error(`Market not found: ${args2.market_slug}`);
195
+ }
196
+ return {
197
+ platform: "polymarket",
198
+ slug: market.market_slug,
199
+ title: market.title,
200
+ status: market.status,
201
+ startTime: market.start_time ? new Date(market.start_time * 1e3).toISOString() : null,
202
+ endTime: market.end_time ? new Date(market.end_time * 1e3).toISOString() : null,
203
+ volume: {
204
+ total: market.volume_total,
205
+ week: market.volume_1_week,
206
+ month: market.volume_1_month
207
+ },
208
+ resolutionSource: market.resolution_source,
209
+ outcomes: [
210
+ { label: market.side_a?.label, id: market.side_a?.id },
211
+ { label: market.side_b?.label, id: market.side_b?.id }
212
+ ],
213
+ winner: market.winning_side,
214
+ tags: market.tags
215
+ };
216
+ } else if (platform === "kalshi") {
217
+ const response = await fetch(
218
+ `${DOME_API_BASE}/kalshi/markets?ticker=${args2.market_slug}`
219
+ );
220
+ if (!response.ok) {
221
+ throw new Error(`Dome API error: ${response.status} ${response.statusText}`);
222
+ }
223
+ const data = await response.json();
224
+ const market = data.markets?.[0];
225
+ if (!market) {
226
+ throw new Error(`Market not found: ${args2.market_slug}`);
227
+ }
228
+ return {
229
+ platform: "kalshi",
230
+ ticker: market.ticker,
231
+ title: market.title,
232
+ subtitle: market.subtitle,
233
+ status: market.status,
234
+ category: market.category,
235
+ yesAsk: market.yes_ask,
236
+ yesBid: market.yes_bid,
237
+ volume: market.volume,
238
+ openInterest: market.open_interest
239
+ };
240
+ }
241
+ throw new Error(`Unsupported platform: ${platform}`);
242
+ },
243
+ get_market_prices: async (args2) => {
244
+ const platform = args2.platform || "polymarket";
245
+ if (platform === "polymarket") {
246
+ const response = await fetch(
247
+ `${DOME_API_BASE}/polymarket/market-price?market_slug=${args2.market_slug}`
248
+ );
249
+ if (!response.ok) {
250
+ throw new Error(`Dome API error: ${response.status} ${response.statusText}`);
251
+ }
252
+ const data = await response.json();
253
+ return { platform: "polymarket", ...data };
254
+ } else if (platform === "kalshi") {
255
+ const response = await fetch(
256
+ `${DOME_API_BASE}/kalshi/markets?ticker=${args2.market_slug}`
257
+ );
258
+ if (!response.ok) {
259
+ throw new Error(`Dome API error: ${response.status} ${response.statusText}`);
260
+ }
261
+ const data = await response.json();
262
+ const market = data.markets?.[0];
263
+ if (!market) {
264
+ throw new Error(`Market not found: ${args2.market_slug}`);
265
+ }
266
+ return {
267
+ platform: "kalshi",
268
+ ticker: market.ticker,
269
+ yesAsk: market.yes_ask,
270
+ yesBid: market.yes_bid,
271
+ lastPrice: market.last_price
272
+ };
273
+ }
274
+ throw new Error(`Unsupported platform: ${platform}`);
275
+ },
276
+ get_market_trades: async (args2) => {
277
+ const platform = args2.platform || "polymarket";
278
+ const limit = String(args2.limit || 20);
279
+ if (platform === "polymarket") {
280
+ const params = new URLSearchParams({
281
+ market_slug: args2.market_slug,
282
+ limit
283
+ });
284
+ const response = await fetch(
285
+ `${DOME_API_BASE}/polymarket/orders?${params}`
286
+ );
287
+ if (!response.ok) {
288
+ throw new Error(`Dome API error: ${response.status} ${response.statusText}`);
289
+ }
290
+ const data = await response.json();
291
+ return { platform: "polymarket", ...data };
292
+ } else if (platform === "kalshi") {
293
+ const params = new URLSearchParams({
294
+ ticker: args2.market_slug,
295
+ limit
296
+ });
297
+ const response = await fetch(
298
+ `${DOME_API_BASE}/kalshi/trades?${params}`
299
+ );
300
+ if (!response.ok) {
301
+ throw new Error(`Dome API error: ${response.status} ${response.statusText}`);
302
+ }
303
+ const data = await response.json();
304
+ return { platform: "kalshi", ...data };
305
+ }
306
+ throw new Error(`Unsupported platform: ${platform}`);
307
+ }
308
+ },
309
+ hooks: {
310
+ onRegister: () => {
311
+ console.log("[Plugin] Prediction Market Alpha v1.1.0 registered (Polymarket + Kalshi)");
312
+ }
313
+ }
314
+ };
315
+
316
+ // src/plugins/migrateFun.ts
317
+ var QA = [
318
+ { id: "migration-steps-bonk", question: "What are all the steps for migrations to Bonk?", answer: `Here's how MigrateFun migrates your token to BonkFun:
319
+ 1) The creator/team sets up a migration portal through migratefun - Create new CA for BonkFun (Ticker, name, image, supply) and set timeline period (1-30 days, 14 days average)
320
+ 2) After portal setup, holders commit their tokens to migration - tokens are locked in migration vault until time period ends
321
+ 3) Once migration ends, ALL tokens are market sold in a single candle to retrieve as much SOL as possible from the locked liquidity pool
322
+ 4) The recovered SOL seeds the new LP paired with appropriate amount of tokens. Set market cap at or slightly below current market cap
323
+ 5) Claims open for 90 days - users burn MFTs and receive new tokens`, keywords: ["bonk", "bonkfun", "steps", "process", "how"], category: "process" },
324
+ { id: "migration-steps-pumpfun", question: "How does a migration work to Pump Fun?", answer: `Here's how the migration to Pump Fun works:
325
+ 1) Set up a new CA for pumpfun using MigrateFun creator dashboard (Ticker, CA, image)
326
+ 2) Users migrate their tokens in the migration portal for a specific time period
327
+ 3) Once migration ends, MigrateFun sells all migrated tokens
328
+ 4) MigrateFun takes all recovered SOL and buys out new token's bonding curve + purchases until it reaches old market cap levels
329
+ 5) Users return to migratefun and claim their new tokens
330
+ 6) 90-day claim period for all users, regardless if they migrated on time or late
331
+ 7) The claim period can also be used to swap tokens with centralized exchanges
332
+ 8) After 90 days, all unclaimed tokens and remaining SOL are returned to the team`, keywords: ["pump", "pumpfun", "steps", "process", "how"], category: "process" },
333
+ { id: "migration-steps-raydium", question: "How does Migrate Fun migrate tokens to Raydium?", answer: `1) The creator/team sets up a migration portal through migratefun.com - Create new CA (Ticker, name, image, supply) and set timeline period (1-30 days, 14 days average)
334
+ 2) After portal setup, holders commit their tokens to migration and get MFTs in exchange - tokens are locked in migration vault until time period ends
335
+ 3) Once migration ends, ALL old tokens are market sold in a single candle to retrieve as much SOL as possible
336
+ 4) The recovered SOL seeds the new LP paired with appropriate amount of new tokens. Market Cap is set by the user
337
+ 5) Claims open for 90 days - users burn MFTs and receive new tokens. Late migrators can swap at discounted rate
338
+ 6) At the end of the 90 day claim window all remaining tokens can be claimed by the team`, keywords: ["raydium", "steps", "process", "how"], category: "process" },
339
+ { id: "post-migration-checklist", question: "What are the steps I need to do after the migration?", answer: `Admin Checklist - places to register your new CA:
340
+
341
+ PRIMARY:
342
+ - Coingecko (Free + migration application process)
343
+ - Dexscreener ($300)
344
+ - GeckoTerminal (free for 5 days wait)
345
+ - Holderscan (Listing free, Verify $125)
346
+
347
+ SECONDARY:
348
+ - Solscan (if metadata updates needed)
349
+ - CoinMarketCap ($5000 for immediate listing)
350
+ - Dextools ($300 for verification)
351
+ - Photon (2 SOL)
352
+ - Cookie.fun (Free, DM needed) [For AI accounts]
353
+ - Kaito (DM needed) [For AI accounts]
354
+
355
+ Note: Coingecko and CoinMarketCap will ask for a post from official twitter with migration details and new CA.`, keywords: ["after", "post", "checklist", "listing", "dexscreener", "coingecko"], category: "post-migration" },
356
+ { id: "post-migration-approval", question: "Do we need to do anything after the migration ends?", answer: `Yes, the team needs to approve several steps in the migration portal including:
357
+ 1) Selling the migrated tokens into the old LP
358
+ 2) Setting the new market cap
359
+ 3) Opening the claim portal
360
+
361
+ Video tutorial: https://www.youtube.com/watch?v=SjPN-1DnXtM`, keywords: ["after", "ends", "approve", "portal"], category: "post-migration" },
362
+ { id: "market-cap-setting", question: "What market cap should we set?", answer: `Set at or slightly below the ending market cap at migration. For example, if your ending market cap is $1 million, set it to around $950,000. This accounts for the fact you won't receive 1:1 liquidity from the old pool compared to the new pool, which is determined by migration participation.`, keywords: ["market cap", "marketcap", "set", "recommend"], category: "settings" },
363
+ { id: "migrate-fun-cost", question: "What does Migrate Fun cost?", answer: `Migrate Fun charges a flat 3.75% fee on the total SOL unlocked from the old Liquidity Pool. This fee is taken automatically during the migration process.`, keywords: ["cost", "fee", "price", "charge", "3.75", "percent"], category: "fees" },
364
+ { id: "claim-fees-bonk", question: "How does the team claim their fees on Bonk Fun?", answer: `Go to https://bonk.fun/creator-rewards to claim your creator fees.`, keywords: ["claim", "fees", "bonk", "creator", "rewards"], category: "fees" },
365
+ { id: "claim-fees-raydium", question: "How do I claim fees on Raydium?", answer: `You can claim fees from https://raydium.io/portfolio/ with the same wallet that set up the migration.`, keywords: ["claim", "fees", "raydium", "portfolio"], category: "fees" },
366
+ { id: "claim-fees-pumpfun", question: "How do I claim fees on Pump Fun?", answer: `Fees are paid automatically to the wallet used to set up the migration. Once migrated to PumpSwap you will receive creator rewards based on their Ascend Program. Details: https://pump.fun/docs/fees`, keywords: ["claim", "fees", "pump", "pumpfun", "automatic"], category: "fees" },
367
+ { id: "audit-info", question: "Has Migrate Fun been audited?", answer: `Yes. Migrate Fun was audited by Halborn, the same auditing firm used by the Solana Foundation.
368
+ Audit: https://www.halborn.com/audits/emblem-vault/migratefun-8ad34b
369
+ Announcement: https://x.com/HalbornSecurity/status/1978869642744811933`, keywords: ["audit", "audited", "security", "halborn", "safe"], category: "security" },
370
+ { id: "user-experience", question: "What is the process like for the user?", answer: `Super easy - takes less than 20 seconds.
371
+ 1) During migration: users swap old tokens for Migrate Fun Tokens (MFTs)
372
+ 2) Once migration ends: claim period opens for 90 days, users burn MFTs to claim new tokens
373
+ 3) Late migrators: can swap old tokens for new at a discounted rate set by the team
374
+
375
+ Video guides:
376
+ - Migration: https://x.com/MigrateFun/status/1971259552856408433
377
+ - Claims: https://x.com/MigrateFun/status/1976376597906325767`, keywords: ["user", "experience", "process", "simple", "easy"], category: "user-experience" },
378
+ { id: "what-is-migrate-fun", question: "What is Migrate Fun?", answer: `Migrate Fun is the category-defining platform that created the migration meta. It allows users to migrate locked liquidity from one launchpad to another.
379
+
380
+ As of October 2025: 15 migrations completed, $5+ million in liquidity moved, largest migration was $35M market cap project. Supports migrations to Bonk Fun, Raydium, and Pump Fun.
381
+
382
+ Links:
383
+ - Website: https://migrate.fun/
384
+ - X: https://x.com/MigrateFun
385
+ - Docs: https://github.com/EmblemCompany/Migrate-fun-docs/
386
+ - Audit: https://www.halborn.com/audits/emblem-vault/migratefun-8ad34b
387
+ - Calculator: https://migrate.fun/migration-calculator`, keywords: ["what", "migrate fun", "about", "general", "overview"], category: "general" },
388
+ { id: "sol-recovery-estimate", question: "How can I see how much SOL we can get from the old LP?", answer: `Use the migration calculator to estimate SOL recovery based on participation percentages: https://migrate.fun/migration-calculator`, keywords: ["sol", "recovery", "estimate", "calculator", "liquidity", "how much"], category: "tools" },
389
+ { id: "documentation", question: "Do you have documentation?", answer: `Yes, documentation is available at: https://github.com/EmblemCompany/Migrate-fun-docs/`, keywords: ["documentation", "docs", "guide", "help"], category: "general" },
390
+ { id: "rebrand", question: "What if I want to rebrand?", answer: `The migration enables a full rebrand - reset metadata, image, logo, name, everything. Or keep it all the same if you prefer.`, keywords: ["rebrand", "change", "name", "logo", "image", "metadata"], category: "features" },
391
+ { id: "sniper-protection", question: "How do you prevent snipers when migrating to Pump Fun?", answer: `On Solana you can stack transactions. When deploying the bonding curve, you are first to purchase so you can buyout the bonding curve and more in the first transaction, preventing snipers.`, keywords: ["sniper", "snipers", "protection", "front-run", "mev"], category: "security" },
392
+ { id: "claim-period-flexibility", question: "Is there flexibility on the 90 day claim period?", answer: `The 90-day claim period is mandatory. Reasons:
393
+ - All users need time to claim tokens after migration
394
+ - Those who missed migration need a window
395
+ - Users don't get tokens until after migration completes
396
+ - Allowing team to withdraw during claims would be risky (potential rug)`, keywords: ["90 day", "claim", "period", "flexibility", "change"], category: "settings" },
397
+ { id: "migration-duration", question: "How long is the migration?", answer: `You can set the migration window for as long as you'd like. Average is 14 days. Some teams choose 7 days (works great), some go up to 30 days.
398
+
399
+ Note: Majority of participation happens in the first and last 24 hours. Example: 76% participation with 50%+ migrating in first 24 hours and additional 10% on the last day.`, keywords: ["how long", "duration", "time", "days", "period", "window"], category: "settings" },
400
+ { id: "migration-performance", question: "Can you give examples of token performance after migration?", answer: `Migration squeeze: When large percentage of old tokens migrate, sell pressure reduces, often causing market cap spike near migration end.
401
+
402
+ Example charts:
403
+ - ZERA Old: https://dexscreener.com/solana/95at5r4i85gfqeew2yr6byfg8rlry1d9ztps7qrskdvc
404
+ New: https://dexscreener.com/solana/nn9vmhjtqgg9l9f8sp3geufwc5zvuhradcwehh7n7di
405
+ - HUSTLE Old: https://dexscreener.com/solana/gjckb2eesjk65nuvpaw4tn2rabnr8wmfcwcwpagk5dzs
406
+ New: https://dexscreener.com/solana/hxo1wrcrdewek8l2j6rxswnolumej2mweh38gajxtw7y
407
+
408
+ Thread: https://x.com/jakegallen_/status/1973051293213028468`, keywords: ["performance", "charts", "example", "before", "after", "squeeze"], category: "examples" },
409
+ { id: "why-migrate", question: "Why would teams want to migrate?", answer: `Top reasons:
410
+ - Access to creator rewards
411
+ - Rebrand opportunity
412
+ - Fresh chart
413
+ - Reclaim part of the token supply
414
+ - Reinvigorated community on the other side`, keywords: ["why", "reasons", "benefits", "advantages", "should"], category: "general" },
415
+ { id: "migration-recommendation-steps", question: "What steps do you recommend when considering a migration?", answer: `1) Discuss with Migrate Fun team: process details, where to move LP (Raydium, Bonk Fun, or Pump Fun)
416
+ 2) Discuss benefits with your community, especially whale holders - get buy-in
417
+ 3) Announce on all social channels - maximize awareness for maximum participation`, keywords: ["recommend", "steps", "considering", "planning", "prepare"], category: "process" },
418
+ { id: "multiple-wallets", question: "Do holders with multiple wallets need to consolidate?", answer: `No. Migration is linear - users can migrate all tokens together or separately. Makes no difference.`, keywords: ["multiple", "wallets", "consolidate", "separate"], category: "user-experience" },
419
+ { id: "mft-value", question: "Do MFTs show value in wallets?", answer: `MFTs (Migrate Fun Tokens) are just placeholder tokens for the migration. They are valueless.`, keywords: ["mft", "migrate fun tokens", "value", "placeholder"], category: "user-experience" },
420
+ { id: "announcement-examples", question: "Can you give me sample migration announcements?", answer: `Here are announcements made by teams:
421
+ - https://x.com/radrdotfun/status/1952127168101949620
422
+ - https://x.com/project_89/status/1951345024656089368
423
+ - https://x.com/HKittyOnSol/status/1948925330032349210
424
+ - https://x.com/ModernStoicAI/status/1948129627362218483
425
+ - https://x.com/pokithehamster/status/1950238636928327927
426
+ - https://x.com/IQ6900_/status/1953002036599173499
427
+ - https://x.com/TheBongoCat/status/1965538945132843333`, keywords: ["announcement", "sample", "example", "post", "twitter"], category: "examples" },
428
+ { id: "graphics", question: "Does Migrate Fun provide graphics for announcements?", answer: `No. For your own migration announcement you create the graphic. Migrate Fun's designer creates group migration announcements only.`, keywords: ["graphics", "images", "design", "announcement"], category: "general" },
429
+ { id: "developer-required", question: "Do I need to be a developer to migrate?", answer: `No development required. The entire process is a few clicks for both pre-migration and post-migration.`, keywords: ["developer", "technical", "coding", "code"], category: "general" },
430
+ { id: "exchange-tokens", question: "What happens to tokens on exchanges or locked in Streamflow?", answer: `They will miss the migration as those tokens are considered circulating supply onchain. Options:
431
+ 1) Join as late migrator during 90-day claim window
432
+ 2) After 90-day period, team takes possession of unclaimed tokens and can reimburse directly`, keywords: ["exchange", "streamflow", "locked", "vested", "cex"], category: "edge-cases" },
433
+ { id: "unclaimed-tokens", question: "Can we get unclaimed tokens?", answer: `After the 90-day claim period ends, all unclaimed tokens are returned to whichever wallet set up the migration (the team).`, keywords: ["unclaimed", "supply", "remaining", "tokens", "team"], category: "post-migration" },
434
+ { id: "participation-rate", question: "What is typical participation percentage?", answer: `Nearly all projects have had over 50% migration participation. View all stats at https://migrate.fun/projects`, keywords: ["participation", "percentage", "rate", "typical", "average"], category: "statistics" },
435
+ { id: "late-penalty", question: "What penalty can teams set for late migrators?", answer: `Teams can set 0-100% penalty for late migrators who swap during the 90-day claim window. 25% seems to be a good balance - encourages participation without being overly punishing.`, keywords: ["penalty", "late", "discount", "punish", "percent"], category: "settings" },
436
+ { id: "new-ca", question: "Will we get a new CA or just change the pair?", answer: `A new CA. If migrating to Bonk Fun your CA will end with "bonk". If migrating to Pump Fun it will end with "pump".`, keywords: ["ca", "contract", "address", "new", "pair"], category: "process" },
437
+ { id: "vanity-ca", question: "Can we create a vanity CA?", answer: `Yes, but if migrating to Bonk Fun it needs to end with "bonk", or for Pump Fun it needs to end with "pump".`, keywords: ["vanity", "ca", "custom", "address", "contract"], category: "features" },
438
+ { id: "vested-tokens", question: "What about team tokens locked with Streamflow?", answer: `Those tokens can't be migrated. They won't be lost - you'll recapture that supply post-migration. Any unmigrated tokens return to team at full or discounted rate depending on your late migrator penalty setting.`, keywords: ["vested", "streamflow", "locked", "team"], category: "edge-cases" },
439
+ { id: "wallet-tracking", question: "Can I track wallet addresses post-migration?", answer: `At the end of migration, there's a snapshot tool that lets you download a CSV of all wallets holding the old token.`, keywords: ["wallet", "track", "snapshot", "csv", "addresses"], category: "tools" },
440
+ { id: "old-listings", question: "What happens to old token listings?", answer: `You will need to apply to new directories. Migrate Fun provides a list once you begin the migration process.`, keywords: ["listings", "directories", "old", "new", "update"], category: "post-migration" },
441
+ { id: "lp-locking", question: "Does the new LP get locked?", answer: `If migrating to Bonk Fun or Pump Fun: LP is locked (their rules). If migrating to Raydium: LP is unlocked and you control it.`, keywords: ["lp", "locked", "liquidity", "pool", "control"], category: "process" },
442
+ { id: "sol-pairs", question: "Are Bonk migrations confined to SOL pairs?", answer: `As of October 2025, they are SOL migrations. Check with the team to see if USD1 pairs are possible.`, keywords: ["sol", "pair", "usd1", "usdc", "bonk"], category: "settings" },
443
+ { id: "change-penalty", question: "Can I change the penalty after setup?", answer: `No. The penalty must be set during migration creation and cannot be changed after.`, keywords: ["change", "penalty", "modify", "update", "after"], category: "settings" },
444
+ { id: "unhappy-holders", question: "What if someone is unhappy about the migration?", answer: `They can sell their tokens and not participate. Migrations are a fresh start - holders who migrate are voting with their tokens that they support the team and believe in the project's future.`, keywords: ["unhappy", "disagree", "against", "sell"], category: "user-experience" },
445
+ { id: "sample-announcement", question: "What is a good announcement template?", answer: `Sample for Bonk Fun migration:
446
+
447
+ "We're excited to announce that we're migrating with @MigrateFun and officially joining the @bonk_inu ecosystem next month!
448
+
449
+ With our 1-year anniversary less than a month away, this migration to @bonk_fun marks the beginning of our next chapter.
450
+
451
+ Why Bonk Fun?
452
+ \u{1F9F0} Purpose-built tools for community projects
453
+ \u{1F4B8} Transaction fee rev share
454
+ \u{1F501} Seamless LP migration
455
+ \u{1F91D} Strategic alignment with top meme coin teams
456
+
457
+ Our migration timeline + holder instructions drop soon."`, keywords: ["announcement", "template", "sample", "post"], category: "examples" },
458
+ { id: "share-link", question: "Do you have a link to share explaining Migrate Fun?", answer: `Overview thread: https://x.com/migratefun/status/1957492884355314035
459
+ Deep dive docs: https://github.com/EmblemCompany/Migrate-fun-docs/`, keywords: ["link", "share", "explain", "overview"], category: "general" },
460
+ { id: "exchange-rate", question: "Is the exchange rate always 1:1?", answer: `Yes, 1 old token = 1 new token for users who participate in migration. Users who miss can swap during the 90-day claim window at a discounted rate set by the team.`, keywords: ["exchange", "rate", "1:1", "ratio", "same"], category: "process" },
461
+ { id: "change-supply", question: "Can I change the total supply?", answer: `Generally yes, with some constraints depending on destination platform. Reach out to Migrate Fun team to discuss specifics.`, keywords: ["supply", "change", "total", "amount"], category: "features" },
462
+ { id: "contact", question: "How can I get in touch with the Migrate Fun team?", answer: `Send a direct message to the Migrate Fun X account: https://x.com/MigrateFun`, keywords: ["contact", "reach", "touch", "dm", "message", "talk"], category: "general" },
463
+ { id: "ready-to-migrate", question: "I am ready to migrate, what is next?", answer: `Send a direct message to the Migrate Fun X account: https://x.com/MigrateFun`, keywords: ["ready", "start", "begin", "next"], category: "general" },
464
+ { id: "risks", question: "What are the risks of migrating?", answer: `Main risk: Failed migration where not enough tokens migrate to fund the new LP. In that case, migrated tokens are sold into the old LP and SOL is returned to community members who participated.`, keywords: ["risk", "danger", "fail", "problem", "issue"], category: "security" },
465
+ { id: "how-detect-non-migrators", question: "How does Migrate Fun know who did not migrate?", answer: `Migrate Fun has a snapshot and claim tool that puts onchain all wallets holding old tokens at migration end. This enables late migrators to swap old tokens for new during the 90-day claim window at the team-set discount.`, keywords: ["snapshot", "detect", "know", "non-migrators"], category: "tools" },
466
+ { id: "no-penalty", question: "What if I do not want to penalize non-migrators?", answer: `Set the late claim penalty to zero. Holders who didn't migrate can then swap old tokens for new at a 1:1 rate during the 90-day claim window.`, keywords: ["no penalty", "zero", "fair"], category: "settings" },
467
+ { id: "missed-claim-window", question: "What happens if holders miss both migration and claim window?", answer: `They won't have access to new tokens through Migrate Fun platform. All remaining tokens go to the team after 90-day window closes. The team has a snapshot of all old token holders and can handle at their discretion.`, keywords: ["missed", "both", "claim", "window", "late"], category: "edge-cases" },
468
+ { id: "exchange-options", question: "What options do exchanges have to swap tokens?", answer: `Two options:
469
+
470
+ Option 1: Participate onchain through the migration portal (same as retail). Load tokens into Phantom wallet, migrate, then claim. ~10 seconds each step.
471
+
472
+ Option 2: Admin withdraw function during 90-day claim period. Migration admin can withdraw new tokens from claims vault and manually swap with exchange.
473
+ - 90-day window for exchange procedures
474
+ - Exchange can observe migration complete before acting
475
+ - Can receive new tokens before sending old
476
+ - Can pause trading during process`, keywords: ["exchange", "cex", "swap", "options", "centralized"], category: "edge-cases" },
477
+ { id: "buy-prevent-dump", question: "Can we buy supply before migration to prevent dumping?", answer: `I would recommend buying now. There is no arb opportunity as you set the market cap of the new token.
478
+
479
+ To regain control of non-migrated tokens, you can penalize non-migrators. Example: If 60% migrate, 40% didn't. With a 50% penalty on non-migrators, you'd recoup 20% of total supply if everyone claimed.`, keywords: ["buy", "dump", "supply", "control", "arb"], category: "strategy" }
480
+ ];
481
+ var migrateFunPlugin = {
482
+ name: "migrate-fun-knowledge",
483
+ version: "1.0.0",
484
+ description: "Search Migrate.fun knowledge base for token migration answers",
485
+ tools: [
486
+ {
487
+ name: "search_migrate_fun_docs",
488
+ description: "Search the Migrate.fun knowledge base for answers about token migrations. Use this tool when users ask about: how migrations work (Bonk Fun, Pump Fun, Raydium), costs/fees/timelines, post-migration steps, user experience, technical details (LP, CA, penalties), or examples. Returns ranked Q&A pairs from real support conversations.",
489
+ parameters: {
490
+ type: "object",
491
+ properties: {
492
+ query: {
493
+ type: "string",
494
+ description: "The search query - user question or key terms about token migrations"
495
+ },
496
+ topK: {
497
+ type: "number",
498
+ description: "Number of results to return (default: 5, max: 10)"
499
+ }
500
+ },
501
+ required: ["query"]
502
+ }
503
+ }
504
+ ],
505
+ executors: {
506
+ search_migrate_fun_docs: async (args2) => {
507
+ const query = args2.query;
508
+ const topK = Math.min(Math.max(1, args2.topK || 5), 10);
509
+ const queryLower = query.toLowerCase();
510
+ const queryWords = queryLower.split(/\s+/).filter((w) => w.length > 2);
511
+ const scored = QA.map((qa) => {
512
+ let score = 0;
513
+ const questionLower = qa.question.toLowerCase();
514
+ const answerLower = qa.answer.toLowerCase();
515
+ const keywordsStr = qa.keywords.join(" ").toLowerCase();
516
+ const fullText = `${questionLower} ${answerLower} ${keywordsStr}`;
517
+ if (questionLower.includes(queryLower)) score += 15;
518
+ if (fullText.includes(queryLower)) score += 8;
519
+ for (const word of queryWords) {
520
+ if (qa.keywords.some((kw) => kw.toLowerCase().includes(word) || word.includes(kw.toLowerCase()))) {
521
+ score += 4;
522
+ }
523
+ if (questionLower.includes(word)) score += 3;
524
+ if (answerLower.includes(word)) score += 1;
525
+ }
526
+ return { ...qa, score };
527
+ });
528
+ const results = scored.filter((qa) => qa.score > 0).sort((a, b) => b.score - a.score).slice(0, topK).map((qa, i) => ({
529
+ rank: i + 1,
530
+ relevance: Math.round(qa.score / 30 * 100) / 100,
531
+ question: qa.question,
532
+ answer: qa.answer,
533
+ category: qa.category
534
+ }));
535
+ return {
536
+ success: true,
537
+ query,
538
+ resultCount: results.length,
539
+ results,
540
+ hint: results.length === 0 ? "No matches found. Suggest contacting @MigrateFun on X: https://x.com/MigrateFun" : "Use these Q&A pairs to answer. Include relevant links from the answers."
541
+ };
542
+ }
543
+ },
544
+ hooks: {
545
+ onRegister: () => {
546
+ console.log("[Plugin] Migrate.fun Knowledge Base v1.0.0 registered");
547
+ }
548
+ }
549
+ };
550
+
551
+ // src/plugins/piiProtection.ts
552
+ var TOKEN_MAP_KEY = "__piiTokenMaps";
553
+ var PERSISTENT_MAP_KEY = "__piiPersistentMap";
554
+ function getTokenMaps() {
555
+ const storage = typeof window !== "undefined" ? window : global;
556
+ if (!storage[TOKEN_MAP_KEY]) {
557
+ storage[TOKEN_MAP_KEY] = /* @__PURE__ */ new Map();
558
+ }
559
+ return storage[TOKEN_MAP_KEY];
560
+ }
561
+ function getPersistentMap() {
562
+ const storage = typeof window !== "undefined" ? window : global;
563
+ if (!storage[PERSISTENT_MAP_KEY]) {
564
+ storage[PERSISTENT_MAP_KEY] = {
565
+ piiToToken: /* @__PURE__ */ new Map(),
566
+ tokenToPii: /* @__PURE__ */ new Map(),
567
+ counter: { value: 0 }
568
+ };
569
+ }
570
+ return storage[PERSISTENT_MAP_KEY];
571
+ }
572
+ var piiProtectionPlugin = {
573
+ name: "pii-protection",
574
+ version: "1.0.0",
575
+ description: "Tokenizes PII before sending to AI, restores in responses",
576
+ tools: [],
577
+ executors: {},
578
+ hooks: {
579
+ onRegister: () => {
580
+ console.log("[PII Protection] Plugin registered - PII will be tokenized in requests");
581
+ },
582
+ beforeRequest: (request) => {
583
+ const maps = getTokenMaps();
584
+ const persistent = getPersistentMap();
585
+ const requestId = Date.now().toString();
586
+ const requestTokenMap = /* @__PURE__ */ new Map();
587
+ const tokenize = (text) => {
588
+ if (typeof text !== "string") return text;
589
+ return text.replace(/\b\d{3}-\d{2}-\d{4}\b/g, (match) => {
590
+ if (persistent.piiToToken.has(match)) {
591
+ const existingToken = persistent.piiToToken.get(match);
592
+ requestTokenMap.set(existingToken, match);
593
+ return existingToken;
594
+ }
595
+ const token = `{{SSN_${++persistent.counter.value}}}`;
596
+ persistent.piiToToken.set(match, token);
597
+ persistent.tokenToPii.set(token, match);
598
+ requestTokenMap.set(token, match);
599
+ return token;
600
+ }).replace(/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/gi, (match) => {
601
+ if (persistent.piiToToken.has(match)) {
602
+ const existingToken = persistent.piiToToken.get(match);
603
+ requestTokenMap.set(existingToken, match);
604
+ return existingToken;
605
+ }
606
+ const token = `{{EMAIL_${++persistent.counter.value}}}`;
607
+ persistent.piiToToken.set(match, token);
608
+ persistent.tokenToPii.set(token, match);
609
+ requestTokenMap.set(token, match);
610
+ return token;
611
+ }).replace(/\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}/g, (match) => {
612
+ if (persistent.piiToToken.has(match)) {
613
+ const existingToken = persistent.piiToToken.get(match);
614
+ requestTokenMap.set(existingToken, match);
615
+ return existingToken;
616
+ }
617
+ const token = `{{PHONE_${++persistent.counter.value}}}`;
618
+ persistent.piiToToken.set(match, token);
619
+ persistent.tokenToPii.set(token, match);
620
+ requestTokenMap.set(token, match);
621
+ return token;
622
+ }).replace(/\b\d{4}[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4}\b/g, (match) => {
623
+ if (persistent.piiToToken.has(match)) {
624
+ const existingToken = persistent.piiToToken.get(match);
625
+ requestTokenMap.set(existingToken, match);
626
+ return existingToken;
627
+ }
628
+ const token = `{{CARD_${++persistent.counter.value}}}`;
629
+ persistent.piiToToken.set(match, token);
630
+ persistent.tokenToPii.set(token, match);
631
+ requestTokenMap.set(token, match);
632
+ return token;
633
+ });
634
+ };
635
+ const anonymizedMessages = request.messages.map((msg) => ({
636
+ ...msg,
637
+ content: typeof msg.content === "string" ? tokenize(msg.content) : msg.content
638
+ }));
639
+ if (requestTokenMap.size > 0) {
640
+ maps.set(requestId, requestTokenMap);
641
+ console.log(`[PII Protection] Tokenized ${requestTokenMap.size} PII values`);
642
+ }
643
+ return { ...request, messages: anonymizedMessages };
644
+ },
645
+ afterResponse: (response) => {
646
+ const persistent = getPersistentMap();
647
+ if (typeof response.content === "string") {
648
+ let restored = response.content;
649
+ let restoredCount = 0;
650
+ for (const [token, original] of persistent.tokenToPii.entries()) {
651
+ if (restored.includes(token)) {
652
+ restored = restored.split(token).join(original);
653
+ restoredCount++;
654
+ }
655
+ }
656
+ if (restoredCount > 0) {
657
+ response.content = restored;
658
+ console.log(`[PII Protection] Restored ${restoredCount} PII values`);
659
+ }
660
+ }
661
+ }
662
+ }
663
+ };
664
+
665
+ // src/plugins/userQuestion.ts
666
+ function ensureModalStyles() {
667
+ if (typeof document === "undefined") return;
668
+ const styleId = "user-question-modal-styles";
669
+ if (document.getElementById(styleId)) return;
670
+ const styles = document.createElement("style");
671
+ styles.id = styleId;
672
+ styles.textContent = `
673
+ .user-question-overlay {
674
+ position: fixed;
675
+ top: 0;
676
+ left: 0;
677
+ right: 0;
678
+ bottom: 0;
679
+ background: rgba(0, 0, 0, 0.6);
680
+ display: flex;
681
+ align-items: center;
682
+ justify-content: center;
683
+ z-index: 10000;
684
+ animation: uqFadeIn 0.2s ease-out;
685
+ }
686
+
687
+ @keyframes uqFadeIn {
688
+ from { opacity: 0; }
689
+ to { opacity: 1; }
690
+ }
691
+
692
+ .user-question-modal {
693
+ background: #1a1a2e;
694
+ border: 1px solid #333;
695
+ border-radius: 12px;
696
+ padding: 24px;
697
+ max-width: 480px;
698
+ width: 90%;
699
+ box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
700
+ animation: uqSlideUp 0.2s ease-out;
701
+ }
702
+
703
+ @keyframes uqSlideUp {
704
+ from { transform: translateY(20px); opacity: 0; }
705
+ to { transform: translateY(0); opacity: 1; }
706
+ }
707
+
708
+ .user-question-title {
709
+ font-size: 18px;
710
+ font-weight: 600;
711
+ color: #fff;
712
+ margin: 0 0 16px 0;
713
+ }
714
+
715
+ .user-question-choices {
716
+ display: flex;
717
+ flex-direction: column;
718
+ gap: 8px;
719
+ margin-bottom: 20px;
720
+ }
721
+
722
+ .user-question-choice {
723
+ display: flex;
724
+ align-items: center;
725
+ gap: 12px;
726
+ padding: 12px 16px;
727
+ background: #252540;
728
+ border: 1px solid #333;
729
+ border-radius: 8px;
730
+ cursor: pointer;
731
+ transition: all 0.15s ease;
732
+ }
733
+
734
+ .user-question-choice:hover {
735
+ background: #2a2a4a;
736
+ border-color: #4a4a6a;
737
+ }
738
+
739
+ .user-question-choice.selected {
740
+ background: #2a3a5a;
741
+ border-color: #4a7aff;
742
+ }
743
+
744
+ .user-question-choice input {
745
+ margin: 0;
746
+ accent-color: #4a7aff;
747
+ }
748
+
749
+ .user-question-choice label {
750
+ flex: 1;
751
+ color: #e0e0e0;
752
+ cursor: pointer;
753
+ font-size: 14px;
754
+ }
755
+
756
+ .user-question-actions {
757
+ display: flex;
758
+ gap: 12px;
759
+ justify-content: flex-end;
760
+ }
761
+
762
+ .user-question-btn {
763
+ padding: 10px 20px;
764
+ border-radius: 6px;
765
+ font-size: 14px;
766
+ font-weight: 500;
767
+ cursor: pointer;
768
+ transition: all 0.15s ease;
769
+ }
770
+
771
+ .user-question-btn-cancel {
772
+ background: transparent;
773
+ border: 1px solid #444;
774
+ color: #aaa;
775
+ }
776
+
777
+ .user-question-btn-cancel:hover {
778
+ background: #333;
779
+ color: #fff;
780
+ }
781
+
782
+ .user-question-btn-submit {
783
+ background: #4a7aff;
784
+ border: none;
785
+ color: #fff;
786
+ }
787
+
788
+ .user-question-btn-submit:hover {
789
+ background: #5a8aff;
790
+ }
791
+
792
+ .user-question-btn-submit:disabled {
793
+ background: #333;
794
+ color: #666;
795
+ cursor: not-allowed;
796
+ }
797
+ `;
798
+ document.head.appendChild(styles);
799
+ }
800
+ var askUserTool = {
801
+ name: "ask_user",
802
+ description: `Ask the user a multiple choice question and wait for their response. Use this when you need user input to proceed - for example: clarifying requirements, getting preferences, or confirming actions. The tool blocks until the user responds.`,
803
+ parameters: {
804
+ type: "object",
805
+ properties: {
806
+ question: {
807
+ type: "string",
808
+ description: "The question to ask the user"
809
+ },
810
+ choices: {
811
+ type: "array",
812
+ items: { type: "string" },
813
+ description: "Array of choices to present (2-6 options recommended)"
814
+ },
815
+ allowMultiple: {
816
+ type: "boolean",
817
+ description: "If true, user can select multiple choices. Default: false"
818
+ }
819
+ },
820
+ required: ["question", "choices"]
821
+ }
822
+ };
823
+ var askUserExecutor = async (args2) => {
824
+ const { question, choices, allowMultiple = false } = args2;
825
+ if (!question || !choices || !Array.isArray(choices) || choices.length === 0) {
826
+ return {
827
+ question: question || "",
828
+ selectedChoices: [],
829
+ answered: false
830
+ };
831
+ }
832
+ if (typeof document === "undefined") {
833
+ console.log(`[User Question] Question: ${question}`);
834
+ console.log(`[User Question] Choices: ${choices.join(", ")}`);
835
+ return {
836
+ question,
837
+ selectedChoices: [choices[0]],
838
+ answered: true
839
+ };
840
+ }
841
+ ensureModalStyles();
842
+ return new Promise((resolve) => {
843
+ const selected = /* @__PURE__ */ new Set();
844
+ const overlay = document.createElement("div");
845
+ overlay.className = "user-question-overlay";
846
+ const modal = document.createElement("div");
847
+ modal.className = "user-question-modal";
848
+ const title = document.createElement("h3");
849
+ title.className = "user-question-title";
850
+ title.textContent = question;
851
+ modal.appendChild(title);
852
+ const choicesDiv = document.createElement("div");
853
+ choicesDiv.className = "user-question-choices";
854
+ const inputType = allowMultiple ? "checkbox" : "radio";
855
+ const inputName = `uq-${Date.now()}`;
856
+ choices.forEach((choice, index) => {
857
+ const choiceDiv = document.createElement("div");
858
+ choiceDiv.className = "user-question-choice";
859
+ const input = document.createElement("input");
860
+ input.type = inputType;
861
+ input.name = inputName;
862
+ input.id = `${inputName}-${index}`;
863
+ input.value = choice;
864
+ const label = document.createElement("label");
865
+ label.htmlFor = input.id;
866
+ label.textContent = choice;
867
+ choiceDiv.appendChild(input);
868
+ choiceDiv.appendChild(label);
869
+ const handleSelect = () => {
870
+ if (allowMultiple) {
871
+ if (selected.has(choice)) {
872
+ selected.delete(choice);
873
+ choiceDiv.classList.remove("selected");
874
+ } else {
875
+ selected.add(choice);
876
+ choiceDiv.classList.add("selected");
877
+ }
878
+ } else {
879
+ selected.clear();
880
+ selected.add(choice);
881
+ choicesDiv.querySelectorAll(".user-question-choice").forEach((c) => c.classList.remove("selected"));
882
+ choiceDiv.classList.add("selected");
883
+ }
884
+ updateSubmitButton();
885
+ };
886
+ input.addEventListener("change", handleSelect);
887
+ choiceDiv.addEventListener("click", (e) => {
888
+ if (e.target !== input) {
889
+ input.checked = !input.checked || !allowMultiple;
890
+ handleSelect();
891
+ }
892
+ });
893
+ choicesDiv.appendChild(choiceDiv);
894
+ });
895
+ modal.appendChild(choicesDiv);
896
+ const actions = document.createElement("div");
897
+ actions.className = "user-question-actions";
898
+ const cancelBtn = document.createElement("button");
899
+ cancelBtn.className = "user-question-btn user-question-btn-cancel";
900
+ cancelBtn.textContent = "Skip";
901
+ cancelBtn.onclick = () => {
902
+ cleanup();
903
+ resolve({
904
+ question,
905
+ selectedChoices: [],
906
+ answered: false
907
+ });
908
+ };
909
+ const submitBtn = document.createElement("button");
910
+ submitBtn.className = "user-question-btn user-question-btn-submit";
911
+ submitBtn.textContent = "Submit";
912
+ submitBtn.disabled = true;
913
+ submitBtn.onclick = () => {
914
+ cleanup();
915
+ resolve({
916
+ question,
917
+ selectedChoices: Array.from(selected),
918
+ answered: true
919
+ });
920
+ };
921
+ const updateSubmitButton = () => {
922
+ submitBtn.disabled = selected.size === 0;
923
+ };
924
+ actions.appendChild(cancelBtn);
925
+ actions.appendChild(submitBtn);
926
+ modal.appendChild(actions);
927
+ overlay.appendChild(modal);
928
+ document.body.appendChild(overlay);
929
+ const cleanup = () => {
930
+ overlay.remove();
931
+ };
932
+ const handleEscape = (e) => {
933
+ if (e.key === "Escape") {
934
+ document.removeEventListener("keydown", handleEscape);
935
+ cleanup();
936
+ resolve({
937
+ question,
938
+ selectedChoices: [],
939
+ answered: false
940
+ });
941
+ }
942
+ };
943
+ document.addEventListener("keydown", handleEscape);
944
+ });
945
+ };
946
+ var userQuestionPlugin = {
947
+ name: "user-question",
948
+ version: "1.0.0",
949
+ description: "Allows AI to ask users multiple choice questions via modal",
950
+ tools: [askUserTool],
951
+ executors: {
952
+ ask_user: askUserExecutor
953
+ },
954
+ hooks: {
955
+ onRegister: () => {
956
+ console.log("[User Question] Plugin registered - AI can now ask you questions");
957
+ }
958
+ }
959
+ };
960
+
961
+ // src/plugins/alert.ts
962
+ var sendAlertTool = {
963
+ name: "send_alert",
964
+ description: "Display a browser alert popup with a message to the user",
965
+ parameters: {
966
+ type: "object",
967
+ properties: {
968
+ message: {
969
+ type: "string",
970
+ description: "The message to display in the alert popup"
971
+ }
972
+ },
973
+ required: ["message"]
974
+ }
975
+ };
976
+ var sendAlertExecutor = async (args2) => {
977
+ const message = args2.message;
978
+ if (typeof window === "undefined") {
979
+ console.log(`[Alert] ${message}`);
980
+ return { success: true, message, environment: "server" };
981
+ }
982
+ alert(message);
983
+ return { success: true, message };
984
+ };
985
+ var alertPlugin = {
986
+ name: "alert",
987
+ version: "1.0.0",
988
+ description: "Display browser alert popups",
989
+ tools: [sendAlertTool],
990
+ executors: {
991
+ send_alert: sendAlertExecutor
992
+ },
993
+ hooks: {
994
+ onRegister: () => {
995
+ console.log("[Alert] Plugin registered");
996
+ }
997
+ }
998
+ };
999
+
1000
+ // src/plugins/jsExecutor.ts
1001
+ var executeJsTool = {
1002
+ name: "execute_javascript",
1003
+ description: `Execute JavaScript code in the browser and return the results. The code runs in the page context with access to DOM, window, localStorage, etc.
1004
+
1005
+ IMPORTANT USAGE NOTES:
1006
+ - Use console.log() to output values that will be captured and returned
1007
+ - The last expression's value OR explicit return statement will be captured as 'returnValue'
1008
+ - All console.log calls are captured in the 'logs' array
1009
+ - For multi-line code, escape newlines or use semicolons: "const x = 1; const y = 2; console.log(x + y);"
1010
+ - Example: "const prices = [100, 200, 150]; const avg = prices.reduce((a,b) => a+b, 0) / prices.length; console.log('Average:', avg); return avg;"
1011
+ - Can access: document, window, localStorage, fetch, etc.`,
1012
+ parameters: {
1013
+ type: "object",
1014
+ properties: {
1015
+ code: {
1016
+ type: "string",
1017
+ description: "The JavaScript code to execute. Use console.log() for output and/or return a value."
1018
+ }
1019
+ },
1020
+ required: ["code"]
1021
+ }
1022
+ };
1023
+ var executeJsExecutor = async (args) => {
1024
+ const code = args.code;
1025
+ if (typeof window === "undefined") {
1026
+ return {
1027
+ success: false,
1028
+ returnValue: null,
1029
+ logs: [],
1030
+ error: { message: "JavaScript execution requires browser environment" }
1031
+ };
1032
+ }
1033
+ const logs = [];
1034
+ const originalLog = console.log;
1035
+ const originalWarn = console.warn;
1036
+ const originalError = console.error;
1037
+ console.log = (...logArgs) => {
1038
+ logs.push({
1039
+ type: "log",
1040
+ args: logArgs.map((a) => typeof a === "object" ? JSON.stringify(a) : String(a))
1041
+ });
1042
+ originalLog.apply(console, logArgs);
1043
+ };
1044
+ console.warn = (...logArgs) => {
1045
+ logs.push({
1046
+ type: "warn",
1047
+ args: logArgs.map((a) => typeof a === "object" ? JSON.stringify(a) : String(a))
1048
+ });
1049
+ originalWarn.apply(console, logArgs);
1050
+ };
1051
+ console.error = (...logArgs) => {
1052
+ logs.push({
1053
+ type: "error",
1054
+ args: logArgs.map((a) => typeof a === "object" ? JSON.stringify(a) : String(a))
1055
+ });
1056
+ originalError.apply(console, logArgs);
1057
+ };
1058
+ let returnValue;
1059
+ let error = null;
1060
+ try {
1061
+ const wrappedCode = "(async () => { " + code + " })()";
1062
+ returnValue = await eval(wrappedCode);
1063
+ } catch (e) {
1064
+ const err = e;
1065
+ error = { message: err.message, stack: err.stack };
1066
+ } finally {
1067
+ console.log = originalLog;
1068
+ console.warn = originalWarn;
1069
+ console.error = originalError;
1070
+ }
1071
+ return {
1072
+ success: !error,
1073
+ returnValue: returnValue !== void 0 ? typeof returnValue === "object" ? JSON.stringify(returnValue) : String(returnValue) : null,
1074
+ logs,
1075
+ error
1076
+ };
1077
+ };
1078
+ var jsExecutorPlugin = {
1079
+ name: "js-executor",
1080
+ version: "1.0.0",
1081
+ description: "Execute JavaScript code in the browser",
1082
+ tools: [executeJsTool],
1083
+ executors: {
1084
+ execute_javascript: executeJsExecutor
1085
+ },
1086
+ hooks: {
1087
+ onRegister: () => {
1088
+ console.log("[JS Executor] Plugin registered - AI can now execute JavaScript");
1089
+ }
1090
+ }
1091
+ };
1092
+
1093
+ // src/plugins/screenshot.ts
1094
+ var screenshotTool = {
1095
+ name: "take_screenshot",
1096
+ description: `Take a screenshot of the current page and upload it. Returns the URL of the uploaded image that can be used in conversation or for analysis.
1097
+
1098
+ The screenshot captures the visible viewport of the page. The image is uploaded to the server and a permanent URL is returned.
1099
+
1100
+ Use this when:
1101
+ - User asks to see what's on their screen
1102
+ - You need to analyze the current page visually
1103
+ - User wants to share/save the current view`,
1104
+ parameters: {
1105
+ type: "object",
1106
+ properties: {
1107
+ selector: {
1108
+ type: "string",
1109
+ description: "Optional CSS selector to capture a specific element instead of the full page. Leave empty for full page screenshot."
1110
+ }
1111
+ }
1112
+ }
1113
+ };
1114
+ var screenshotExecutor = async (args2) => {
1115
+ const selector = args2.selector;
1116
+ if (typeof window === "undefined" || typeof document === "undefined") {
1117
+ return {
1118
+ success: false,
1119
+ error: "Screenshot requires browser environment"
1120
+ };
1121
+ }
1122
+ try {
1123
+ if (!window.html2canvas) {
1124
+ await new Promise((resolve, reject) => {
1125
+ const script = document.createElement("script");
1126
+ script.src = "https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js";
1127
+ script.onload = () => resolve();
1128
+ script.onerror = () => reject(new Error("Failed to load html2canvas"));
1129
+ document.head.appendChild(script);
1130
+ });
1131
+ }
1132
+ const target = selector ? document.querySelector(selector) : document.body;
1133
+ if (!target) {
1134
+ return { success: false, error: "Element not found: " + selector };
1135
+ }
1136
+ const canvas = await window.html2canvas(target, {
1137
+ useCORS: true,
1138
+ allowTaint: true,
1139
+ backgroundColor: "#000000",
1140
+ scale: 1
1141
+ });
1142
+ const blob = await new Promise((resolve) => {
1143
+ canvas.toBlob(resolve, "image/png", 0.9);
1144
+ });
1145
+ if (!blob) {
1146
+ return { success: false, error: "Failed to create image blob" };
1147
+ }
1148
+ const formData = new FormData();
1149
+ formData.append("file", blob, "screenshot-" + Date.now() + ".png");
1150
+ const response = await fetch("/api/files/upload", {
1151
+ method: "POST",
1152
+ body: formData
1153
+ });
1154
+ if (!response.ok) {
1155
+ const errorData = await response.json().catch(() => ({}));
1156
+ return { success: false, error: errorData.error || "Upload failed" };
1157
+ }
1158
+ const data = await response.json();
1159
+ return {
1160
+ success: true,
1161
+ url: data.url,
1162
+ contentType: data.contentType,
1163
+ message: "Screenshot captured and uploaded successfully"
1164
+ };
1165
+ } catch (e) {
1166
+ const err = e;
1167
+ return {
1168
+ success: false,
1169
+ error: err.message || "Screenshot failed"
1170
+ };
1171
+ }
1172
+ };
1173
+ var screenshotPlugin = {
1174
+ name: "screenshot",
1175
+ version: "1.0.0",
1176
+ description: "Take screenshots of the current page",
1177
+ tools: [screenshotTool],
1178
+ executors: {
1179
+ take_screenshot: screenshotExecutor
1180
+ },
1181
+ hooks: {
1182
+ onRegister: () => {
1183
+ console.log("[Screenshot] Plugin registered - AI can now take screenshots");
1184
+ }
1185
+ }
1186
+ };
1187
+
1188
+ // src/plugins/index.ts
1189
+ var availablePlugins = [
1190
+ {
1191
+ ...predictionMarketPlugin,
1192
+ description: "Search and analyze Polymarket and Kalshi prediction markets"
1193
+ },
1194
+ {
1195
+ ...migrateFunPlugin,
1196
+ description: "Search Migrate.fun knowledge base for token migration answers"
1197
+ },
1198
+ {
1199
+ ...piiProtectionPlugin,
1200
+ description: "Tokenizes PII before sending to AI, restores in responses"
1201
+ },
1202
+ {
1203
+ ...userQuestionPlugin,
1204
+ description: "Allows AI to ask users multiple choice questions via modal"
1205
+ },
1206
+ {
1207
+ ...alertPlugin,
1208
+ description: "Display browser alert popups"
1209
+ },
1210
+ {
1211
+ ...jsExecutorPlugin,
1212
+ description: "Execute JavaScript code in the browser"
1213
+ },
1214
+ {
1215
+ ...screenshotPlugin,
1216
+ description: "Take screenshots of the current page"
1217
+ }
1218
+ ];
1219
+ function getAvailablePlugin(name) {
1220
+ return availablePlugins.find((p) => p.name === name);
1221
+ }
1222
+
1223
+ export { alertPlugin, availablePlugins, getAvailablePlugin, jsExecutorPlugin, migrateFunPlugin, piiProtectionPlugin, predictionMarketPlugin, screenshotPlugin, userQuestionPlugin };
1224
+ //# sourceMappingURL=index.js.map
1225
+ //# sourceMappingURL=index.js.map