@tangle-network/sandbox-ui 0.2.2 → 0.3.3

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 (67) hide show
  1. package/README.md +201 -10
  2. package/dist/auth.js +2 -2
  3. package/dist/chat-container-C8eHLw8z.d.ts +67 -0
  4. package/dist/chat.d.ts +70 -78
  5. package/dist/chat.js +8 -8
  6. package/dist/chunk-4F2GJRGU.js +756 -0
  7. package/dist/{chunk-HYEAX3DC.js → chunk-5LV6DZZF.js} +445 -114
  8. package/dist/chunk-67C53XVV.js +1106 -0
  9. package/dist/{chunk-QSQBDR3N.js → chunk-BX6AQMUS.js} +5 -2
  10. package/dist/chunk-CCKNIAS7.js +124 -0
  11. package/dist/chunk-CJ2RYVZH.js +128 -0
  12. package/dist/{chunk-KMXV7DDX.js → chunk-CNWVHQFY.js} +1 -1
  13. package/dist/{chunk-OU4TRNQZ.js → chunk-COCSO7FG.js} +3 -3
  14. package/dist/chunk-FJSVPBKY.js +85 -0
  15. package/dist/chunk-FRGMMANX.js +102 -0
  16. package/dist/{chunk-E6FS7R4X.js → chunk-HWLX5NME.js} +1 -1
  17. package/dist/chunk-JF6E2DS5.js +610 -0
  18. package/dist/chunk-MUOL44AE.js +121 -0
  19. package/dist/chunk-MXCSSOGH.js +105 -0
  20. package/dist/{chunk-J4OADEUK.js → chunk-OM6ON27W.js} +24 -9
  21. package/dist/{chunk-NI2EI43H.js → chunk-PDV7W4NY.js} +9 -124
  22. package/dist/chunk-TQN3VR4F.js +92 -0
  23. package/dist/{chunk-SOT2V7TX.js → chunk-TXI4MZAZ.js} +62 -144
  24. package/dist/chunk-WUR652Y3.js +1140 -0
  25. package/dist/chunk-YDBXQQLC.js +336 -0
  26. package/dist/{chunk-4EIWPJMJ.js → chunk-ZP6GSX4D.js} +36 -27
  27. package/dist/dashboard.d.ts +5 -2
  28. package/dist/dashboard.js +5 -4
  29. package/dist/{expanded-tool-detail-OkXGqTHe.d.ts → expanded-tool-detail-BDi_h_dZ.d.ts} +11 -4
  30. package/dist/file-tabs-CmaoDVBI.d.ts +72 -0
  31. package/dist/files.d.ts +25 -44
  32. package/dist/files.js +8 -3
  33. package/{src/styles → dist}/globals.css +16 -67
  34. package/dist/hooks.d.ts +5 -4
  35. package/dist/hooks.js +14 -9
  36. package/dist/index.d.ts +38 -9
  37. package/dist/index.js +100 -126
  38. package/dist/markdown.d.ts +1 -24
  39. package/dist/markdown.js +1 -7
  40. package/dist/openui.d.ts +115 -0
  41. package/dist/openui.js +11 -0
  42. package/dist/pages.d.ts +3 -2
  43. package/dist/pages.js +19 -16
  44. package/dist/primitives.js +25 -19
  45. package/dist/run.d.ts +2 -2
  46. package/dist/run.js +8 -7
  47. package/dist/{use-sidecar-auth-Bb0-w3lX.d.ts → sdk-hooks.d.ts} +61 -72
  48. package/dist/sdk-hooks.js +29 -0
  49. package/dist/styles.css +179 -0
  50. package/dist/tokens.css +165 -0
  51. package/dist/{tool-display-BvsVW_Ur.d.ts → tool-display-Ct9nFAzJ.d.ts} +1 -1
  52. package/dist/types.d.ts +1 -1
  53. package/dist/{usage-chart-DINgSVL5.d.ts → usage-chart-CY9xo3KX.d.ts} +8 -3
  54. package/dist/use-pty-session-DeZSxOCN.d.ts +69 -0
  55. package/dist/utils.d.ts +1 -1
  56. package/dist/utils.js +1 -1
  57. package/dist/workspace.d.ts +171 -33
  58. package/dist/workspace.js +25 -1
  59. package/package.json +10 -3
  60. package/dist/chunk-2UHPE5T7.js +0 -201
  61. package/dist/chunk-6MQIDUPA.js +0 -502
  62. package/dist/chunk-KYY2X6LY.js +0 -318
  63. package/dist/chunk-L6ZDH5F4.js +0 -334
  64. package/dist/chunk-M34OA6PQ.js +0 -233
  65. package/dist/chunk-M6VLC32S.js +0 -219
  66. package/dist/chunk-U62G5TS7.js +0 -472
  67. package/src/styles/tokens.css +0 -73
@@ -1,233 +0,0 @@
1
- import {
2
- cn
3
- } from "./chunk-RQHJBTEU.js";
4
-
5
- // src/markdown/simple-markdown.tsx
6
- import { jsx } from "react/jsx-runtime";
7
- function SimpleMarkdown({ content, className }) {
8
- const html = renderMarkdown(content);
9
- return /* @__PURE__ */ jsx(
10
- "div",
11
- {
12
- className: cn("tangle-prose", className),
13
- dangerouslySetInnerHTML: { __html: html }
14
- }
15
- );
16
- }
17
- function escapeHtml(text) {
18
- return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
19
- }
20
- function renderInline(text) {
21
- let result = escapeHtml(text);
22
- result = result.replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>");
23
- result = result.replace(/__(.+?)__/g, "<strong>$1</strong>");
24
- result = result.replace(/\*(.+?)\*/g, "<em>$1</em>");
25
- result = result.replace(/_(.+?)_/g, "<em>$1</em>");
26
- result = result.replace(/`([^`]+)`/g, '<code class="tangle-inline-code">$1</code>');
27
- result = result.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2" target="_blank" rel="noopener" class="tangle-link">$1</a>');
28
- return result;
29
- }
30
- function renderMarkdown(md) {
31
- const lines = md.split("\n");
32
- const output = [];
33
- let i = 0;
34
- let inList = false;
35
- let listType = "ul";
36
- const closeList = () => {
37
- if (inList) {
38
- output.push(`</${listType}>`);
39
- inList = false;
40
- }
41
- };
42
- while (i < lines.length) {
43
- const line = lines[i];
44
- if (line.startsWith("```")) {
45
- closeList();
46
- const lang = line.slice(3).trim();
47
- const codeLines = [];
48
- i++;
49
- while (i < lines.length && !lines[i].startsWith("```")) {
50
- codeLines.push(lines[i]);
51
- i++;
52
- }
53
- i++;
54
- const code = escapeHtml(codeLines.join("\n"));
55
- output.push(`<div class="tangle-code-block">`);
56
- if (lang) output.push(`<div class="tangle-code-lang">${escapeHtml(lang)}</div>`);
57
- output.push(`<pre><code>${code}</code></pre></div>`);
58
- continue;
59
- }
60
- if (line.includes("|") && i + 1 < lines.length && /^\s*\|?[\s-:|]+\|/.test(lines[i + 1])) {
61
- closeList();
62
- const headers = line.split("|").map((h) => h.trim()).filter(Boolean);
63
- i += 2;
64
- output.push('<div class="tangle-table-wrap"><table class="tangle-table">');
65
- output.push("<thead><tr>");
66
- for (const h of headers) output.push(`<th>${renderInline(h)}</th>`);
67
- output.push("</tr></thead><tbody>");
68
- while (i < lines.length && lines[i].includes("|")) {
69
- const cells = lines[i].split("|").map((c) => c.trim()).filter(Boolean);
70
- output.push("<tr>");
71
- for (const c of cells) output.push(`<td>${renderInline(c)}</td>`);
72
- output.push("</tr>");
73
- i++;
74
- }
75
- output.push("</tbody></table></div>");
76
- continue;
77
- }
78
- const headingMatch = line.match(/^(#{1,6})\s+(.+)/);
79
- if (headingMatch) {
80
- closeList();
81
- const level = headingMatch[1].length;
82
- output.push(`<h${level} class="tangle-h${level}">${renderInline(headingMatch[2])}</h${level}>`);
83
- i++;
84
- continue;
85
- }
86
- if (line.startsWith("> ")) {
87
- closeList();
88
- const quoteLines = [];
89
- while (i < lines.length && lines[i].startsWith("> ")) {
90
- quoteLines.push(lines[i].slice(2));
91
- i++;
92
- }
93
- output.push(`<blockquote class="tangle-blockquote">${quoteLines.map(renderInline).join("<br>")}</blockquote>`);
94
- continue;
95
- }
96
- if (/^[\s]*[-*+]\s/.test(line)) {
97
- if (!inList || listType !== "ul") {
98
- closeList();
99
- output.push('<ul class="tangle-list">');
100
- inList = true;
101
- listType = "ul";
102
- }
103
- output.push(`<li>${renderInline(line.replace(/^[\s]*[-*+]\s/, ""))}</li>`);
104
- i++;
105
- continue;
106
- }
107
- if (/^[\s]*\d+\.\s/.test(line)) {
108
- if (!inList || listType !== "ol") {
109
- closeList();
110
- output.push('<ol class="tangle-list tangle-list-ordered">');
111
- inList = true;
112
- listType = "ol";
113
- }
114
- output.push(`<li>${renderInline(line.replace(/^[\s]*\d+\.\s/, ""))}</li>`);
115
- i++;
116
- continue;
117
- }
118
- if (/^[-*_]{3,}\s*$/.test(line)) {
119
- closeList();
120
- output.push('<hr class="tangle-hr">');
121
- i++;
122
- continue;
123
- }
124
- if (!line.trim()) {
125
- closeList();
126
- i++;
127
- continue;
128
- }
129
- closeList();
130
- output.push(`<p>${renderInline(line)}</p>`);
131
- i++;
132
- }
133
- closeList();
134
- return output.join("\n");
135
- }
136
- var simpleMarkdownStyles = `
137
- .tangle-prose {
138
- font-family: var(--font-sans);
139
- color: var(--text-primary);
140
- font-size: 0.9375rem;
141
- line-height: 1.6;
142
- }
143
- .tangle-prose p { margin: 0.5em 0; }
144
- .tangle-prose p:last-child { margin-bottom: 0; }
145
- .tangle-h1 { font-size: 1.5rem; font-weight: 700; margin: 1em 0 0.5em; }
146
- .tangle-h2 { font-size: 1.25rem; font-weight: 700; margin: 1em 0 0.5em; }
147
- .tangle-h3 { font-size: 1.1rem; font-weight: 600; margin: 0.75em 0 0.4em; }
148
- .tangle-h4, .tangle-h5, .tangle-h6 { font-size: 1rem; font-weight: 600; margin: 0.5em 0 0.3em; }
149
- .tangle-inline-code {
150
- font-family: var(--font-mono);
151
- font-size: 0.85em;
152
- background: var(--bg-input);
153
- border: 1px solid var(--border-subtle);
154
- border-radius: 4px;
155
- padding: 0.15em 0.4em;
156
- }
157
- .tangle-code-block {
158
- position: relative;
159
- margin: 0.75em 0;
160
- background: var(--bg-input);
161
- border: 1px solid var(--border-subtle);
162
- border-radius: var(--radius-md);
163
- overflow: hidden;
164
- }
165
- .tangle-code-lang {
166
- position: absolute;
167
- top: 8px;
168
- right: 12px;
169
- font-family: var(--font-mono);
170
- font-size: 11px;
171
- color: var(--text-muted);
172
- text-transform: uppercase;
173
- letter-spacing: 0.05em;
174
- }
175
- .tangle-code-block pre {
176
- margin: 0;
177
- padding: 1rem;
178
- overflow-x: auto;
179
- font-family: var(--font-mono);
180
- font-size: 13px;
181
- line-height: 1.55;
182
- color: var(--text-secondary);
183
- }
184
- .tangle-link {
185
- color: var(--brand-cool);
186
- text-decoration: none;
187
- }
188
- .tangle-link:hover { text-decoration: underline; }
189
- .tangle-blockquote {
190
- border-left: 3px solid var(--border-accent);
191
- padding: 0.5em 1em;
192
- margin: 0.5em 0;
193
- color: var(--text-secondary);
194
- }
195
- .tangle-list {
196
- margin: 0.5em 0;
197
- padding-left: 1.5em;
198
- }
199
- .tangle-list li { margin: 0.2em 0; }
200
- .tangle-list-ordered { list-style-type: decimal; }
201
- .tangle-table-wrap { overflow-x: auto; margin: 0.75em 0; }
202
- .tangle-table {
203
- width: 100%;
204
- border-collapse: collapse;
205
- font-size: 0.875rem;
206
- }
207
- .tangle-table th {
208
- text-align: left;
209
- padding: 0.5em 0.75em;
210
- border-bottom: 2px solid var(--border-default);
211
- font-weight: 600;
212
- color: var(--text-secondary);
213
- white-space: nowrap;
214
- }
215
- .tangle-table td {
216
- padding: 0.4em 0.75em;
217
- border-bottom: 1px solid var(--border-subtle);
218
- color: var(--text-secondary);
219
- }
220
- .tangle-table tr:hover td { background: var(--bg-hover); }
221
- .tangle-hr {
222
- border: none;
223
- border-top: 1px solid var(--border-subtle);
224
- margin: 1em 0;
225
- }
226
- strong { font-weight: 700; }
227
- em { font-style: italic; }
228
- `;
229
-
230
- export {
231
- SimpleMarkdown,
232
- simpleMarkdownStyles
233
- };
@@ -1,219 +0,0 @@
1
- import {
2
- SimpleMarkdown
3
- } from "./chunk-M34OA6PQ.js";
4
- import {
5
- cn
6
- } from "./chunk-RQHJBTEU.js";
7
-
8
- // src/run/tool-call-step.tsx
9
- import { useState } from "react";
10
- import {
11
- Terminal,
12
- FileText,
13
- FileCode,
14
- Search,
15
- CheckCircle,
16
- ChevronRight,
17
- Loader2,
18
- FolderOpen,
19
- Download,
20
- Pencil,
21
- Eye
22
- } from "lucide-react";
23
- import { jsx, jsxs } from "react/jsx-runtime";
24
- var ICONS = {
25
- bash: Terminal,
26
- read: Eye,
27
- write: FileText,
28
- edit: Pencil,
29
- glob: FolderOpen,
30
- grep: Search,
31
- list: FolderOpen,
32
- download: Download,
33
- inspect: Search,
34
- audit: CheckCircle,
35
- unknown: FileCode
36
- };
37
- var STATUS_COLORS = {
38
- running: "text-[var(--brand-cool)]",
39
- success: "text-[var(--code-success)]",
40
- error: "text-[var(--code-error)]"
41
- };
42
- function ToolCallStep({
43
- type,
44
- label,
45
- status,
46
- detail,
47
- output,
48
- duration,
49
- className
50
- }) {
51
- const [expanded, setExpanded] = useState(false);
52
- const Icon = ICONS[type] || ICONS.unknown;
53
- const hasExpandable = !!(detail || output);
54
- return /* @__PURE__ */ jsxs(
55
- "div",
56
- {
57
- className: cn(
58
- "group border-l-2 pl-3 py-1.5 transition-colors",
59
- status === "running" && "border-[var(--brand-cool)] bg-[var(--brand-cool)]/5",
60
- status === "success" && "border-[var(--border-subtle)] hover:border-[var(--border-accent)]",
61
- status === "error" && "border-[var(--code-error)]/40",
62
- className
63
- ),
64
- children: [
65
- /* @__PURE__ */ jsxs(
66
- "button",
67
- {
68
- onClick: () => hasExpandable && setExpanded(!expanded),
69
- disabled: !hasExpandable,
70
- className: cn(
71
- "flex items-center gap-2 w-full text-left text-sm",
72
- hasExpandable && "cursor-pointer"
73
- ),
74
- children: [
75
- status === "running" ? /* @__PURE__ */ jsx(Loader2, { className: "h-3.5 w-3.5 animate-spin text-[var(--brand-cool)] shrink-0" }) : /* @__PURE__ */ jsx(Icon, { className: cn("h-3.5 w-3.5 shrink-0", STATUS_COLORS[status]) }),
76
- /* @__PURE__ */ jsx("span", { className: "text-[var(--text-secondary)] truncate flex-1 font-[var(--font-sans)]", children: label }),
77
- duration !== void 0 && status !== "running" && /* @__PURE__ */ jsx("span", { className: "text-[var(--text-muted)] text-xs tabular-nums shrink-0", children: duration < 1e3 ? `${duration}ms` : `${(duration / 1e3).toFixed(1)}s` }),
78
- hasExpandable && /* @__PURE__ */ jsx(
79
- ChevronRight,
80
- {
81
- className: cn(
82
- "h-3 w-3 text-[var(--text-muted)] transition-transform shrink-0",
83
- expanded && "rotate-90"
84
- )
85
- }
86
- )
87
- ]
88
- }
89
- ),
90
- expanded && (detail || output) && /* @__PURE__ */ jsxs("div", { className: "mt-1.5 ml-5.5 space-y-1", children: [
91
- detail && /* @__PURE__ */ jsx("div", { className: "text-xs text-[var(--text-muted)] font-[var(--font-mono)]", children: detail }),
92
- output && /* @__PURE__ */ jsx("pre", { className: "text-xs text-[var(--text-secondary)] bg-[var(--bg-input)] border border-[var(--border-subtle)] rounded-[var(--radius-sm)] p-2 overflow-x-auto max-h-48 font-[var(--font-mono)]", children: output })
93
- ] })
94
- ]
95
- }
96
- );
97
- }
98
- function ToolCallGroup({ title, children, className }) {
99
- return /* @__PURE__ */ jsxs("div", { className: cn("space-y-0.5 my-2", className), children: [
100
- title && /* @__PURE__ */ jsx("div", { className: "text-xs font-medium text-[var(--text-muted)] uppercase tracking-wider mb-1 px-1", children: title }),
101
- children
102
- ] });
103
- }
104
-
105
- // src/run/tool-call-feed.tsx
106
- import { jsx as jsx2 } from "react/jsx-runtime";
107
- function ToolCallFeed({ segments, className }) {
108
- if (segments.length === 0) return null;
109
- return /* @__PURE__ */ jsx2("div", { className: cn("space-y-1", className), children: segments.map((segment, i) => {
110
- if (segment.kind === "text") {
111
- return segment.content.trim() ? /* @__PURE__ */ jsx2(SimpleMarkdown, { content: segment.content }, i) : null;
112
- }
113
- if (segment.kind === "tool_call") {
114
- return /* @__PURE__ */ jsx2(
115
- ToolCallStep,
116
- {
117
- type: segment.call.type,
118
- label: segment.call.label,
119
- status: segment.call.status,
120
- detail: segment.call.detail,
121
- output: segment.call.output,
122
- duration: segment.call.duration
123
- },
124
- segment.call.id || i
125
- );
126
- }
127
- if (segment.kind === "tool_group") {
128
- return /* @__PURE__ */ jsx2(ToolCallGroup, { title: segment.title, children: segment.calls.map((call) => /* @__PURE__ */ jsx2(
129
- ToolCallStep,
130
- {
131
- type: call.type,
132
- label: call.label,
133
- status: call.status,
134
- detail: call.detail,
135
- output: call.output,
136
- duration: call.duration
137
- },
138
- call.id
139
- )) }, i);
140
- }
141
- return null;
142
- }) });
143
- }
144
- function parseToolEvent(event) {
145
- const { type, data } = event;
146
- if (type === "tool.invocation" || type === "tool_use") {
147
- const toolName = data.name || data.tool || "unknown";
148
- const input = data.input;
149
- return {
150
- id: data.id || data.toolUseId || crypto.randomUUID(),
151
- type: mapToolName(toolName),
152
- label: formatToolLabel(toolName, input),
153
- status: "running",
154
- detail: input ? formatToolInput(toolName, input) : void 0
155
- };
156
- }
157
- if (type === "tool.result" || type === "tool_result") {
158
- return {
159
- id: data.id || data.toolUseId || "",
160
- type: mapToolName(data.name || data.tool || "unknown"),
161
- label: formatToolLabel(data.name || data.tool || "unknown"),
162
- status: data.error ? "error" : "success",
163
- output: truncate(data.output || data.result || "", 500),
164
- duration: data.duration
165
- };
166
- }
167
- return null;
168
- }
169
- function mapToolName(name) {
170
- const lower = name.toLowerCase();
171
- if (lower.includes("bash") || lower.includes("terminal") || lower.includes("exec")) return "bash";
172
- if (lower.includes("read") || lower.includes("cat")) return "read";
173
- if (lower.includes("write") || lower.includes("create")) return "write";
174
- if (lower.includes("edit") || lower.includes("replace")) return "edit";
175
- if (lower.includes("glob") || lower.includes("find")) return "glob";
176
- if (lower.includes("grep") || lower.includes("search")) return "grep";
177
- if (lower.includes("list") || lower.includes("ls")) return "list";
178
- if (lower.includes("inspect")) return "inspect";
179
- if (lower.includes("audit")) return "audit";
180
- return "unknown";
181
- }
182
- function formatToolLabel(toolName, input) {
183
- const lower = toolName.toLowerCase();
184
- if (lower.includes("bash") && input?.command) {
185
- const cmd = String(input.command);
186
- return cmd.length > 80 ? `${cmd.slice(0, 77)}...` : cmd;
187
- }
188
- if ((lower.includes("read") || lower.includes("cat")) && input?.path) {
189
- return `Read ${input.path}`;
190
- }
191
- if (lower.includes("write") && input?.path) {
192
- return `Write ${input.path}`;
193
- }
194
- if (lower.includes("edit") && input?.path) {
195
- return `Edit ${input.path}`;
196
- }
197
- if (lower.includes("glob") && input?.pattern) {
198
- return `Find ${input.pattern}`;
199
- }
200
- if (lower.includes("grep") && input?.pattern) {
201
- return `Search for ${input.pattern}`;
202
- }
203
- return toolName;
204
- }
205
- function formatToolInput(toolName, input) {
206
- if (input.command) return String(input.command);
207
- if (input.path) return String(input.path);
208
- return JSON.stringify(input, null, 2).slice(0, 300);
209
- }
210
- function truncate(text, max) {
211
- return text.length > max ? text.slice(0, max - 3) + "..." : text;
212
- }
213
-
214
- export {
215
- ToolCallStep,
216
- ToolCallGroup,
217
- ToolCallFeed,
218
- parseToolEvent
219
- };