@tangle-network/sandbox-ui 0.6.1 → 0.9.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 (68) hide show
  1. package/README.md +5 -6
  2. package/dist/auth.d.ts +10 -6
  3. package/dist/auth.js +3 -3
  4. package/dist/{chat-container-Cg-GwyiK.d.ts → chat-container-f4yEs6KN.d.ts} +9 -1
  5. package/dist/chat.d.ts +12 -2
  6. package/dist/chat.js +10 -10
  7. package/dist/{chunk-WBQ7VULC.js → chunk-34A66VBG.js} +7 -7
  8. package/dist/{chunk-JP725R4W.js → chunk-34I7UFSX.js} +2 -2
  9. package/dist/{chunk-CNWVHQFY.js → chunk-54SQQMMM.js} +6 -24
  10. package/dist/{chunk-DLCFZDGX.js → chunk-5UM2XMEJ.js} +39 -14
  11. package/dist/{chunk-YYGECNZZ.js → chunk-66EZOYZR.js} +3 -3
  12. package/dist/{chunk-6V4XVKFY.js → chunk-7YWFOGKQ.js} +344 -338
  13. package/dist/{chunk-DCPYTL4W.js → chunk-D4CZWJCD.js} +72 -148
  14. package/dist/{chunk-XTPAWK7L.js → chunk-DI3NZ5ZX.js} +15 -51
  15. package/dist/{chunk-MXRQ4MJE.js → chunk-DXMIEK4K.js} +34 -23
  16. package/dist/{chunk-ZMWWE5RF.js → chunk-EXSOPXIY.js} +141 -123
  17. package/dist/{chunk-GW4GRAWJ.js → chunk-GSZA3TSY.js} +18 -12
  18. package/dist/{chunk-W4LM3QYZ.js → chunk-HB5Y37YU.js} +8 -8
  19. package/dist/{chunk-RKXIRRKQ.js → chunk-JLKYXLFN.js} +70 -66
  20. package/dist/{chunk-BRBTD7RH.js → chunk-MA7YKRUP.js} +28 -18
  21. package/dist/{chunk-TSE423UF.js → chunk-MKTSMWVD.js} +6 -6
  22. package/dist/{chunk-MJUDMVRU.js → chunk-MT5FJ3ZT.js} +17 -17
  23. package/dist/{chunk-565V6JTN.js → chunk-OHPW55EV.js} +60 -99
  24. package/dist/chunk-OKLQVY3Y.js +139 -0
  25. package/dist/{chunk-OVNLOE3Y.js → chunk-PLTZB5BC.js} +41 -41
  26. package/dist/{chunk-E2XT3G52.js → chunk-QC4BJEG6.js} +136 -137
  27. package/dist/{chunk-KH5UDAJ2.js → chunk-QDH5GEGY.js} +58 -54
  28. package/dist/{chunk-33W2TLUL.js → chunk-QID2OOMG.js} +12 -3
  29. package/dist/{chunk-FJSVPBKY.js → chunk-S7OXQTST.js} +17 -3
  30. package/dist/chunk-T7HMZEVO.js +216 -0
  31. package/dist/{chunk-FNYJFCGU.js → chunk-U6QTHMY6.js} +145 -256
  32. package/dist/{chunk-YS66Q3RC.js → chunk-US6JKJKH.js} +2 -2
  33. package/dist/chunk-VX3XOUEB.js +63 -0
  34. package/dist/{chunk-TDYQBLL5.js → chunk-ZMNSRDMH.js} +6 -6
  35. package/dist/dashboard.d.ts +156 -4
  36. package/dist/dashboard.js +885 -8
  37. package/dist/{document-editor-pane-DWWUTTTZ.js → document-editor-pane-TLPVRBBU.js} +3 -3
  38. package/dist/editor.d.ts +9 -8
  39. package/dist/editor.js +3 -3
  40. package/dist/files.js +3 -3
  41. package/dist/globals.css +4787 -69
  42. package/dist/hooks.d.ts +1 -1
  43. package/dist/hooks.js +7 -7
  44. package/dist/index.d.ts +4 -4
  45. package/dist/index.js +28 -28
  46. package/dist/markdown.js +1 -1
  47. package/dist/openui.js +5 -5
  48. package/dist/pages.d.ts +114 -5
  49. package/dist/pages.js +1978 -365
  50. package/dist/primitives.d.ts +5 -2
  51. package/dist/primitives.js +10 -10
  52. package/dist/run.js +4 -4
  53. package/dist/sdk-hooks.d.ts +2 -3
  54. package/dist/sdk-hooks.js +5 -5
  55. package/dist/styles.css +4787 -69
  56. package/dist/template-card-BAtvcAkU.d.ts +18 -0
  57. package/dist/terminal.d.ts +3 -1
  58. package/dist/terminal.js +66 -32
  59. package/dist/tokens.css +289 -237
  60. package/dist/{usage-chart-XCoB_7Xu.d.ts → usage-chart-SSiOgeQI.d.ts} +3 -1
  61. package/dist/{use-pty-session-COzVkhtc.d.ts → use-pty-session-0AOuwXgq.d.ts} +2 -0
  62. package/dist/{index-BT_-ecpc.d.ts → variant-list-CsS6ydgm.d.ts} +16 -7
  63. package/dist/workspace.d.ts +2 -2
  64. package/dist/workspace.js +13 -13
  65. package/package.json +18 -3
  66. package/tailwind.config.cjs +3 -2
  67. package/dist/chunk-3HW53XTH.js +0 -228
  68. package/dist/chunk-OKCIKTXQ.js +0 -63
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  parseToolEvent
3
- } from "./chunk-33W2TLUL.js";
3
+ } from "./chunk-QID2OOMG.js";
4
4
  import {
5
5
  bumpActiveSessionActivity,
6
6
  registerActiveSession,
@@ -97,9 +97,9 @@ function useSSEStream(options) {
97
97
  const [events, setEvents] = React.useState([]);
98
98
  const [lastEvent, setLastEvent] = React.useState(null);
99
99
  const [error, setError] = React.useState(null);
100
- const [retryCount, setRetryCount] = React.useState(0);
101
100
  const [lastEventTime, setLastEventTime] = React.useState(Date.now());
102
101
  const [timeSinceLastEvent, setTimeSinceLastEvent] = React.useState(0);
102
+ const retryCountRef = React.useRef(0);
103
103
  const eventSourceRef = React.useRef(null);
104
104
  const abortControllerRef = React.useRef(null);
105
105
  const reconnectTimeoutRef = React.useRef(null);
@@ -126,7 +126,10 @@ function useSSEStream(options) {
126
126
  }
127
127
  setLastEventTime(Date.now());
128
128
  setLastEvent(event);
129
- setEvents((prev) => [...prev, event]);
129
+ setEvents((prev) => {
130
+ const next = [...prev, event];
131
+ return next.length > 1e3 ? next.slice(-1e3) : next;
132
+ });
130
133
  onEvent?.(event);
131
134
  },
132
135
  [onEvent]
@@ -181,7 +184,7 @@ function useSSEStream(options) {
181
184
  throw new Error("Response body is null");
182
185
  }
183
186
  setState("connected");
184
- setRetryCount(0);
187
+ retryCountRef.current = 0;
185
188
  const reader = response.body.getReader();
186
189
  const decoder = new TextDecoder();
187
190
  let buffer = "";
@@ -227,10 +230,10 @@ function useSSEStream(options) {
227
230
  }
228
231
  if (autoReconnect && enabled) {
229
232
  setState("reconnecting");
230
- const delay = reconnectDelay * 2 ** retryCount;
233
+ const delay = reconnectDelay * 2 ** retryCountRef.current;
231
234
  reconnectTimeoutRef.current = setTimeout(
232
235
  () => {
233
- setRetryCount((c) => c + 1);
236
+ retryCountRef.current += 1;
234
237
  connect();
235
238
  },
236
239
  Math.min(delay, 3e4)
@@ -245,12 +248,12 @@ function useSSEStream(options) {
245
248
  setError(err);
246
249
  onError?.(err);
247
250
  setState("error");
248
- if (autoReconnect && enabled && retryCount < maxRetries) {
251
+ if (autoReconnect && enabled && retryCountRef.current < maxRetries) {
249
252
  setState("reconnecting");
250
- const delay = reconnectDelay * 2 ** retryCount;
253
+ const delay = reconnectDelay * 2 ** retryCountRef.current;
251
254
  reconnectTimeoutRef.current = setTimeout(
252
255
  () => {
253
- setRetryCount((c) => c + 1);
256
+ retryCountRef.current += 1;
254
257
  connect();
255
258
  },
256
259
  Math.min(delay, 3e4)
@@ -262,19 +265,19 @@ function useSSEStream(options) {
262
265
  eventSourceRef.current = es;
263
266
  es.onopen = () => {
264
267
  setState("connected");
265
- setRetryCount(0);
268
+ retryCountRef.current = 0;
266
269
  };
267
270
  es.onerror = () => {
268
271
  const err = new Error("EventSource connection error");
269
272
  setError(err);
270
273
  onError?.(err);
271
- if (autoReconnect && enabled && retryCount < maxRetries) {
274
+ if (autoReconnect && enabled && retryCountRef.current < maxRetries) {
272
275
  setState("reconnecting");
273
276
  es.close();
274
- const delay = reconnectDelay * 2 ** retryCount;
277
+ const delay = reconnectDelay * 2 ** retryCountRef.current;
275
278
  reconnectTimeoutRef.current = setTimeout(
276
279
  () => {
277
- setRetryCount((c) => c + 1);
280
+ retryCountRef.current += 1;
278
281
  connect();
279
282
  },
280
283
  Math.min(delay, 3e4)
@@ -313,7 +316,6 @@ function useSSEStream(options) {
313
316
  autoReconnect,
314
317
  maxRetries,
315
318
  reconnectDelay,
316
- retryCount,
317
319
  eventTypes,
318
320
  handleEvent,
319
321
  onError,
@@ -337,7 +339,7 @@ function useSSEStream(options) {
337
339
  connect,
338
340
  disconnect,
339
341
  clearEvents,
340
- retryCount,
342
+ retryCount: retryCountRef.current,
341
343
  timeSinceLastEvent
342
344
  };
343
345
  }
@@ -345,8 +347,11 @@ function useSSEStream(options) {
345
347
  // src/hooks/use-sdk-session.ts
346
348
  import { useCallback as useCallback3, useMemo, useRef as useRef3, useState as useState3 } from "react";
347
349
  function uid() {
348
- if (typeof crypto !== "undefined" && crypto.randomUUID) {
349
- return crypto.randomUUID();
350
+ if (typeof globalThis.crypto !== "undefined" && typeof globalThis.crypto.randomUUID === "function") {
351
+ try {
352
+ return globalThis.crypto.randomUUID();
353
+ } catch {
354
+ }
350
355
  }
351
356
  return `sdk-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`;
352
357
  }
@@ -1001,14 +1006,13 @@ function RealtimeSessionRegistry({ sessions }) {
1001
1006
 
1002
1007
  // src/hooks/use-session-stream.ts
1003
1008
  import { useCallback as useCallback4, useEffect as useEffect3, useRef as useRef5, useState as useState5 } from "react";
1004
- var _insertionCounter = 0;
1005
- function mapApiMessage(msg) {
1009
+ function mapApiMessage(msg, counterRef) {
1006
1010
  const created = msg.info.timestamp ? new Date(msg.info.timestamp).getTime() : Date.now();
1007
1011
  const message = {
1008
1012
  id: msg.info.id,
1009
1013
  role: msg.info.role,
1010
1014
  time: { created },
1011
- _insertionIndex: _insertionCounter++
1015
+ _insertionIndex: counterRef.current++
1012
1016
  };
1013
1017
  const parts = (msg.parts ?? []).map((p, i) => {
1014
1018
  if (p.type === "tool" && p.tool) {
@@ -1056,7 +1060,9 @@ function useSessionStream({
1056
1060
  const [error, setError] = useState5(null);
1057
1061
  const [connected, setConnected] = useState5(false);
1058
1062
  const abortRef = useRef5(null);
1063
+ const reconnectTimerRef = useRef5(null);
1059
1064
  const streamingMsgIdRef = useRef5(null);
1065
+ const insertionCounterRef = useRef5(0);
1060
1066
  const handleSSEEventRef = useRef5(null);
1061
1067
  const refetch = useCallback4(async () => {
1062
1068
  if (!token || !sessionId || !apiUrl) return;
@@ -1067,7 +1073,7 @@ function useSessionStream({
1067
1073
  const newMessages = [];
1068
1074
  const newPartMap = {};
1069
1075
  for (const apiMsg of apiMessages) {
1070
- const { message, parts } = mapApiMessage(apiMsg);
1076
+ const { message, parts } = mapApiMessage(apiMsg, insertionCounterRef);
1071
1077
  newMessages.push(message);
1072
1078
  newPartMap[message.id] = parts;
1073
1079
  }
@@ -1081,6 +1087,10 @@ function useSessionStream({
1081
1087
  }, [apiUrl, token, sessionId]);
1082
1088
  const connectSSE = useCallback4(async () => {
1083
1089
  if (!token || !sessionId || !apiUrl || !enabled) return;
1090
+ if (reconnectTimerRef.current) {
1091
+ clearTimeout(reconnectTimerRef.current);
1092
+ reconnectTimerRef.current = null;
1093
+ }
1084
1094
  abortRef.current?.abort();
1085
1095
  const controller = new AbortController();
1086
1096
  abortRef.current = controller;
@@ -1131,7 +1141,7 @@ function useSessionStream({
1131
1141
  setError(msg);
1132
1142
  setConnected(false);
1133
1143
  if (!controller.signal.aborted) {
1134
- setTimeout(() => connectSSE(), 3e3);
1144
+ reconnectTimerRef.current = setTimeout(() => connectSSE(), 3e3);
1135
1145
  }
1136
1146
  }
1137
1147
  }, [apiUrl, token, sessionId, enabled]);
@@ -1151,7 +1161,7 @@ function useSessionStream({
1151
1161
  id,
1152
1162
  role,
1153
1163
  time: { created: Date.now() },
1154
- _insertionIndex: _insertionCounter++
1164
+ _insertionIndex: insertionCounterRef.current++
1155
1165
  }
1156
1166
  ];
1157
1167
  });
@@ -1254,6 +1264,7 @@ function useSessionStream({
1254
1264
  connectSSE();
1255
1265
  return () => {
1256
1266
  abortRef.current?.abort();
1267
+ if (reconnectTimerRef.current) clearTimeout(reconnectTimerRef.current);
1257
1268
  setConnected(false);
1258
1269
  };
1259
1270
  }, [enabled, token, sessionId, refetch, connectSSE]);