@tangle-network/sandbox-ui 0.113.7 → 0.114.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/dist/WorkflowGraph-B-NsdYz_.js +1961 -0
  2. package/dist/assets.d.ts +214 -206
  3. package/dist/assets.js +1057 -908
  4. package/dist/auth-CWe17Hly.js +37 -0
  5. package/dist/auth.d.ts +2 -30
  6. package/dist/auth.js +2 -15
  7. package/dist/chat-BOvFAe6p.js +903 -0
  8. package/dist/chat.d.ts +2 -230
  9. package/dist/chat.js +2 -34
  10. package/dist/connectors.d.ts +52 -49
  11. package/dist/connectors.js +595 -643
  12. package/dist/dashboard-CZ3VgNPR.js +4969 -0
  13. package/dist/dashboard.d.ts +4 -1297
  14. package/dist/dashboard.js +4 -152
  15. package/dist/editor.d.ts +2 -1
  16. package/dist/editor.js +2 -31
  17. package/dist/files.d.ts +2 -6
  18. package/dist/files.js +2 -33
  19. package/dist/globals.css +63 -3
  20. package/dist/hooks.d.ts +146 -148
  21. package/dist/hooks.js +222 -55
  22. package/dist/index-CKRaj1pM.d.ts +776 -0
  23. package/dist/index-CXX5IpH2.d.ts +2 -0
  24. package/dist/index-DPePq7c8.d.ts +1340 -0
  25. package/dist/index-DiyLLZuJ.d.ts +230 -0
  26. package/dist/index-DvmZLMT1.d.ts +30 -0
  27. package/dist/index-I8ZLVtHd.d.ts +330 -0
  28. package/dist/index-PRM636Ex.d.ts +86 -0
  29. package/dist/index.d.ts +21 -33
  30. package/dist/index.js +21 -701
  31. package/dist/info-panel-C9cqDzOL.js +594 -0
  32. package/dist/integrations.d.ts +133 -141
  33. package/dist/integrations.js +491 -673
  34. package/dist/markdown.d.ts +2 -1
  35. package/dist/markdown.js +2 -13
  36. package/dist/model-I-NIxeM-.js +1250 -0
  37. package/dist/model-brand-B9A4H9pJ.d.ts +98 -0
  38. package/dist/model-brand-hMyDTUqB.js +624 -0
  39. package/dist/motion-DkyBRJb9.js +37 -0
  40. package/dist/openui.d.ts +2 -1
  41. package/dist/openui.js +2 -7
  42. package/dist/pages.d.ts +307 -300
  43. package/dist/pages.js +4404 -4181
  44. package/dist/primitives-Dh1vG6J3.js +113 -0
  45. package/dist/primitives.d.ts +2 -74
  46. package/dist/primitives.js +2 -204
  47. package/dist/provider-logo-DjqmConF.js +311 -0
  48. package/dist/run.d.ts +2 -1
  49. package/dist/run.js +2 -23
  50. package/dist/sdk-hooks.d.ts +3 -4
  51. package/dist/sdk-hooks.js +3 -31
  52. package/dist/sidecar-DgH_vQ6m.d.ts +9 -0
  53. package/dist/stores.d.ts +14 -15
  54. package/dist/stores.js +13 -81
  55. package/dist/styles.css +63 -3
  56. package/dist/template-card-L-4gmjx2.d.ts +90 -0
  57. package/dist/terminal-CN9ZgHRt.js +197 -0
  58. package/dist/terminal.d.ts +60 -60
  59. package/dist/terminal.js +2 -10
  60. package/dist/tokens.css +51 -0
  61. package/dist/types.d.ts +4 -11
  62. package/dist/types.js +0 -1
  63. package/dist/use-pty-session-C8cE0adT.js +669 -0
  64. package/dist/use-sidecar-auth-CCTJcrq7.d.ts +145 -0
  65. package/dist/use-sidecar-auth-DkdcufOz.js +742 -0
  66. package/dist/utils-DzWbktWG.js +2 -0
  67. package/dist/utils.d.ts +2 -1
  68. package/dist/utils.js +2 -37
  69. package/dist/workbench-BCaCKl-J.js +8347 -0
  70. package/dist/workbench.d.ts +2 -310
  71. package/dist/workbench.js +2 -44
  72. package/dist/workflows.d.ts +341 -339
  73. package/dist/workflows.js +74 -109
  74. package/dist/workspace-B6AtI6ld.js +2510 -0
  75. package/dist/workspace.d.ts +2 -761
  76. package/dist/workspace.js +2 -51
  77. package/package.json +46 -40
  78. package/dist/WorkflowGraph-2QOORYIR.js +0 -1722
  79. package/dist/chunk-2BUPSB7O.js +0 -0
  80. package/dist/chunk-3KBNPQQF.js +0 -2697
  81. package/dist/chunk-3LIXVEEE.js +0 -279
  82. package/dist/chunk-72UF2H5H.js +0 -707
  83. package/dist/chunk-AI25G5MX.js +0 -944
  84. package/dist/chunk-ANSC5AFC.js +0 -314
  85. package/dist/chunk-AZ3AWMTM.js +0 -8
  86. package/dist/chunk-BGVEHENC.js +0 -10
  87. package/dist/chunk-CZ7CSFO4.js +0 -39
  88. package/dist/chunk-DYXXYGS4.js +0 -4700
  89. package/dist/chunk-EI44GEQ5.js +0 -6
  90. package/dist/chunk-IACRDXER.js +0 -219
  91. package/dist/chunk-IOB2PW5Z.js +0 -55
  92. package/dist/chunk-M4K7ZGR2.js +0 -24
  93. package/dist/chunk-MYZAW4RX.js +0 -665
  94. package/dist/chunk-OMUIPJQZ.js +0 -555
  95. package/dist/chunk-RQZRXKMR.js +0 -398
  96. package/dist/chunk-SOKKTB7W.js +0 -230
  97. package/dist/chunk-TADGS4Q7.js +0 -1010
  98. package/dist/chunk-UCQNOUN3.js +0 -7964
  99. package/dist/chunk-ULPLRBMF.js +0 -34
  100. package/dist/chunk-WID73FPH.js +0 -89
  101. package/dist/chunk-X3YXP7FG.js +0 -38
  102. package/dist/logo-DiAjq759.d.ts +0 -15
  103. package/dist/model-brand-BNnaUKKZ.d.ts +0 -99
  104. package/dist/ports-list-CDIvTNnX.d.ts +0 -17
  105. package/dist/sdk-hooks-Djkjq4cp.d.ts +0 -145
  106. package/dist/template-card-Bn-Bw5xC.d.ts +0 -87
@@ -1,230 +0,0 @@
1
- // src/hooks/index.ts
2
- import {
3
- RealtimeSessionRegistry,
4
- createAuthFetcher,
5
- useApiKey,
6
- useAuth,
7
- useAutoScroll,
8
- useDropdownMenu,
9
- useLiveTime,
10
- useRealtimeSession,
11
- useRunCollapseState,
12
- useRunGroups,
13
- useSSEStream,
14
- useSdkSession,
15
- useToolCallStream
16
- } from "@tangle-network/ui/hooks";
17
-
18
- // src/hooks/use-sandbox-metrics.ts
19
- import * as React from "react";
20
- function useSandboxMetrics({
21
- apiBaseUrl,
22
- sandboxId,
23
- token,
24
- enabled = true,
25
- intervalMs = 3e3,
26
- historyLimit = 120
27
- }) {
28
- const [metrics, setMetrics] = React.useState(null);
29
- const [system, setSystem] = React.useState(null);
30
- const [latency, setLatency] = React.useState(null);
31
- const [history, setHistory] = React.useState([]);
32
- const [loading, setLoading] = React.useState(false);
33
- const [error, setError] = React.useState(null);
34
- const [lastUpdatedAt, setLastUpdatedAt] = React.useState(null);
35
- const sampleRef = React.useRef(null);
36
- const hasLoadedRef = React.useRef(false);
37
- const prevSandboxIdRef = React.useRef(null);
38
- React.useEffect(() => {
39
- const sandboxCleared = !sandboxId || !apiBaseUrl;
40
- const sandboxChanged = prevSandboxIdRef.current !== null && prevSandboxIdRef.current !== sandboxId;
41
- if (sandboxCleared && prevSandboxIdRef.current !== null || sandboxChanged) {
42
- sampleRef.current = null;
43
- hasLoadedRef.current = false;
44
- setMetrics(null);
45
- setSystem(null);
46
- setLatency(null);
47
- setHistory([]);
48
- setLastUpdatedAt(null);
49
- setError(null);
50
- if (sandboxCleared) setLoading(false);
51
- }
52
- prevSandboxIdRef.current = sandboxId ?? null;
53
- if (!enabled || sandboxCleared) {
54
- return;
55
- }
56
- const controller = new AbortController();
57
- let cancelled = false;
58
- let timeoutId = null;
59
- const delay = Math.max(intervalMs, 500);
60
- const fetchOnce = async () => {
61
- if (!hasLoadedRef.current) setLoading(true);
62
- try {
63
- const headers = {};
64
- if (token) headers.Authorization = `Bearer ${token}`;
65
- const res = await fetch(
66
- `${apiBaseUrl}/v1/sidecar-proxy/${encodeURIComponent(sandboxId)}/metrics/json`,
67
- {
68
- method: "GET",
69
- credentials: "include",
70
- headers,
71
- signal: controller.signal
72
- }
73
- );
74
- if (!res.ok) {
75
- throw new Error(`Metrics request failed (HTTP ${res.status})`);
76
- }
77
- const data = await res.json();
78
- const user = data?.process?.cpuSeconds?.user ?? 0;
79
- const system2 = data?.process?.cpuSeconds?.system ?? 0;
80
- const cpuSeconds = user + system2;
81
- const wallMs = Date.now();
82
- if (cancelled) return;
83
- let cpuPercent = null;
84
- const prev = sampleRef.current;
85
- if (prev && prev.sandboxId === sandboxId) {
86
- const dCpu = cpuSeconds - prev.cpuSeconds;
87
- const dWallSec = (wallMs - prev.wallMs) / 1e3;
88
- if (dWallSec > 0 && dCpu >= 0) {
89
- cpuPercent = dCpu / dWallSec * 100;
90
- }
91
- }
92
- sampleRef.current = { cpuSeconds, wallMs, sandboxId };
93
- setMetrics({
94
- cpuPercent,
95
- rssBytes: data?.process?.memoryBytes?.rss ?? 0,
96
- heapUsedBytes: data?.process?.memoryBytes?.heapUsed ?? 0,
97
- heapTotalBytes: data?.process?.memoryBytes?.heapTotal ?? 0
98
- });
99
- const sys = data?.system ?? null;
100
- setSystem(sys);
101
- setLatency(data?.latency ?? null);
102
- if (sys) {
103
- const sample = {
104
- at: wallMs,
105
- cpuPercent: sys.cpuPercent,
106
- memoryUsedBytes: sys.memory?.usedBytes ?? null,
107
- memoryTotalBytes: sys.memory?.totalBytes ?? null,
108
- diskUsedBytes: sys.disk?.usedBytes ?? null,
109
- diskTotalBytes: sys.disk?.totalBytes ?? null
110
- };
111
- setHistory((prevHistory) => {
112
- const next = [...prevHistory, sample];
113
- return next.length > historyLimit ? next.slice(next.length - historyLimit) : next;
114
- });
115
- }
116
- setLastUpdatedAt(wallMs);
117
- setError(null);
118
- hasLoadedRef.current = true;
119
- setLoading(false);
120
- } catch (err) {
121
- if (cancelled || err instanceof DOMException && err.name === "AbortError") {
122
- return;
123
- }
124
- setError(err instanceof Error ? err : new Error(String(err)));
125
- if (!hasLoadedRef.current) setLoading(false);
126
- }
127
- };
128
- const runLoop = async () => {
129
- if (cancelled) return;
130
- await fetchOnce();
131
- if (cancelled) return;
132
- timeoutId = window.setTimeout(runLoop, delay);
133
- };
134
- runLoop();
135
- return () => {
136
- cancelled = true;
137
- controller.abort();
138
- if (timeoutId !== null) window.clearTimeout(timeoutId);
139
- };
140
- }, [apiBaseUrl, sandboxId, token, enabled, intervalMs, historyLimit]);
141
- return { metrics, system, latency, history, loading, error, lastUpdatedAt };
142
- }
143
-
144
- // src/hooks/use-session-crud.ts
145
- import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
146
- async function sessionFetch(apiUrl, token, path, opts) {
147
- const res = await fetch(`${apiUrl}${path}`, {
148
- ...opts,
149
- headers: {
150
- "Content-Type": "application/json",
151
- Authorization: `Bearer ${token}`,
152
- ...opts?.headers ?? {}
153
- }
154
- });
155
- if (!res.ok) {
156
- const text = await res.text();
157
- throw new Error(text || `API error: ${res.status}`);
158
- }
159
- return res.json();
160
- }
161
- function useSessions(apiUrl, token) {
162
- return useQuery({
163
- queryKey: ["sessions", apiUrl, token],
164
- queryFn: () => sessionFetch(apiUrl, token, "/session/sessions"),
165
- enabled: !!token,
166
- staleTime: 3e4
167
- });
168
- }
169
- function useCreateSession(apiUrl, token) {
170
- const queryClient = useQueryClient();
171
- return useMutation({
172
- mutationFn: async (title) => {
173
- return sessionFetch(apiUrl, token, "/session/sessions", {
174
- method: "POST",
175
- body: JSON.stringify({ title, backend: { type: "opencode" } })
176
- });
177
- },
178
- onSuccess: () => {
179
- queryClient.invalidateQueries({ queryKey: ["sessions", apiUrl, token] });
180
- }
181
- });
182
- }
183
- function useDeleteSession(apiUrl, token) {
184
- const queryClient = useQueryClient();
185
- return useMutation({
186
- mutationFn: async (sessionId) => {
187
- return sessionFetch(apiUrl, token, `/session/sessions/${encodeURIComponent(sessionId)}`, {
188
- method: "DELETE"
189
- });
190
- },
191
- onSuccess: () => {
192
- queryClient.invalidateQueries({ queryKey: ["sessions", apiUrl, token] });
193
- }
194
- });
195
- }
196
- function useRenameSession(apiUrl, token) {
197
- const queryClient = useQueryClient();
198
- return useMutation({
199
- mutationFn: async ({ sessionId, title }) => {
200
- return sessionFetch(apiUrl, token, `/session/sessions/${encodeURIComponent(sessionId)}`, {
201
- method: "PATCH",
202
- body: JSON.stringify({ title })
203
- });
204
- },
205
- onSuccess: () => {
206
- queryClient.invalidateQueries({ queryKey: ["sessions", apiUrl, token] });
207
- }
208
- });
209
- }
210
-
211
- export {
212
- useSandboxMetrics,
213
- useSessions,
214
- useCreateSession,
215
- useDeleteSession,
216
- useRenameSession,
217
- RealtimeSessionRegistry,
218
- createAuthFetcher,
219
- useApiKey,
220
- useAuth,
221
- useAutoScroll,
222
- useDropdownMenu,
223
- useLiveTime,
224
- useRealtimeSession,
225
- useRunCollapseState,
226
- useRunGroups,
227
- useSSEStream,
228
- useSdkSession,
229
- useToolCallStream
230
- };