@elizaos/plugin-vincent 2.0.3-beta.6 → 2.0.3-beta.7

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 (91) hide show
  1. package/dist/TradingProfileCard.d.ts +8 -0
  2. package/dist/TradingProfileCard.d.ts.map +1 -0
  3. package/dist/TradingProfileCard.js +70 -0
  4. package/dist/TradingProfileCard.js.map +1 -0
  5. package/dist/TradingStrategyPanel.d.ts +10 -0
  6. package/dist/TradingStrategyPanel.d.ts.map +1 -0
  7. package/dist/TradingStrategyPanel.js +133 -0
  8. package/dist/TradingStrategyPanel.js.map +1 -0
  9. package/dist/VincentAppView.d.ts +4 -0
  10. package/dist/VincentAppView.d.ts.map +1 -0
  11. package/dist/VincentAppView.helpers.d.ts +10 -0
  12. package/dist/VincentAppView.helpers.d.ts.map +1 -0
  13. package/dist/VincentAppView.helpers.js +21 -0
  14. package/dist/VincentAppView.helpers.js.map +1 -0
  15. package/dist/VincentAppView.interact.d.ts +2 -0
  16. package/dist/VincentAppView.interact.d.ts.map +1 -0
  17. package/dist/VincentAppView.interact.js +45 -0
  18. package/dist/VincentAppView.interact.js.map +1 -0
  19. package/dist/VincentAppView.js +145 -0
  20. package/dist/VincentAppView.js.map +1 -0
  21. package/dist/VincentConnectionCard.d.ts +9 -0
  22. package/dist/VincentConnectionCard.d.ts.map +1 -0
  23. package/dist/VincentConnectionCard.js +121 -0
  24. package/dist/VincentConnectionCard.js.map +1 -0
  25. package/dist/VincentView.d.ts +13 -0
  26. package/dist/VincentView.d.ts.map +1 -0
  27. package/dist/VincentView.js +86 -0
  28. package/dist/VincentView.js.map +1 -0
  29. package/dist/WalletStatusCard.d.ts +12 -0
  30. package/dist/WalletStatusCard.d.ts.map +1 -0
  31. package/dist/WalletStatusCard.js +203 -0
  32. package/dist/WalletStatusCard.js.map +1 -0
  33. package/dist/client.d.ts +21 -0
  34. package/dist/client.d.ts.map +1 -0
  35. package/dist/client.js +31 -0
  36. package/dist/client.js.map +1 -0
  37. package/dist/components/VincentSpatialView.d.ts +32 -0
  38. package/dist/components/VincentSpatialView.d.ts.map +1 -0
  39. package/dist/components/VincentSpatialView.js +191 -0
  40. package/dist/components/VincentSpatialView.js.map +1 -0
  41. package/dist/index.d.ts +15 -0
  42. package/dist/index.d.ts.map +1 -0
  43. package/dist/index.js +21 -0
  44. package/dist/index.js.map +1 -0
  45. package/dist/plugin.d.ts +14 -0
  46. package/dist/plugin.d.ts.map +1 -0
  47. package/dist/plugin.js +98 -0
  48. package/dist/plugin.js.map +1 -0
  49. package/dist/register-routes.d.ts +2 -0
  50. package/dist/register-routes.d.ts.map +1 -0
  51. package/dist/register-routes.js +6 -0
  52. package/dist/register-routes.js.map +1 -0
  53. package/dist/register-terminal-view.d.ts +15 -0
  54. package/dist/register-terminal-view.d.ts.map +1 -0
  55. package/dist/register-terminal-view.js +28 -0
  56. package/dist/register-terminal-view.js.map +1 -0
  57. package/dist/register.d.ts +2 -0
  58. package/dist/register.d.ts.map +1 -0
  59. package/dist/register.js +6 -0
  60. package/dist/register.js.map +1 -0
  61. package/dist/routes.d.ts +24 -0
  62. package/dist/routes.d.ts.map +1 -0
  63. package/dist/routes.js +429 -0
  64. package/dist/routes.js.map +1 -0
  65. package/dist/ui.d.ts +11 -0
  66. package/dist/ui.d.ts.map +1 -0
  67. package/dist/ui.js +16 -0
  68. package/dist/ui.js.map +1 -0
  69. package/dist/useVincentDashboard.d.ts +21 -0
  70. package/dist/useVincentDashboard.d.ts.map +1 -0
  71. package/dist/useVincentDashboard.js +105 -0
  72. package/dist/useVincentDashboard.js.map +1 -0
  73. package/dist/useVincentState.d.ts +15 -0
  74. package/dist/useVincentState.d.ts.map +1 -0
  75. package/dist/useVincentState.js +116 -0
  76. package/dist/useVincentState.js.map +1 -0
  77. package/dist/views/bundle.js +500 -0
  78. package/dist/views/bundle.js.map +1 -0
  79. package/dist/vincent-app.d.ts +10 -0
  80. package/dist/vincent-app.d.ts.map +1 -0
  81. package/dist/vincent-app.js +16 -0
  82. package/dist/vincent-app.js.map +1 -0
  83. package/dist/vincent-contracts.d.ts +52 -0
  84. package/dist/vincent-contracts.d.ts.map +1 -0
  85. package/dist/vincent-contracts.js +8 -0
  86. package/dist/vincent-contracts.js.map +1 -0
  87. package/dist/vincent-view-bundle.d.ts +3 -0
  88. package/dist/vincent-view-bundle.d.ts.map +1 -0
  89. package/dist/vincent-view-bundle.js +7 -0
  90. package/dist/vincent-view-bundle.js.map +1 -0
  91. package/package.json +7 -7
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/useVincentDashboard.ts"],"sourcesContent":["/**\n * useVincentDashboard — aggregated data hook for the Vincent overlay app.\n *\n * Polls Vincent-specific endpoints every 15 s when connected, and fetches\n * the agent wallet addresses and balances for dashboard context.\n */\n\nimport type { WalletAddresses, WalletBalancesResponse } from \"@elizaos/shared\";\nimport { ApiError } from \"@elizaos/ui\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { vincentClient } from \"./client.js\";\nimport type {\n VincentStrategy,\n VincentTradingProfile,\n} from \"./vincent-contracts.js\";\n\nexport interface VincentDashboardState {\n vincentConnected: boolean;\n vincentConnectedAt: number | null;\n\n walletAddresses: WalletAddresses | null;\n walletBalances: WalletBalancesResponse | null;\n\n strategy: VincentStrategy | null;\n\n tradingProfile: VincentTradingProfile | null;\n\n loading: boolean;\n error: string | null;\n\n refresh: () => void;\n}\n\nconst POLL_INTERVAL_MS = 15_000;\n\nexport function useVincentDashboard(): VincentDashboardState {\n const [vincentConnected, setVincentConnected] = useState(false);\n const [vincentConnectedAt, setVincentConnectedAt] = useState<number | null>(\n null,\n );\n const [walletAddresses, setWalletAddresses] =\n useState<WalletAddresses | null>(null);\n const [walletBalances, setWalletBalances] =\n useState<WalletBalancesResponse | null>(null);\n const [strategy, setStrategy] = useState<VincentStrategy | null>(null);\n const [tradingProfile, setTradingProfile] =\n useState<VincentTradingProfile | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<string | null>(null);\n\n const intervalRef = useRef<ReturnType<typeof setInterval> | null>(null);\n const mountedRef = useRef(true);\n\n const fetchAll = useCallback(async () => {\n try {\n // Always check Vincent OAuth status first\n const vincentStatusResult = await vincentClient.vincentStatus();\n if (!mountedRef.current) return;\n setVincentConnected(vincentStatusResult.connected);\n setVincentConnectedAt(vincentStatusResult.connectedAt);\n\n // Fetch internal wallet + Vincent data in parallel\n const [\n addressResult,\n balanceResult,\n strategyResult,\n tradingProfileResult,\n ] = await Promise.allSettled([\n vincentClient.getWalletAddresses(),\n vincentClient.getWalletBalances(),\n vincentClient.vincentStrategy(),\n vincentClient.vincentTradingProfile(),\n ]);\n\n if (!mountedRef.current) return;\n\n if (addressResult.status === \"fulfilled\") {\n setWalletAddresses(addressResult.value);\n }\n if (balanceResult.status === \"fulfilled\") {\n setWalletBalances(balanceResult.value);\n }\n if (strategyResult.status === \"fulfilled\") {\n setStrategy(strategyResult.value.strategy);\n }\n if (tradingProfileResult.status === \"fulfilled\") {\n setTradingProfile(tradingProfileResult.value.profile);\n }\n\n setError(null);\n } catch (err) {\n if (!mountedRef.current) return;\n // Vincent is an opt-in server-launch app: its routes only mount once the\n // app is launched. On the un-launched base agent the status call 404s,\n // which is the normal \"disconnected\" state — not a real error. Show the\n // Connect CTA instead of a hard error banner.\n if (err instanceof ApiError && err.status === 404) {\n setVincentConnected(false);\n setError(null);\n return;\n }\n setError(err instanceof Error ? err.message : \"Failed to load data\");\n } finally {\n if (mountedRef.current) setLoading(false);\n }\n }, []);\n\n // Initial load\n useEffect(() => {\n mountedRef.current = true;\n void fetchAll();\n return () => {\n mountedRef.current = false;\n };\n }, [fetchAll]);\n\n // Start polling when connected, stop when disconnected\n useEffect(() => {\n if (intervalRef.current) {\n clearInterval(intervalRef.current);\n intervalRef.current = null;\n }\n if (vincentConnected) {\n intervalRef.current = setInterval(\n () => void fetchAll(),\n POLL_INTERVAL_MS,\n );\n }\n return () => {\n if (intervalRef.current) {\n clearInterval(intervalRef.current);\n intervalRef.current = null;\n }\n };\n }, [vincentConnected, fetchAll]);\n\n const refresh = useCallback(() => {\n setLoading(true);\n void fetchAll();\n }, [fetchAll]);\n\n return {\n vincentConnected,\n vincentConnectedAt,\n walletAddresses,\n walletBalances,\n strategy,\n tradingProfile,\n loading,\n error,\n refresh,\n };\n}\n"],"mappings":"AAQA,SAAS,gBAAgB;AACzB,SAAS,aAAa,WAAW,QAAQ,gBAAgB;AACzD,SAAS,qBAAqB;AAuB9B,MAAM,mBAAmB;AAElB,SAAS,sBAA6C;AAC3D,QAAM,CAAC,kBAAkB,mBAAmB,IAAI,SAAS,KAAK;AAC9D,QAAM,CAAC,oBAAoB,qBAAqB,IAAI;AAAA,IAClD;AAAA,EACF;AACA,QAAM,CAAC,iBAAiB,kBAAkB,IACxC,SAAiC,IAAI;AACvC,QAAM,CAAC,gBAAgB,iBAAiB,IACtC,SAAwC,IAAI;AAC9C,QAAM,CAAC,UAAU,WAAW,IAAI,SAAiC,IAAI;AACrE,QAAM,CAAC,gBAAgB,iBAAiB,IACtC,SAAuC,IAAI;AAC7C,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,IAAI;AAC3C,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAwB,IAAI;AAEtD,QAAM,cAAc,OAA8C,IAAI;AACtE,QAAM,aAAa,OAAO,IAAI;AAE9B,QAAM,WAAW,YAAY,YAAY;AACvC,QAAI;AAEF,YAAM,sBAAsB,MAAM,cAAc,cAAc;AAC9D,UAAI,CAAC,WAAW,QAAS;AACzB,0BAAoB,oBAAoB,SAAS;AACjD,4BAAsB,oBAAoB,WAAW;AAGrD,YAAM;AAAA,QACJ;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF,IAAI,MAAM,QAAQ,WAAW;AAAA,QAC3B,cAAc,mBAAmB;AAAA,QACjC,cAAc,kBAAkB;AAAA,QAChC,cAAc,gBAAgB;AAAA,QAC9B,cAAc,sBAAsB;AAAA,MACtC,CAAC;A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AAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,15 @@
1
+ interface VincentStateParams {
2
+ setActionNotice: (text: string, tone?: "info" | "success" | "error", ttlMs?: number) => void;
3
+ t: (key: string, opts?: Record<string, unknown>) => string;
4
+ }
5
+ export declare function useVincentState({ setActionNotice, t }: VincentStateParams): {
6
+ vincentConnected: boolean;
7
+ vincentLoginBusy: boolean;
8
+ vincentLoginError: string | null;
9
+ vincentConnectedAt: number | null;
10
+ handleVincentLogin: () => Promise<void>;
11
+ handleVincentDisconnect: () => Promise<void>;
12
+ pollVincentStatus: () => Promise<boolean>;
13
+ };
14
+ export {};
15
+ //# sourceMappingURL=useVincentState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useVincentState.d.ts","sourceRoot":"","sources":["../src/useVincentState.ts"],"names":[],"mappings":"AAIA,UAAU,kBAAkB;IAC1B,eAAe,EAAE,CACf,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,EACnC,KAAK,CAAC,EAAE,MAAM,KACX,IAAI,CAAC;IACV,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,CAAC;CAC5D;AAED,wBAAgB,eAAe,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,EAAE,kBAAkB;;;;;;;;EAoHzE"}
@@ -0,0 +1,116 @@
1
+ import { openExternalUrl } from "@elizaos/ui";
2
+ import { useCallback, useEffect, useRef, useState } from "react";
3
+ import { vincentClient } from "./client.js";
4
+ function useVincentState({ setActionNotice, t }) {
5
+ const [vincentConnected, setVincentConnected] = useState(false);
6
+ const [vincentLoginBusy, setVincentLoginBusy] = useState(false);
7
+ const [vincentLoginError, setVincentLoginError] = useState(
8
+ null
9
+ );
10
+ const [vincentConnectedAt, setVincentConnectedAt] = useState(
11
+ null
12
+ );
13
+ const busyRef = useRef(false);
14
+ const loginPollRef = useRef(null);
15
+ const pollVincentStatus = useCallback(async () => {
16
+ try {
17
+ const status = await vincentClient.vincentStatus();
18
+ setVincentConnected(status.connected);
19
+ setVincentConnectedAt(status.connectedAt);
20
+ return status.connected;
21
+ } catch {
22
+ return false;
23
+ }
24
+ }, []);
25
+ useEffect(() => {
26
+ void pollVincentStatus();
27
+ return () => {
28
+ if (loginPollRef.current) {
29
+ clearInterval(loginPollRef.current);
30
+ loginPollRef.current = null;
31
+ }
32
+ };
33
+ }, [pollVincentStatus]);
34
+ const handleVincentLogin = useCallback(async () => {
35
+ if (vincentConnected || busyRef.current || vincentLoginBusy) return;
36
+ busyRef.current = true;
37
+ setVincentLoginBusy(true);
38
+ setVincentLoginError(null);
39
+ try {
40
+ const { authUrl } = await vincentClient.vincentStartLogin("Eliza");
41
+ await openExternalUrl(authUrl);
42
+ if (loginPollRef.current) clearInterval(loginPollRef.current);
43
+ let pollAttempts = 0;
44
+ const maxPollAttempts = 24;
45
+ loginPollRef.current = setInterval(async () => {
46
+ pollAttempts++;
47
+ const connected = await pollVincentStatus();
48
+ if (connected) {
49
+ if (loginPollRef.current) clearInterval(loginPollRef.current);
50
+ loginPollRef.current = null;
51
+ setVincentLoginBusy(false);
52
+ busyRef.current = false;
53
+ setVincentLoginError(null);
54
+ setActionNotice(
55
+ t("vincent.connected", { defaultValue: "Vincent connected" }),
56
+ "success",
57
+ 5e3
58
+ );
59
+ return;
60
+ }
61
+ if (pollAttempts >= maxPollAttempts) {
62
+ if (loginPollRef.current) clearInterval(loginPollRef.current);
63
+ loginPollRef.current = null;
64
+ setVincentLoginBusy(false);
65
+ busyRef.current = false;
66
+ setVincentLoginError(
67
+ t("vincent.loginTimeout", {
68
+ defaultValue: "Login timed out. Close the auth window and try again."
69
+ })
70
+ );
71
+ }
72
+ }, 5e3);
73
+ } catch (err) {
74
+ const msg = err instanceof Error ? err.message : "Vincent login failed";
75
+ setVincentLoginError(msg);
76
+ setVincentLoginBusy(false);
77
+ busyRef.current = false;
78
+ }
79
+ }, [
80
+ pollVincentStatus,
81
+ setActionNotice,
82
+ t,
83
+ vincentConnected,
84
+ vincentLoginBusy
85
+ ]);
86
+ const handleVincentDisconnect = useCallback(async () => {
87
+ try {
88
+ await vincentClient.vincentDisconnect();
89
+ setVincentConnected(false);
90
+ setVincentConnectedAt(null);
91
+ setVincentLoginError(null);
92
+ setActionNotice(
93
+ t("vincent.disconnected", { defaultValue: "Vincent disconnected" }),
94
+ "info",
95
+ 3e3
96
+ );
97
+ } catch (err) {
98
+ setVincentLoginError(
99
+ err instanceof Error ? err.message : "Disconnect failed"
100
+ );
101
+ }
102
+ }, [setActionNotice, t]);
103
+ return {
104
+ vincentConnected,
105
+ vincentLoginBusy,
106
+ vincentLoginError,
107
+ vincentConnectedAt,
108
+ handleVincentLogin,
109
+ handleVincentDisconnect,
110
+ pollVincentStatus
111
+ };
112
+ }
113
+ export {
114
+ useVincentState
115
+ };
116
+ //# sourceMappingURL=useVincentState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/useVincentState.ts"],"sourcesContent":["import { openExternalUrl } from \"@elizaos/ui\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { vincentClient } from \"./client.js\";\n\ninterface VincentStateParams {\n setActionNotice: (\n text: string,\n tone?: \"info\" | \"success\" | \"error\",\n ttlMs?: number,\n ) => void;\n t: (key: string, opts?: Record<string, unknown>) => string;\n}\n\nexport function useVincentState({ setActionNotice, t }: VincentStateParams) {\n const [vincentConnected, setVincentConnected] = useState(false);\n const [vincentLoginBusy, setVincentLoginBusy] = useState(false);\n const [vincentLoginError, setVincentLoginError] = useState<string | null>(\n null,\n );\n const [vincentConnectedAt, setVincentConnectedAt] = useState<number | null>(\n null,\n );\n const busyRef = useRef(false);\n const loginPollRef = useRef<ReturnType<typeof setInterval> | null>(null);\n\n const pollVincentStatus = useCallback(async () => {\n try {\n const status = await vincentClient.vincentStatus();\n setVincentConnected(status.connected);\n setVincentConnectedAt(status.connectedAt);\n return status.connected;\n } catch {\n return false;\n }\n }, []);\n\n useEffect(() => {\n void pollVincentStatus();\n return () => {\n if (loginPollRef.current) {\n clearInterval(loginPollRef.current);\n loginPollRef.current = null;\n }\n };\n }, [pollVincentStatus]);\n\n const handleVincentLogin = useCallback(async () => {\n if (vincentConnected || busyRef.current || vincentLoginBusy) return;\n busyRef.current = true;\n setVincentLoginBusy(true);\n setVincentLoginError(null);\n\n try {\n const { authUrl } = await vincentClient.vincentStartLogin(\"Eliza\");\n await openExternalUrl(authUrl);\n\n if (loginPollRef.current) clearInterval(loginPollRef.current);\n let pollAttempts = 0;\n const maxPollAttempts = 24;\n loginPollRef.current = setInterval(async () => {\n pollAttempts++;\n const connected = await pollVincentStatus();\n if (connected) {\n if (loginPollRef.current) clearInterval(loginPollRef.current);\n loginPollRef.current = null;\n setVincentLoginBusy(false);\n busyRef.current = false;\n setVincentLoginError(null);\n setActionNotice(\n t(\"vincent.connected\", { defaultValue: \"Vincent connected\" }),\n \"success\",\n 5000,\n );\n return;\n }\n if (pollAttempts >= maxPollAttempts) {\n if (loginPollRef.current) clearInterval(loginPollRef.current);\n loginPollRef.current = null;\n setVincentLoginBusy(false);\n busyRef.current = false;\n setVincentLoginError(\n t(\"vincent.loginTimeout\", {\n defaultValue:\n \"Login timed out. Close the auth window and try again.\",\n }),\n );\n }\n }, 5000);\n } catch (err) {\n const msg = err instanceof Error ? err.message : \"Vincent login failed\";\n setVincentLoginError(msg);\n setVincentLoginBusy(false);\n busyRef.current = false;\n }\n }, [\n pollVincentStatus,\n setActionNotice,\n t,\n vincentConnected,\n vincentLoginBusy,\n ]);\n\n const handleVincentDisconnect = useCallback(async () => {\n try {\n await vincentClient.vincentDisconnect();\n setVincentConnected(false);\n setVincentConnectedAt(null);\n setVincentLoginError(null);\n setActionNotice(\n t(\"vincent.disconnected\", { defaultValue: \"Vincent disconnected\" }),\n \"info\",\n 3000,\n );\n } catch (err) {\n setVincentLoginError(\n err instanceof Error ? err.message : \"Disconnect failed\",\n );\n }\n }, [setActionNotice, t]);\n\n return {\n vincentConnected,\n vincentLoginBusy,\n vincentLoginError,\n vincentConnectedAt,\n handleVincentLogin,\n handleVincentDisconnect,\n pollVincentStatus,\n };\n}\n"],"mappings":"AAAA,SAAS,uBAAuB;AAChC,SAAS,aAAa,WAAW,QAAQ,gBAAgB;AACzD,SAAS,qBAAqB;AAWvB,SAAS,gBAAgB,EAAE,iBAAiB,EAAE,GAAuB;AAC1E,QAAM,CAAC,kBAAkB,mBAAmB,IAAI,SAAS,KAAK;AAC9D,QAAM,CAAC,kBAAkB,mBAAmB,IAAI,SAAS,KAAK;AAC9D,QAAM,CAAC,mBAAmB,oBAAoB,IAAI;AAAA,IAChD;AAAA,EACF;AACA,QAAM,CAAC,oBAAoB,qBAAqB,IAAI;AAAA,IAClD;AAAA,EACF;AACA,QAAM,UAAU,OAAO,KAAK;AAC5B,QAAM,eAAe,OAA8C,IAAI;AAEvE,QAAM,oBAAoB,YAAY,YAAY;AAChD,QAAI;AACF,YAAM,SAAS,MAAM,cAAc,cAAc;AACjD,0BAAoB,OAAO,SAAS;AACpC,4BAAsB,OAAO,WAAW;AACxC,aAAO,OAAO;AAAA,IAChB,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,YAAU,MAAM;AACd,SAAK,kBAAkB;AACvB,WAAO,MAAM;AACX,UAAI,aAAa,SAAS;AACxB,sBAAc,aAAa,OAAO;AAClC,qBAAa,UAAU;AAAA,MACzB;AAAA,IACF;AAAA,EACF,GAAG,CAAC,iBAAiB,CAAC;AAEtB,QAAM,qBAAqB,YAAY,YAAY;AACjD,QAAI,oBAAoB,QAAQ,WAAW,iBAAkB;AAC7D,YAAQ,UAAU;AAClB,wBAAoB,IAAI;AACxB,yBAAqB,IAAI;AAEzB,QAAI;A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I,UAAU;AAAA,MACvC;AAAA,IACF;AAAA,EACF,GAAG,CAAC,iBAAiB,CAAC,CAAC;AAEvB,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,500 @@
1
+ import { ApiError as e, ElizaClient as t, client as n, openExternalUrl as r, useAppSelector as i } from "@elizaos/ui";
2
+ import { Button as a, Card as o, Divider as s, HStack as c, List as l, SpatialSurface as u, Text as d, VStack as f } from "@elizaos/ui/spatial";
3
+ import { useCallback as p, useEffect as m, useRef as h, useState as g } from "react";
4
+ import { jsx as _, jsxs as v } from "react/jsx-runtime";
5
+ //#region src/client.ts
6
+ var y = t.prototype;
7
+ y.vincentStartLogin = async function(e) {
8
+ return this.fetch("/api/vincent/start-login", {
9
+ method: "POST",
10
+ body: JSON.stringify({ appName: e ?? "Eliza" })
11
+ });
12
+ }, y.vincentStatus = async function() {
13
+ return this.fetch("/api/vincent/status");
14
+ }, y.vincentDisconnect = async function() {
15
+ return this.fetch("/api/vincent/disconnect", { method: "POST" });
16
+ }, y.vincentStrategy = async function() {
17
+ return this.fetch("/api/vincent/strategy");
18
+ }, y.vincentUpdateStrategy = async function(e) {
19
+ return this.fetch("/api/vincent/strategy", {
20
+ method: "POST",
21
+ body: JSON.stringify(e)
22
+ });
23
+ }, y.vincentTradingProfile = async function() {
24
+ return this.fetch("/api/vincent/trading-profile");
25
+ };
26
+ var b = n;
27
+ //#endregion
28
+ //#region src/VincentAppView.helpers.ts
29
+ async function x() {
30
+ let e = await b.vincentStatus(), [t, n, r, i] = await Promise.allSettled([
31
+ b.getWalletAddresses(),
32
+ b.getWalletBalances(),
33
+ b.vincentStrategy(),
34
+ b.vincentTradingProfile()
35
+ ]);
36
+ return {
37
+ status: e,
38
+ walletAddresses: t.status === "fulfilled" ? t.value : null,
39
+ walletBalances: n.status === "fulfilled" ? n.value : null,
40
+ strategy: r.status === "fulfilled" ? r.value : {
41
+ connected: e.connected,
42
+ strategy: null
43
+ },
44
+ tradingProfile: i.status === "fulfilled" ? i.value : {
45
+ connected: e.connected,
46
+ profile: null
47
+ }
48
+ };
49
+ }
50
+ //#endregion
51
+ //#region src/VincentAppView.interact.ts
52
+ async function S(e, t) {
53
+ if (e === "terminal-vincent-state") return {
54
+ viewType: "tui",
55
+ ...await x()
56
+ };
57
+ if (e === "terminal-vincent-start-login") return {
58
+ viewType: "tui",
59
+ login: await b.vincentStartLogin(typeof t?.appName == "string" ? t.appName : "Eliza")
60
+ };
61
+ if (e === "terminal-vincent-disconnect") return {
62
+ viewType: "tui",
63
+ disconnected: await b.vincentDisconnect()
64
+ };
65
+ if (e === "terminal-vincent-update-strategy") {
66
+ let e = {};
67
+ return typeof t?.strategy == "string" && (e.strategy = t.strategy), t?.params && typeof t.params == "object" && (e.params = t.params), typeof t?.intervalSeconds == "number" && (e.intervalSeconds = t.intervalSeconds), typeof t?.dryRun == "boolean" && (e.dryRun = t.dryRun), {
68
+ viewType: "tui",
69
+ update: await b.vincentUpdateStrategy(e)
70
+ };
71
+ }
72
+ throw Error(`Unsupported capability "${e}"`);
73
+ }
74
+ //#endregion
75
+ //#region src/components/VincentSpatialView.tsx
76
+ function C(e) {
77
+ return e ? e.length <= 14 ? e : `${e.slice(0, 6)}..${e.slice(-4)}` : "not set";
78
+ }
79
+ function w(e) {
80
+ return e ? e.running ? "success" : "warning" : "muted";
81
+ }
82
+ function T(e) {
83
+ let t = Number.parseFloat(e);
84
+ return !Number.isFinite(t) || t === 0 ? "muted" : t > 0 ? "success" : "danger";
85
+ }
86
+ function E(e) {
87
+ let t = Number.parseFloat(e);
88
+ return Number.isFinite(t) ? `${t > 0 ? "+" : ""}${e}` : e;
89
+ }
90
+ function D(e) {
91
+ return Number.isFinite(e) ? `${Math.round(e * 100)}%` : "--";
92
+ }
93
+ function O({ snapshot: e, onAction: t }) {
94
+ let n = (e) => () => t?.(e), { vincentConnected: r, walletAddresses: i, strategy: u, tradingProfile: p, loading: m, error: h } = e;
95
+ return /* @__PURE__ */ v(o, {
96
+ gap: 1,
97
+ padding: 1,
98
+ children: [
99
+ /* @__PURE__ */ v(c, {
100
+ gap: 1,
101
+ align: "center",
102
+ children: [/* @__PURE__ */ _(d, {
103
+ style: "caption",
104
+ tone: r ? "success" : "muted",
105
+ grow: 1,
106
+ children: r ? "connected" : "disconnected"
107
+ }), /* @__PURE__ */ _(d, {
108
+ style: "caption",
109
+ tone: "muted",
110
+ children: m ? "loading" : "trading"
111
+ })]
112
+ }),
113
+ h ? /* @__PURE__ */ _(d, {
114
+ tone: "danger",
115
+ style: "caption",
116
+ children: h
117
+ }) : null,
118
+ /* @__PURE__ */ _(s, { label: "access" }),
119
+ r ? /* @__PURE__ */ v(l, {
120
+ gap: 0,
121
+ children: [/* @__PURE__ */ v(c, {
122
+ gap: 1,
123
+ align: "center",
124
+ agent: "wallet-evm",
125
+ children: [
126
+ /* @__PURE__ */ _(d, {
127
+ style: "caption",
128
+ tone: "muted",
129
+ width: 8,
130
+ children: "evm"
131
+ }),
132
+ /* @__PURE__ */ _(d, {
133
+ grow: 1,
134
+ wrap: !1,
135
+ children: C(i?.evmAddress ?? null)
136
+ }),
137
+ i?.evmAddress ? /* @__PURE__ */ _(a, {
138
+ variant: "ghost",
139
+ tone: "default",
140
+ agent: "copy-evm",
141
+ onPress: n("copy-evm"),
142
+ children: "Copy"
143
+ }) : null
144
+ ]
145
+ }), /* @__PURE__ */ v(c, {
146
+ gap: 1,
147
+ align: "center",
148
+ agent: "wallet-solana",
149
+ children: [
150
+ /* @__PURE__ */ _(d, {
151
+ style: "caption",
152
+ tone: "muted",
153
+ width: 8,
154
+ children: "sol"
155
+ }),
156
+ /* @__PURE__ */ _(d, {
157
+ grow: 1,
158
+ wrap: !1,
159
+ children: C(i?.solanaAddress ?? null)
160
+ }),
161
+ i?.solanaAddress ? /* @__PURE__ */ _(a, {
162
+ variant: "ghost",
163
+ tone: "default",
164
+ agent: "copy-solana",
165
+ onPress: n("copy-solana"),
166
+ children: "Copy"
167
+ }) : null
168
+ ]
169
+ })]
170
+ }) : /* @__PURE__ */ _(d, {
171
+ tone: "muted",
172
+ style: "caption",
173
+ children: "Connect Vincent to trade on Hyperliquid and Polymarket."
174
+ }),
175
+ /* @__PURE__ */ v(c, {
176
+ gap: 1,
177
+ wrap: !0,
178
+ children: [r ? /* @__PURE__ */ _(a, {
179
+ variant: "outline",
180
+ tone: "danger",
181
+ grow: 1,
182
+ agent: "disconnect",
183
+ onPress: n("disconnect"),
184
+ children: "Disconnect"
185
+ }) : /* @__PURE__ */ _(a, {
186
+ grow: 1,
187
+ agent: "connect",
188
+ onPress: n("connect"),
189
+ children: "Connect"
190
+ }), /* @__PURE__ */ _(a, {
191
+ variant: "ghost",
192
+ tone: "default",
193
+ agent: "refresh",
194
+ onPress: n("refresh"),
195
+ children: "Refresh"
196
+ })]
197
+ }),
198
+ /* @__PURE__ */ _(s, { label: "strategy" }),
199
+ u ? /* @__PURE__ */ v(f, {
200
+ gap: 0,
201
+ children: [
202
+ /* @__PURE__ */ v(c, {
203
+ gap: 1,
204
+ align: "center",
205
+ children: [/* @__PURE__ */ _(d, {
206
+ bold: !0,
207
+ grow: 1,
208
+ wrap: !1,
209
+ children: u.name
210
+ }), /* @__PURE__ */ _(d, {
211
+ style: "caption",
212
+ tone: w(u),
213
+ children: u.running ? "running" : "idle"
214
+ })]
215
+ }),
216
+ /* @__PURE__ */ v(c, {
217
+ gap: 1,
218
+ align: "center",
219
+ children: [/* @__PURE__ */ _(d, {
220
+ style: "caption",
221
+ tone: "muted",
222
+ grow: 1,
223
+ wrap: !1,
224
+ children: u.venues.join(", ") || "no venues"
225
+ }), /* @__PURE__ */ _(d, {
226
+ style: "caption",
227
+ tone: u.dryRun ? "warning" : "muted",
228
+ children: u.dryRun ? "dry-run" : "live"
229
+ })]
230
+ }),
231
+ /* @__PURE__ */ v(d, {
232
+ style: "caption",
233
+ tone: "muted",
234
+ children: [
235
+ "interval ",
236
+ u.intervalSeconds,
237
+ "s"
238
+ ]
239
+ }),
240
+ p ? /* @__PURE__ */ v(l, {
241
+ gap: 0,
242
+ children: [
243
+ /* @__PURE__ */ v(c, {
244
+ gap: 1,
245
+ align: "center",
246
+ children: [/* @__PURE__ */ _(d, {
247
+ style: "caption",
248
+ tone: "muted",
249
+ grow: 1,
250
+ children: "pnl"
251
+ }), /* @__PURE__ */ _(d, {
252
+ style: "caption",
253
+ tone: T(p.totalPnl),
254
+ bold: !0,
255
+ children: E(p.totalPnl)
256
+ })]
257
+ }),
258
+ /* @__PURE__ */ v(c, {
259
+ gap: 1,
260
+ align: "center",
261
+ children: [/* @__PURE__ */ _(d, {
262
+ style: "caption",
263
+ tone: "muted",
264
+ grow: 1,
265
+ children: "win rate"
266
+ }), /* @__PURE__ */ _(d, {
267
+ style: "caption",
268
+ children: D(p.winRate)
269
+ })]
270
+ }),
271
+ /* @__PURE__ */ v(c, {
272
+ gap: 1,
273
+ align: "center",
274
+ children: [/* @__PURE__ */ _(d, {
275
+ style: "caption",
276
+ tone: "muted",
277
+ grow: 1,
278
+ children: "swaps / vol24h"
279
+ }), /* @__PURE__ */ v(d, {
280
+ style: "caption",
281
+ children: [
282
+ p.totalSwaps,
283
+ " / ",
284
+ p.volume24h
285
+ ]
286
+ })]
287
+ }),
288
+ p.tokenBreakdown.length > 0 ? /* @__PURE__ */ _(l, {
289
+ gap: 0,
290
+ children: p.tokenBreakdown.slice(0, 6).map((e) => /* @__PURE__ */ v(c, {
291
+ gap: 1,
292
+ align: "center",
293
+ agent: `token-${e.symbol}`,
294
+ children: [
295
+ /* @__PURE__ */ _(d, {
296
+ bold: !0,
297
+ width: 10,
298
+ wrap: !1,
299
+ children: e.symbol
300
+ }),
301
+ /* @__PURE__ */ _(d, {
302
+ grow: 1,
303
+ tone: T(e.pnl),
304
+ wrap: !1,
305
+ children: E(e.pnl)
306
+ }),
307
+ /* @__PURE__ */ v(d, {
308
+ style: "caption",
309
+ tone: "muted",
310
+ children: [e.swaps, " swaps"]
311
+ })
312
+ ]
313
+ }, e.symbol))
314
+ }) : null
315
+ ]
316
+ }) : /* @__PURE__ */ _(d, {
317
+ tone: "muted",
318
+ style: "caption",
319
+ children: "No P&L"
320
+ }),
321
+ /* @__PURE__ */ _(c, {
322
+ gap: 1,
323
+ wrap: !0,
324
+ children: /* @__PURE__ */ _(a, {
325
+ variant: "outline",
326
+ tone: "default",
327
+ agent: "open-vincent",
328
+ onPress: n("open-vincent"),
329
+ children: "Open Vincent"
330
+ })
331
+ })
332
+ ]
333
+ }) : /* @__PURE__ */ _(d, {
334
+ tone: "muted",
335
+ align: "center",
336
+ style: "caption",
337
+ children: "None"
338
+ })
339
+ ]
340
+ });
341
+ }
342
+ //#endregion
343
+ //#region src/useVincentDashboard.ts
344
+ var k = 15e3;
345
+ function A() {
346
+ let [t, n] = g(!1), [r, i] = g(null), [a, o] = g(null), [s, c] = g(null), [l, u] = g(null), [d, f] = g(null), [_, v] = g(!0), [y, x] = g(null), S = h(null), C = h(!0), w = p(async () => {
347
+ try {
348
+ let e = await b.vincentStatus();
349
+ if (!C.current) return;
350
+ n(e.connected), i(e.connectedAt);
351
+ let [t, r, a, s] = await Promise.allSettled([
352
+ b.getWalletAddresses(),
353
+ b.getWalletBalances(),
354
+ b.vincentStrategy(),
355
+ b.vincentTradingProfile()
356
+ ]);
357
+ if (!C.current) return;
358
+ t.status === "fulfilled" && o(t.value), r.status === "fulfilled" && c(r.value), a.status === "fulfilled" && u(a.value.strategy), s.status === "fulfilled" && f(s.value.profile), x(null);
359
+ } catch (t) {
360
+ if (!C.current) return;
361
+ if (t instanceof e && t.status === 404) {
362
+ n(!1), x(null);
363
+ return;
364
+ }
365
+ x(t instanceof Error ? t.message : "Failed to load data");
366
+ } finally {
367
+ C.current && v(!1);
368
+ }
369
+ }, []);
370
+ return m(() => (C.current = !0, w(), () => {
371
+ C.current = !1;
372
+ }), [w]), m(() => (S.current &&= (clearInterval(S.current), null), t && (S.current = setInterval(() => void w(), k)), () => {
373
+ S.current &&= (clearInterval(S.current), null);
374
+ }), [t, w]), {
375
+ vincentConnected: t,
376
+ vincentConnectedAt: r,
377
+ walletAddresses: a,
378
+ walletBalances: s,
379
+ strategy: l,
380
+ tradingProfile: d,
381
+ loading: _,
382
+ error: y,
383
+ refresh: p(() => {
384
+ v(!0), w();
385
+ }, [w])
386
+ };
387
+ }
388
+ //#endregion
389
+ //#region src/useVincentState.ts
390
+ function j({ setActionNotice: e, t }) {
391
+ let [n, i] = g(!1), [a, o] = g(!1), [s, c] = g(null), [l, u] = g(null), d = h(!1), f = h(null), _ = p(async () => {
392
+ try {
393
+ let e = await b.vincentStatus();
394
+ return i(e.connected), u(e.connectedAt), e.connected;
395
+ } catch {
396
+ return !1;
397
+ }
398
+ }, []);
399
+ return m(() => (_(), () => {
400
+ f.current &&= (clearInterval(f.current), null);
401
+ }), [_]), {
402
+ vincentConnected: n,
403
+ vincentLoginBusy: a,
404
+ vincentLoginError: s,
405
+ vincentConnectedAt: l,
406
+ handleVincentLogin: p(async () => {
407
+ if (!(n || d.current || a)) {
408
+ d.current = !0, o(!0), c(null);
409
+ try {
410
+ let { authUrl: n } = await b.vincentStartLogin("Eliza");
411
+ await r(n), f.current && clearInterval(f.current);
412
+ let i = 0;
413
+ f.current = setInterval(async () => {
414
+ if (i++, await _()) {
415
+ f.current && clearInterval(f.current), f.current = null, o(!1), d.current = !1, c(null), e(t("vincent.connected", { defaultValue: "Vincent connected" }), "success", 5e3);
416
+ return;
417
+ }
418
+ i >= 24 && (f.current && clearInterval(f.current), f.current = null, o(!1), d.current = !1, c(t("vincent.loginTimeout", { defaultValue: "Login timed out. Close the auth window and try again." })));
419
+ }, 5e3);
420
+ } catch (e) {
421
+ c(e instanceof Error ? e.message : "Vincent login failed"), o(!1), d.current = !1;
422
+ }
423
+ }
424
+ }, [
425
+ _,
426
+ e,
427
+ t,
428
+ n,
429
+ a
430
+ ]),
431
+ handleVincentDisconnect: p(async () => {
432
+ try {
433
+ await b.vincentDisconnect(), i(!1), u(null), c(null), e(t("vincent.disconnected", { defaultValue: "Vincent disconnected" }), "info", 3e3);
434
+ } catch (e) {
435
+ c(e instanceof Error ? e.message : "Disconnect failed");
436
+ }
437
+ }, [e, t]),
438
+ pollVincentStatus: _
439
+ };
440
+ }
441
+ //#endregion
442
+ //#region src/VincentView.tsx
443
+ var M = "https://heyvincent.ai";
444
+ function N(e, t) {
445
+ return typeof t?.defaultValue == "string" ? t.defaultValue : e;
446
+ }
447
+ function P() {
448
+ let e = i((e) => e.setActionNotice), { vincentConnected: t, vincentConnectedAt: n, walletAddresses: a, walletBalances: o, strategy: s, tradingProfile: c, loading: l, error: d, refresh: f } = A(), { handleVincentLogin: m, handleVincentDisconnect: h } = j({
449
+ setActionNotice: e,
450
+ t: N
451
+ }), g = p((t, n) => {
452
+ t && navigator.clipboard.writeText(t).then(() => {
453
+ e(`${n} address copied`, "success", 2e3);
454
+ });
455
+ }, [e]), v = p((e) => {
456
+ switch (e) {
457
+ case "connect":
458
+ m();
459
+ return;
460
+ case "disconnect":
461
+ h();
462
+ return;
463
+ case "refresh":
464
+ f();
465
+ return;
466
+ case "open-vincent":
467
+ r(M);
468
+ return;
469
+ case "copy-evm":
470
+ g(a?.evmAddress, "EVM");
471
+ return;
472
+ case "copy-solana":
473
+ g(a?.solanaAddress, "Solana");
474
+ return;
475
+ }
476
+ }, [
477
+ g,
478
+ h,
479
+ m,
480
+ f,
481
+ a
482
+ ]);
483
+ return /* @__PURE__ */ _(u, { children: /* @__PURE__ */ _(O, {
484
+ snapshot: {
485
+ vincentConnected: t,
486
+ vincentConnectedAt: n,
487
+ walletAddresses: a,
488
+ walletBalances: o,
489
+ strategy: s,
490
+ tradingProfile: c,
491
+ loading: l,
492
+ error: d
493
+ },
494
+ onAction: v
495
+ }) });
496
+ }
497
+ //#endregion
498
+ export { P as VincentView, S as interact };
499
+
500
+ //# sourceMappingURL=bundle.js.map