@tangle-network/sandbox-ui 0.4.0 → 0.5.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 (61) hide show
  1. package/dist/auth.js +3 -3
  2. package/dist/chat.d.ts +1 -1
  3. package/dist/chat.js +11 -9
  4. package/dist/{chunk-ZP6GSX4D.js → chunk-565V6JTN.js} +26 -50
  5. package/dist/chunk-5CEMHKBP.js +72 -0
  6. package/dist/{chunk-FOQTE67I.js → chunk-5F4NX5R2.js} +10 -5
  7. package/dist/{chunk-MUOL44AE.js → chunk-BRBTD7RH.js} +6 -6
  8. package/dist/{chunk-SSKVYXCR.js → chunk-DCPYTL4W.js} +62 -79
  9. package/dist/chunk-DLCFZDGX.js +182 -0
  10. package/dist/{chunk-HXEA7L2T.js → chunk-FFOXUHOF.js} +10 -10
  11. package/dist/chunk-H5XYSFYE.js +228 -0
  12. package/dist/{chunk-TQN3VR4F.js → chunk-JP725R4W.js} +2 -2
  13. package/dist/{chunk-CJ2RYVZH.js → chunk-NTSRY4GW.js} +68 -10
  14. package/dist/{chunk-DQYODCBN.js → chunk-P24K22CV.js} +57 -66
  15. package/dist/{chunk-GVUW4VDD.js → chunk-R3IU37AW.js} +161 -229
  16. package/dist/chunk-TDYQBLL5.js +127 -0
  17. package/dist/{chunk-HWLX5NME.js → chunk-TSE423UF.js} +12 -12
  18. package/dist/{chunk-YDBXQQLC.js → chunk-VBWY44UU.js} +30 -76
  19. package/dist/{chunk-IW2JZCOC.js → chunk-WBQ7VULC.js} +7 -7
  20. package/dist/{chunk-72UEKFZ2.js → chunk-WC7QTWPN.js} +65 -42
  21. package/dist/{chunk-HYLTXGOI.js → chunk-WQH233GF.js} +5 -5
  22. package/dist/{chunk-CCKNIAS7.js → chunk-XBR3IP7B.js} +2 -2
  23. package/dist/{chunk-OHMO7NUX.js → chunk-XTPAWK7L.js} +20 -31
  24. package/dist/{chunk-SULQQJPB.js → chunk-YS66Q3RC.js} +1 -1
  25. package/dist/{chunk-FRGMMANX.js → chunk-YYGECNZZ.js} +3 -3
  26. package/dist/{chunk-MVYFNPAH.js → chunk-ZOZX2U6I.js} +285 -271
  27. package/dist/dashboard.d.ts +2 -2
  28. package/dist/dashboard.js +6 -6
  29. package/dist/{document-editor-pane-5TN2VWGZ.js → document-editor-pane-JNXPANWM.js} +2 -2
  30. package/dist/editor.js +2 -2
  31. package/dist/files.js +2 -2
  32. package/dist/globals.css +129 -95
  33. package/dist/hooks.d.ts +2 -2
  34. package/dist/hooks.js +5 -5
  35. package/dist/{index-tTfThG0n.d.ts → index-CDt0GE4A.d.ts} +7 -8
  36. package/dist/index.d.ts +16 -23
  37. package/dist/index.js +27 -26
  38. package/dist/markdown.d.ts +14 -17
  39. package/dist/markdown.js +1 -1
  40. package/dist/openui.js +5 -5
  41. package/dist/pages.d.ts +10 -3
  42. package/dist/pages.js +147 -184
  43. package/dist/primitives.d.ts +8 -5
  44. package/dist/primitives.js +8 -8
  45. package/dist/run.d.ts +1 -1
  46. package/dist/run.js +4 -4
  47. package/dist/sdk-hooks.d.ts +1 -1
  48. package/dist/sdk-hooks.js +4 -4
  49. package/dist/styles.css +129 -95
  50. package/dist/terminal.d.ts +2 -2
  51. package/dist/terminal.js +13 -43
  52. package/dist/tokens.css +299 -179
  53. package/dist/{tool-call-feed-D5Ume-Pt.d.ts → tool-call-feed-Bs3MyQMT.d.ts} +3 -1
  54. package/dist/{usage-chart-CY9xo3KX.d.ts → usage-chart-XCoB_7Xu.d.ts} +1 -2
  55. package/dist/{use-pty-session-DeZSxOCN.d.ts → use-pty-session-COzVkhtc.d.ts} +1 -1
  56. package/dist/workspace.d.ts +3 -1
  57. package/dist/workspace.js +11 -11
  58. package/package.json +14 -2
  59. package/dist/chunk-GRYHFH5O.js +0 -110
  60. package/dist/chunk-LTFK464G.js +0 -103
  61. package/dist/chunk-MXCSSOGH.js +0 -105
@@ -0,0 +1,228 @@
1
+ import {
2
+ cn
3
+ } from "./chunk-RQHJBTEU.js";
4
+
5
+ // src/markdown/code-block.tsx
6
+ import {
7
+ memo,
8
+ useCallback,
9
+ useEffect,
10
+ useState
11
+ } from "react";
12
+ import SyntaxHighlighter from "react-syntax-highlighter";
13
+ import { Check, Copy } from "lucide-react";
14
+ import { jsx, jsxs } from "react/jsx-runtime";
15
+ var tangleDark = {
16
+ "hljs-comment": { color: "#6B7094", fontStyle: "italic" },
17
+ "hljs-quote": { color: "#6B7094", fontStyle: "italic" },
18
+ "hljs-doctag": { color: "#6B7094" },
19
+ "hljs-keyword": { color: "#A78FFF" },
20
+ "hljs-selector-tag": { color: "#A78FFF" },
21
+ "hljs-literal": { color: "#A78FFF" },
22
+ "hljs-type": { color: "#A78FFF" },
23
+ "hljs-class": { color: "#A78FFF" },
24
+ "hljs-string": { color: "#10b981" },
25
+ "hljs-template-tag": { color: "#10b981" },
26
+ "hljs-template-variable": { color: "#10b981" },
27
+ "hljs-addition": { color: "#10b981" },
28
+ "hljs-regexp": { color: "#10b981" },
29
+ "hljs-title": { color: "#6D9FFF" },
30
+ "hljs-section": { color: "#6D9FFF" },
31
+ "hljs-built_in": { color: "#6D9FFF" },
32
+ "hljs-name": { color: "#6D9FFF" },
33
+ "hljs-function": { color: "#6D9FFF" },
34
+ "hljs-selector-id": { color: "#6D9FFF" },
35
+ "hljs-selector-class": { color: "#6D9FFF" },
36
+ "hljs-attribute": { color: "#6D9FFF" },
37
+ "hljs-number": { color: "#FFB347" },
38
+ "hljs-symbol": { color: "#FFB347" },
39
+ "hljs-bullet": { color: "#FFB347" },
40
+ "hljs-link": { color: "#FFB347", textDecoration: "underline" },
41
+ "hljs-meta": { color: "#8263FF" },
42
+ "hljs-selector-pseudo": { color: "#8263FF" },
43
+ "hljs-deletion": { color: "#FF4D6D" },
44
+ "hljs-params": { color: "#C4C0D8" },
45
+ "hljs-variable": { color: "#C4C0D8" },
46
+ "hljs-tag": { color: "#C4C0D8" },
47
+ "hljs-attr": { color: "#C4C0D8" },
48
+ "hljs-subst": { color: "#C4C0D8" },
49
+ "hljs-strong": { fontWeight: "bold" },
50
+ "hljs-emphasis": { fontStyle: "italic" },
51
+ "hljs": { color: "#E8E6F6", background: "transparent" }
52
+ };
53
+ var tangleLight = {
54
+ "hljs-comment": { color: "#8B92B8", fontStyle: "italic" },
55
+ "hljs-quote": { color: "#8B92B8", fontStyle: "italic" },
56
+ "hljs-doctag": { color: "#8B92B8" },
57
+ "hljs-keyword": { color: "#5B3FCC" },
58
+ "hljs-selector-tag": { color: "#5B3FCC" },
59
+ "hljs-literal": { color: "#5B3FCC" },
60
+ "hljs-type": { color: "#5B3FCC" },
61
+ "hljs-class": { color: "#5B3FCC" },
62
+ "hljs-string": { color: "#0D7A57" },
63
+ "hljs-template-tag": { color: "#0D7A57" },
64
+ "hljs-template-variable": { color: "#0D7A57" },
65
+ "hljs-addition": { color: "#0D7A57" },
66
+ "hljs-regexp": { color: "#0D7A57" },
67
+ "hljs-title": { color: "#1B5EBF" },
68
+ "hljs-section": { color: "#1B5EBF" },
69
+ "hljs-built_in": { color: "#1B5EBF" },
70
+ "hljs-name": { color: "#1B5EBF" },
71
+ "hljs-function": { color: "#1B5EBF" },
72
+ "hljs-selector-id": { color: "#1B5EBF" },
73
+ "hljs-selector-class": { color: "#1B5EBF" },
74
+ "hljs-attribute": { color: "#1B5EBF" },
75
+ "hljs-number": { color: "#B85C00" },
76
+ "hljs-symbol": { color: "#B85C00" },
77
+ "hljs-bullet": { color: "#B85C00" },
78
+ "hljs-link": { color: "#B85C00", textDecoration: "underline" },
79
+ "hljs-meta": { color: "#6940C4" },
80
+ "hljs-selector-pseudo": { color: "#6940C4" },
81
+ "hljs-deletion": { color: "#CC1A3A" },
82
+ "hljs-params": { color: "#2D2D4A" },
83
+ "hljs-variable": { color: "#2D2D4A" },
84
+ "hljs-tag": { color: "#2D2D4A" },
85
+ "hljs-attr": { color: "#2D2D4A" },
86
+ "hljs-subst": { color: "#2D2D4A" },
87
+ "hljs-strong": { fontWeight: "bold" },
88
+ "hljs-emphasis": { fontStyle: "italic" },
89
+ "hljs": { color: "#1A1A2E", background: "transparent" }
90
+ };
91
+ function useIsVaultTheme() {
92
+ const detect = () => typeof document !== "undefined" && document.documentElement.getAttribute("data-sandbox-theme") === "vault";
93
+ const [isVault, setIsVault] = useState(detect);
94
+ useEffect(() => {
95
+ setIsVault(detect());
96
+ const observer = new MutationObserver(() => setIsVault(detect()));
97
+ observer.observe(document.documentElement, {
98
+ attributes: true,
99
+ attributeFilter: ["data-sandbox-theme"]
100
+ });
101
+ return () => observer.disconnect();
102
+ }, []);
103
+ return isVault;
104
+ }
105
+ var CodeBlock = memo(
106
+ ({ code, language, showLineNumbers = false, light: lightProp, className, children, ...props }) => {
107
+ const isVault = useIsVaultTheme();
108
+ const light = lightProp ?? isVault;
109
+ const theme = light ? tangleLight : tangleDark;
110
+ const bg = "bg-[var(--depth-2)] border-[var(--border-subtle)]";
111
+ const headerBg = light ? "bg-[var(--depth-3)] border-[var(--border-subtle)]" : "bg-[var(--depth-1)] border-[var(--border-subtle)]";
112
+ const langColor = "text-[var(--text-muted)]";
113
+ return /* @__PURE__ */ jsxs(
114
+ "div",
115
+ {
116
+ className: cn("group relative overflow-hidden rounded-lg border font-mono", bg, className),
117
+ ...props,
118
+ children: [
119
+ language && /* @__PURE__ */ jsxs("div", { className: cn("flex items-center justify-between border-b px-4 py-1.5", headerBg), children: [
120
+ /* @__PURE__ */ jsx("span", { className: cn("text-[11px] font-mono font-medium uppercase tracking-widest", langColor), children: language }),
121
+ children
122
+ ] }),
123
+ !language && children && /* @__PURE__ */ jsx("div", { className: "absolute right-2 top-2 z-10 flex items-center gap-2 opacity-0 transition-opacity group-hover:opacity-100", children }),
124
+ /* @__PURE__ */ jsx(
125
+ SyntaxHighlighter,
126
+ {
127
+ language: language ?? "text",
128
+ style: theme,
129
+ showLineNumbers,
130
+ lineNumberStyle: {
131
+ color: light ? "#8B92B8" : "#4A4D6A",
132
+ minWidth: "2.5em",
133
+ paddingRight: "1em"
134
+ },
135
+ customStyle: {
136
+ margin: 0,
137
+ padding: "1rem",
138
+ background: "transparent",
139
+ fontSize: "0.8125rem",
140
+ lineHeight: "1.65",
141
+ overflowX: "auto"
142
+ },
143
+ codeTagProps: { style: { fontFamily: "var(--font-mono, 'JetBrains Mono', ui-monospace, monospace)" } },
144
+ wrapLines: false,
145
+ children: code
146
+ }
147
+ )
148
+ ]
149
+ }
150
+ );
151
+ }
152
+ );
153
+ CodeBlock.displayName = "CodeBlock";
154
+ var CopyButton = memo(({ text }) => {
155
+ const [copied, setCopied] = useState(false);
156
+ const handleCopy = useCallback(async () => {
157
+ try {
158
+ await navigator.clipboard.writeText(text);
159
+ setCopied(true);
160
+ setTimeout(() => setCopied(false), 2e3);
161
+ } catch {
162
+ }
163
+ }, [text]);
164
+ return /* @__PURE__ */ jsx(
165
+ "button",
166
+ {
167
+ onClick: handleCopy,
168
+ className: "flex items-center justify-center w-7 h-7 rounded-md bg-[var(--bg-section)] border border-[var(--border-subtle)] hover:border-[var(--border-default)] transition-colors",
169
+ title: "Copy to clipboard",
170
+ children: copied ? /* @__PURE__ */ jsx(Check, { className: "w-3.5 h-3.5 text-[var(--brand-emerald)]" }) : /* @__PURE__ */ jsx(Copy, { className: "w-3.5 h-3.5 text-[var(--text-muted)]" })
171
+ }
172
+ );
173
+ });
174
+ CopyButton.displayName = "CopyButton";
175
+
176
+ // src/markdown/markdown.tsx
177
+ import { memo as memo2 } from "react";
178
+ import ReactMarkdown from "react-markdown";
179
+ import remarkGfm from "remark-gfm";
180
+ import rehypeSanitize from "rehype-sanitize";
181
+ import { Fragment, jsx as jsx2 } from "react/jsx-runtime";
182
+ var Markdown = memo2(({ children, className }) => {
183
+ return /* @__PURE__ */ jsx2(
184
+ "div",
185
+ {
186
+ className: cn("prose prose-sm dark:prose-invert max-w-none", className),
187
+ children: /* @__PURE__ */ jsx2(
188
+ ReactMarkdown,
189
+ {
190
+ remarkPlugins: [remarkGfm],
191
+ rehypePlugins: [rehypeSanitize],
192
+ components: {
193
+ pre({ children: preChildren }) {
194
+ return /* @__PURE__ */ jsx2(Fragment, { children: preChildren });
195
+ },
196
+ code({ className: codeClass, children: codeChildren, ...rest }) {
197
+ const match = /language-(\w+)/.exec(codeClass || "");
198
+ const language = match?.[1];
199
+ const code = String(codeChildren).replace(/\n$/, "");
200
+ if (!language && !code.includes("\n")) {
201
+ return /* @__PURE__ */ jsx2(
202
+ "code",
203
+ {
204
+ className: cn(
205
+ "px-1.5 py-0.5 rounded border border-[var(--border-subtle)] bg-[var(--depth-2)] text-[var(--code-keyword)] text-[0.85em] font-mono",
206
+ codeClass
207
+ ),
208
+ ...rest,
209
+ children: codeChildren
210
+ }
211
+ );
212
+ }
213
+ return /* @__PURE__ */ jsx2(CodeBlock, { code, language, children: /* @__PURE__ */ jsx2(CopyButton, { text: code }) });
214
+ }
215
+ },
216
+ children
217
+ }
218
+ )
219
+ }
220
+ );
221
+ });
222
+ Markdown.displayName = "Markdown";
223
+
224
+ export {
225
+ CodeBlock,
226
+ CopyButton,
227
+ Markdown
228
+ };
@@ -30,7 +30,7 @@ var TableFooter = React.forwardRef(({ className, ...props }, ref) => /* @__PURE_
30
30
  {
31
31
  ref,
32
32
  className: cn(
33
- "border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",
33
+ "border-t bg-[var(--depth-2)] font-medium [&>tr]:last:border-b-0",
34
34
  className
35
35
  ),
36
36
  ...props
@@ -42,7 +42,7 @@ var TableRow = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ *
42
42
  {
43
43
  ref,
44
44
  className: cn(
45
- "border-border border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",
45
+ "border-border border-b transition-colors hover:bg-[var(--depth-3)] data-[state=selected]:bg-[var(--depth-3)]",
46
46
  className
47
47
  ),
48
48
  ...props
@@ -1,3 +1,6 @@
1
+ import {
2
+ CodeBlock
3
+ } from "./chunk-H5XYSFYE.js";
1
4
  import {
2
5
  cn
3
6
  } from "./chunk-RQHJBTEU.js";
@@ -18,6 +21,52 @@ import {
18
21
  Eye
19
22
  } from "lucide-react";
20
23
  import { jsx, jsxs } from "react/jsx-runtime";
24
+ var EXT_LANGUAGE = {
25
+ ts: "typescript",
26
+ tsx: "typescript",
27
+ js: "javascript",
28
+ jsx: "javascript",
29
+ mjs: "javascript",
30
+ cjs: "javascript",
31
+ css: "css",
32
+ scss: "scss",
33
+ json: "json",
34
+ jsonc: "json",
35
+ md: "markdown",
36
+ mdx: "markdown",
37
+ py: "python",
38
+ sh: "bash",
39
+ bash: "bash",
40
+ zsh: "bash",
41
+ html: "html",
42
+ htm: "html",
43
+ yaml: "yaml",
44
+ yml: "yaml",
45
+ toml: "toml",
46
+ rs: "rust",
47
+ go: "go",
48
+ sql: "sql",
49
+ xml: "xml"
50
+ };
51
+ function inferLanguage(detail, language) {
52
+ if (language) return language;
53
+ if (!detail) return void 0;
54
+ const ext = detail.split(".").pop()?.toLowerCase();
55
+ return ext ? EXT_LANGUAGE[ext] : void 0;
56
+ }
57
+ function isFilePath(detail) {
58
+ return /[/\\]/.test(detail) || /\.\w{1,6}$/.test(detail);
59
+ }
60
+ function FilePathChip({ path }) {
61
+ const parts = path.replace(/\\/g, "/").split("/");
62
+ const filename = parts.pop() ?? path;
63
+ const dir = parts.length > 0 ? parts.join("/") + "/" : "";
64
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 rounded-[var(--radius-sm)] border border-[var(--border-subtle)] bg-[var(--depth-1)] px-2.5 py-1.5 font-[var(--font-mono)] text-xs min-w-0", children: [
65
+ /* @__PURE__ */ jsx(FileCode, { className: "h-3.5 w-3.5 shrink-0 text-[var(--brand-cool)]" }),
66
+ dir && /* @__PURE__ */ jsx("span", { className: "truncate text-[var(--text-muted)]", children: dir }),
67
+ /* @__PURE__ */ jsx("span", { className: "shrink-0 font-semibold text-[var(--text-primary)]", children: filename })
68
+ ] });
69
+ }
21
70
  var ICONS = {
22
71
  bash: Terminal,
23
72
  read: Eye,
@@ -42,12 +91,14 @@ function ToolCallStep({
42
91
  status,
43
92
  detail,
44
93
  output,
94
+ language,
45
95
  duration,
46
96
  className
47
97
  }) {
48
98
  const [expanded, setExpanded] = useState(false);
49
99
  const Icon = ICONS[type] || ICONS.unknown;
50
100
  const hasExpandable = !!(detail || output);
101
+ const lang = inferLanguage(detail, language);
51
102
  return /* @__PURE__ */ jsxs(
52
103
  "div",
53
104
  {
@@ -55,7 +106,7 @@ function ToolCallStep({
55
106
  "group overflow-hidden rounded-[var(--radius-lg)] border bg-[var(--bg-card)] transition-colors",
56
107
  status === "running" && "border-[var(--border-accent)]",
57
108
  status === "success" && "border-[var(--border-subtle)] hover:border-[var(--border-accent)]",
58
- status === "error" && "border-red-500/30",
109
+ status === "error" && "border-[var(--surface-danger-border)]",
59
110
  className
60
111
  ),
61
112
  children: [
@@ -74,9 +125,9 @@ function ToolCallStep({
74
125
  {
75
126
  className: cn(
76
127
  "flex h-8 w-8 shrink-0 items-center justify-center rounded-[var(--radius-md)] border",
77
- status === "running" && "border-[var(--border-accent)] bg-[var(--brand-cool)]/12 text-[var(--brand-cool)]",
78
- status === "success" && "border-emerald-500/30 bg-emerald-500/10 text-emerald-200",
79
- status === "error" && "border-red-500/30 bg-red-500/10 text-red-200"
128
+ status === "running" && "border-[var(--border-accent)] bg-[var(--accent-surface-soft)] text-[var(--brand-cool)]",
129
+ status === "success" && "border-[var(--surface-success-border)] bg-[var(--surface-success-bg)] text-[var(--surface-success-text)]",
130
+ status === "error" && "border-[var(--surface-danger-border)] bg-[var(--surface-danger-bg)] text-[var(--surface-danger-text)]"
80
131
  ),
81
132
  children: status === "running" ? /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin shrink-0" }) : /* @__PURE__ */ jsx(Icon, { className: cn("h-4 w-4 shrink-0", STATUS_COLORS[status]) })
82
133
  }
@@ -87,9 +138,9 @@ function ToolCallStep({
87
138
  {
88
139
  className: cn(
89
140
  "rounded-full border px-2 py-0.5 text-[11px] font-semibold uppercase tracking-[0.06em]",
90
- status === "running" && "border-[var(--border-accent)] bg-[var(--brand-cool)]/10 text-[var(--brand-cool)]",
91
- status === "success" && "border-emerald-500/30 bg-emerald-500/10 text-emerald-200",
92
- status === "error" && "border-red-500/30 bg-red-500/10 text-red-200"
141
+ status === "running" && "border-[var(--border-accent)] bg-[var(--accent-surface-soft)] text-[var(--brand-cool)]",
142
+ status === "success" && "border-[var(--surface-success-border)] bg-[var(--surface-success-bg)] text-[var(--surface-success-text)]",
143
+ status === "error" && "border-[var(--surface-danger-border)] bg-[var(--surface-danger-bg)] text-[var(--surface-danger-text)]"
93
144
  ),
94
145
  children: status
95
146
  }
@@ -107,9 +158,16 @@ function ToolCallStep({
107
158
  ]
108
159
  }
109
160
  ),
110
- expanded && (detail || output) && /* @__PURE__ */ jsxs("div", { className: "space-y-2 border-t border-[var(--border-subtle)] bg-[var(--bg-section)]/50 px-4 py-4", children: [
111
- detail && /* @__PURE__ */ jsx("div", { className: "text-xs font-[var(--font-mono)] text-[var(--text-muted)]", children: detail }),
112
- output && /* @__PURE__ */ jsx("pre", { className: "max-h-48 overflow-x-auto rounded-[var(--radius-md)] border border-[var(--border-subtle)] bg-[var(--bg-input)] p-3 text-xs font-[var(--font-mono)] text-[var(--text-secondary)]", children: output })
161
+ expanded && (detail || output) && /* @__PURE__ */ jsxs("div", { className: "space-y-2 border-t border-[var(--border-subtle)] bg-[var(--bg-section)] px-4 py-4", children: [
162
+ detail && (isFilePath(detail) ? /* @__PURE__ */ jsx(FilePathChip, { path: detail }) : /* @__PURE__ */ jsx("div", { className: "text-xs font-[var(--font-mono)] text-[var(--text-muted)]", children: detail })),
163
+ output && /* @__PURE__ */ jsx(
164
+ CodeBlock,
165
+ {
166
+ code: output,
167
+ language: lang,
168
+ className: "max-h-72 overflow-auto text-xs"
169
+ }
170
+ )
113
171
  ] })
114
172
  ]
115
173
  }