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,3141 @@
1
+ 'use strict';
2
+
3
+ var react = require('react');
4
+ require('emblem-auth-sdk');
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+ require('hustle-incognito');
7
+ var marked = require('marked');
8
+ var hljs = require('highlight.js/lib/core');
9
+ var javascript = require('highlight.js/lib/languages/javascript');
10
+ var typescript = require('highlight.js/lib/languages/typescript');
11
+ var python = require('highlight.js/lib/languages/python');
12
+ var json = require('highlight.js/lib/languages/json');
13
+ var bash = require('highlight.js/lib/languages/bash');
14
+ var shell = require('highlight.js/lib/languages/shell');
15
+ var css = require('highlight.js/lib/languages/css');
16
+ var xml = require('highlight.js/lib/languages/xml');
17
+ var markdown = require('highlight.js/lib/languages/markdown');
18
+ var sql = require('highlight.js/lib/languages/sql');
19
+ var yaml = require('highlight.js/lib/languages/yaml');
20
+ var rust = require('highlight.js/lib/languages/rust');
21
+ var go = require('highlight.js/lib/languages/go');
22
+ var java = require('highlight.js/lib/languages/java');
23
+ var cpp = require('highlight.js/lib/languages/cpp');
24
+ var csharp = require('highlight.js/lib/languages/csharp');
25
+ var php = require('highlight.js/lib/languages/php');
26
+ var ruby = require('highlight.js/lib/languages/ruby');
27
+ var swift = require('highlight.js/lib/languages/swift');
28
+ var kotlin = require('highlight.js/lib/languages/kotlin');
29
+
30
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
31
+
32
+ var hljs__default = /*#__PURE__*/_interopDefault(hljs);
33
+ var javascript__default = /*#__PURE__*/_interopDefault(javascript);
34
+ var typescript__default = /*#__PURE__*/_interopDefault(typescript);
35
+ var python__default = /*#__PURE__*/_interopDefault(python);
36
+ var json__default = /*#__PURE__*/_interopDefault(json);
37
+ var bash__default = /*#__PURE__*/_interopDefault(bash);
38
+ var shell__default = /*#__PURE__*/_interopDefault(shell);
39
+ var css__default = /*#__PURE__*/_interopDefault(css);
40
+ var xml__default = /*#__PURE__*/_interopDefault(xml);
41
+ var markdown__default = /*#__PURE__*/_interopDefault(markdown);
42
+ var sql__default = /*#__PURE__*/_interopDefault(sql);
43
+ var yaml__default = /*#__PURE__*/_interopDefault(yaml);
44
+ var rust__default = /*#__PURE__*/_interopDefault(rust);
45
+ var go__default = /*#__PURE__*/_interopDefault(go);
46
+ var java__default = /*#__PURE__*/_interopDefault(java);
47
+ var cpp__default = /*#__PURE__*/_interopDefault(cpp);
48
+ var csharp__default = /*#__PURE__*/_interopDefault(csharp);
49
+ var php__default = /*#__PURE__*/_interopDefault(php);
50
+ var ruby__default = /*#__PURE__*/_interopDefault(ruby);
51
+ var swift__default = /*#__PURE__*/_interopDefault(swift);
52
+ var kotlin__default = /*#__PURE__*/_interopDefault(kotlin);
53
+
54
+ var EmblemAuthContext = react.createContext(void 0);
55
+ function useEmblemAuth() {
56
+ const context = react.useContext(EmblemAuthContext);
57
+ if (context === void 0) {
58
+ throw new Error("useEmblemAuth must be used within an EmblemAuthProvider");
59
+ }
60
+ return context;
61
+ }
62
+
63
+ // src/styles/tokens.ts
64
+ var defaults = {
65
+ colors: {
66
+ // Backgrounds
67
+ bgPrimary: "#0b0d10",
68
+ bgSecondary: "#12161b",
69
+ bgTertiary: "#1a1f25",
70
+ bgHover: "#252b33",
71
+ bgOverlay: "rgba(0, 0, 0, 0.7)",
72
+ // Borders
73
+ borderPrimary: "#222b35",
74
+ borderSecondary: "#333",
75
+ borderHover: "#444",
76
+ // Text
77
+ textPrimary: "#e6eef8",
78
+ textSecondary: "#8892a4",
79
+ textTertiary: "#6b7280",
80
+ textInverse: "#fff",
81
+ // Accent - Primary (blue)
82
+ accentPrimary: "#4c9aff",
83
+ accentPrimaryHover: "#7bb6ff",
84
+ accentPrimaryBg: "rgba(76, 154, 255, 0.1)",
85
+ // Accent - Success (green)
86
+ accentSuccess: "#10b981",
87
+ accentSuccessHover: "#34d399",
88
+ accentSuccessBg: "rgba(16, 185, 129, 0.1)",
89
+ // Accent - Warning (yellow/orange)
90
+ accentWarning: "#f59e0b",
91
+ accentWarningBg: "rgba(245, 158, 11, 0.1)",
92
+ // Accent - Error (red)
93
+ accentError: "#dc2626",
94
+ accentErrorHover: "#ef4444",
95
+ accentErrorBg: "rgba(239, 68, 68, 0.1)",
96
+ // Messages
97
+ msgUser: "#1e3a5f",
98
+ msgAssistant: "#1a2633"
99
+ },
100
+ typography: {
101
+ fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
102
+ fontFamilyMono: '"SF Mono", Monaco, monospace',
103
+ fontSizeXs: "11px",
104
+ fontSizeSm: "13px",
105
+ fontSizeMd: "14px",
106
+ fontSizeLg: "16px",
107
+ fontSizeXl: "18px",
108
+ fontWeightNormal: "400",
109
+ fontWeightMedium: "500",
110
+ fontWeightSemibold: "600",
111
+ lineHeightTight: "1.3",
112
+ lineHeightNormal: "1.5",
113
+ lineHeightRelaxed: "1.7"
114
+ },
115
+ spacing: {
116
+ xs: "4px",
117
+ sm: "8px",
118
+ md: "12px",
119
+ lg: "16px",
120
+ xl: "20px",
121
+ xxl: "24px"
122
+ },
123
+ radius: {
124
+ sm: "4px",
125
+ md: "6px",
126
+ lg: "8px",
127
+ xl: "12px",
128
+ pill: "20px",
129
+ full: "50%"
130
+ },
131
+ shadows: {
132
+ sm: "0 2px 8px rgba(0,0,0,0.2)",
133
+ md: "0 4px 16px rgba(0,0,0,0.3)",
134
+ lg: "0 8px 32px rgba(0,0,0,0.4)",
135
+ xl: "0 16px 48px rgba(0,0,0,0.5)"
136
+ },
137
+ // Glow effects (for enhanced themes)
138
+ glows: {
139
+ primary: "rgba(76, 154, 255, 0.4)",
140
+ success: "rgba(16, 185, 129, 0.4)",
141
+ error: "rgba(239, 68, 68, 0.4)",
142
+ ambient: "rgba(76, 154, 255, 0.08)"
143
+ },
144
+ transitions: {
145
+ fast: "0.15s ease",
146
+ normal: "0.2s ease",
147
+ slow: "0.3s ease"
148
+ },
149
+ zIndex: {
150
+ dropdown: "100",
151
+ modal: "1000",
152
+ fullscreen: "1000",
153
+ modalOverFullscreen: "10000"
154
+ }
155
+ };
156
+ function toVarName(category, key) {
157
+ const kebab = key.replace(/([A-Z])/g, "-$1").toLowerCase();
158
+ return `--hustle-${category}-${kebab}`;
159
+ }
160
+ function generateCSSVariables() {
161
+ const lines = [":root {"];
162
+ for (const [key, value] of Object.entries(defaults.colors)) {
163
+ lines.push(` ${toVarName("color", key)}: ${value};`);
164
+ }
165
+ for (const [key, value] of Object.entries(defaults.typography)) {
166
+ lines.push(` ${toVarName("font", key)}: ${value};`);
167
+ }
168
+ for (const [key, value] of Object.entries(defaults.spacing)) {
169
+ lines.push(` ${toVarName("space", key)}: ${value};`);
170
+ }
171
+ for (const [key, value] of Object.entries(defaults.radius)) {
172
+ lines.push(` ${toVarName("radius", key)}: ${value};`);
173
+ }
174
+ for (const [key, value] of Object.entries(defaults.shadows)) {
175
+ lines.push(` ${toVarName("shadow", key)}: ${value};`);
176
+ }
177
+ for (const [key, value] of Object.entries(defaults.glows)) {
178
+ lines.push(` ${toVarName("glow", key)}: ${value};`);
179
+ }
180
+ for (const [key, value] of Object.entries(defaults.transitions)) {
181
+ lines.push(` ${toVarName("transition", key)}: ${value};`);
182
+ }
183
+ for (const [key, value] of Object.entries(defaults.zIndex)) {
184
+ lines.push(` ${toVarName("z", key)}: ${value};`);
185
+ }
186
+ lines.push("}");
187
+ return lines.join("\n");
188
+ }
189
+ generateCSSVariables();
190
+ function createColorTokens() {
191
+ const result = {};
192
+ for (const [key, defaultValue] of Object.entries(defaults.colors)) {
193
+ result[key] = `var(${toVarName("color", key)}, ${defaultValue})`;
194
+ }
195
+ return result;
196
+ }
197
+ function createTypographyTokens() {
198
+ const result = {};
199
+ for (const [key, defaultValue] of Object.entries(defaults.typography)) {
200
+ result[key] = `var(${toVarName("font", key)}, ${defaultValue})`;
201
+ }
202
+ return result;
203
+ }
204
+ function createSpacingTokens() {
205
+ const result = {};
206
+ for (const [key, defaultValue] of Object.entries(defaults.spacing)) {
207
+ result[key] = `var(${toVarName("space", key)}, ${defaultValue})`;
208
+ }
209
+ return result;
210
+ }
211
+ function createRadiusTokens() {
212
+ const result = {};
213
+ for (const [key, defaultValue] of Object.entries(defaults.radius)) {
214
+ result[key] = `var(${toVarName("radius", key)}, ${defaultValue})`;
215
+ }
216
+ return result;
217
+ }
218
+ function createShadowTokens() {
219
+ const result = {};
220
+ for (const [key, defaultValue] of Object.entries(defaults.shadows)) {
221
+ result[key] = `var(${toVarName("shadow", key)}, ${defaultValue})`;
222
+ }
223
+ return result;
224
+ }
225
+ function createGlowTokens() {
226
+ const result = {};
227
+ for (const [key, defaultValue] of Object.entries(defaults.glows)) {
228
+ result[key] = `var(${toVarName("glow", key)}, ${defaultValue})`;
229
+ }
230
+ return result;
231
+ }
232
+ function createTransitionTokens() {
233
+ const result = {};
234
+ for (const [key, defaultValue] of Object.entries(defaults.transitions)) {
235
+ result[key] = `var(${toVarName("transition", key)}, ${defaultValue})`;
236
+ }
237
+ return result;
238
+ }
239
+ function createZIndexTokens() {
240
+ const result = {};
241
+ for (const [key, defaultValue] of Object.entries(defaults.zIndex)) {
242
+ result[key] = parseInt(defaultValue, 10);
243
+ }
244
+ return result;
245
+ }
246
+ var tokens = {
247
+ colors: createColorTokens(),
248
+ typography: createTypographyTokens(),
249
+ spacing: createSpacingTokens(),
250
+ radius: createRadiusTokens(),
251
+ shadows: createShadowTokens(),
252
+ glows: createGlowTokens(),
253
+ transitions: createTransitionTokens(),
254
+ zIndex: createZIndexTokens()
255
+ };
256
+ var presets = {
257
+ base: {
258
+ fontFamily: tokens.typography.fontFamily,
259
+ fontSize: tokens.typography.fontSizeMd,
260
+ lineHeight: tokens.typography.lineHeightNormal,
261
+ color: tokens.colors.textPrimary
262
+ },
263
+ card: {
264
+ background: tokens.colors.bgSecondary,
265
+ border: `1px solid ${tokens.colors.borderPrimary}`,
266
+ borderRadius: tokens.radius.xl
267
+ },
268
+ input: {
269
+ background: tokens.colors.bgTertiary,
270
+ border: `1px solid ${tokens.colors.borderSecondary}`,
271
+ borderRadius: tokens.radius.lg,
272
+ color: tokens.colors.textPrimary,
273
+ fontSize: tokens.typography.fontSizeMd,
274
+ padding: `${tokens.spacing.md} ${tokens.spacing.lg}`,
275
+ transition: `border-color ${tokens.transitions.normal}`
276
+ },
277
+ button: {
278
+ display: "inline-flex",
279
+ alignItems: "center",
280
+ justifyContent: "center",
281
+ gap: tokens.spacing.sm,
282
+ padding: `${tokens.spacing.sm} ${tokens.spacing.lg}`,
283
+ borderRadius: tokens.radius.lg,
284
+ fontSize: tokens.typography.fontSizeMd,
285
+ fontWeight: tokens.typography.fontWeightMedium,
286
+ cursor: "pointer",
287
+ transition: `all ${tokens.transitions.normal}`,
288
+ border: `1px solid ${tokens.colors.borderSecondary}`,
289
+ outline: "none"
290
+ },
291
+ buttonPrimary: {
292
+ background: tokens.colors.accentPrimary,
293
+ color: tokens.colors.textInverse,
294
+ borderColor: tokens.colors.accentPrimary
295
+ },
296
+ buttonSecondary: {
297
+ background: tokens.colors.bgTertiary,
298
+ color: tokens.colors.textPrimary,
299
+ borderColor: tokens.colors.borderSecondary
300
+ },
301
+ buttonIcon: {
302
+ width: "36px",
303
+ height: "36px",
304
+ padding: 0,
305
+ // background inherited from global button styles
306
+ color: tokens.colors.textSecondary
307
+ },
308
+ mono: {
309
+ fontFamily: tokens.typography.fontFamilyMono,
310
+ fontSize: tokens.typography.fontSizeSm
311
+ },
312
+ label: {
313
+ fontSize: tokens.typography.fontSizeXs,
314
+ color: tokens.colors.textTertiary,
315
+ marginBottom: tokens.spacing.xs
316
+ }
317
+ };
318
+ var animations = `
319
+ @keyframes hustle-spin {
320
+ to { transform: rotate(360deg); }
321
+ }
322
+ @keyframes hustle-pulse {
323
+ 0%, 100% { opacity: 1; }
324
+ 50% { opacity: 0.5; }
325
+ }
326
+ @keyframes hustle-glow {
327
+ 0%, 100% {
328
+ opacity: 1;
329
+ text-shadow: 0 0 4px ${defaults.colors.accentPrimaryBg};
330
+ }
331
+ 50% {
332
+ opacity: 0.6;
333
+ text-shadow: 0 0 8px ${defaults.colors.accentPrimary};
334
+ }
335
+ }
336
+ `;
337
+ function truncateAddress(address) {
338
+ if (!address || address.length < 10) return address || "";
339
+ return `${address.slice(0, 6)}...${address.slice(-4)}`;
340
+ }
341
+ async function copyToClipboard(text) {
342
+ try {
343
+ await navigator.clipboard.writeText(text);
344
+ return true;
345
+ } catch {
346
+ return false;
347
+ }
348
+ }
349
+ var styles = {
350
+ wrapper: {
351
+ position: "relative",
352
+ display: "inline-flex",
353
+ alignItems: "center",
354
+ gap: tokens.spacing.sm
355
+ },
356
+ button: {
357
+ ...presets.button,
358
+ padding: `${tokens.spacing.sm} ${tokens.spacing.xl}`
359
+ },
360
+ disconnected: {
361
+ background: tokens.colors.bgTertiary,
362
+ color: tokens.colors.textPrimary,
363
+ borderColor: tokens.colors.borderSecondary
364
+ },
365
+ disconnectedHover: {
366
+ background: tokens.colors.bgHover,
367
+ borderColor: tokens.colors.borderHover
368
+ },
369
+ connected: {
370
+ background: "transparent",
371
+ color: tokens.colors.accentSuccess,
372
+ borderColor: tokens.colors.accentSuccess,
373
+ borderRadius: tokens.radius.pill
374
+ },
375
+ connectedHover: {
376
+ background: tokens.colors.accentSuccessBg
377
+ },
378
+ loading: {
379
+ background: tokens.colors.borderSecondary,
380
+ color: tokens.colors.textSecondary,
381
+ cursor: "wait"
382
+ },
383
+ disabled: {
384
+ background: tokens.colors.borderSecondary,
385
+ color: tokens.colors.textTertiary,
386
+ cursor: "not-allowed",
387
+ opacity: 0.5
388
+ },
389
+ icon: {
390
+ fontSize: tokens.typography.fontSizeLg
391
+ },
392
+ spinner: {
393
+ display: "inline-block",
394
+ width: "14px",
395
+ height: "14px",
396
+ border: "2px solid currentColor",
397
+ borderTopColor: "transparent",
398
+ borderRadius: tokens.radius.full,
399
+ animation: "hustle-spin 0.8s linear infinite"
400
+ },
401
+ address: {
402
+ ...presets.mono,
403
+ color: tokens.colors.textPrimary
404
+ },
405
+ dot: {
406
+ color: tokens.colors.textSecondary
407
+ },
408
+ check: {
409
+ color: tokens.colors.accentSuccess
410
+ },
411
+ arrow: {
412
+ fontSize: "10px",
413
+ color: tokens.colors.textSecondary,
414
+ marginLeft: tokens.spacing.xs
415
+ },
416
+ // Disconnect button
417
+ disconnectBtn: {
418
+ display: "flex",
419
+ alignItems: "center",
420
+ justifyContent: "center",
421
+ width: "36px",
422
+ height: "36px",
423
+ background: "transparent",
424
+ border: `1px solid ${tokens.colors.borderSecondary}`,
425
+ borderRadius: tokens.radius.lg,
426
+ color: tokens.colors.textSecondary,
427
+ cursor: "pointer",
428
+ fontSize: "16px",
429
+ transition: `all ${tokens.transitions.normal}`
430
+ },
431
+ disconnectBtnHover: {
432
+ borderColor: tokens.colors.accentError,
433
+ color: tokens.colors.accentError
434
+ },
435
+ // Vault info dropdown
436
+ dropdown: {
437
+ position: "absolute",
438
+ top: "100%",
439
+ left: 0,
440
+ marginTop: tokens.spacing.xs,
441
+ background: tokens.colors.bgPrimary,
442
+ border: `1px solid ${tokens.colors.accentSuccess}`,
443
+ borderRadius: tokens.radius.xl,
444
+ padding: tokens.spacing.lg,
445
+ minWidth: "300px",
446
+ zIndex: tokens.zIndex.dropdown,
447
+ boxShadow: `0 8px 32px rgba(0,0,0,0.4), 0 0 0 1px ${tokens.colors.accentSuccessBg}`
448
+ },
449
+ dropdownHeader: {
450
+ fontSize: tokens.typography.fontSizeXs,
451
+ fontWeight: tokens.typography.fontWeightSemibold,
452
+ color: tokens.colors.textSecondary,
453
+ letterSpacing: "0.5px",
454
+ marginBottom: tokens.spacing.lg,
455
+ textTransform: "uppercase"
456
+ },
457
+ dropdownRow: {
458
+ marginBottom: tokens.spacing.md
459
+ },
460
+ dropdownLabel: {
461
+ display: "block",
462
+ fontSize: tokens.typography.fontSizeXs,
463
+ color: tokens.colors.textTertiary,
464
+ marginBottom: tokens.spacing.xs
465
+ },
466
+ dropdownValueRow: {
467
+ display: "flex",
468
+ alignItems: "center",
469
+ justifyContent: "space-between",
470
+ gap: tokens.spacing.sm
471
+ },
472
+ dropdownValue: {
473
+ fontSize: tokens.typography.fontSizeMd,
474
+ color: tokens.colors.textPrimary,
475
+ fontWeight: tokens.typography.fontWeightMedium,
476
+ flex: 1
477
+ },
478
+ dropdownValueMono: {
479
+ ...presets.mono,
480
+ wordBreak: "break-all"
481
+ },
482
+ copyBtn: {
483
+ background: "transparent",
484
+ border: `1px solid ${tokens.colors.borderSecondary}`,
485
+ color: tokens.colors.textSecondary,
486
+ padding: `${tokens.spacing.xs} ${tokens.spacing.sm}`,
487
+ borderRadius: tokens.radius.sm,
488
+ cursor: "pointer",
489
+ fontSize: tokens.typography.fontSizeXs,
490
+ transition: `all ${tokens.transitions.normal}`,
491
+ whiteSpace: "nowrap"
492
+ },
493
+ copyBtnHover: {
494
+ background: tokens.colors.bgHover,
495
+ borderColor: tokens.colors.accentPrimary,
496
+ color: tokens.colors.accentPrimary
497
+ },
498
+ copyBtnCopied: {
499
+ background: tokens.colors.accentSuccess,
500
+ borderColor: tokens.colors.accentSuccess,
501
+ color: tokens.colors.textInverse
502
+ }
503
+ };
504
+ function ConnectButton({
505
+ className = "",
506
+ style,
507
+ connectLabel = "Connect",
508
+ loadingLabel = "Connecting...",
509
+ onConnect,
510
+ onDisconnect,
511
+ showVaultInfo = true,
512
+ disabled = false
513
+ }) {
514
+ const {
515
+ isAuthenticated,
516
+ isLoading,
517
+ walletAddress,
518
+ vaultId,
519
+ openAuthModal,
520
+ logout
521
+ } = useEmblemAuth();
522
+ const [isHovered, setIsHovered] = react.useState(false);
523
+ const [showDropdown, setShowDropdown] = react.useState(false);
524
+ const [disconnectHovered, setDisconnectHovered] = react.useState(false);
525
+ const [copiedField, setCopiedField] = react.useState(null);
526
+ const [copyHovered, setCopyHovered] = react.useState(null);
527
+ const handleClick = react.useCallback(async () => {
528
+ if (disabled) return;
529
+ if (!isAuthenticated && !isLoading) {
530
+ await openAuthModal();
531
+ onConnect?.();
532
+ }
533
+ }, [disabled, isAuthenticated, isLoading, openAuthModal, onConnect]);
534
+ const handleDisconnect = react.useCallback(() => {
535
+ logout();
536
+ onDisconnect?.();
537
+ setShowDropdown(false);
538
+ }, [logout, onDisconnect]);
539
+ const handleCopy = react.useCallback(async (field, value) => {
540
+ const success = await copyToClipboard(value);
541
+ if (success) {
542
+ setCopiedField(field);
543
+ setTimeout(() => setCopiedField(null), 1500);
544
+ }
545
+ }, []);
546
+ let buttonStyle = { ...styles.button };
547
+ let content = connectLabel;
548
+ if (disabled) {
549
+ buttonStyle = { ...buttonStyle, ...styles.disconnected, ...styles.disabled };
550
+ } else if (isLoading) {
551
+ buttonStyle = { ...buttonStyle, ...styles.disconnected, ...styles.loading };
552
+ content = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
553
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: styles.spinner }),
554
+ loadingLabel
555
+ ] });
556
+ } else if (isAuthenticated) {
557
+ buttonStyle = { ...buttonStyle, ...styles.connected };
558
+ if (isHovered || showDropdown) {
559
+ buttonStyle = { ...buttonStyle, ...styles.connectedHover };
560
+ }
561
+ const truncated = truncateAddress(walletAddress || "");
562
+ content = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
563
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: styles.check, children: "\u2713" }),
564
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Connected" }),
565
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: styles.dot, children: "\u2022" }),
566
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: styles.address, children: truncated }),
567
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: styles.arrow, children: "\u25BE" })
568
+ ] });
569
+ } else {
570
+ buttonStyle = { ...buttonStyle, ...styles.disconnected };
571
+ if (isHovered) {
572
+ buttonStyle = { ...buttonStyle, ...styles.disconnectedHover };
573
+ }
574
+ content = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
575
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: styles.icon, children: "\u2192" }),
576
+ connectLabel
577
+ ] });
578
+ }
579
+ if (style) {
580
+ buttonStyle = { ...buttonStyle, ...style };
581
+ }
582
+ const renderCopyBtn = (field, value) => {
583
+ const isCopied = copiedField === field;
584
+ const isHover = copyHovered === field;
585
+ return /* @__PURE__ */ jsxRuntime.jsx(
586
+ "button",
587
+ {
588
+ type: "button",
589
+ onClick: (e) => {
590
+ e.stopPropagation();
591
+ handleCopy(field, value);
592
+ },
593
+ style: {
594
+ ...styles.copyBtn,
595
+ ...isCopied ? styles.copyBtnCopied : isHover ? styles.copyBtnHover : {}
596
+ },
597
+ onMouseEnter: () => setCopyHovered(field),
598
+ onMouseLeave: () => setCopyHovered(null),
599
+ children: isCopied ? "Copied!" : "Copy"
600
+ }
601
+ );
602
+ };
603
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
604
+ /* @__PURE__ */ jsxRuntime.jsx("style", { children: animations }),
605
+ /* @__PURE__ */ jsxRuntime.jsxs(
606
+ "div",
607
+ {
608
+ style: styles.wrapper,
609
+ onMouseEnter: () => isAuthenticated && showVaultInfo && setShowDropdown(true),
610
+ onMouseLeave: () => setShowDropdown(false),
611
+ children: [
612
+ /* @__PURE__ */ jsxRuntime.jsx(
613
+ "button",
614
+ {
615
+ type: "button",
616
+ onClick: handleClick,
617
+ disabled: disabled || isLoading,
618
+ className,
619
+ style: buttonStyle,
620
+ onMouseEnter: () => setIsHovered(true),
621
+ onMouseLeave: () => setIsHovered(false),
622
+ children: content
623
+ }
624
+ ),
625
+ isAuthenticated && /* @__PURE__ */ jsxRuntime.jsx(
626
+ "button",
627
+ {
628
+ type: "button",
629
+ onClick: handleDisconnect,
630
+ style: {
631
+ ...styles.disconnectBtn,
632
+ ...disconnectHovered ? styles.disconnectBtnHover : {}
633
+ },
634
+ onMouseEnter: () => setDisconnectHovered(true),
635
+ onMouseLeave: () => setDisconnectHovered(false),
636
+ title: "Disconnect",
637
+ children: "\u23FB"
638
+ }
639
+ ),
640
+ isAuthenticated && showVaultInfo && showDropdown && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles.dropdown, children: [
641
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: styles.dropdownHeader, children: "Vault Information" }),
642
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles.dropdownRow, children: [
643
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: styles.dropdownLabel, children: "Vault ID" }),
644
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles.dropdownValueRow, children: [
645
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { style: styles.dropdownValue, children: [
646
+ "#",
647
+ vaultId
648
+ ] }),
649
+ renderCopyBtn("vaultId", vaultId || "")
650
+ ] })
651
+ ] }),
652
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { ...styles.dropdownRow, marginBottom: 0 }, children: [
653
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: styles.dropdownLabel, children: "Connected Wallet" }),
654
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles.dropdownValueRow, children: [
655
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { ...styles.dropdownValue, ...styles.dropdownValueMono }, children: walletAddress }),
656
+ renderCopyBtn("wallet", walletAddress || "")
657
+ ] })
658
+ ] })
659
+ ] })
660
+ ]
661
+ }
662
+ )
663
+ ] });
664
+ }
665
+ async function copyToClipboard2(text) {
666
+ try {
667
+ await navigator.clipboard.writeText(text);
668
+ return true;
669
+ } catch {
670
+ return false;
671
+ }
672
+ }
673
+ var s = {
674
+ container: {
675
+ position: "relative",
676
+ display: "inline-flex",
677
+ alignItems: "center",
678
+ gap: tokens.spacing.sm,
679
+ fontFamily: tokens.typography.fontFamily
680
+ },
681
+ disconnected: {
682
+ display: "inline-flex",
683
+ alignItems: "center",
684
+ gap: tokens.spacing.sm,
685
+ color: tokens.colors.textSecondary,
686
+ fontSize: tokens.typography.fontSizeMd
687
+ },
688
+ dot: {
689
+ display: "inline-block",
690
+ width: "8px",
691
+ height: "8px",
692
+ borderRadius: tokens.radius.full,
693
+ backgroundColor: tokens.colors.textTertiary
694
+ },
695
+ dotConnected: {
696
+ backgroundColor: tokens.colors.accentSuccess
697
+ },
698
+ spinner: {
699
+ display: "inline-block",
700
+ width: "12px",
701
+ height: "12px",
702
+ border: `2px solid ${tokens.colors.textSecondary}`,
703
+ borderTopColor: "transparent",
704
+ borderRadius: tokens.radius.full,
705
+ animation: "hustle-spin 0.8s linear infinite"
706
+ },
707
+ logoutBtn: {
708
+ ...presets.buttonIcon,
709
+ border: `1px solid ${tokens.colors.borderSecondary}`,
710
+ borderRadius: tokens.radius.lg,
711
+ transition: `all ${tokens.transitions.normal}`
712
+ },
713
+ logoutBtnHover: {
714
+ borderColor: tokens.colors.accentError,
715
+ color: tokens.colors.accentError
716
+ },
717
+ vaultInfoWrapper: {
718
+ position: "relative"
719
+ },
720
+ vaultInfo: {
721
+ position: "absolute",
722
+ top: "100%",
723
+ right: 0,
724
+ marginTop: tokens.spacing.sm,
725
+ background: tokens.colors.bgSecondary,
726
+ border: `1px solid ${tokens.colors.borderPrimary}`,
727
+ borderRadius: tokens.radius.xl,
728
+ padding: tokens.spacing.lg,
729
+ minWidth: "380px",
730
+ zIndex: tokens.zIndex.dropdown,
731
+ boxShadow: tokens.shadows.lg
732
+ },
733
+ vaultInfoHeader: {
734
+ fontSize: tokens.typography.fontSizeXs,
735
+ fontWeight: tokens.typography.fontWeightSemibold,
736
+ color: tokens.colors.textSecondary,
737
+ letterSpacing: "0.5px",
738
+ marginBottom: tokens.spacing.lg,
739
+ textTransform: "uppercase"
740
+ },
741
+ vaultInfoRow: {
742
+ marginBottom: tokens.spacing.md
743
+ },
744
+ vaultLabel: {
745
+ display: "block",
746
+ fontSize: "12px",
747
+ color: tokens.colors.textTertiary,
748
+ marginBottom: tokens.spacing.xs
749
+ },
750
+ vaultValueRow: {
751
+ display: "flex",
752
+ alignItems: "center",
753
+ justifyContent: "space-between",
754
+ gap: tokens.spacing.sm
755
+ },
756
+ vaultValue: {
757
+ fontSize: tokens.typography.fontSizeMd,
758
+ color: tokens.colors.textPrimary,
759
+ fontWeight: tokens.typography.fontWeightMedium,
760
+ flex: 1
761
+ },
762
+ vaultValueMono: {
763
+ ...presets.mono,
764
+ wordBreak: "break-all"
765
+ },
766
+ copyBtn: {
767
+ background: "transparent",
768
+ border: `1px solid ${tokens.colors.borderSecondary}`,
769
+ color: tokens.colors.textSecondary,
770
+ padding: `${tokens.spacing.xs} ${tokens.spacing.sm}`,
771
+ borderRadius: tokens.radius.sm,
772
+ cursor: "pointer",
773
+ fontSize: tokens.typography.fontSizeXs,
774
+ transition: `all ${tokens.transitions.normal}`,
775
+ whiteSpace: "nowrap"
776
+ },
777
+ copyBtnHover: {
778
+ background: tokens.colors.bgHover,
779
+ borderColor: tokens.colors.accentPrimary,
780
+ color: tokens.colors.accentPrimary
781
+ },
782
+ copyBtnCopied: {
783
+ background: tokens.colors.accentSuccess,
784
+ borderColor: tokens.colors.accentSuccess,
785
+ color: tokens.colors.textInverse
786
+ }
787
+ };
788
+ function AuthStatus({
789
+ className = "",
790
+ style,
791
+ showVaultInfo = false,
792
+ showLogout = false
793
+ }) {
794
+ const {
795
+ isAuthenticated,
796
+ isLoading,
797
+ walletAddress,
798
+ vaultId,
799
+ vaultInfo,
800
+ logout
801
+ } = useEmblemAuth();
802
+ const [isHovered, setIsHovered] = react.useState(false);
803
+ const [logoutHovered, setLogoutHovered] = react.useState(false);
804
+ const [copiedField, setCopiedField] = react.useState(null);
805
+ const [copyHovered, setCopyHovered] = react.useState(null);
806
+ const handleCopy = react.useCallback(async (field, value) => {
807
+ const success = await copyToClipboard2(value);
808
+ if (success) {
809
+ setCopiedField(field);
810
+ setTimeout(() => setCopiedField(null), 1500);
811
+ }
812
+ }, []);
813
+ if (!isAuthenticated) {
814
+ if (isLoading) {
815
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
816
+ /* @__PURE__ */ jsxRuntime.jsx("style", { children: animations }),
817
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: { ...s.disconnected, ...style }, children: [
818
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: s.spinner }),
819
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Connecting..." })
820
+ ] })
821
+ ] });
822
+ }
823
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: { ...s.disconnected, ...style }, children: [
824
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: s.dot }),
825
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Not connected" })
826
+ ] });
827
+ }
828
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
829
+ /* @__PURE__ */ jsxRuntime.jsx("style", { children: animations }),
830
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: { ...s.container, ...style }, children: [
831
+ /* @__PURE__ */ jsxRuntime.jsxs(
832
+ "div",
833
+ {
834
+ style: s.vaultInfoWrapper,
835
+ onMouseEnter: () => showVaultInfo && setIsHovered(true),
836
+ onMouseLeave: () => showVaultInfo && setIsHovered(false),
837
+ children: [
838
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { ...s.dot, ...s.dotConnected }, title: "Connected" }),
839
+ showVaultInfo && isHovered && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: s.vaultInfo, children: [
840
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: s.vaultInfoHeader, children: "Vault Information" }),
841
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: s.vaultInfoRow, children: [
842
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: s.vaultLabel, children: "Vault ID" }),
843
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: s.vaultValueRow, children: [
844
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { style: s.vaultValue, children: [
845
+ "#",
846
+ vaultId
847
+ ] }),
848
+ /* @__PURE__ */ jsxRuntime.jsx(
849
+ CopyButton,
850
+ {
851
+ field: "vaultId",
852
+ value: vaultId || "",
853
+ copiedField,
854
+ copyHovered,
855
+ setCopyHovered,
856
+ onCopy: handleCopy
857
+ }
858
+ )
859
+ ] })
860
+ ] }),
861
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: s.vaultInfoRow, children: [
862
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: s.vaultLabel, children: "Connected Wallet" }),
863
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: s.vaultValueRow, children: [
864
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { ...s.vaultValue, ...s.vaultValueMono }, children: walletAddress }),
865
+ /* @__PURE__ */ jsxRuntime.jsx(
866
+ CopyButton,
867
+ {
868
+ field: "wallet",
869
+ value: walletAddress || "",
870
+ copiedField,
871
+ copyHovered,
872
+ setCopyHovered,
873
+ onCopy: handleCopy
874
+ }
875
+ )
876
+ ] })
877
+ ] }),
878
+ vaultInfo?.evmAddress && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: s.vaultInfoRow, children: [
879
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: s.vaultLabel, children: "Vault EVM Address" }),
880
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: s.vaultValueRow, children: [
881
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { ...s.vaultValue, ...s.vaultValueMono }, children: vaultInfo.evmAddress }),
882
+ /* @__PURE__ */ jsxRuntime.jsx(
883
+ CopyButton,
884
+ {
885
+ field: "evmAddress",
886
+ value: vaultInfo.evmAddress,
887
+ copiedField,
888
+ copyHovered,
889
+ setCopyHovered,
890
+ onCopy: handleCopy
891
+ }
892
+ )
893
+ ] })
894
+ ] }),
895
+ vaultInfo?.solanaAddress && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: s.vaultInfoRow, children: [
896
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: s.vaultLabel, children: "Vault Solana Address" }),
897
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: s.vaultValueRow, children: [
898
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { ...s.vaultValue, ...s.vaultValueMono }, children: vaultInfo.solanaAddress }),
899
+ /* @__PURE__ */ jsxRuntime.jsx(
900
+ CopyButton,
901
+ {
902
+ field: "solAddress",
903
+ value: vaultInfo.solanaAddress,
904
+ copiedField,
905
+ copyHovered,
906
+ setCopyHovered,
907
+ onCopy: handleCopy
908
+ }
909
+ )
910
+ ] })
911
+ ] })
912
+ ] })
913
+ ]
914
+ }
915
+ ),
916
+ showLogout && /* @__PURE__ */ jsxRuntime.jsx(
917
+ "button",
918
+ {
919
+ type: "button",
920
+ onClick: logout,
921
+ style: {
922
+ ...s.logoutBtn,
923
+ ...logoutHovered ? s.logoutBtnHover : {}
924
+ },
925
+ onMouseEnter: () => setLogoutHovered(true),
926
+ onMouseLeave: () => setLogoutHovered(false),
927
+ title: "Disconnect",
928
+ children: "\u23FB"
929
+ }
930
+ )
931
+ ] })
932
+ ] });
933
+ }
934
+ function CopyButton({ field, value, copiedField, copyHovered, setCopyHovered, onCopy }) {
935
+ const isCopied = copiedField === field;
936
+ const isHovered = copyHovered === field;
937
+ return /* @__PURE__ */ jsxRuntime.jsx(
938
+ "button",
939
+ {
940
+ type: "button",
941
+ onClick: () => onCopy(field, value),
942
+ style: {
943
+ ...s.copyBtn,
944
+ ...isCopied ? s.copyBtnCopied : isHovered ? s.copyBtnHover : {}
945
+ },
946
+ onMouseEnter: () => setCopyHovered(field),
947
+ onMouseLeave: () => setCopyHovered(null),
948
+ children: isCopied ? "Copied!" : "Copy"
949
+ }
950
+ );
951
+ }
952
+
953
+ // src/utils/pluginRegistry.ts
954
+ var PLUGINS_KEY = "hustle-plugins";
955
+ function getEnabledStateKey(instanceId) {
956
+ return `hustle-plugin-state-${instanceId}`;
957
+ }
958
+ function serializeFunction(fn) {
959
+ return fn.toString();
960
+ }
961
+ function deserializeExecutor(code) {
962
+ try {
963
+ return eval(`(${code})`);
964
+ } catch (err) {
965
+ console.error("[Hustle] Failed to deserialize executor:", err);
966
+ return async () => ({ error: "Failed to deserialize executor", code });
967
+ }
968
+ }
969
+ function deserializeHook(code) {
970
+ try {
971
+ return eval(`(${code})`);
972
+ } catch (err) {
973
+ console.error("[Hustle] Failed to deserialize hook:", err);
974
+ return (() => {
975
+ });
976
+ }
977
+ }
978
+ function serializePluginTools(tools, executors) {
979
+ if (!tools) return [];
980
+ return tools.map((tool) => ({
981
+ ...tool,
982
+ executorCode: executors?.[tool.name] ? serializeFunction(executors[tool.name]) : void 0
983
+ }));
984
+ }
985
+ function serializeHooks(hooks) {
986
+ if (!hooks) return void 0;
987
+ const serialized = {};
988
+ if (hooks.onRegister) {
989
+ serialized.onRegisterCode = serializeFunction(hooks.onRegister);
990
+ }
991
+ if (hooks.beforeRequest) {
992
+ serialized.beforeRequestCode = serializeFunction(hooks.beforeRequest);
993
+ }
994
+ if (hooks.afterResponse) {
995
+ serialized.afterResponseCode = serializeFunction(hooks.afterResponse);
996
+ }
997
+ if (hooks.onError) {
998
+ serialized.onErrorCode = serializeFunction(hooks.onError);
999
+ }
1000
+ return Object.keys(serialized).length > 0 ? serialized : void 0;
1001
+ }
1002
+ function hydratePlugin(stored) {
1003
+ const executors = {};
1004
+ if (stored.tools) {
1005
+ for (const tool of stored.tools) {
1006
+ if (tool.executorCode) {
1007
+ executors[tool.name] = deserializeExecutor(tool.executorCode);
1008
+ }
1009
+ }
1010
+ }
1011
+ let hooks;
1012
+ if (stored.hooksCode) {
1013
+ hooks = {};
1014
+ if (stored.hooksCode.onRegisterCode) {
1015
+ hooks.onRegister = deserializeHook(stored.hooksCode.onRegisterCode);
1016
+ }
1017
+ if (stored.hooksCode.beforeRequestCode) {
1018
+ hooks.beforeRequest = deserializeHook(stored.hooksCode.beforeRequestCode);
1019
+ }
1020
+ if (stored.hooksCode.afterResponseCode) {
1021
+ hooks.afterResponse = deserializeHook(stored.hooksCode.afterResponseCode);
1022
+ }
1023
+ if (stored.hooksCode.onErrorCode) {
1024
+ hooks.onError = deserializeHook(stored.hooksCode.onErrorCode);
1025
+ }
1026
+ }
1027
+ return {
1028
+ ...stored,
1029
+ executors: Object.keys(executors).length > 0 ? executors : void 0,
1030
+ hooks
1031
+ };
1032
+ }
1033
+ var PluginRegistry = class {
1034
+ constructor() {
1035
+ this.listeners = /* @__PURE__ */ new Map();
1036
+ }
1037
+ /**
1038
+ * Get listeners for a specific instance
1039
+ */
1040
+ getListeners(instanceId) {
1041
+ if (!this.listeners.has(instanceId)) {
1042
+ this.listeners.set(instanceId, /* @__PURE__ */ new Set());
1043
+ }
1044
+ return this.listeners.get(instanceId);
1045
+ }
1046
+ /**
1047
+ * Load installed plugins (global)
1048
+ */
1049
+ loadInstalledPlugins() {
1050
+ if (typeof window === "undefined") return [];
1051
+ try {
1052
+ const stored = localStorage.getItem(PLUGINS_KEY);
1053
+ return stored ? JSON.parse(stored) : [];
1054
+ } catch {
1055
+ return [];
1056
+ }
1057
+ }
1058
+ /**
1059
+ * Save installed plugins (global)
1060
+ * Serializes executors as executorCode strings
1061
+ */
1062
+ saveInstalledPlugins(plugins) {
1063
+ if (typeof window === "undefined") return;
1064
+ localStorage.setItem(PLUGINS_KEY, JSON.stringify(plugins));
1065
+ }
1066
+ /**
1067
+ * Load enabled state for an instance
1068
+ */
1069
+ loadEnabledState(instanceId) {
1070
+ if (typeof window === "undefined") return {};
1071
+ try {
1072
+ const stored = localStorage.getItem(getEnabledStateKey(instanceId));
1073
+ return stored ? JSON.parse(stored) : {};
1074
+ } catch {
1075
+ return {};
1076
+ }
1077
+ }
1078
+ /**
1079
+ * Save enabled state for an instance
1080
+ */
1081
+ saveEnabledState(state, instanceId) {
1082
+ if (typeof window === "undefined") return;
1083
+ localStorage.setItem(getEnabledStateKey(instanceId), JSON.stringify(state));
1084
+ }
1085
+ /**
1086
+ * Load plugins with instance-specific enabled state
1087
+ * Combines global plugin list with per-instance enabled state
1088
+ */
1089
+ loadFromStorage(instanceId = "default") {
1090
+ const installed = this.loadInstalledPlugins();
1091
+ const enabledState = this.loadEnabledState(instanceId);
1092
+ return installed.map((plugin) => ({
1093
+ ...plugin,
1094
+ // Default to enabled if no state exists for this instance
1095
+ enabled: enabledState[plugin.name] ?? true
1096
+ }));
1097
+ }
1098
+ /**
1099
+ * Register a new plugin (global - available to all instances)
1100
+ * Serializes executors as executorCode for persistence
1101
+ *
1102
+ * @param plugin The plugin to install
1103
+ * @param enabled Initial enabled state for this instance (default: true)
1104
+ * @param instanceId Instance to set initial enabled state for
1105
+ */
1106
+ register(plugin, enabled = true, instanceId = "default") {
1107
+ const installed = this.loadInstalledPlugins();
1108
+ const existing = installed.findIndex((p) => p.name === plugin.name);
1109
+ const storedPlugin = {
1110
+ name: plugin.name,
1111
+ version: plugin.version,
1112
+ description: plugin.description,
1113
+ tools: serializePluginTools(plugin.tools, plugin.executors),
1114
+ hooksCode: serializeHooks(plugin.hooks),
1115
+ installedAt: (/* @__PURE__ */ new Date()).toISOString()
1116
+ };
1117
+ if (existing >= 0) {
1118
+ installed[existing] = storedPlugin;
1119
+ } else {
1120
+ installed.push(storedPlugin);
1121
+ }
1122
+ this.saveInstalledPlugins(installed);
1123
+ const enabledState = this.loadEnabledState(instanceId);
1124
+ enabledState[plugin.name] = enabled;
1125
+ this.saveEnabledState(enabledState, instanceId);
1126
+ this.notifyListeners(instanceId);
1127
+ }
1128
+ /**
1129
+ * Unregister a plugin (global - removes from all instances)
1130
+ */
1131
+ unregister(pluginName, instanceId = "default") {
1132
+ const installed = this.loadInstalledPlugins().filter((p) => p.name !== pluginName);
1133
+ this.saveInstalledPlugins(installed);
1134
+ const enabledState = this.loadEnabledState(instanceId);
1135
+ delete enabledState[pluginName];
1136
+ this.saveEnabledState(enabledState, instanceId);
1137
+ this.notifyListeners(instanceId);
1138
+ }
1139
+ /**
1140
+ * Enable or disable a plugin (instance-scoped)
1141
+ */
1142
+ setEnabled(pluginName, enabled, instanceId = "default") {
1143
+ const enabledState = this.loadEnabledState(instanceId);
1144
+ enabledState[pluginName] = enabled;
1145
+ this.saveEnabledState(enabledState, instanceId);
1146
+ this.notifyListeners(instanceId);
1147
+ }
1148
+ /**
1149
+ * Check if a plugin is installed (global)
1150
+ */
1151
+ isRegistered(pluginName) {
1152
+ return this.loadInstalledPlugins().some((p) => p.name === pluginName);
1153
+ }
1154
+ /**
1155
+ * Get a specific plugin with instance-specific enabled state
1156
+ */
1157
+ getPlugin(pluginName, instanceId = "default") {
1158
+ return this.loadFromStorage(instanceId).find((p) => p.name === pluginName);
1159
+ }
1160
+ /**
1161
+ * Get all enabled plugins for an instance (hydrated with executors)
1162
+ */
1163
+ getEnabledPlugins(instanceId = "default") {
1164
+ return this.loadFromStorage(instanceId).filter((p) => p.enabled).map(hydratePlugin);
1165
+ }
1166
+ /**
1167
+ * Subscribe to plugin changes for a specific instance
1168
+ */
1169
+ onChange(callback, instanceId = "default") {
1170
+ const listeners = this.getListeners(instanceId);
1171
+ listeners.add(callback);
1172
+ return () => listeners.delete(callback);
1173
+ }
1174
+ /**
1175
+ * Notify all listeners for a specific instance
1176
+ */
1177
+ notifyListeners(instanceId = "default") {
1178
+ const plugins = this.loadFromStorage(instanceId);
1179
+ const listeners = this.getListeners(instanceId);
1180
+ listeners.forEach((cb) => cb(plugins));
1181
+ }
1182
+ /**
1183
+ * Clear enabled state for an instance (plugins remain installed globally)
1184
+ */
1185
+ clear(instanceId = "default") {
1186
+ if (typeof window === "undefined") return;
1187
+ localStorage.removeItem(getEnabledStateKey(instanceId));
1188
+ this.notifyListeners(instanceId);
1189
+ }
1190
+ /**
1191
+ * Clear all installed plugins globally
1192
+ */
1193
+ clearAll() {
1194
+ if (typeof window === "undefined") return;
1195
+ localStorage.removeItem(PLUGINS_KEY);
1196
+ }
1197
+ };
1198
+ var pluginRegistry = new PluginRegistry();
1199
+
1200
+ // src/hooks/usePlugins.ts
1201
+ function getStorageKey(instanceId) {
1202
+ return `hustle-plugins-${instanceId}`;
1203
+ }
1204
+ function usePlugins(instanceId = "default") {
1205
+ const [plugins, setPlugins] = react.useState([]);
1206
+ react.useEffect(() => {
1207
+ setPlugins(pluginRegistry.loadFromStorage(instanceId));
1208
+ const unsubscribe = pluginRegistry.onChange(setPlugins, instanceId);
1209
+ const storageKey = getStorageKey(instanceId);
1210
+ const handleStorage = (e) => {
1211
+ if (e.key === storageKey) {
1212
+ setPlugins(pluginRegistry.loadFromStorage(instanceId));
1213
+ }
1214
+ };
1215
+ window.addEventListener("storage", handleStorage);
1216
+ return () => {
1217
+ unsubscribe();
1218
+ window.removeEventListener("storage", handleStorage);
1219
+ };
1220
+ }, [instanceId]);
1221
+ const registerPlugin = react.useCallback((plugin) => {
1222
+ pluginRegistry.register(plugin, true, instanceId);
1223
+ }, [instanceId]);
1224
+ const unregisterPlugin = react.useCallback((name) => {
1225
+ pluginRegistry.unregister(name, instanceId);
1226
+ }, [instanceId]);
1227
+ const enablePlugin = react.useCallback((name) => {
1228
+ pluginRegistry.setEnabled(name, true, instanceId);
1229
+ }, [instanceId]);
1230
+ const disablePlugin = react.useCallback((name) => {
1231
+ pluginRegistry.setEnabled(name, false, instanceId);
1232
+ }, [instanceId]);
1233
+ const isRegistered = react.useCallback(
1234
+ (name) => plugins.some((p) => p.name === name),
1235
+ [plugins]
1236
+ );
1237
+ const isEnabled = react.useCallback(
1238
+ (name) => plugins.some((p) => p.name === name && p.enabled),
1239
+ [plugins]
1240
+ );
1241
+ const enabledPlugins = plugins.filter((p) => p.enabled).map(hydratePlugin);
1242
+ return {
1243
+ plugins,
1244
+ enabledPlugins,
1245
+ registerPlugin,
1246
+ unregisterPlugin,
1247
+ enablePlugin,
1248
+ disablePlugin,
1249
+ isRegistered,
1250
+ isEnabled
1251
+ };
1252
+ }
1253
+ var HustleContext = react.createContext(void 0);
1254
+ function useHustle() {
1255
+ const context = react.useContext(HustleContext);
1256
+ if (context === void 0) {
1257
+ throw new Error("useHustle must be used within a HustleProvider (which requires EmblemAuthProvider)");
1258
+ }
1259
+ return context;
1260
+ }
1261
+
1262
+ // src/plugins/predictionMarket.ts
1263
+ var DOME_API_BASE = "https://api.domeapi.io/v1";
1264
+ var predictionMarketPlugin = {
1265
+ name: "prediction-market-alpha",
1266
+ version: "1.1.0",
1267
+ description: "Search and analyze prediction markets on Polymarket and Kalshi",
1268
+ tools: [
1269
+ {
1270
+ name: "get_supported_platforms",
1271
+ description: "Get a list of supported prediction market platforms. Call this first to know which platforms are available for querying.",
1272
+ parameters: {
1273
+ type: "object",
1274
+ properties: {}
1275
+ }
1276
+ },
1277
+ {
1278
+ name: "search_prediction_markets",
1279
+ 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.",
1280
+ parameters: {
1281
+ type: "object",
1282
+ properties: {
1283
+ platform: {
1284
+ type: "string",
1285
+ enum: ["polymarket", "kalshi"],
1286
+ description: "The prediction market platform to search (default: polymarket)"
1287
+ },
1288
+ tags: {
1289
+ type: "array",
1290
+ items: { type: "string" },
1291
+ description: 'REQUIRED: Single word categories or tags to identify a market segment (e.g., "politics", "crypto", "sports", "finance", "entertainment", "ai")'
1292
+ },
1293
+ status: {
1294
+ type: "string",
1295
+ enum: ["open", "closed"],
1296
+ description: "Filter by market status"
1297
+ },
1298
+ limit: {
1299
+ type: "number",
1300
+ description: "Number of results (1-100)",
1301
+ default: 10
1302
+ }
1303
+ },
1304
+ required: ["tags"]
1305
+ }
1306
+ },
1307
+ {
1308
+ name: "get_market_details",
1309
+ description: "Get detailed information about a specific prediction market including current prices, trading history, and resolution source.",
1310
+ parameters: {
1311
+ type: "object",
1312
+ properties: {
1313
+ platform: {
1314
+ type: "string",
1315
+ enum: ["polymarket", "kalshi"],
1316
+ description: "The prediction market platform (default: polymarket)"
1317
+ },
1318
+ market_slug: {
1319
+ type: "string",
1320
+ description: "The market slug/identifier (ticker for Kalshi)"
1321
+ }
1322
+ },
1323
+ required: ["market_slug"]
1324
+ }
1325
+ },
1326
+ {
1327
+ name: "get_market_prices",
1328
+ description: "Get current prices/odds for a prediction market. Shows probability for each outcome.",
1329
+ parameters: {
1330
+ type: "object",
1331
+ properties: {
1332
+ platform: {
1333
+ type: "string",
1334
+ enum: ["polymarket", "kalshi"],
1335
+ description: "The prediction market platform (default: polymarket)"
1336
+ },
1337
+ market_slug: {
1338
+ type: "string",
1339
+ description: "The market slug/identifier (ticker for Kalshi)"
1340
+ }
1341
+ },
1342
+ required: ["market_slug"]
1343
+ }
1344
+ },
1345
+ {
1346
+ name: "get_market_trades",
1347
+ description: "Get recent orders/trading activity for a prediction market.",
1348
+ parameters: {
1349
+ type: "object",
1350
+ properties: {
1351
+ platform: {
1352
+ type: "string",
1353
+ enum: ["polymarket", "kalshi"],
1354
+ description: "The prediction market platform (default: polymarket)"
1355
+ },
1356
+ market_slug: {
1357
+ type: "string",
1358
+ description: "The market slug/identifier (ticker for Kalshi)"
1359
+ },
1360
+ limit: {
1361
+ type: "number",
1362
+ description: "Number of orders to return (max 100)",
1363
+ default: 20
1364
+ }
1365
+ },
1366
+ required: ["market_slug"]
1367
+ }
1368
+ }
1369
+ ],
1370
+ executors: {
1371
+ get_supported_platforms: async () => {
1372
+ return {
1373
+ platforms: [
1374
+ {
1375
+ id: "polymarket",
1376
+ name: "Polymarket",
1377
+ description: "Decentralized prediction market on Polygon",
1378
+ features: ["tags", "volume_filtering"]
1379
+ },
1380
+ {
1381
+ id: "kalshi",
1382
+ name: "Kalshi",
1383
+ description: "CFTC-regulated prediction market exchange",
1384
+ features: ["regulated", "event_based"]
1385
+ }
1386
+ ]
1387
+ };
1388
+ },
1389
+ search_prediction_markets: async (args) => {
1390
+ const platform = args.platform || "polymarket";
1391
+ const params = new URLSearchParams();
1392
+ if (args.limit) params.append("limit", String(args.limit));
1393
+ if (platform === "polymarket") {
1394
+ if (args.tags) params.append("tags", args.tags.join(","));
1395
+ if (args.status) params.append("status", args.status);
1396
+ const response = await fetch(`${DOME_API_BASE}/polymarket/markets?${params}`);
1397
+ if (!response.ok) {
1398
+ throw new Error(`Dome API error: ${response.status} ${response.statusText}`);
1399
+ }
1400
+ const data = await response.json();
1401
+ return {
1402
+ platform: "polymarket",
1403
+ markets: data.markets?.map((m) => ({
1404
+ slug: m.market_slug,
1405
+ title: m.title,
1406
+ status: m.status,
1407
+ volume: m.volume_total,
1408
+ tags: m.tags,
1409
+ outcomes: [
1410
+ { label: m.side_a?.label, id: m.side_a?.id },
1411
+ { label: m.side_b?.label, id: m.side_b?.id }
1412
+ ],
1413
+ winner: m.winning_side
1414
+ })) || [],
1415
+ total: data.pagination?.total || 0,
1416
+ hasMore: data.pagination?.has_more || false
1417
+ };
1418
+ } else if (platform === "kalshi") {
1419
+ if (args.status) params.append("status", args.status);
1420
+ const response = await fetch(`${DOME_API_BASE}/kalshi/markets?${params}`);
1421
+ if (!response.ok) {
1422
+ throw new Error(`Dome API error: ${response.status} ${response.statusText}`);
1423
+ }
1424
+ const data = await response.json();
1425
+ return {
1426
+ platform: "kalshi",
1427
+ markets: data.markets?.map((m) => ({
1428
+ ticker: m.ticker,
1429
+ title: m.title,
1430
+ status: m.status,
1431
+ category: m.category,
1432
+ subtitle: m.subtitle,
1433
+ yesAsk: m.yes_ask,
1434
+ yesBid: m.yes_bid,
1435
+ volume: m.volume
1436
+ })) || [],
1437
+ total: data.pagination?.total || 0,
1438
+ hasMore: data.pagination?.has_more || false
1439
+ };
1440
+ }
1441
+ throw new Error(`Unsupported platform: ${platform}`);
1442
+ },
1443
+ get_market_details: async (args) => {
1444
+ const platform = args.platform || "polymarket";
1445
+ if (platform === "polymarket") {
1446
+ const response = await fetch(
1447
+ `${DOME_API_BASE}/polymarket/markets?market_slug=${args.market_slug}`
1448
+ );
1449
+ if (!response.ok) {
1450
+ throw new Error(`Dome API error: ${response.status} ${response.statusText}`);
1451
+ }
1452
+ const data = await response.json();
1453
+ const market = data.markets?.[0];
1454
+ if (!market) {
1455
+ throw new Error(`Market not found: ${args.market_slug}`);
1456
+ }
1457
+ return {
1458
+ platform: "polymarket",
1459
+ slug: market.market_slug,
1460
+ title: market.title,
1461
+ status: market.status,
1462
+ startTime: market.start_time ? new Date(market.start_time * 1e3).toISOString() : null,
1463
+ endTime: market.end_time ? new Date(market.end_time * 1e3).toISOString() : null,
1464
+ volume: {
1465
+ total: market.volume_total,
1466
+ week: market.volume_1_week,
1467
+ month: market.volume_1_month
1468
+ },
1469
+ resolutionSource: market.resolution_source,
1470
+ outcomes: [
1471
+ { label: market.side_a?.label, id: market.side_a?.id },
1472
+ { label: market.side_b?.label, id: market.side_b?.id }
1473
+ ],
1474
+ winner: market.winning_side,
1475
+ tags: market.tags
1476
+ };
1477
+ } else if (platform === "kalshi") {
1478
+ const response = await fetch(
1479
+ `${DOME_API_BASE}/kalshi/markets?ticker=${args.market_slug}`
1480
+ );
1481
+ if (!response.ok) {
1482
+ throw new Error(`Dome API error: ${response.status} ${response.statusText}`);
1483
+ }
1484
+ const data = await response.json();
1485
+ const market = data.markets?.[0];
1486
+ if (!market) {
1487
+ throw new Error(`Market not found: ${args.market_slug}`);
1488
+ }
1489
+ return {
1490
+ platform: "kalshi",
1491
+ ticker: market.ticker,
1492
+ title: market.title,
1493
+ subtitle: market.subtitle,
1494
+ status: market.status,
1495
+ category: market.category,
1496
+ yesAsk: market.yes_ask,
1497
+ yesBid: market.yes_bid,
1498
+ volume: market.volume,
1499
+ openInterest: market.open_interest
1500
+ };
1501
+ }
1502
+ throw new Error(`Unsupported platform: ${platform}`);
1503
+ },
1504
+ get_market_prices: async (args) => {
1505
+ const platform = args.platform || "polymarket";
1506
+ if (platform === "polymarket") {
1507
+ const response = await fetch(
1508
+ `${DOME_API_BASE}/polymarket/market-price?market_slug=${args.market_slug}`
1509
+ );
1510
+ if (!response.ok) {
1511
+ throw new Error(`Dome API error: ${response.status} ${response.statusText}`);
1512
+ }
1513
+ const data = await response.json();
1514
+ return { platform: "polymarket", ...data };
1515
+ } else if (platform === "kalshi") {
1516
+ const response = await fetch(
1517
+ `${DOME_API_BASE}/kalshi/markets?ticker=${args.market_slug}`
1518
+ );
1519
+ if (!response.ok) {
1520
+ throw new Error(`Dome API error: ${response.status} ${response.statusText}`);
1521
+ }
1522
+ const data = await response.json();
1523
+ const market = data.markets?.[0];
1524
+ if (!market) {
1525
+ throw new Error(`Market not found: ${args.market_slug}`);
1526
+ }
1527
+ return {
1528
+ platform: "kalshi",
1529
+ ticker: market.ticker,
1530
+ yesAsk: market.yes_ask,
1531
+ yesBid: market.yes_bid,
1532
+ lastPrice: market.last_price
1533
+ };
1534
+ }
1535
+ throw new Error(`Unsupported platform: ${platform}`);
1536
+ },
1537
+ get_market_trades: async (args) => {
1538
+ const platform = args.platform || "polymarket";
1539
+ const limit = String(args.limit || 20);
1540
+ if (platform === "polymarket") {
1541
+ const params = new URLSearchParams({
1542
+ market_slug: args.market_slug,
1543
+ limit
1544
+ });
1545
+ const response = await fetch(
1546
+ `${DOME_API_BASE}/polymarket/orders?${params}`
1547
+ );
1548
+ if (!response.ok) {
1549
+ throw new Error(`Dome API error: ${response.status} ${response.statusText}`);
1550
+ }
1551
+ const data = await response.json();
1552
+ return { platform: "polymarket", ...data };
1553
+ } else if (platform === "kalshi") {
1554
+ const params = new URLSearchParams({
1555
+ ticker: args.market_slug,
1556
+ limit
1557
+ });
1558
+ const response = await fetch(
1559
+ `${DOME_API_BASE}/kalshi/trades?${params}`
1560
+ );
1561
+ if (!response.ok) {
1562
+ throw new Error(`Dome API error: ${response.status} ${response.statusText}`);
1563
+ }
1564
+ const data = await response.json();
1565
+ return { platform: "kalshi", ...data };
1566
+ }
1567
+ throw new Error(`Unsupported platform: ${platform}`);
1568
+ }
1569
+ },
1570
+ hooks: {
1571
+ onRegister: () => {
1572
+ console.log("[Plugin] Prediction Market Alpha v1.1.0 registered (Polymarket + Kalshi)");
1573
+ }
1574
+ }
1575
+ };
1576
+
1577
+ // src/plugins/migrateFun.ts
1578
+ var QA = [
1579
+ { id: "migration-steps-bonk", question: "What are all the steps for migrations to Bonk?", answer: `Here's how MigrateFun migrates your token to BonkFun:
1580
+ 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)
1581
+ 2) After portal setup, holders commit their tokens to migration - tokens are locked in migration vault until time period ends
1582
+ 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
1583
+ 4) The recovered SOL seeds the new LP paired with appropriate amount of tokens. Set market cap at or slightly below current market cap
1584
+ 5) Claims open for 90 days - users burn MFTs and receive new tokens`, keywords: ["bonk", "bonkfun", "steps", "process", "how"], category: "process" },
1585
+ { id: "migration-steps-pumpfun", question: "How does a migration work to Pump Fun?", answer: `Here's how the migration to Pump Fun works:
1586
+ 1) Set up a new CA for pumpfun using MigrateFun creator dashboard (Ticker, CA, image)
1587
+ 2) Users migrate their tokens in the migration portal for a specific time period
1588
+ 3) Once migration ends, MigrateFun sells all migrated tokens
1589
+ 4) MigrateFun takes all recovered SOL and buys out new token's bonding curve + purchases until it reaches old market cap levels
1590
+ 5) Users return to migratefun and claim their new tokens
1591
+ 6) 90-day claim period for all users, regardless if they migrated on time or late
1592
+ 7) The claim period can also be used to swap tokens with centralized exchanges
1593
+ 8) After 90 days, all unclaimed tokens and remaining SOL are returned to the team`, keywords: ["pump", "pumpfun", "steps", "process", "how"], category: "process" },
1594
+ { 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)
1595
+ 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
1596
+ 3) Once migration ends, ALL old tokens are market sold in a single candle to retrieve as much SOL as possible
1597
+ 4) The recovered SOL seeds the new LP paired with appropriate amount of new tokens. Market Cap is set by the user
1598
+ 5) Claims open for 90 days - users burn MFTs and receive new tokens. Late migrators can swap at discounted rate
1599
+ 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" },
1600
+ { 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:
1601
+
1602
+ PRIMARY:
1603
+ - Coingecko (Free + migration application process)
1604
+ - Dexscreener ($300)
1605
+ - GeckoTerminal (free for 5 days wait)
1606
+ - Holderscan (Listing free, Verify $125)
1607
+
1608
+ SECONDARY:
1609
+ - Solscan (if metadata updates needed)
1610
+ - CoinMarketCap ($5000 for immediate listing)
1611
+ - Dextools ($300 for verification)
1612
+ - Photon (2 SOL)
1613
+ - Cookie.fun (Free, DM needed) [For AI accounts]
1614
+ - Kaito (DM needed) [For AI accounts]
1615
+
1616
+ 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" },
1617
+ { 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:
1618
+ 1) Selling the migrated tokens into the old LP
1619
+ 2) Setting the new market cap
1620
+ 3) Opening the claim portal
1621
+
1622
+ Video tutorial: https://www.youtube.com/watch?v=SjPN-1DnXtM`, keywords: ["after", "ends", "approve", "portal"], category: "post-migration" },
1623
+ { 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" },
1624
+ { 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" },
1625
+ { 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" },
1626
+ { 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" },
1627
+ { 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" },
1628
+ { 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.
1629
+ Audit: https://www.halborn.com/audits/emblem-vault/migratefun-8ad34b
1630
+ Announcement: https://x.com/HalbornSecurity/status/1978869642744811933`, keywords: ["audit", "audited", "security", "halborn", "safe"], category: "security" },
1631
+ { id: "user-experience", question: "What is the process like for the user?", answer: `Super easy - takes less than 20 seconds.
1632
+ 1) During migration: users swap old tokens for Migrate Fun Tokens (MFTs)
1633
+ 2) Once migration ends: claim period opens for 90 days, users burn MFTs to claim new tokens
1634
+ 3) Late migrators: can swap old tokens for new at a discounted rate set by the team
1635
+
1636
+ Video guides:
1637
+ - Migration: https://x.com/MigrateFun/status/1971259552856408433
1638
+ - Claims: https://x.com/MigrateFun/status/1976376597906325767`, keywords: ["user", "experience", "process", "simple", "easy"], category: "user-experience" },
1639
+ { 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.
1640
+
1641
+ 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.
1642
+
1643
+ Links:
1644
+ - Website: https://migrate.fun/
1645
+ - X: https://x.com/MigrateFun
1646
+ - Docs: https://github.com/EmblemCompany/Migrate-fun-docs/
1647
+ - Audit: https://www.halborn.com/audits/emblem-vault/migratefun-8ad34b
1648
+ - Calculator: https://migrate.fun/migration-calculator`, keywords: ["what", "migrate fun", "about", "general", "overview"], category: "general" },
1649
+ { 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" },
1650
+ { 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" },
1651
+ { 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" },
1652
+ { 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" },
1653
+ { id: "claim-period-flexibility", question: "Is there flexibility on the 90 day claim period?", answer: `The 90-day claim period is mandatory. Reasons:
1654
+ - All users need time to claim tokens after migration
1655
+ - Those who missed migration need a window
1656
+ - Users don't get tokens until after migration completes
1657
+ - Allowing team to withdraw during claims would be risky (potential rug)`, keywords: ["90 day", "claim", "period", "flexibility", "change"], category: "settings" },
1658
+ { 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.
1659
+
1660
+ 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" },
1661
+ { 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.
1662
+
1663
+ Example charts:
1664
+ - ZERA Old: https://dexscreener.com/solana/95at5r4i85gfqeew2yr6byfg8rlry1d9ztps7qrskdvc
1665
+ New: https://dexscreener.com/solana/nn9vmhjtqgg9l9f8sp3geufwc5zvuhradcwehh7n7di
1666
+ - HUSTLE Old: https://dexscreener.com/solana/gjckb2eesjk65nuvpaw4tn2rabnr8wmfcwcwpagk5dzs
1667
+ New: https://dexscreener.com/solana/hxo1wrcrdewek8l2j6rxswnolumej2mweh38gajxtw7y
1668
+
1669
+ Thread: https://x.com/jakegallen_/status/1973051293213028468`, keywords: ["performance", "charts", "example", "before", "after", "squeeze"], category: "examples" },
1670
+ { id: "why-migrate", question: "Why would teams want to migrate?", answer: `Top reasons:
1671
+ - Access to creator rewards
1672
+ - Rebrand opportunity
1673
+ - Fresh chart
1674
+ - Reclaim part of the token supply
1675
+ - Reinvigorated community on the other side`, keywords: ["why", "reasons", "benefits", "advantages", "should"], category: "general" },
1676
+ { 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)
1677
+ 2) Discuss benefits with your community, especially whale holders - get buy-in
1678
+ 3) Announce on all social channels - maximize awareness for maximum participation`, keywords: ["recommend", "steps", "considering", "planning", "prepare"], category: "process" },
1679
+ { 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" },
1680
+ { 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" },
1681
+ { id: "announcement-examples", question: "Can you give me sample migration announcements?", answer: `Here are announcements made by teams:
1682
+ - https://x.com/radrdotfun/status/1952127168101949620
1683
+ - https://x.com/project_89/status/1951345024656089368
1684
+ - https://x.com/HKittyOnSol/status/1948925330032349210
1685
+ - https://x.com/ModernStoicAI/status/1948129627362218483
1686
+ - https://x.com/pokithehamster/status/1950238636928327927
1687
+ - https://x.com/IQ6900_/status/1953002036599173499
1688
+ - https://x.com/TheBongoCat/status/1965538945132843333`, keywords: ["announcement", "sample", "example", "post", "twitter"], category: "examples" },
1689
+ { 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" },
1690
+ { 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" },
1691
+ { 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:
1692
+ 1) Join as late migrator during 90-day claim window
1693
+ 2) After 90-day period, team takes possession of unclaimed tokens and can reimburse directly`, keywords: ["exchange", "streamflow", "locked", "vested", "cex"], category: "edge-cases" },
1694
+ { 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" },
1695
+ { 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" },
1696
+ { 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" },
1697
+ { 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" },
1698
+ { 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" },
1699
+ { 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" },
1700
+ { 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" },
1701
+ { 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" },
1702
+ { 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" },
1703
+ { 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" },
1704
+ { 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" },
1705
+ { 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" },
1706
+ { id: "sample-announcement", question: "What is a good announcement template?", answer: `Sample for Bonk Fun migration:
1707
+
1708
+ "We're excited to announce that we're migrating with @MigrateFun and officially joining the @bonk_inu ecosystem next month!
1709
+
1710
+ With our 1-year anniversary less than a month away, this migration to @bonk_fun marks the beginning of our next chapter.
1711
+
1712
+ Why Bonk Fun?
1713
+ \u{1F9F0} Purpose-built tools for community projects
1714
+ \u{1F4B8} Transaction fee rev share
1715
+ \u{1F501} Seamless LP migration
1716
+ \u{1F91D} Strategic alignment with top meme coin teams
1717
+
1718
+ Our migration timeline + holder instructions drop soon."`, keywords: ["announcement", "template", "sample", "post"], category: "examples" },
1719
+ { id: "share-link", question: "Do you have a link to share explaining Migrate Fun?", answer: `Overview thread: https://x.com/migratefun/status/1957492884355314035
1720
+ Deep dive docs: https://github.com/EmblemCompany/Migrate-fun-docs/`, keywords: ["link", "share", "explain", "overview"], category: "general" },
1721
+ { 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" },
1722
+ { 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" },
1723
+ { 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" },
1724
+ { 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" },
1725
+ { 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" },
1726
+ { 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" },
1727
+ { 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" },
1728
+ { 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" },
1729
+ { id: "exchange-options", question: "What options do exchanges have to swap tokens?", answer: `Two options:
1730
+
1731
+ Option 1: Participate onchain through the migration portal (same as retail). Load tokens into Phantom wallet, migrate, then claim. ~10 seconds each step.
1732
+
1733
+ Option 2: Admin withdraw function during 90-day claim period. Migration admin can withdraw new tokens from claims vault and manually swap with exchange.
1734
+ - 90-day window for exchange procedures
1735
+ - Exchange can observe migration complete before acting
1736
+ - Can receive new tokens before sending old
1737
+ - Can pause trading during process`, keywords: ["exchange", "cex", "swap", "options", "centralized"], category: "edge-cases" },
1738
+ { 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.
1739
+
1740
+ 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" }
1741
+ ];
1742
+ var migrateFunPlugin = {
1743
+ name: "migrate-fun-knowledge",
1744
+ version: "1.0.0",
1745
+ description: "Search Migrate.fun knowledge base for token migration answers",
1746
+ tools: [
1747
+ {
1748
+ name: "search_migrate_fun_docs",
1749
+ 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.",
1750
+ parameters: {
1751
+ type: "object",
1752
+ properties: {
1753
+ query: {
1754
+ type: "string",
1755
+ description: "The search query - user question or key terms about token migrations"
1756
+ },
1757
+ topK: {
1758
+ type: "number",
1759
+ description: "Number of results to return (default: 5, max: 10)"
1760
+ }
1761
+ },
1762
+ required: ["query"]
1763
+ }
1764
+ }
1765
+ ],
1766
+ executors: {
1767
+ search_migrate_fun_docs: async (args) => {
1768
+ const query = args.query;
1769
+ const topK = Math.min(Math.max(1, args.topK || 5), 10);
1770
+ const queryLower = query.toLowerCase();
1771
+ const queryWords = queryLower.split(/\s+/).filter((w) => w.length > 2);
1772
+ const scored = QA.map((qa) => {
1773
+ let score = 0;
1774
+ const questionLower = qa.question.toLowerCase();
1775
+ const answerLower = qa.answer.toLowerCase();
1776
+ const keywordsStr = qa.keywords.join(" ").toLowerCase();
1777
+ const fullText = `${questionLower} ${answerLower} ${keywordsStr}`;
1778
+ if (questionLower.includes(queryLower)) score += 15;
1779
+ if (fullText.includes(queryLower)) score += 8;
1780
+ for (const word of queryWords) {
1781
+ if (qa.keywords.some((kw) => kw.toLowerCase().includes(word) || word.includes(kw.toLowerCase()))) {
1782
+ score += 4;
1783
+ }
1784
+ if (questionLower.includes(word)) score += 3;
1785
+ if (answerLower.includes(word)) score += 1;
1786
+ }
1787
+ return { ...qa, score };
1788
+ });
1789
+ const results = scored.filter((qa) => qa.score > 0).sort((a, b) => b.score - a.score).slice(0, topK).map((qa, i) => ({
1790
+ rank: i + 1,
1791
+ relevance: Math.round(qa.score / 30 * 100) / 100,
1792
+ question: qa.question,
1793
+ answer: qa.answer,
1794
+ category: qa.category
1795
+ }));
1796
+ return {
1797
+ success: true,
1798
+ query,
1799
+ resultCount: results.length,
1800
+ results,
1801
+ 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."
1802
+ };
1803
+ }
1804
+ },
1805
+ hooks: {
1806
+ onRegister: () => {
1807
+ console.log("[Plugin] Migrate.fun Knowledge Base v1.0.0 registered");
1808
+ }
1809
+ }
1810
+ };
1811
+
1812
+ // src/plugins/index.ts
1813
+ var availablePlugins = [
1814
+ {
1815
+ ...predictionMarketPlugin,
1816
+ description: "Search and analyze Polymarket and Kalshi prediction markets"
1817
+ },
1818
+ {
1819
+ ...migrateFunPlugin,
1820
+ description: "Search Migrate.fun knowledge base for token migration answers"
1821
+ }
1822
+ ];
1823
+ hljs__default.default.registerLanguage("javascript", javascript__default.default);
1824
+ hljs__default.default.registerLanguage("js", javascript__default.default);
1825
+ hljs__default.default.registerLanguage("typescript", typescript__default.default);
1826
+ hljs__default.default.registerLanguage("ts", typescript__default.default);
1827
+ hljs__default.default.registerLanguage("python", python__default.default);
1828
+ hljs__default.default.registerLanguage("py", python__default.default);
1829
+ hljs__default.default.registerLanguage("json", json__default.default);
1830
+ hljs__default.default.registerLanguage("bash", bash__default.default);
1831
+ hljs__default.default.registerLanguage("sh", bash__default.default);
1832
+ hljs__default.default.registerLanguage("shell", shell__default.default);
1833
+ hljs__default.default.registerLanguage("css", css__default.default);
1834
+ hljs__default.default.registerLanguage("xml", xml__default.default);
1835
+ hljs__default.default.registerLanguage("html", xml__default.default);
1836
+ hljs__default.default.registerLanguage("markdown", markdown__default.default);
1837
+ hljs__default.default.registerLanguage("md", markdown__default.default);
1838
+ hljs__default.default.registerLanguage("sql", sql__default.default);
1839
+ hljs__default.default.registerLanguage("yaml", yaml__default.default);
1840
+ hljs__default.default.registerLanguage("yml", yaml__default.default);
1841
+ hljs__default.default.registerLanguage("rust", rust__default.default);
1842
+ hljs__default.default.registerLanguage("go", go__default.default);
1843
+ hljs__default.default.registerLanguage("java", java__default.default);
1844
+ hljs__default.default.registerLanguage("cpp", cpp__default.default);
1845
+ hljs__default.default.registerLanguage("c", cpp__default.default);
1846
+ hljs__default.default.registerLanguage("csharp", csharp__default.default);
1847
+ hljs__default.default.registerLanguage("cs", csharp__default.default);
1848
+ hljs__default.default.registerLanguage("php", php__default.default);
1849
+ hljs__default.default.registerLanguage("ruby", ruby__default.default);
1850
+ hljs__default.default.registerLanguage("rb", ruby__default.default);
1851
+ hljs__default.default.registerLanguage("swift", swift__default.default);
1852
+ hljs__default.default.registerLanguage("kotlin", kotlin__default.default);
1853
+ hljs__default.default.registerLanguage("kt", kotlin__default.default);
1854
+ var containerStyle = {
1855
+ fontFamily: tokens.typography.fontFamily,
1856
+ fontSize: tokens.typography.fontSizeMd,
1857
+ lineHeight: 1.5,
1858
+ color: "inherit",
1859
+ wordBreak: "break-word"
1860
+ };
1861
+ var scopedStyles = `
1862
+ .hljs-md p {
1863
+ margin: 0 0 0.5em 0;
1864
+ }
1865
+ .hljs-md p:last-child {
1866
+ margin-bottom: 0;
1867
+ }
1868
+ .hljs-md ul,
1869
+ .hljs-md ol {
1870
+ margin: 0.25em 0 0.5em 0;
1871
+ padding-left: 1.5em;
1872
+ }
1873
+ .hljs-md li {
1874
+ margin: 0.1em 0;
1875
+ line-height: 1.4;
1876
+ }
1877
+ .hljs-md li > p {
1878
+ margin: 0;
1879
+ display: inline;
1880
+ }
1881
+ .hljs-md li > ul,
1882
+ .hljs-md li > ol {
1883
+ margin: 0.1em 0;
1884
+ }
1885
+ .hljs-md .code-block-wrapper {
1886
+ position: relative;
1887
+ margin: 0.5em 0;
1888
+ }
1889
+ .hljs-md .code-block-wrapper pre {
1890
+ position: relative;
1891
+ margin: 0;
1892
+ padding: 0.75em 1em;
1893
+ border-radius: 6px;
1894
+ background: #1e1e1e;
1895
+ overflow-x: auto;
1896
+ }
1897
+ .hljs-md .code-block-toolbar {
1898
+ position: absolute;
1899
+ top: 6px;
1900
+ right: 6px;
1901
+ display: flex;
1902
+ gap: 4px;
1903
+ z-index: 10;
1904
+ }
1905
+ .hljs-md .code-block-btn {
1906
+ display: flex;
1907
+ align-items: center;
1908
+ justify-content: center;
1909
+ width: 26px;
1910
+ height: 26px;
1911
+ padding: 0;
1912
+ background: #2d2d2d;
1913
+ border: 1px solid #404040;
1914
+ border-radius: 4px;
1915
+ color: #888;
1916
+ cursor: pointer;
1917
+ transition: all 0.15s ease;
1918
+ opacity: 0.7;
1919
+ }
1920
+ .hljs-md .code-block-wrapper:hover .code-block-btn {
1921
+ opacity: 1;
1922
+ }
1923
+ .hljs-md .code-block-btn:hover {
1924
+ background: #3d3d3d;
1925
+ border-color: #555;
1926
+ color: #ccc;
1927
+ }
1928
+ .hljs-md .code-block-btn.copied {
1929
+ color: ${tokens.colors.accentSuccess};
1930
+ }
1931
+ .hljs-md code {
1932
+ font-family: ${tokens.typography.fontFamilyMono};
1933
+ font-size: 0.9em;
1934
+ }
1935
+ .hljs-md :not(pre) > code {
1936
+ padding: 0.15em 0.4em;
1937
+ border-radius: 4px;
1938
+ background: rgba(255, 255, 255, 0.1);
1939
+ }
1940
+ .hljs-md pre code {
1941
+ padding: 0;
1942
+ background: transparent;
1943
+ font-size: 0.875em;
1944
+ line-height: 1.5;
1945
+ }
1946
+ .hljs-md h1, .hljs-md h2, .hljs-md h3, .hljs-md h4 {
1947
+ margin: 0.5em 0 0.25em 0;
1948
+ font-weight: 600;
1949
+ line-height: 1.3;
1950
+ }
1951
+ .hljs-md h1:first-child, .hljs-md h2:first-child, .hljs-md h3:first-child {
1952
+ margin-top: 0;
1953
+ }
1954
+ .hljs-md h1 { font-size: 1.5em; }
1955
+ .hljs-md h2 { font-size: 1.25em; }
1956
+ .hljs-md h3 { font-size: 1.1em; }
1957
+ .hljs-md h4 { font-size: 1em; }
1958
+ .hljs-md blockquote {
1959
+ margin: 0.5em 0;
1960
+ padding: 0.5em 0 0.5em 1em;
1961
+ border-left: 3px solid ${tokens.colors.borderSecondary};
1962
+ color: ${tokens.colors.textSecondary};
1963
+ }
1964
+ .hljs-md a {
1965
+ color: ${tokens.colors.accentPrimary};
1966
+ text-decoration: underline;
1967
+ }
1968
+ .hljs-md hr {
1969
+ margin: 1em 0;
1970
+ border: none;
1971
+ border-top: 1px solid ${tokens.colors.borderSecondary};
1972
+ }
1973
+ .hljs-md table {
1974
+ width: 100%;
1975
+ margin: 0.5em 0;
1976
+ border-collapse: collapse;
1977
+ }
1978
+ .hljs-md th, .hljs-md td {
1979
+ padding: 0.5em;
1980
+ border: 1px solid ${tokens.colors.borderPrimary};
1981
+ text-align: left;
1982
+ }
1983
+ .hljs-md th {
1984
+ font-weight: 600;
1985
+ background: rgba(255, 255, 255, 0.05);
1986
+ }
1987
+
1988
+ /* highlight.js dark theme (VS Code Dark+ inspired) */
1989
+ .hljs {
1990
+ color: #d4d4d4;
1991
+ background: #1e1e1e;
1992
+ }
1993
+ .hljs-keyword,
1994
+ .hljs-selector-tag,
1995
+ .hljs-title,
1996
+ .hljs-section,
1997
+ .hljs-doctag,
1998
+ .hljs-name,
1999
+ .hljs-strong {
2000
+ color: #569cd6;
2001
+ font-weight: normal;
2002
+ }
2003
+ .hljs-built_in,
2004
+ .hljs-literal,
2005
+ .hljs-type,
2006
+ .hljs-params,
2007
+ .hljs-meta,
2008
+ .hljs-link {
2009
+ color: #4ec9b0;
2010
+ }
2011
+ .hljs-string,
2012
+ .hljs-symbol,
2013
+ .hljs-bullet,
2014
+ .hljs-addition {
2015
+ color: #ce9178;
2016
+ }
2017
+ .hljs-number {
2018
+ color: #b5cea8;
2019
+ }
2020
+ .hljs-comment,
2021
+ .hljs-quote,
2022
+ .hljs-deletion {
2023
+ color: #6a9955;
2024
+ }
2025
+ .hljs-variable,
2026
+ .hljs-template-variable,
2027
+ .hljs-attr {
2028
+ color: #9cdcfe;
2029
+ }
2030
+ .hljs-regexp,
2031
+ .hljs-selector-id,
2032
+ .hljs-selector-class {
2033
+ color: #d7ba7d;
2034
+ }
2035
+ .hljs-emphasis {
2036
+ font-style: italic;
2037
+ }
2038
+ `;
2039
+ marked.marked.use({
2040
+ gfm: true,
2041
+ breaks: false
2042
+ });
2043
+ function highlightCode(code2, lang) {
2044
+ if (lang && hljs__default.default.getLanguage(lang)) {
2045
+ try {
2046
+ return hljs__default.default.highlight(code2, { language: lang }).value;
2047
+ } catch {
2048
+ }
2049
+ }
2050
+ try {
2051
+ return hljs__default.default.highlightAuto(code2).value;
2052
+ } catch {
2053
+ return code2.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
2054
+ }
2055
+ }
2056
+ var codeBlockCounter = 0;
2057
+ function generateCodeBlockId() {
2058
+ return `code-block-${++codeBlockCounter}`;
2059
+ }
2060
+ function renderMarkdown(content) {
2061
+ const html = marked.marked.parse(content, { async: false });
2062
+ const codeBlockRegex = /<pre><code class="language-(\w+)">([\s\S]*?)<\/code><\/pre>/g;
2063
+ let result = html.replace(codeBlockRegex, (_, lang, code2) => {
2064
+ const decoded = code2.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&").replace(/&quot;/g, '"');
2065
+ const highlighted = highlightCode(decoded, lang);
2066
+ const id = generateCodeBlockId();
2067
+ const encodedCode = encodeURIComponent(decoded);
2068
+ return `<div class="code-block-wrapper" data-code-id="${id}" data-code="${encodedCode}"><pre><code class="hljs language-${lang}">${highlighted}</code></pre><div class="code-block-toolbar"><button class="code-block-btn" data-action="copy" data-code-id="${id}" title="Copy code"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg></button><button class="code-block-btn" data-action="emblem" data-code-id="${id}" title="Open in Emblem AI"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="16 18 22 12 16 6"></polyline><polyline points="8 6 2 12 8 18"></polyline></svg></button></div></div>`;
2069
+ });
2070
+ const plainCodeRegex = /<pre><code>([\s\S]*?)<\/code><\/pre>/g;
2071
+ result = result.replace(plainCodeRegex, (_, code2) => {
2072
+ const decoded = code2.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&").replace(/&quot;/g, '"');
2073
+ const highlighted = highlightCode(decoded, "");
2074
+ const id = generateCodeBlockId();
2075
+ const encodedCode = encodeURIComponent(decoded);
2076
+ return `<div class="code-block-wrapper" data-code-id="${id}" data-code="${encodedCode}"><pre><code class="hljs">${highlighted}</code></pre><div class="code-block-toolbar"><button class="code-block-btn" data-action="copy" data-code-id="${id}" title="Copy code"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg></button><button class="code-block-btn" data-action="emblem" data-code-id="${id}" title="Open in Emblem AI"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="16 18 22 12 16 6"></polyline><polyline points="8 6 2 12 8 18"></polyline></svg></button></div></div>`;
2077
+ });
2078
+ return result;
2079
+ }
2080
+ function MarkdownContent({ content, className }) {
2081
+ const [rendered, setRendered] = react.useState("");
2082
+ const containerRef = react.useRef(null);
2083
+ react.useEffect(() => {
2084
+ try {
2085
+ const html = renderMarkdown(content);
2086
+ setRendered(html);
2087
+ } catch (err) {
2088
+ console.error("[MarkdownContent] Render error:", err);
2089
+ setRendered(
2090
+ content.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/\n/g, "<br>")
2091
+ );
2092
+ }
2093
+ }, [content]);
2094
+ react.useEffect(() => {
2095
+ const container = containerRef.current;
2096
+ if (!container) return;
2097
+ const handleClick = async (e) => {
2098
+ const target = e.target;
2099
+ const button = target.closest("[data-action]");
2100
+ if (!button) return;
2101
+ const action = button.dataset.action;
2102
+ const codeId = button.dataset.codeId;
2103
+ if (!codeId) return;
2104
+ const wrapper = container.querySelector(`[data-code-id="${codeId}"]`);
2105
+ if (!wrapper) return;
2106
+ const encodedCode = wrapper.dataset.code;
2107
+ if (!encodedCode) return;
2108
+ const code2 = decodeURIComponent(encodedCode);
2109
+ if (action === "copy") {
2110
+ e.preventDefault();
2111
+ try {
2112
+ await navigator.clipboard.writeText(code2);
2113
+ button.classList.add("copied");
2114
+ button.innerHTML = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
2115
+ <polyline points="20 6 9 17 4 12"></polyline>
2116
+ </svg>`;
2117
+ setTimeout(() => {
2118
+ button.classList.remove("copied");
2119
+ button.innerHTML = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
2120
+ <rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
2121
+ <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
2122
+ </svg>`;
2123
+ }, 2e3);
2124
+ } catch (err) {
2125
+ console.error("Failed to copy:", err);
2126
+ }
2127
+ } else if (action === "emblem") {
2128
+ e.preventDefault();
2129
+ const url = `https://build.emblemvault.ai/?q=${encodeURIComponent(code2)}`;
2130
+ window.open(url, "_blank", "noopener,noreferrer");
2131
+ }
2132
+ };
2133
+ container.addEventListener("click", handleClick);
2134
+ return () => container.removeEventListener("click", handleClick);
2135
+ }, [rendered]);
2136
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2137
+ /* @__PURE__ */ jsxRuntime.jsx("style", { children: scopedStyles }),
2138
+ /* @__PURE__ */ jsxRuntime.jsx(
2139
+ "div",
2140
+ {
2141
+ ref: containerRef,
2142
+ style: containerStyle,
2143
+ className: `hljs-md ${className || ""}`,
2144
+ dangerouslySetInnerHTML: { __html: rendered }
2145
+ }
2146
+ )
2147
+ ] });
2148
+ }
2149
+ var styles2 = {
2150
+ // Container
2151
+ container: {
2152
+ display: "flex",
2153
+ flexDirection: "column",
2154
+ height: "100%",
2155
+ background: tokens.colors.bgSecondary,
2156
+ borderRadius: tokens.radius.xl,
2157
+ border: `1px solid ${tokens.colors.borderPrimary}`,
2158
+ fontFamily: tokens.typography.fontFamily,
2159
+ color: tokens.colors.textPrimary
2160
+ },
2161
+ // Not ready / auth required states
2162
+ placeholder: {
2163
+ padding: tokens.spacing.xxl,
2164
+ background: tokens.colors.bgSecondary,
2165
+ borderRadius: tokens.radius.xl,
2166
+ border: `1px solid ${tokens.colors.borderPrimary}`
2167
+ },
2168
+ placeholderContent: {
2169
+ color: tokens.colors.textSecondary
2170
+ },
2171
+ placeholderTitle: {
2172
+ fontSize: tokens.typography.fontSizeLg,
2173
+ fontWeight: tokens.typography.fontWeightMedium,
2174
+ marginBottom: tokens.spacing.xs
2175
+ },
2176
+ placeholderText: {
2177
+ fontSize: tokens.typography.fontSizeSm,
2178
+ color: tokens.colors.textTertiary
2179
+ },
2180
+ loadingSpinner: {
2181
+ border: `2px solid ${tokens.colors.textTertiary}`,
2182
+ borderRadius: tokens.radius.full,
2183
+ marginBottom: tokens.spacing.sm
2184
+ },
2185
+ // Header - darker shade
2186
+ header: {
2187
+ display: "flex",
2188
+ alignItems: "center",
2189
+ justifyContent: "space-between",
2190
+ padding: `${tokens.spacing.md} ${tokens.spacing.lg}`,
2191
+ background: tokens.colors.bgPrimary,
2192
+ borderBottom: `1px solid ${tokens.colors.borderPrimary}`,
2193
+ borderRadius: `${tokens.radius.xl} ${tokens.radius.xl} 0 0`
2194
+ },
2195
+ headerTitle: {
2196
+ fontWeight: tokens.typography.fontWeightSemibold,
2197
+ color: tokens.colors.textPrimary,
2198
+ fontSize: tokens.typography.fontSizeMd
2199
+ },
2200
+ headerActions: {
2201
+ display: "flex",
2202
+ alignItems: "center",
2203
+ gap: tokens.spacing.sm
2204
+ },
2205
+ // Model selector
2206
+ select: {
2207
+ fontSize: tokens.typography.fontSizeSm,
2208
+ padding: `${tokens.spacing.xs} ${tokens.spacing.sm}`,
2209
+ border: `1px solid ${tokens.colors.borderSecondary}`,
2210
+ borderRadius: tokens.radius.md,
2211
+ background: tokens.colors.bgTertiary,
2212
+ color: tokens.colors.textPrimary},
2213
+ // Settings button
2214
+ settingsBtn: {
2215
+ ...presets.buttonIcon,
2216
+ borderRadius: tokens.radius.md
2217
+ },
2218
+ settingsBtnActive: {
2219
+ background: tokens.colors.accentPrimaryBg,
2220
+ color: tokens.colors.accentPrimary
2221
+ },
2222
+ settingsBtnInactive: {
2223
+ color: tokens.colors.textSecondary
2224
+ },
2225
+ // Settings Modal
2226
+ modalOverlay: {
2227
+ position: "fixed",
2228
+ top: 0,
2229
+ left: 0,
2230
+ right: 0,
2231
+ bottom: 0,
2232
+ background: tokens.colors.bgOverlay,
2233
+ display: "flex",
2234
+ alignItems: "center",
2235
+ justifyContent: "center",
2236
+ zIndex: tokens.zIndex.modal
2237
+ },
2238
+ modal: {
2239
+ background: tokens.colors.bgSecondary,
2240
+ borderRadius: tokens.radius.xl,
2241
+ border: `1px solid ${tokens.colors.borderPrimary}`,
2242
+ width: "100%",
2243
+ maxWidth: "440px",
2244
+ maxHeight: "90vh",
2245
+ overflow: "auto",
2246
+ boxShadow: tokens.shadows.xl
2247
+ },
2248
+ modalHeader: {
2249
+ display: "flex",
2250
+ alignItems: "center",
2251
+ justifyContent: "space-between",
2252
+ padding: `${tokens.spacing.lg} ${tokens.spacing.xl}`,
2253
+ borderBottom: `1px solid ${tokens.colors.borderPrimary}`
2254
+ },
2255
+ modalTitle: {
2256
+ fontSize: tokens.typography.fontSizeLg,
2257
+ fontWeight: tokens.typography.fontWeightSemibold,
2258
+ color: tokens.colors.textPrimary
2259
+ },
2260
+ modalClose: {
2261
+ background: "transparent",
2262
+ border: "none",
2263
+ color: tokens.colors.textTertiary,
2264
+ fontSize: "20px",
2265
+ cursor: "pointer",
2266
+ padding: tokens.spacing.xs,
2267
+ lineHeight: 1,
2268
+ transition: `color ${tokens.transitions.fast}`
2269
+ },
2270
+ modalBody: {
2271
+ padding: tokens.spacing.xl
2272
+ },
2273
+ // Settings sections
2274
+ settingGroup: {
2275
+ marginBottom: tokens.spacing.xl
2276
+ },
2277
+ settingLabel: {
2278
+ display: "block",
2279
+ fontSize: tokens.typography.fontSizeMd,
2280
+ fontWeight: tokens.typography.fontWeightMedium,
2281
+ color: tokens.colors.textPrimary,
2282
+ marginBottom: tokens.spacing.xs
2283
+ },
2284
+ settingDescription: {
2285
+ fontSize: tokens.typography.fontSizeSm,
2286
+ color: tokens.colors.textTertiary,
2287
+ marginBottom: tokens.spacing.md
2288
+ },
2289
+ settingSelect: {
2290
+ width: "100%",
2291
+ padding: `${tokens.spacing.md} ${tokens.spacing.lg}`,
2292
+ fontSize: tokens.typography.fontSizeMd,
2293
+ background: tokens.colors.bgTertiary,
2294
+ border: `1px solid ${tokens.colors.borderSecondary}`,
2295
+ borderRadius: tokens.radius.lg,
2296
+ color: tokens.colors.textPrimary,
2297
+ outline: "none",
2298
+ cursor: "pointer",
2299
+ appearance: "none",
2300
+ backgroundImage: `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238892a4' d='M6 8L1 3h10z'/%3E%3C/svg%3E")`,
2301
+ backgroundRepeat: "no-repeat",
2302
+ backgroundPosition: "right 12px center",
2303
+ paddingRight: "36px"
2304
+ },
2305
+ modelInfo: {
2306
+ fontSize: tokens.typography.fontSizeXs,
2307
+ color: tokens.colors.textTertiary,
2308
+ marginTop: tokens.spacing.sm
2309
+ },
2310
+ // Toggle switch row
2311
+ toggleRow: {
2312
+ display: "flex",
2313
+ alignItems: "center",
2314
+ justifyContent: "space-between",
2315
+ padding: `${tokens.spacing.md} ${tokens.spacing.lg}`,
2316
+ background: tokens.colors.bgTertiary,
2317
+ borderRadius: tokens.radius.lg,
2318
+ marginBottom: tokens.spacing.sm
2319
+ },
2320
+ toggleLabel: {
2321
+ fontSize: tokens.typography.fontSizeMd,
2322
+ color: tokens.colors.textPrimary
2323
+ },
2324
+ toggleSwitch: {
2325
+ position: "relative",
2326
+ width: "44px",
2327
+ height: "24px",
2328
+ background: tokens.colors.borderSecondary,
2329
+ borderRadius: "12px",
2330
+ cursor: "pointer",
2331
+ transition: `background ${tokens.transitions.fast}`
2332
+ },
2333
+ toggleSwitchActive: {
2334
+ background: tokens.colors.accentPrimary
2335
+ },
2336
+ toggleKnob: {
2337
+ position: "absolute",
2338
+ top: "2px",
2339
+ left: "2px",
2340
+ width: "20px",
2341
+ height: "20px",
2342
+ background: tokens.colors.textPrimary,
2343
+ borderRadius: tokens.radius.full,
2344
+ transition: `transform ${tokens.transitions.fast}`
2345
+ },
2346
+ toggleKnobActive: {
2347
+ transform: "translateX(20px)"
2348
+ },
2349
+ // Settings textarea
2350
+ settingTextarea: {
2351
+ width: "100%",
2352
+ minHeight: "100px",
2353
+ padding: tokens.spacing.lg,
2354
+ fontSize: tokens.typography.fontSizeMd,
2355
+ background: tokens.colors.bgTertiary,
2356
+ border: `1px solid ${tokens.colors.borderSecondary}`,
2357
+ borderRadius: tokens.radius.lg,
2358
+ color: tokens.colors.textPrimary,
2359
+ outline: "none",
2360
+ resize: "vertical",
2361
+ fontFamily: tokens.typography.fontFamily
2362
+ },
2363
+ // Messages area
2364
+ messagesArea: {
2365
+ flex: 1,
2366
+ overflowY: "auto",
2367
+ padding: tokens.spacing.lg,
2368
+ background: tokens.colors.bgSecondary
2369
+ },
2370
+ messagesEmpty: {
2371
+ textAlign: "center",
2372
+ color: tokens.colors.textTertiary,
2373
+ padding: tokens.spacing.xxl
2374
+ },
2375
+ messagesContainer: {
2376
+ display: "flex",
2377
+ flexDirection: "column",
2378
+ gap: tokens.spacing.lg
2379
+ },
2380
+ // Tool calls indicator
2381
+ toolCallsIndicator: {
2382
+ display: "flex",
2383
+ flexWrap: "wrap",
2384
+ gap: tokens.spacing.sm,
2385
+ padding: `0 ${tokens.spacing.lg}`
2386
+ },
2387
+ toolCallBadge: {
2388
+ display: "inline-flex",
2389
+ alignItems: "center",
2390
+ gap: tokens.spacing.xs,
2391
+ padding: `${tokens.spacing.xs} ${tokens.spacing.sm}`,
2392
+ fontSize: tokens.typography.fontSizeXs,
2393
+ background: tokens.colors.accentWarningBg,
2394
+ color: tokens.colors.accentWarning,
2395
+ borderRadius: tokens.radius.pill
2396
+ },
2397
+ toolCallDot: {
2398
+ width: "8px",
2399
+ height: "8px",
2400
+ background: tokens.colors.accentWarning,
2401
+ borderRadius: tokens.radius.full,
2402
+ animation: "hustle-pulse 1s ease-in-out infinite"
2403
+ },
2404
+ // Attachments preview
2405
+ attachmentsPreview: {
2406
+ padding: `${tokens.spacing.sm} ${tokens.spacing.lg}`,
2407
+ borderTop: `1px solid ${tokens.colors.borderPrimary}`,
2408
+ display: "flex",
2409
+ flexWrap: "wrap",
2410
+ gap: tokens.spacing.sm
2411
+ },
2412
+ attachmentItem: {
2413
+ display: "inline-flex",
2414
+ alignItems: "center",
2415
+ gap: tokens.spacing.xs,
2416
+ padding: `${tokens.spacing.xs} ${tokens.spacing.sm}`,
2417
+ background: tokens.colors.bgTertiary,
2418
+ borderRadius: tokens.radius.md,
2419
+ fontSize: tokens.typography.fontSizeSm
2420
+ },
2421
+ attachmentName: {
2422
+ maxWidth: "100px",
2423
+ overflow: "hidden",
2424
+ textOverflow: "ellipsis",
2425
+ whiteSpace: "nowrap"
2426
+ },
2427
+ attachmentRemove: {
2428
+ background: "none",
2429
+ border: "none",
2430
+ color: tokens.colors.textTertiary,
2431
+ cursor: "pointer",
2432
+ fontSize: "14px",
2433
+ padding: 0,
2434
+ lineHeight: 1
2435
+ },
2436
+ // Input area - slightly darker than messages
2437
+ inputArea: {
2438
+ padding: tokens.spacing.lg,
2439
+ background: tokens.colors.bgPrimary,
2440
+ borderTop: `1px solid ${tokens.colors.borderPrimary}`,
2441
+ borderRadius: `0 0 ${tokens.radius.xl} ${tokens.radius.xl}`
2442
+ },
2443
+ inputRow: {
2444
+ display: "flex",
2445
+ alignItems: "center",
2446
+ gap: tokens.spacing.sm
2447
+ },
2448
+ inputContainer: {
2449
+ flex: 1,
2450
+ display: "flex",
2451
+ alignItems: "center",
2452
+ background: tokens.colors.bgTertiary,
2453
+ border: `1px solid ${tokens.colors.borderSecondary}`,
2454
+ borderRadius: tokens.radius.lg,
2455
+ overflow: "hidden"
2456
+ },
2457
+ attachBtn: {
2458
+ width: "40px",
2459
+ height: "40px",
2460
+ padding: 0,
2461
+ background: "transparent",
2462
+ border: "none",
2463
+ borderRadius: 0,
2464
+ color: tokens.colors.textTertiary,
2465
+ flexShrink: 0
2466
+ },
2467
+ inputWrapper: {
2468
+ flex: 1
2469
+ },
2470
+ input: {
2471
+ width: "100%",
2472
+ padding: `${tokens.spacing.md} ${tokens.spacing.sm}`,
2473
+ background: "transparent",
2474
+ border: "none",
2475
+ color: tokens.colors.textPrimary,
2476
+ fontSize: tokens.typography.fontSizeMd,
2477
+ outline: "none",
2478
+ resize: "none"
2479
+ },
2480
+ inputDisabled: {
2481
+ background: tokens.colors.bgTertiary,
2482
+ cursor: "not-allowed"
2483
+ },
2484
+ sendBtn: {
2485
+ // Inherits global button styles from CSS
2486
+ height: "40px",
2487
+ padding: `0 ${tokens.spacing.lg}`,
2488
+ fontWeight: tokens.typography.fontWeightMedium
2489
+ },
2490
+ sendBtnDisabled: {
2491
+ opacity: 0.5,
2492
+ cursor: "not-allowed"
2493
+ },
2494
+ sendSpinner: {
2495
+ display: "inline-block",
2496
+ width: "16px",
2497
+ height: "16px",
2498
+ border: "2px solid currentColor",
2499
+ borderTopColor: "transparent",
2500
+ borderRadius: tokens.radius.full,
2501
+ animation: "hustle-spin 0.8s linear infinite"
2502
+ },
2503
+ // Error display
2504
+ errorBox: {
2505
+ marginTop: tokens.spacing.sm,
2506
+ padding: `${tokens.spacing.sm} ${tokens.spacing.md}`,
2507
+ background: tokens.colors.accentErrorBg,
2508
+ color: tokens.colors.accentError,
2509
+ fontSize: tokens.typography.fontSizeSm,
2510
+ borderRadius: tokens.radius.md
2511
+ },
2512
+ // Message bubbles
2513
+ messageBubbleContainer: {
2514
+ display: "flex"
2515
+ },
2516
+ messageBubbleUser: {
2517
+ justifyContent: "flex-end"
2518
+ },
2519
+ messageBubbleAssistant: {
2520
+ justifyContent: "flex-start"
2521
+ },
2522
+ messageBubble: {
2523
+ maxWidth: "80%",
2524
+ padding: `${tokens.spacing.sm} ${tokens.spacing.lg}`,
2525
+ borderRadius: tokens.radius.lg
2526
+ },
2527
+ messageBubbleUserStyle: {
2528
+ background: tokens.colors.msgUser,
2529
+ color: tokens.colors.textPrimary
2530
+ },
2531
+ messageBubbleAssistantStyle: {
2532
+ background: tokens.colors.msgAssistant,
2533
+ color: tokens.colors.textPrimary
2534
+ },
2535
+ messageBubbleSystemStyle: {
2536
+ background: tokens.colors.bgTertiary,
2537
+ color: tokens.colors.textSecondary,
2538
+ fontSize: tokens.typography.fontSizeSm,
2539
+ fontStyle: "italic"
2540
+ },
2541
+ messageContent: {
2542
+ whiteSpace: "pre-wrap",
2543
+ wordBreak: "break-word",
2544
+ lineHeight: tokens.typography.lineHeightRelaxed
2545
+ },
2546
+ streamingCursor: {
2547
+ display: "inline-block",
2548
+ width: "2px",
2549
+ height: "16px",
2550
+ marginLeft: tokens.spacing.xs,
2551
+ background: "currentColor",
2552
+ animation: "hustle-pulse 0.8s ease-in-out infinite"
2553
+ },
2554
+ // Tool calls debug
2555
+ toolCallsDebug: {
2556
+ marginTop: tokens.spacing.sm,
2557
+ paddingTop: tokens.spacing.sm,
2558
+ borderTop: `1px solid ${tokens.colors.borderSecondary}`,
2559
+ fontSize: tokens.typography.fontSizeXs
2560
+ },
2561
+ toolCallsDebugTitle: {
2562
+ fontWeight: tokens.typography.fontWeightMedium,
2563
+ color: tokens.colors.textSecondary,
2564
+ marginBottom: tokens.spacing.xs
2565
+ },
2566
+ toolCallDebugItem: {
2567
+ background: "rgba(255,255,255,0.05)",
2568
+ borderRadius: tokens.radius.sm,
2569
+ padding: tokens.spacing.xs,
2570
+ marginTop: tokens.spacing.xs
2571
+ },
2572
+ toolCallDebugName: {
2573
+ ...presets.mono
2574
+ },
2575
+ toolCallDebugArgs: {
2576
+ ...presets.mono,
2577
+ marginTop: tokens.spacing.xs,
2578
+ fontSize: "10px",
2579
+ overflow: "auto"
2580
+ },
2581
+ // Plugin management styles
2582
+ settingDivider: {
2583
+ height: "1px",
2584
+ background: tokens.colors.borderPrimary,
2585
+ margin: `${tokens.spacing.xl} 0`
2586
+ },
2587
+ pluginList: {
2588
+ display: "flex",
2589
+ flexDirection: "column",
2590
+ gap: tokens.spacing.sm
2591
+ },
2592
+ pluginRow: {
2593
+ display: "flex",
2594
+ alignItems: "center",
2595
+ justifyContent: "space-between",
2596
+ padding: `${tokens.spacing.md} ${tokens.spacing.lg}`,
2597
+ background: tokens.colors.bgTertiary,
2598
+ borderRadius: tokens.radius.lg
2599
+ },
2600
+ pluginInfo: {
2601
+ display: "flex",
2602
+ alignItems: "center",
2603
+ gap: tokens.spacing.md,
2604
+ flex: 1,
2605
+ minWidth: 0
2606
+ },
2607
+ pluginIcon: {
2608
+ fontSize: "20px",
2609
+ flexShrink: 0
2610
+ },
2611
+ pluginDetails: {
2612
+ flex: 1,
2613
+ minWidth: 0
2614
+ },
2615
+ pluginName: {
2616
+ display: "block",
2617
+ fontWeight: tokens.typography.fontWeightMedium,
2618
+ color: tokens.colors.textPrimary,
2619
+ whiteSpace: "nowrap",
2620
+ overflow: "hidden",
2621
+ textOverflow: "ellipsis"
2622
+ },
2623
+ pluginMeta: {
2624
+ display: "block",
2625
+ fontSize: tokens.typography.fontSizeXs,
2626
+ color: tokens.colors.textTertiary
2627
+ },
2628
+ pluginEmpty: {
2629
+ padding: tokens.spacing.lg,
2630
+ textAlign: "center",
2631
+ color: tokens.colors.textTertiary,
2632
+ fontSize: tokens.typography.fontSizeSm
2633
+ },
2634
+ availablePluginsHeader: {
2635
+ fontSize: tokens.typography.fontSizeXs,
2636
+ fontWeight: tokens.typography.fontWeightSemibold,
2637
+ color: tokens.colors.textSecondary,
2638
+ textTransform: "uppercase",
2639
+ letterSpacing: "0.5px",
2640
+ marginTop: tokens.spacing.lg,
2641
+ marginBottom: tokens.spacing.sm
2642
+ },
2643
+ installBtn: {
2644
+ padding: `${tokens.spacing.xs} ${tokens.spacing.md}`,
2645
+ fontSize: tokens.typography.fontSizeSm,
2646
+ background: "transparent",
2647
+ border: `1px solid ${tokens.colors.accentPrimary}`,
2648
+ borderRadius: tokens.radius.md,
2649
+ color: tokens.colors.accentPrimary,
2650
+ cursor: "pointer",
2651
+ transition: `all ${tokens.transitions.fast}`,
2652
+ whiteSpace: "nowrap"
2653
+ },
2654
+ uninstallBtn: {
2655
+ padding: `${tokens.spacing.xs} ${tokens.spacing.md}`,
2656
+ fontSize: tokens.typography.fontSizeSm,
2657
+ background: "transparent",
2658
+ border: `1px solid ${tokens.colors.accentError}`,
2659
+ borderRadius: tokens.radius.md,
2660
+ color: tokens.colors.accentError,
2661
+ cursor: "pointer",
2662
+ transition: `all ${tokens.transitions.fast}`,
2663
+ whiteSpace: "nowrap"
2664
+ }
2665
+ };
2666
+ function generateId() {
2667
+ return `msg-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
2668
+ }
2669
+ function HustleChat({
2670
+ className = "",
2671
+ placeholder = "Type a message...",
2672
+ showSettings = false,
2673
+ showDebug = false,
2674
+ initialSystemPrompt = "",
2675
+ onMessage,
2676
+ onToolCall,
2677
+ onResponse
2678
+ }) {
2679
+ const { isAuthenticated } = useEmblemAuth();
2680
+ const {
2681
+ instanceId,
2682
+ isReady,
2683
+ isLoading,
2684
+ error,
2685
+ models,
2686
+ chatStream,
2687
+ uploadFile,
2688
+ selectedModel,
2689
+ setSelectedModel,
2690
+ systemPrompt,
2691
+ setSystemPrompt,
2692
+ skipServerPrompt,
2693
+ setSkipServerPrompt
2694
+ } = useHustle();
2695
+ const {
2696
+ plugins,
2697
+ registerPlugin,
2698
+ unregisterPlugin,
2699
+ enablePlugin,
2700
+ disablePlugin
2701
+ } = usePlugins(instanceId);
2702
+ const [messages, setMessages] = react.useState([]);
2703
+ const [inputValue, setInputValue] = react.useState("");
2704
+ const [isStreaming, setIsStreaming] = react.useState(false);
2705
+ const [attachments, setAttachments] = react.useState([]);
2706
+ const [currentToolCalls, setCurrentToolCalls] = react.useState([]);
2707
+ const [showSettingsPanel, setShowSettingsPanel] = react.useState(false);
2708
+ const messagesEndRef = react.useRef(null);
2709
+ const fileInputRef = react.useRef(null);
2710
+ react.useEffect(() => {
2711
+ if (initialSystemPrompt && !systemPrompt) {
2712
+ setSystemPrompt(initialSystemPrompt);
2713
+ }
2714
+ }, [initialSystemPrompt, systemPrompt, setSystemPrompt]);
2715
+ react.useEffect(() => {
2716
+ messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
2717
+ }, [messages]);
2718
+ const handleFileSelect = react.useCallback(
2719
+ async (e) => {
2720
+ const files = e.target.files;
2721
+ if (!files || files.length === 0) return;
2722
+ for (const file of Array.from(files)) {
2723
+ try {
2724
+ const attachment = await uploadFile(file);
2725
+ setAttachments((prev) => [...prev, attachment]);
2726
+ } catch (err) {
2727
+ console.error("Upload failed:", err);
2728
+ }
2729
+ }
2730
+ if (fileInputRef.current) {
2731
+ fileInputRef.current.value = "";
2732
+ }
2733
+ },
2734
+ [uploadFile]
2735
+ );
2736
+ const removeAttachment = react.useCallback((index) => {
2737
+ setAttachments((prev) => prev.filter((_, i) => i !== index));
2738
+ }, []);
2739
+ const sendMessage = react.useCallback(async () => {
2740
+ const content = inputValue.trim();
2741
+ if (!content || isStreaming || !isReady) return;
2742
+ const userMessage = {
2743
+ id: generateId(),
2744
+ role: "user",
2745
+ content
2746
+ };
2747
+ setMessages((prev) => [...prev, userMessage]);
2748
+ setInputValue("");
2749
+ onMessage?.(userMessage);
2750
+ const assistantMessage = {
2751
+ id: generateId(),
2752
+ role: "assistant",
2753
+ content: "",
2754
+ isStreaming: true,
2755
+ toolCalls: []
2756
+ };
2757
+ setMessages((prev) => [...prev, assistantMessage]);
2758
+ setIsStreaming(true);
2759
+ setCurrentToolCalls([]);
2760
+ try {
2761
+ const chatMessages = messages.filter((m) => !m.isStreaming).map((m) => ({ role: m.role, content: m.content }));
2762
+ chatMessages.push({ role: "user", content });
2763
+ const stream = chatStream({
2764
+ messages: chatMessages,
2765
+ attachments: attachments.length > 0 ? attachments : void 0,
2766
+ processChunks: true
2767
+ });
2768
+ setAttachments([]);
2769
+ let fullContent = "";
2770
+ const toolCallsAccumulated = [];
2771
+ for await (const chunk of stream) {
2772
+ if (chunk.type === "text") {
2773
+ fullContent += chunk.value;
2774
+ setMessages(
2775
+ (prev) => prev.map(
2776
+ (m) => m.id === assistantMessage.id ? { ...m, content: fullContent } : m
2777
+ )
2778
+ );
2779
+ } else if (chunk.type === "tool_call") {
2780
+ const toolCall = chunk.value;
2781
+ toolCallsAccumulated.push(toolCall);
2782
+ setCurrentToolCalls([...toolCallsAccumulated]);
2783
+ setMessages(
2784
+ (prev) => prev.map(
2785
+ (m) => m.id === assistantMessage.id ? { ...m, toolCalls: [...toolCallsAccumulated] } : m
2786
+ )
2787
+ );
2788
+ onToolCall?.(toolCall);
2789
+ } else if (chunk.type === "error") {
2790
+ console.error("Stream error:", chunk.value);
2791
+ }
2792
+ }
2793
+ setMessages(
2794
+ (prev) => prev.map(
2795
+ (m) => m.id === assistantMessage.id ? { ...m, isStreaming: false, content: fullContent || "(No response)" } : m
2796
+ )
2797
+ );
2798
+ onResponse?.(fullContent);
2799
+ } catch (err) {
2800
+ console.error("Chat error:", err);
2801
+ setMessages(
2802
+ (prev) => prev.map(
2803
+ (m) => m.id === assistantMessage.id ? { ...m, isStreaming: false, content: `Error: ${err instanceof Error ? err.message : "Unknown error"}` } : m
2804
+ )
2805
+ );
2806
+ } finally {
2807
+ setIsStreaming(false);
2808
+ setCurrentToolCalls([]);
2809
+ }
2810
+ }, [inputValue, isStreaming, isReady, messages, chatStream, attachments, onMessage, onToolCall, onResponse]);
2811
+ const handleKeyPress = react.useCallback(
2812
+ (e) => {
2813
+ if (e.key === "Enter" && !e.shiftKey) {
2814
+ e.preventDefault();
2815
+ sendMessage();
2816
+ }
2817
+ },
2818
+ [sendMessage]
2819
+ );
2820
+ const getPlaceholderMessage = () => {
2821
+ if (!isAuthenticated) {
2822
+ return "Connect to start chatting...";
2823
+ }
2824
+ if (!isReady) {
2825
+ return "Initializing...";
2826
+ }
2827
+ return "Start a conversation...";
2828
+ };
2829
+ const canChat = isAuthenticated && isReady;
2830
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2831
+ /* @__PURE__ */ jsxRuntime.jsx("style", { children: animations }),
2832
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: styles2.container, children: [
2833
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles2.header, children: [
2834
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { style: styles2.headerTitle, children: "Chat" }),
2835
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles2.headerActions, children: [
2836
+ selectedModel && /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: tokens.typography.fontSizeSm, color: tokens.colors.textSecondary }, children: selectedModel.split("/").pop() }),
2837
+ showSettings && /* @__PURE__ */ jsxRuntime.jsx(
2838
+ "button",
2839
+ {
2840
+ type: "button",
2841
+ onClick: () => setShowSettingsPanel(!showSettingsPanel),
2842
+ style: {
2843
+ ...styles2.settingsBtn,
2844
+ ...showSettingsPanel ? styles2.settingsBtnActive : styles2.settingsBtnInactive
2845
+ },
2846
+ title: "Settings",
2847
+ children: /* @__PURE__ */ jsxRuntime.jsx(SettingsIcon, {})
2848
+ }
2849
+ )
2850
+ ] })
2851
+ ] }),
2852
+ showSettings && showSettingsPanel && /* @__PURE__ */ jsxRuntime.jsx("div", { style: styles2.modalOverlay, onClick: () => setShowSettingsPanel(false), children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles2.modal, onClick: (e) => e.stopPropagation(), children: [
2853
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles2.modalHeader, children: [
2854
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: styles2.modalTitle, children: "Settings" }),
2855
+ /* @__PURE__ */ jsxRuntime.jsx(
2856
+ "button",
2857
+ {
2858
+ type: "button",
2859
+ style: styles2.modalClose,
2860
+ onClick: () => setShowSettingsPanel(false),
2861
+ children: "\xD7"
2862
+ }
2863
+ )
2864
+ ] }),
2865
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles2.modalBody, children: [
2866
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles2.settingGroup, children: [
2867
+ /* @__PURE__ */ jsxRuntime.jsx("label", { style: styles2.settingLabel, children: "Model" }),
2868
+ /* @__PURE__ */ jsxRuntime.jsx("p", { style: styles2.settingDescription, children: "Select the AI model to use for chat responses" }),
2869
+ /* @__PURE__ */ jsxRuntime.jsxs(
2870
+ "select",
2871
+ {
2872
+ value: selectedModel,
2873
+ onChange: (e) => setSelectedModel(e.target.value),
2874
+ style: styles2.settingSelect,
2875
+ children: [
2876
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: "Default (server decides)" }),
2877
+ (() => {
2878
+ const grouped = {};
2879
+ models.forEach((model) => {
2880
+ const [provider] = model.id.split("/");
2881
+ if (!grouped[provider]) grouped[provider] = [];
2882
+ grouped[provider].push(model);
2883
+ });
2884
+ return Object.entries(grouped).map(([provider, providerModels]) => /* @__PURE__ */ jsxRuntime.jsx("optgroup", { label: provider.charAt(0).toUpperCase() + provider.slice(1), children: providerModels.map((model) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: model.id, children: model.name }, model.id)) }, provider));
2885
+ })()
2886
+ ]
2887
+ }
2888
+ ),
2889
+ selectedModel && (() => {
2890
+ const model = models.find((m) => m.id === selectedModel);
2891
+ if (!model) return null;
2892
+ const contextK = Math.round(model.context_length / 1e3);
2893
+ const promptCost = parseFloat(model.pricing?.prompt || "0") * 1e6;
2894
+ const completionCost = parseFloat(model.pricing?.completion || "0") * 1e6;
2895
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles2.modelInfo, children: [
2896
+ "Context: ",
2897
+ contextK,
2898
+ "K tokens | Cost: $",
2899
+ promptCost.toFixed(2),
2900
+ "/$",
2901
+ completionCost.toFixed(2),
2902
+ " per 1M tokens"
2903
+ ] });
2904
+ })()
2905
+ ] }),
2906
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles2.settingGroup, children: [
2907
+ /* @__PURE__ */ jsxRuntime.jsx("label", { style: styles2.settingLabel, children: "Server System Prompt" }),
2908
+ /* @__PURE__ */ jsxRuntime.jsxs(
2909
+ "div",
2910
+ {
2911
+ style: styles2.toggleRow,
2912
+ onClick: () => setSkipServerPrompt(!skipServerPrompt),
2913
+ children: [
2914
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: styles2.toggleLabel, children: "Skip server-provided system prompt" }),
2915
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
2916
+ ...styles2.toggleSwitch,
2917
+ ...skipServerPrompt ? styles2.toggleSwitchActive : {}
2918
+ }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
2919
+ ...styles2.toggleKnob,
2920
+ ...skipServerPrompt ? styles2.toggleKnobActive : {}
2921
+ } }) })
2922
+ ]
2923
+ }
2924
+ ),
2925
+ /* @__PURE__ */ jsxRuntime.jsx("p", { style: styles2.settingDescription, children: "When enabled, the server's default system prompt will not be used" })
2926
+ ] }),
2927
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles2.settingGroup, children: [
2928
+ /* @__PURE__ */ jsxRuntime.jsx("label", { style: styles2.settingLabel, children: "Custom System Prompt" }),
2929
+ /* @__PURE__ */ jsxRuntime.jsx("p", { style: styles2.settingDescription, children: "Provide instructions for how the AI should behave" }),
2930
+ /* @__PURE__ */ jsxRuntime.jsx(
2931
+ "textarea",
2932
+ {
2933
+ value: systemPrompt,
2934
+ onChange: (e) => setSystemPrompt(e.target.value),
2935
+ placeholder: "You are a helpful assistant...",
2936
+ style: styles2.settingTextarea
2937
+ }
2938
+ )
2939
+ ] }),
2940
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: styles2.settingDivider }),
2941
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { ...styles2.settingGroup, marginBottom: 0 }, children: [
2942
+ /* @__PURE__ */ jsxRuntime.jsx("label", { style: styles2.settingLabel, children: "Plugins" }),
2943
+ /* @__PURE__ */ jsxRuntime.jsx("p", { style: styles2.settingDescription, children: "Extend the AI with custom tools" }),
2944
+ plugins.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: styles2.pluginList, children: plugins.map((plugin) => /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles2.pluginRow, children: [
2945
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles2.pluginInfo, children: [
2946
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: styles2.pluginIcon, children: plugin.enabled ? "\u{1F50C}" : "\u26AA" }),
2947
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles2.pluginDetails, children: [
2948
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: styles2.pluginName, children: plugin.name }),
2949
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { style: styles2.pluginMeta, children: [
2950
+ "v",
2951
+ plugin.version,
2952
+ " \u2022 ",
2953
+ plugin.tools?.length || 0,
2954
+ " tools"
2955
+ ] })
2956
+ ] })
2957
+ ] }),
2958
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", gap: tokens.spacing.sm }, children: [
2959
+ /* @__PURE__ */ jsxRuntime.jsx(
2960
+ "div",
2961
+ {
2962
+ style: {
2963
+ ...styles2.toggleSwitch,
2964
+ ...plugin.enabled ? styles2.toggleSwitchActive : {}
2965
+ },
2966
+ onClick: () => plugin.enabled ? disablePlugin(plugin.name) : enablePlugin(plugin.name),
2967
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
2968
+ ...styles2.toggleKnob,
2969
+ ...plugin.enabled ? styles2.toggleKnobActive : {}
2970
+ } })
2971
+ }
2972
+ ),
2973
+ /* @__PURE__ */ jsxRuntime.jsx(
2974
+ "button",
2975
+ {
2976
+ type: "button",
2977
+ style: styles2.uninstallBtn,
2978
+ onClick: () => unregisterPlugin(plugin.name),
2979
+ children: "Remove"
2980
+ }
2981
+ )
2982
+ ] })
2983
+ ] }, plugin.name)) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { style: styles2.pluginEmpty, children: "No plugins installed" }),
2984
+ availablePlugins.filter((p) => !plugins.some((installed) => installed.name === p.name)).length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2985
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: styles2.availablePluginsHeader, children: "Available" }),
2986
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: styles2.pluginList, children: availablePlugins.filter((p) => !plugins.some((installed) => installed.name === p.name)).map((plugin) => /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles2.pluginRow, children: [
2987
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles2.pluginInfo, children: [
2988
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: styles2.pluginIcon, children: "\u{1F4E6}" }),
2989
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles2.pluginDetails, children: [
2990
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: styles2.pluginName, children: plugin.name }),
2991
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: styles2.pluginMeta, children: plugin.description })
2992
+ ] })
2993
+ ] }),
2994
+ /* @__PURE__ */ jsxRuntime.jsx(
2995
+ "button",
2996
+ {
2997
+ type: "button",
2998
+ style: styles2.installBtn,
2999
+ onClick: () => registerPlugin(plugin),
3000
+ children: "+ Install"
3001
+ }
3002
+ )
3003
+ ] }, plugin.name)) })
3004
+ ] })
3005
+ ] })
3006
+ ] })
3007
+ ] }) }),
3008
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles2.messagesArea, children: [
3009
+ messages.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { style: styles2.messagesEmpty, children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: getPlaceholderMessage() }) }),
3010
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: styles2.messagesContainer, children: messages.map((message) => /* @__PURE__ */ jsxRuntime.jsx(
3011
+ MessageBubble,
3012
+ {
3013
+ message,
3014
+ showDebug
3015
+ },
3016
+ message.id
3017
+ )) }),
3018
+ currentToolCalls.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { style: styles2.toolCallsIndicator, children: currentToolCalls.map((tool) => /* @__PURE__ */ jsxRuntime.jsxs("span", { style: styles2.toolCallBadge, children: [
3019
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: styles2.toolCallDot }),
3020
+ tool.toolName
3021
+ ] }, tool.toolCallId)) }),
3022
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref: messagesEndRef })
3023
+ ] }),
3024
+ attachments.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { style: styles2.attachmentsPreview, children: attachments.map((att, index) => /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles2.attachmentItem, children: [
3025
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: styles2.attachmentName, children: att.name }),
3026
+ /* @__PURE__ */ jsxRuntime.jsx(
3027
+ "button",
3028
+ {
3029
+ type: "button",
3030
+ onClick: () => removeAttachment(index),
3031
+ style: styles2.attachmentRemove,
3032
+ children: "\xD7"
3033
+ }
3034
+ )
3035
+ ] }, index)) }),
3036
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles2.inputArea, children: [
3037
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles2.inputRow, children: [
3038
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles2.inputContainer, children: [
3039
+ /* @__PURE__ */ jsxRuntime.jsx(
3040
+ "button",
3041
+ {
3042
+ type: "button",
3043
+ onClick: () => fileInputRef.current?.click(),
3044
+ style: styles2.attachBtn,
3045
+ title: "Attach file",
3046
+ children: /* @__PURE__ */ jsxRuntime.jsx(AttachIcon, {})
3047
+ }
3048
+ ),
3049
+ /* @__PURE__ */ jsxRuntime.jsx(
3050
+ "input",
3051
+ {
3052
+ ref: fileInputRef,
3053
+ type: "file",
3054
+ accept: "image/*",
3055
+ multiple: true,
3056
+ onChange: handleFileSelect,
3057
+ style: { display: "none" }
3058
+ }
3059
+ ),
3060
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: styles2.inputWrapper, children: /* @__PURE__ */ jsxRuntime.jsx(
3061
+ "textarea",
3062
+ {
3063
+ value: inputValue,
3064
+ onChange: (e) => setInputValue(e.target.value),
3065
+ onKeyPress: handleKeyPress,
3066
+ placeholder,
3067
+ disabled: !canChat || isStreaming || isLoading,
3068
+ rows: 1,
3069
+ style: {
3070
+ ...styles2.input,
3071
+ ...!canChat || isStreaming || isLoading ? styles2.inputDisabled : {}
3072
+ }
3073
+ }
3074
+ ) })
3075
+ ] }),
3076
+ /* @__PURE__ */ jsxRuntime.jsx(
3077
+ "button",
3078
+ {
3079
+ type: "button",
3080
+ onClick: sendMessage,
3081
+ disabled: !canChat || !inputValue.trim() || isStreaming || isLoading,
3082
+ style: {
3083
+ ...styles2.sendBtn,
3084
+ ...!canChat || !inputValue.trim() || isStreaming || isLoading ? styles2.sendBtnDisabled : {}
3085
+ },
3086
+ children: isStreaming ? /* @__PURE__ */ jsxRuntime.jsx("span", { style: styles2.sendSpinner }) : "Send"
3087
+ }
3088
+ )
3089
+ ] }),
3090
+ error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: styles2.errorBox, children: error.message })
3091
+ ] })
3092
+ ] })
3093
+ ] });
3094
+ }
3095
+ function MessageBubble({ message, showDebug }) {
3096
+ const isUser = message.role === "user";
3097
+ const isSystem = message.role === "system";
3098
+ const containerStyle2 = {
3099
+ ...styles2.messageBubbleContainer,
3100
+ ...isUser ? styles2.messageBubbleUser : styles2.messageBubbleAssistant
3101
+ };
3102
+ const bubbleStyle = {
3103
+ ...styles2.messageBubble,
3104
+ ...isUser ? styles2.messageBubbleUserStyle : isSystem ? styles2.messageBubbleSystemStyle : styles2.messageBubbleAssistantStyle
3105
+ };
3106
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: containerStyle2, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: bubbleStyle, children: [
3107
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles2.messageContent, children: [
3108
+ isUser || isSystem ? (
3109
+ // User and system messages: plain text
3110
+ message.content
3111
+ ) : (
3112
+ // Assistant messages: render markdown
3113
+ /* @__PURE__ */ jsxRuntime.jsx(MarkdownContent, { content: message.content })
3114
+ ),
3115
+ message.isStreaming && /* @__PURE__ */ jsxRuntime.jsx("span", { style: styles2.streamingCursor })
3116
+ ] }),
3117
+ showDebug && message.toolCalls && message.toolCalls.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles2.toolCallsDebug, children: [
3118
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: styles2.toolCallsDebugTitle, children: "Tool calls:" }),
3119
+ message.toolCalls.map((tool) => /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles2.toolCallDebugItem, children: [
3120
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: styles2.toolCallDebugName, children: tool.toolName }),
3121
+ tool.args && /* @__PURE__ */ jsxRuntime.jsx("pre", { style: styles2.toolCallDebugArgs, children: JSON.stringify(tool.args, null, 2) })
3122
+ ] }, tool.toolCallId))
3123
+ ] })
3124
+ ] }) });
3125
+ }
3126
+ function SettingsIcon() {
3127
+ return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
3128
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "3" }),
3129
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z" })
3130
+ ] });
3131
+ }
3132
+ function AttachIcon() {
3133
+ return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48" }) });
3134
+ }
3135
+
3136
+ exports.AuthStatus = AuthStatus;
3137
+ exports.ConnectButton = ConnectButton;
3138
+ exports.HustleChat = HustleChat;
3139
+ exports.MarkdownContent = MarkdownContent;
3140
+ //# sourceMappingURL=index.cjs.map
3141
+ //# sourceMappingURL=index.cjs.map