@tangle-network/sandbox-ui 0.14.0 → 0.15.1
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.
- package/dist/auth.d.ts +1 -74
- package/dist/auth.js +1 -4
- package/dist/chat.d.ts +1 -136
- package/dist/chat.js +2 -15
- package/dist/chunk-2BUPSB7O.js +0 -0
- package/dist/chunk-3J6FG3FJ.js +18 -0
- package/dist/chunk-76IQLPW2.js +206 -0
- package/dist/chunk-7ZA5SEK3.js +239 -0
- package/dist/chunk-AHBZCBDO.js +2960 -0
- package/dist/chunk-AZ3AWMTM.js +8 -0
- package/dist/chunk-CMY7W45U.js +380 -0
- package/dist/{chunk-QMU2PWOU.js → chunk-DNZ4DTNA.js} +71 -17
- package/dist/chunk-EI44GEQ5.js +6 -0
- package/dist/{chunk-5OQ27N57.js → chunk-GPT7VKK6.js} +34 -38
- package/dist/chunk-JBGKGLD7.js +16 -0
- package/dist/chunk-NJNME4J4.js +14 -0
- package/dist/chunk-QPAJR74X.js +20 -0
- package/dist/chunk-TK46XFLM.js +28 -0
- package/dist/chunk-WID73FPH.js +89 -0
- package/dist/chunk-YVXK4XRO.js +30 -0
- package/dist/dashboard.d.ts +538 -4
- package/dist/dashboard.js +15 -886
- package/dist/editor.d.ts +1 -120
- package/dist/editor.js +1 -5
- package/dist/files.d.ts +1 -129
- package/dist/files.js +2 -7
- package/dist/globals.css +2 -1265
- package/dist/hooks.d.ts +114 -11
- package/dist/hooks.js +17 -88
- package/dist/index.d.ts +24 -99
- package/dist/index.js +247 -252
- package/dist/markdown.d.ts +1 -29
- package/dist/markdown.js +2 -2
- package/dist/openui.d.ts +8 -115
- package/dist/openui.js +1 -6
- package/dist/pages.d.ts +1 -2
- package/dist/pages.js +68 -66
- package/dist/primitives.d.ts +14 -49
- package/dist/primitives.js +69 -77
- package/dist/run.d.ts +1 -14
- package/dist/run.js +2 -22
- package/dist/sdk-hooks.d.ts +3 -283
- package/dist/sdk-hooks.js +10 -14
- package/dist/stores.d.ts +2 -14
- package/dist/stores.js +11 -39
- package/dist/styles.css +2 -1265
- package/dist/{usage-chart-CPTcNlGs.d.ts → template-card-UhV3pmRC.d.ts} +16 -1
- package/dist/types.d.ts +11 -8
- package/dist/types.js +1 -0
- package/dist/utils.d.ts +1 -44
- package/dist/utils.js +6 -12
- package/dist/workspace.d.ts +5 -10
- package/dist/workspace.js +3 -19
- package/package.json +19 -54
- package/dist/active-sessions-store-CeOmXgv5.d.ts +0 -85
- package/dist/artifact-pane-Bh45Ssco.d.ts +0 -24
- package/dist/branding-DCi5VEik.d.ts +0 -13
- package/dist/button-CMQuQEW_.d.ts +0 -17
- package/dist/chat-container-f4yEs6KN.d.ts +0 -106
- package/dist/chunk-34A66VBG.js +0 -214
- package/dist/chunk-34I7UFSX.js +0 -92
- package/dist/chunk-36QY2W5G.js +0 -802
- package/dist/chunk-4CLN43XT.js +0 -45
- package/dist/chunk-54SQQMMM.js +0 -156
- package/dist/chunk-66EZOYZR.js +0 -102
- package/dist/chunk-BX6AQMUS.js +0 -183
- package/dist/chunk-DI3NZ5ZX.js +0 -192
- package/dist/chunk-DPGIXDAI.js +0 -220
- package/dist/chunk-DXMIEK4K.js +0 -1426
- package/dist/chunk-GSZA3TSY.js +0 -79
- package/dist/chunk-HB5Y37YU.js +0 -54
- package/dist/chunk-LQNEZDRM.js +0 -109
- package/dist/chunk-MA7YKRUP.js +0 -131
- package/dist/chunk-MKTSMWVD.js +0 -109
- package/dist/chunk-MQXABZTB.js +0 -1348
- package/dist/chunk-MT5FJ3ZT.js +0 -186
- package/dist/chunk-NKUPJC34.js +0 -2070
- package/dist/chunk-OEX7NZE3.js +0 -321
- package/dist/chunk-OKLQVY3Y.js +0 -139
- package/dist/chunk-Q56BYXQF.js +0 -61
- package/dist/chunk-QD4QE5P5.js +0 -40
- package/dist/chunk-QDH5GEGY.js +0 -630
- package/dist/chunk-QID2OOMG.js +0 -133
- package/dist/chunk-RQHJBTEU.js +0 -10
- package/dist/chunk-T7HMZEVO.js +0 -216
- package/dist/chunk-U6QTHMY6.js +0 -1290
- package/dist/chunk-US6JKJKH.js +0 -124
- package/dist/chunk-VX3XOUEB.js +0 -63
- package/dist/chunk-XLG757B6.js +0 -933
- package/dist/chunk-ZMNSRDMH.js +0 -127
- package/dist/chunk-ZNCEM5CD.js +0 -316
- package/dist/document-editor-pane-A70-EhdQ.d.ts +0 -124
- package/dist/document-editor-pane-TLPVRBBU.js +0 -11
- package/dist/expanded-tool-detail-Dh99mcbY.d.ts +0 -63
- package/dist/file-tabs-BLfxfmAH.d.ts +0 -51
- package/dist/parts-CyGkM6Fp.d.ts +0 -50
- package/dist/run-CtFZ6s-D.d.ts +0 -41
- package/dist/sidebar-drop-zone-tDBsuOH5.d.ts +0 -301
- package/dist/sidecar-CFU2W9j1.d.ts +0 -8
- package/dist/template-card-BAtvcAkU.d.ts +0 -18
- package/dist/tool-call-feed-Bs3MyQMT.d.ts +0 -68
- package/dist/tool-display-Ct9nFAzJ.d.ts +0 -32
- package/dist/use-sandbox-metrics-DWc0k9Xm.d.ts +0 -153
- package/dist/variant-list-BrHYcBCk.d.ts +0 -540
package/dist/chunk-MQXABZTB.js
DELETED
|
@@ -1,1348 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
formatDuration,
|
|
3
|
-
truncateText
|
|
4
|
-
} from "./chunk-4CLN43XT.js";
|
|
5
|
-
import {
|
|
6
|
-
getToolCategory,
|
|
7
|
-
getToolDisplayMetadata,
|
|
8
|
-
getToolErrorText
|
|
9
|
-
} from "./chunk-BX6AQMUS.js";
|
|
10
|
-
import {
|
|
11
|
-
OpenUIArtifactRenderer
|
|
12
|
-
} from "./chunk-ZNCEM5CD.js";
|
|
13
|
-
import {
|
|
14
|
-
CodeBlock,
|
|
15
|
-
CopyButton,
|
|
16
|
-
Markdown
|
|
17
|
-
} from "./chunk-T7HMZEVO.js";
|
|
18
|
-
import {
|
|
19
|
-
cn
|
|
20
|
-
} from "./chunk-RQHJBTEU.js";
|
|
21
|
-
|
|
22
|
-
// src/tool-previews/command-preview.tsx
|
|
23
|
-
import { memo, useState } from "react";
|
|
24
|
-
import {
|
|
25
|
-
Terminal,
|
|
26
|
-
ChevronDown,
|
|
27
|
-
ChevronRight
|
|
28
|
-
} from "lucide-react";
|
|
29
|
-
|
|
30
|
-
// src/tool-previews/preview-primitives.tsx
|
|
31
|
-
import { Loader2 } from "lucide-react";
|
|
32
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
33
|
-
function PreviewCard({
|
|
34
|
-
icon,
|
|
35
|
-
title,
|
|
36
|
-
description,
|
|
37
|
-
meta,
|
|
38
|
-
children,
|
|
39
|
-
className
|
|
40
|
-
}) {
|
|
41
|
-
return /* @__PURE__ */ jsxs(
|
|
42
|
-
"div",
|
|
43
|
-
{
|
|
44
|
-
className: cn(
|
|
45
|
-
"overflow-hidden rounded-[var(--radius-lg)] border border-border bg-card shadow-[var(--shadow-card)]",
|
|
46
|
-
className
|
|
47
|
-
),
|
|
48
|
-
children: [
|
|
49
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2.5 border-b border-border bg-card px-[var(--tool-card-px)] py-[var(--tool-card-py)]", children: [
|
|
50
|
-
/* @__PURE__ */ jsx("div", { className: "flex h-[var(--tool-icon-size)] w-[var(--tool-icon-size)] shrink-0 items-center justify-center rounded-[var(--radius-sm)] border border-[var(--border-accent)] bg-muted text-primary", children: icon }),
|
|
51
|
-
/* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
52
|
-
/* @__PURE__ */ jsx("span", { className: "text-xs font-semibold text-foreground", children: title }),
|
|
53
|
-
description ? /* @__PURE__ */ jsx("span", { className: "truncate text-xs font-mono text-muted-foreground", children: description }) : null
|
|
54
|
-
] }) }),
|
|
55
|
-
meta ? /* @__PURE__ */ jsx("div", { className: "shrink-0 text-xs text-muted-foreground", children: meta }) : null
|
|
56
|
-
] }),
|
|
57
|
-
children ? /* @__PURE__ */ jsx("div", { className: "space-y-2 px-[var(--tool-card-px)] py-[var(--tool-card-py)]", children }) : null
|
|
58
|
-
]
|
|
59
|
-
}
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
function PreviewEmpty({
|
|
63
|
-
label,
|
|
64
|
-
className
|
|
65
|
-
}) {
|
|
66
|
-
return /* @__PURE__ */ jsx(
|
|
67
|
-
"div",
|
|
68
|
-
{
|
|
69
|
-
className: cn(
|
|
70
|
-
"rounded-[var(--radius-md)] border border-dashed border-border bg-muted px-3 py-2.5 text-xs text-muted-foreground",
|
|
71
|
-
className
|
|
72
|
-
),
|
|
73
|
-
children: label
|
|
74
|
-
}
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
function PreviewError({ error }) {
|
|
78
|
-
return /* @__PURE__ */ jsx("div", { className: "rounded-[var(--radius-md)] border border-[var(--surface-danger-border)] bg-[var(--surface-danger-bg)] px-3 py-3 text-sm text-[var(--surface-danger-text)]", children: error });
|
|
79
|
-
}
|
|
80
|
-
function PreviewLoading({ label = "Running\u2026" }) {
|
|
81
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 rounded-[var(--radius-md)] border border-border bg-muted px-3 py-2 text-xs text-muted-foreground", children: [
|
|
82
|
-
/* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin text-primary" }),
|
|
83
|
-
/* @__PURE__ */ jsx("span", { children: label })
|
|
84
|
-
] });
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// src/tool-previews/command-preview.tsx
|
|
88
|
-
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
89
|
-
function extractCommandOutput(output) {
|
|
90
|
-
if (!output) return { stdout: "", stderr: "", exitCode: 0 };
|
|
91
|
-
if (typeof output === "string") return { stdout: output, stderr: "", exitCode: 0 };
|
|
92
|
-
if (typeof output === "object" && output !== null) {
|
|
93
|
-
const obj = output;
|
|
94
|
-
return {
|
|
95
|
-
stdout: String(obj.stdout ?? obj.output ?? ""),
|
|
96
|
-
stderr: String(obj.stderr ?? ""),
|
|
97
|
-
exitCode: Number(obj.exitCode ?? obj.exit_code ?? obj.code ?? 0)
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
return { stdout: String(output), stderr: "", exitCode: 0 };
|
|
101
|
-
}
|
|
102
|
-
var CommandPreview = memo(({ part }) => {
|
|
103
|
-
const [expanded, setExpanded] = useState(true);
|
|
104
|
-
const input = part.state.input;
|
|
105
|
-
const command = typeof input?.command === "string" ? input.command : String(input ?? "");
|
|
106
|
-
const output = part.state.status === "completed" ? extractCommandOutput(part.state.output) : null;
|
|
107
|
-
const isError = output ? output.exitCode !== 0 : part.state.status === "error";
|
|
108
|
-
const errorText = part.state.error;
|
|
109
|
-
const lineCount = output?.stdout ? output.stdout.split("\n").length : 0;
|
|
110
|
-
return /* @__PURE__ */ jsxs2(
|
|
111
|
-
PreviewCard,
|
|
112
|
-
{
|
|
113
|
-
icon: /* @__PURE__ */ jsx2(Terminal, { className: "h-4 w-4" }),
|
|
114
|
-
title: "Command",
|
|
115
|
-
description: command,
|
|
116
|
-
meta: output ? /* @__PURE__ */ jsxs2(
|
|
117
|
-
"span",
|
|
118
|
-
{
|
|
119
|
-
className: cn(
|
|
120
|
-
"inline-flex items-center rounded-full border px-2 py-0.5 font-mono",
|
|
121
|
-
isError ? "border-[var(--surface-danger-border)] bg-[var(--surface-danger-bg)] text-[var(--surface-danger-text)]" : "border-[var(--surface-success-border)] bg-[var(--surface-success-bg)] text-[var(--surface-success-text)]"
|
|
122
|
-
),
|
|
123
|
-
children: [
|
|
124
|
-
"exit ",
|
|
125
|
-
output.exitCode
|
|
126
|
-
]
|
|
127
|
-
}
|
|
128
|
-
) : null,
|
|
129
|
-
children: [
|
|
130
|
-
/* @__PURE__ */ jsxs2(
|
|
131
|
-
"button",
|
|
132
|
-
{
|
|
133
|
-
onClick: () => setExpanded((value) => !value),
|
|
134
|
-
className: "flex w-full items-center gap-2 rounded-[var(--radius-md)] border border-border bg-muted px-3 py-2 text-left transition-colors hover:border-[var(--border-accent-hover)] hover:bg-accent/45",
|
|
135
|
-
children: [
|
|
136
|
-
/* @__PURE__ */ jsx2("code", { className: "min-w-0 flex-1 truncate text-xs font-mono text-foreground", children: command }),
|
|
137
|
-
lineCount > 0 ? /* @__PURE__ */ jsxs2("span", { className: "shrink-0 text-xs text-muted-foreground", children: [
|
|
138
|
-
lineCount,
|
|
139
|
-
" line",
|
|
140
|
-
lineCount === 1 ? "" : "s"
|
|
141
|
-
] }) : null,
|
|
142
|
-
expanded ? /* @__PURE__ */ jsx2(ChevronDown, { className: "h-3.5 w-3.5 text-muted-foreground" }) : /* @__PURE__ */ jsx2(ChevronRight, { className: "h-3.5 w-3.5 text-muted-foreground" })
|
|
143
|
-
]
|
|
144
|
-
}
|
|
145
|
-
),
|
|
146
|
-
part.state.status === "running" ? /* @__PURE__ */ jsx2(PreviewLoading, {}) : null,
|
|
147
|
-
errorText ? /* @__PURE__ */ jsx2(PreviewError, { error: errorText }) : null,
|
|
148
|
-
expanded && output ? /* @__PURE__ */ jsxs2("div", { className: "overflow-hidden rounded-[var(--radius-md)] border border-border bg-muted", children: [
|
|
149
|
-
output.stdout ? /* @__PURE__ */ jsx2("pre", { className: "max-h-80 overflow-auto px-3 py-3 text-xs font-mono whitespace-pre-wrap break-all text-foreground", children: output.stdout }) : null,
|
|
150
|
-
output.stderr ? /* @__PURE__ */ jsx2("pre", { className: "max-h-80 overflow-auto border-t border-border px-3 py-3 text-xs font-mono whitespace-pre-wrap break-all text-red-200", children: output.stderr }) : null
|
|
151
|
-
] }) : null
|
|
152
|
-
]
|
|
153
|
-
}
|
|
154
|
-
);
|
|
155
|
-
});
|
|
156
|
-
CommandPreview.displayName = "CommandPreview";
|
|
157
|
-
|
|
158
|
-
// src/tool-previews/write-file-preview.tsx
|
|
159
|
-
import { memo as memo2 } from "react";
|
|
160
|
-
import { FileEdit } from "lucide-react";
|
|
161
|
-
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
162
|
-
function extractWriteContent(input) {
|
|
163
|
-
if (!input || typeof input !== "object") return null;
|
|
164
|
-
const obj = input;
|
|
165
|
-
const path = String(obj.file_path ?? obj.path ?? obj.filePath ?? "unknown");
|
|
166
|
-
const content = String(obj.content ?? obj.contents ?? obj.data ?? "");
|
|
167
|
-
return { path, content };
|
|
168
|
-
}
|
|
169
|
-
function getLanguageFromPath(path) {
|
|
170
|
-
const ext = path.split(".").pop()?.toLowerCase();
|
|
171
|
-
const map = {
|
|
172
|
-
ts: "typescript",
|
|
173
|
-
tsx: "tsx",
|
|
174
|
-
js: "javascript",
|
|
175
|
-
jsx: "jsx",
|
|
176
|
-
rs: "rust",
|
|
177
|
-
py: "python",
|
|
178
|
-
go: "go",
|
|
179
|
-
rb: "ruby",
|
|
180
|
-
json: "json",
|
|
181
|
-
yaml: "yaml",
|
|
182
|
-
yml: "yaml",
|
|
183
|
-
toml: "toml",
|
|
184
|
-
md: "markdown",
|
|
185
|
-
css: "css",
|
|
186
|
-
scss: "scss",
|
|
187
|
-
html: "html",
|
|
188
|
-
sh: "bash",
|
|
189
|
-
bash: "bash",
|
|
190
|
-
zsh: "bash",
|
|
191
|
-
sql: "sql",
|
|
192
|
-
sol: "solidity",
|
|
193
|
-
proto: "protobuf"
|
|
194
|
-
};
|
|
195
|
-
return ext ? map[ext] : void 0;
|
|
196
|
-
}
|
|
197
|
-
var WriteFilePreview = memo2(({ part }) => {
|
|
198
|
-
const write = extractWriteContent(part.state.input);
|
|
199
|
-
if (!write) return null;
|
|
200
|
-
const lineCount = write.content.split("\n").length;
|
|
201
|
-
const language = getLanguageFromPath(write.path);
|
|
202
|
-
return /* @__PURE__ */ jsxs3(
|
|
203
|
-
PreviewCard,
|
|
204
|
-
{
|
|
205
|
-
icon: /* @__PURE__ */ jsx3(FileEdit, { className: "h-4 w-4" }),
|
|
206
|
-
title: "Write file",
|
|
207
|
-
description: write.path,
|
|
208
|
-
meta: /* @__PURE__ */ jsxs3("span", { className: "text-xs text-muted-foreground", children: [
|
|
209
|
-
"+",
|
|
210
|
-
lineCount,
|
|
211
|
-
" line",
|
|
212
|
-
lineCount !== 1 ? "s" : ""
|
|
213
|
-
] }),
|
|
214
|
-
children: [
|
|
215
|
-
part.state.status === "running" ? /* @__PURE__ */ jsx3(PreviewLoading, { label: "Writing file\u2026" }) : null,
|
|
216
|
-
part.state.error ? /* @__PURE__ */ jsx3(PreviewError, { error: part.state.error }) : null,
|
|
217
|
-
/* @__PURE__ */ jsx3(CodeBlock, { code: write.content, language, className: "rounded-[var(--radius-md)]", children: /* @__PURE__ */ jsx3(CopyButton, { text: write.content }) })
|
|
218
|
-
]
|
|
219
|
-
}
|
|
220
|
-
);
|
|
221
|
-
});
|
|
222
|
-
WriteFilePreview.displayName = "WriteFilePreview";
|
|
223
|
-
|
|
224
|
-
// src/tool-previews/grep-results-preview.tsx
|
|
225
|
-
import { memo as memo3, useMemo } from "react";
|
|
226
|
-
import { Search } from "lucide-react";
|
|
227
|
-
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
228
|
-
function coerceString(value) {
|
|
229
|
-
return typeof value === "string" && value.trim() ? value : void 0;
|
|
230
|
-
}
|
|
231
|
-
function parseMatch(value) {
|
|
232
|
-
if (typeof value === "string") {
|
|
233
|
-
const [path2, maybeLine, ...rest] = value.split(":");
|
|
234
|
-
const line2 = Number(maybeLine);
|
|
235
|
-
if (rest.length > 0 && Number.isFinite(line2)) {
|
|
236
|
-
return {
|
|
237
|
-
path: path2,
|
|
238
|
-
line: line2,
|
|
239
|
-
text: rest.join(":").trim()
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
return {
|
|
243
|
-
path: "match",
|
|
244
|
-
text: value
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
if (!value || typeof value !== "object") {
|
|
248
|
-
return null;
|
|
249
|
-
}
|
|
250
|
-
const record = value;
|
|
251
|
-
const path = coerceString(record.path) ?? coerceString(record.file) ?? coerceString(record.filePath) ?? "match";
|
|
252
|
-
const lineValue = record.line ?? record.lineNumber ?? record.line_number;
|
|
253
|
-
const line = typeof lineValue === "number" ? lineValue : Number(lineValue);
|
|
254
|
-
const text = coerceString(record.text) ?? coerceString(record.content) ?? coerceString(record.lineText) ?? coerceString(record.preview);
|
|
255
|
-
if (!text) {
|
|
256
|
-
return null;
|
|
257
|
-
}
|
|
258
|
-
return {
|
|
259
|
-
path,
|
|
260
|
-
line: Number.isFinite(line) ? line : void 0,
|
|
261
|
-
text
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
function extractPattern(input) {
|
|
265
|
-
if (!input || typeof input !== "object") {
|
|
266
|
-
return void 0;
|
|
267
|
-
}
|
|
268
|
-
const record = input;
|
|
269
|
-
return coerceString(record.pattern) ?? coerceString(record.query);
|
|
270
|
-
}
|
|
271
|
-
function extractMatches(output) {
|
|
272
|
-
if (Array.isArray(output)) {
|
|
273
|
-
return output.map(parseMatch).filter((value) => value !== null);
|
|
274
|
-
}
|
|
275
|
-
if (output && typeof output === "object") {
|
|
276
|
-
const record = output;
|
|
277
|
-
const candidates = [record.matches, record.results, record.output];
|
|
278
|
-
for (const candidate of candidates) {
|
|
279
|
-
if (Array.isArray(candidate)) {
|
|
280
|
-
return candidate.map(parseMatch).filter((value) => value !== null);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
if (typeof output === "string") {
|
|
285
|
-
return output.split("\n").map((line) => line.trim()).filter(Boolean).map(parseMatch).filter((value) => value !== null);
|
|
286
|
-
}
|
|
287
|
-
return [];
|
|
288
|
-
}
|
|
289
|
-
var GrepResultsPreview = memo3(({ part }) => {
|
|
290
|
-
const pattern = extractPattern(part.state.input);
|
|
291
|
-
const matches = useMemo(() => extractMatches(part.state.output), [part.state.output]);
|
|
292
|
-
const groupedMatches = useMemo(() => {
|
|
293
|
-
const groups = /* @__PURE__ */ new Map();
|
|
294
|
-
for (const match of matches) {
|
|
295
|
-
const list = groups.get(match.path) ?? [];
|
|
296
|
-
list.push(match);
|
|
297
|
-
groups.set(match.path, list);
|
|
298
|
-
}
|
|
299
|
-
return [...groups.entries()];
|
|
300
|
-
}, [matches]);
|
|
301
|
-
return /* @__PURE__ */ jsxs4(
|
|
302
|
-
PreviewCard,
|
|
303
|
-
{
|
|
304
|
-
icon: /* @__PURE__ */ jsx4(Search, { className: "h-4 w-4" }),
|
|
305
|
-
title: pattern ? `Search results for "${pattern}"` : "Search results",
|
|
306
|
-
description: matches.length > 0 ? `${matches.length} match${matches.length === 1 ? "" : "es"}` : void 0,
|
|
307
|
-
children: [
|
|
308
|
-
part.state.status === "running" ? /* @__PURE__ */ jsx4(PreviewLoading, { label: "Searching files\u2026" }) : null,
|
|
309
|
-
part.state.error ? /* @__PURE__ */ jsx4(PreviewError, { error: part.state.error }) : null,
|
|
310
|
-
part.state.status === "completed" && matches.length === 0 ? /* @__PURE__ */ jsx4(PreviewEmpty, { label: "No matching files or lines were returned." }) : null,
|
|
311
|
-
groupedMatches.map(([path, pathMatches]) => /* @__PURE__ */ jsxs4(
|
|
312
|
-
"div",
|
|
313
|
-
{
|
|
314
|
-
className: "rounded-[var(--radius-md)] border border-border bg-muted/55",
|
|
315
|
-
children: [
|
|
316
|
-
/* @__PURE__ */ jsx4("div", { className: "border-b border-border px-3 py-2 text-xs font-medium text-foreground", children: path }),
|
|
317
|
-
/* @__PURE__ */ jsx4("div", { className: "divide-y divide-border", children: pathMatches.map((match, index) => /* @__PURE__ */ jsxs4("div", { className: "grid grid-cols-[auto_minmax(0,1fr)] gap-3 px-3 py-2", children: [
|
|
318
|
-
/* @__PURE__ */ jsx4("div", { className: "pt-0.5 text-xs font-mono text-muted-foreground", children: match.line ?? "\xB7" }),
|
|
319
|
-
/* @__PURE__ */ jsx4("pre", { className: "overflow-x-auto whitespace-pre-wrap break-words text-xs font-mono text-foreground", children: match.text })
|
|
320
|
-
] }, `${path}-${match.line ?? index}-${index}`)) })
|
|
321
|
-
]
|
|
322
|
-
},
|
|
323
|
-
path
|
|
324
|
-
))
|
|
325
|
-
]
|
|
326
|
-
}
|
|
327
|
-
);
|
|
328
|
-
});
|
|
329
|
-
GrepResultsPreview.displayName = "GrepResultsPreview";
|
|
330
|
-
|
|
331
|
-
// src/tool-previews/glob-results-preview.tsx
|
|
332
|
-
import { memo as memo4, useMemo as useMemo2 } from "react";
|
|
333
|
-
import { FileText, FolderOpen } from "lucide-react";
|
|
334
|
-
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
335
|
-
function coerceString2(value) {
|
|
336
|
-
return typeof value === "string" && value.trim() ? value : void 0;
|
|
337
|
-
}
|
|
338
|
-
function extractPattern2(input) {
|
|
339
|
-
if (!input || typeof input !== "object") {
|
|
340
|
-
return void 0;
|
|
341
|
-
}
|
|
342
|
-
const record = input;
|
|
343
|
-
return coerceString2(record.pattern) ?? coerceString2(record.path);
|
|
344
|
-
}
|
|
345
|
-
function extractFiles(output) {
|
|
346
|
-
if (Array.isArray(output)) {
|
|
347
|
-
return output.map((item) => String(item)).filter(Boolean);
|
|
348
|
-
}
|
|
349
|
-
if (output && typeof output === "object") {
|
|
350
|
-
const record = output;
|
|
351
|
-
const candidate = record.files ?? record.matches ?? record.paths ?? record.results;
|
|
352
|
-
if (Array.isArray(candidate)) {
|
|
353
|
-
return candidate.map(
|
|
354
|
-
(item) => typeof item === "string" ? item : item && typeof item === "object" ? String(
|
|
355
|
-
item.path ?? item.file ?? ""
|
|
356
|
-
) : ""
|
|
357
|
-
).filter(Boolean);
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
if (typeof output === "string") {
|
|
361
|
-
return output.split("\n").map((line) => line.trim()).filter(Boolean);
|
|
362
|
-
}
|
|
363
|
-
return [];
|
|
364
|
-
}
|
|
365
|
-
var GlobResultsPreview = memo4(({ part }) => {
|
|
366
|
-
const pattern = extractPattern2(part.state.input);
|
|
367
|
-
const files = useMemo2(() => extractFiles(part.state.output), [part.state.output]);
|
|
368
|
-
return /* @__PURE__ */ jsxs5(
|
|
369
|
-
PreviewCard,
|
|
370
|
-
{
|
|
371
|
-
icon: /* @__PURE__ */ jsx5(FolderOpen, { className: "h-4 w-4" }),
|
|
372
|
-
title: pattern ? `Files for ${pattern}` : "File results",
|
|
373
|
-
description: files.length > 0 ? `${files.length} path${files.length === 1 ? "" : "s"}` : void 0,
|
|
374
|
-
children: [
|
|
375
|
-
part.state.status === "running" ? /* @__PURE__ */ jsx5(PreviewLoading, { label: "Collecting files\u2026" }) : null,
|
|
376
|
-
part.state.error ? /* @__PURE__ */ jsx5(PreviewError, { error: part.state.error }) : null,
|
|
377
|
-
part.state.status === "completed" && files.length === 0 ? /* @__PURE__ */ jsx5(PreviewEmpty, { label: "No matching files were returned." }) : null,
|
|
378
|
-
files.length > 0 ? /* @__PURE__ */ jsx5("div", { className: "grid gap-2 sm:grid-cols-2", children: files.map((file) => {
|
|
379
|
-
const isDirectory = file.endsWith("/");
|
|
380
|
-
const Icon = isDirectory ? FolderOpen : FileText;
|
|
381
|
-
return /* @__PURE__ */ jsxs5(
|
|
382
|
-
"div",
|
|
383
|
-
{
|
|
384
|
-
className: "flex items-center gap-2 rounded-[var(--radius-md)] border border-border bg-muted/55 px-3 py-2",
|
|
385
|
-
children: [
|
|
386
|
-
/* @__PURE__ */ jsx5(Icon, { className: "h-4 w-4 shrink-0 text-primary" }),
|
|
387
|
-
/* @__PURE__ */ jsx5("span", { className: "min-w-0 truncate text-xs font-mono text-foreground", children: file })
|
|
388
|
-
]
|
|
389
|
-
},
|
|
390
|
-
file
|
|
391
|
-
);
|
|
392
|
-
}) }) : null
|
|
393
|
-
]
|
|
394
|
-
}
|
|
395
|
-
);
|
|
396
|
-
});
|
|
397
|
-
GlobResultsPreview.displayName = "GlobResultsPreview";
|
|
398
|
-
|
|
399
|
-
// src/tool-previews/web-search-preview.tsx
|
|
400
|
-
import { memo as memo5, useMemo as useMemo3 } from "react";
|
|
401
|
-
import { Globe } from "lucide-react";
|
|
402
|
-
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
403
|
-
function coerceString3(value) {
|
|
404
|
-
return typeof value === "string" && value.trim() ? value : void 0;
|
|
405
|
-
}
|
|
406
|
-
function extractQuery(input, output) {
|
|
407
|
-
if (input && typeof input === "object") {
|
|
408
|
-
const record = input;
|
|
409
|
-
const query = coerceString3(record.query) ?? coerceString3(record.url);
|
|
410
|
-
if (query) return query;
|
|
411
|
-
}
|
|
412
|
-
if (output && typeof output === "object") {
|
|
413
|
-
const record = output;
|
|
414
|
-
return coerceString3(record.query);
|
|
415
|
-
}
|
|
416
|
-
return void 0;
|
|
417
|
-
}
|
|
418
|
-
function parseResult(value) {
|
|
419
|
-
if (!value || typeof value !== "object") {
|
|
420
|
-
return null;
|
|
421
|
-
}
|
|
422
|
-
const record = value;
|
|
423
|
-
const title = coerceString3(record.title) ?? coerceString3(record.name) ?? "Untitled result";
|
|
424
|
-
const url = coerceString3(record.url) ?? coerceString3(record.link);
|
|
425
|
-
if (!url) {
|
|
426
|
-
return null;
|
|
427
|
-
}
|
|
428
|
-
return {
|
|
429
|
-
title,
|
|
430
|
-
url,
|
|
431
|
-
snippet: coerceString3(record.snippet) ?? coerceString3(record.description) ?? coerceString3(record.text)
|
|
432
|
-
};
|
|
433
|
-
}
|
|
434
|
-
function extractResults(output) {
|
|
435
|
-
if (output && typeof output === "object") {
|
|
436
|
-
const record = output;
|
|
437
|
-
const candidate = record.results ?? record.items ?? record.output;
|
|
438
|
-
if (Array.isArray(candidate)) {
|
|
439
|
-
return candidate.map(parseResult).filter((value) => value !== null);
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
if (Array.isArray(output)) {
|
|
443
|
-
return output.map(parseResult).filter((value) => value !== null);
|
|
444
|
-
}
|
|
445
|
-
return [];
|
|
446
|
-
}
|
|
447
|
-
var WebSearchPreview = memo5(({ part }) => {
|
|
448
|
-
const query = extractQuery(part.state.input, part.state.output);
|
|
449
|
-
const results = useMemo3(() => extractResults(part.state.output), [part.state.output]);
|
|
450
|
-
return /* @__PURE__ */ jsxs6(
|
|
451
|
-
PreviewCard,
|
|
452
|
-
{
|
|
453
|
-
icon: /* @__PURE__ */ jsx6(Globe, { className: "h-4 w-4" }),
|
|
454
|
-
title: query ? `Web results for ${query}` : "Web results",
|
|
455
|
-
description: results.length > 0 ? `${results.length} result${results.length === 1 ? "" : "s"}` : void 0,
|
|
456
|
-
children: [
|
|
457
|
-
part.state.status === "running" ? /* @__PURE__ */ jsx6(PreviewLoading, { label: "Searching the web\u2026" }) : null,
|
|
458
|
-
part.state.error ? /* @__PURE__ */ jsx6(PreviewError, { error: part.state.error }) : null,
|
|
459
|
-
part.state.status === "completed" && results.length === 0 ? /* @__PURE__ */ jsx6(PreviewEmpty, { label: "No web results were returned." }) : null,
|
|
460
|
-
/* @__PURE__ */ jsx6("div", { className: "space-y-2", children: results.map((result) => /* @__PURE__ */ jsxs6(
|
|
461
|
-
"a",
|
|
462
|
-
{
|
|
463
|
-
href: result.url,
|
|
464
|
-
target: "_blank",
|
|
465
|
-
rel: "noreferrer",
|
|
466
|
-
className: "block rounded-[var(--radius-md)] border border-border bg-muted/55 px-3 py-3 transition-colors hover:border-[var(--border-accent-hover)] hover:bg-accent/50",
|
|
467
|
-
children: [
|
|
468
|
-
/* @__PURE__ */ jsx6("div", { className: "text-sm font-medium text-foreground", children: result.title }),
|
|
469
|
-
/* @__PURE__ */ jsx6("div", { className: "mt-1 truncate text-xs text-primary", children: result.url }),
|
|
470
|
-
result.snippet ? /* @__PURE__ */ jsx6("p", { className: "mt-2 text-sm leading-relaxed text-muted-foreground", children: result.snippet }) : null
|
|
471
|
-
]
|
|
472
|
-
},
|
|
473
|
-
result.url
|
|
474
|
-
)) })
|
|
475
|
-
]
|
|
476
|
-
}
|
|
477
|
-
);
|
|
478
|
-
});
|
|
479
|
-
WebSearchPreview.displayName = "WebSearchPreview";
|
|
480
|
-
|
|
481
|
-
// src/tool-previews/question-preview.tsx
|
|
482
|
-
import { memo as memo6, useMemo as useMemo4 } from "react";
|
|
483
|
-
import { MessageSquareQuote } from "lucide-react";
|
|
484
|
-
import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
485
|
-
function toQuestionList(input) {
|
|
486
|
-
if (!input) {
|
|
487
|
-
return [];
|
|
488
|
-
}
|
|
489
|
-
if (typeof input === "string") {
|
|
490
|
-
return [input];
|
|
491
|
-
}
|
|
492
|
-
if (Array.isArray(input)) {
|
|
493
|
-
return input.map((item) => String(item)).filter(Boolean);
|
|
494
|
-
}
|
|
495
|
-
if (typeof input === "object") {
|
|
496
|
-
const record = input;
|
|
497
|
-
const value = record.questions ?? record.question ?? record.prompt;
|
|
498
|
-
if (Array.isArray(value)) {
|
|
499
|
-
return value.map((item) => String(item)).filter(Boolean);
|
|
500
|
-
}
|
|
501
|
-
if (typeof value === "string") {
|
|
502
|
-
return [value];
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
return [];
|
|
506
|
-
}
|
|
507
|
-
function toAnswerList(output) {
|
|
508
|
-
if (!output) {
|
|
509
|
-
return [];
|
|
510
|
-
}
|
|
511
|
-
if (typeof output === "string") {
|
|
512
|
-
return [output];
|
|
513
|
-
}
|
|
514
|
-
if (Array.isArray(output)) {
|
|
515
|
-
return output.map((item) => String(item)).filter(Boolean);
|
|
516
|
-
}
|
|
517
|
-
if (typeof output === "object") {
|
|
518
|
-
const record = output;
|
|
519
|
-
const value = record.answers ?? record.answer ?? record.response;
|
|
520
|
-
if (Array.isArray(value)) {
|
|
521
|
-
return value.map((item) => String(item)).filter(Boolean);
|
|
522
|
-
}
|
|
523
|
-
if (typeof value === "string") {
|
|
524
|
-
return [value];
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
return [];
|
|
528
|
-
}
|
|
529
|
-
var QuestionPreview = memo6(({ part }) => {
|
|
530
|
-
const questions = useMemo4(() => toQuestionList(part.state.input), [part.state.input]);
|
|
531
|
-
const answers = useMemo4(() => toAnswerList(part.state.output), [part.state.output]);
|
|
532
|
-
return /* @__PURE__ */ jsxs7(
|
|
533
|
-
PreviewCard,
|
|
534
|
-
{
|
|
535
|
-
icon: /* @__PURE__ */ jsx7(MessageSquareQuote, { className: "h-4 w-4" }),
|
|
536
|
-
title: "Agent question",
|
|
537
|
-
description: questions.length > 1 ? `${questions.length} questions require attention` : void 0,
|
|
538
|
-
children: [
|
|
539
|
-
part.state.status === "running" ? /* @__PURE__ */ jsx7(PreviewLoading, { label: "Waiting for an answer\u2026" }) : null,
|
|
540
|
-
part.state.error ? /* @__PURE__ */ jsx7(PreviewError, { error: part.state.error }) : null,
|
|
541
|
-
questions.length === 0 ? /* @__PURE__ */ jsx7(PreviewEmpty, { label: "No question text was provided." }) : null,
|
|
542
|
-
questions.map((question, index) => /* @__PURE__ */ jsxs7(
|
|
543
|
-
"div",
|
|
544
|
-
{
|
|
545
|
-
className: "rounded-[var(--radius-md)] border border-border bg-muted px-3 py-3",
|
|
546
|
-
children: [
|
|
547
|
-
/* @__PURE__ */ jsxs7("div", { className: "text-xs font-semibold uppercase tracking-[0.08em] text-muted-foreground", children: [
|
|
548
|
-
"Question ",
|
|
549
|
-
index + 1
|
|
550
|
-
] }),
|
|
551
|
-
/* @__PURE__ */ jsx7("div", { className: "mt-2 text-sm leading-relaxed text-foreground", children: question }),
|
|
552
|
-
/* @__PURE__ */ jsx7("div", { className: "mt-3 rounded-[var(--radius-sm)] border border-border bg-card px-3 py-2 text-sm text-foreground", children: answers[index] ?? (part.state.status === "completed" ? "No answer recorded." : "Awaiting answer") })
|
|
553
|
-
]
|
|
554
|
-
},
|
|
555
|
-
`${question}-${index}`
|
|
556
|
-
))
|
|
557
|
-
]
|
|
558
|
-
}
|
|
559
|
-
);
|
|
560
|
-
});
|
|
561
|
-
QuestionPreview.displayName = "QuestionPreview";
|
|
562
|
-
|
|
563
|
-
// src/tool-previews/diff-preview.tsx
|
|
564
|
-
import { memo as memo7 } from "react";
|
|
565
|
-
import { GitCompareArrows } from "lucide-react";
|
|
566
|
-
import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
567
|
-
function extractString(record, ...keys) {
|
|
568
|
-
for (const key of keys) {
|
|
569
|
-
const value = record[key];
|
|
570
|
-
if (typeof value === "string" && value.length > 0) {
|
|
571
|
-
return value;
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
return void 0;
|
|
575
|
-
}
|
|
576
|
-
function extractDiffPayload(part) {
|
|
577
|
-
const sources = [part.state.input, part.state.output, part.state.metadata];
|
|
578
|
-
for (const source of sources) {
|
|
579
|
-
if (!source || typeof source !== "object") {
|
|
580
|
-
continue;
|
|
581
|
-
}
|
|
582
|
-
const record = source;
|
|
583
|
-
const diff = extractString(record, "diff", "patch", "unifiedDiff", "unified_diff");
|
|
584
|
-
const before = extractString(record, "oldString", "old_string", "before", "previous");
|
|
585
|
-
const after = extractString(record, "newString", "new_string", "after", "updated");
|
|
586
|
-
const path = extractString(record, "file_path", "filePath", "path");
|
|
587
|
-
if (diff || before || after) {
|
|
588
|
-
return { path, diff, before, after };
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
return {};
|
|
592
|
-
}
|
|
593
|
-
var DiffPreview = memo7(({ part }) => {
|
|
594
|
-
const payload = extractDiffPayload(part);
|
|
595
|
-
return /* @__PURE__ */ jsxs8(
|
|
596
|
-
PreviewCard,
|
|
597
|
-
{
|
|
598
|
-
icon: /* @__PURE__ */ jsx8(GitCompareArrows, { className: "h-4 w-4" }),
|
|
599
|
-
title: payload.path ? `Changes for ${payload.path}` : "File changes",
|
|
600
|
-
children: [
|
|
601
|
-
part.state.status === "running" ? /* @__PURE__ */ jsx8(PreviewLoading, { label: "Computing changes\u2026" }) : null,
|
|
602
|
-
part.state.error ? /* @__PURE__ */ jsx8(PreviewError, { error: part.state.error }) : null,
|
|
603
|
-
!payload.diff && !payload.before && !payload.after ? /* @__PURE__ */ jsx8(PreviewEmpty, { label: "No structured diff payload was provided." }) : null,
|
|
604
|
-
payload.diff ? /* @__PURE__ */ jsx8(CodeBlock, { code: payload.diff, language: "diff", className: "rounded-[var(--radius-md)]" }) : null,
|
|
605
|
-
!payload.diff && payload.before ? /* @__PURE__ */ jsxs8("div", { className: "space-y-2", children: [
|
|
606
|
-
/* @__PURE__ */ jsx8("div", { className: "text-xs font-semibold uppercase tracking-[0.08em] text-muted-foreground", children: "Before" }),
|
|
607
|
-
/* @__PURE__ */ jsx8(CodeBlock, { code: payload.before, language: "text", className: "rounded-[var(--radius-md)]" })
|
|
608
|
-
] }) : null,
|
|
609
|
-
!payload.diff && payload.after ? /* @__PURE__ */ jsxs8("div", { className: "space-y-2", children: [
|
|
610
|
-
/* @__PURE__ */ jsx8("div", { className: "text-xs font-semibold uppercase tracking-[0.08em] text-muted-foreground", children: "After" }),
|
|
611
|
-
/* @__PURE__ */ jsx8(CodeBlock, { code: payload.after, language: "text", className: "rounded-[var(--radius-md)]" })
|
|
612
|
-
] }) : null
|
|
613
|
-
]
|
|
614
|
-
}
|
|
615
|
-
);
|
|
616
|
-
});
|
|
617
|
-
DiffPreview.displayName = "DiffPreview";
|
|
618
|
-
|
|
619
|
-
// src/run/expanded-tool-detail.tsx
|
|
620
|
-
import { memo as memo8 } from "react";
|
|
621
|
-
import {
|
|
622
|
-
ArrowRight,
|
|
623
|
-
ArrowLeft,
|
|
624
|
-
AlertCircle,
|
|
625
|
-
Loader2 as Loader23,
|
|
626
|
-
FileText as FileText2
|
|
627
|
-
} from "lucide-react";
|
|
628
|
-
import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
629
|
-
var EXT_LANG = {
|
|
630
|
-
ts: "typescript",
|
|
631
|
-
tsx: "tsx",
|
|
632
|
-
js: "javascript",
|
|
633
|
-
jsx: "jsx",
|
|
634
|
-
rs: "rust",
|
|
635
|
-
py: "python",
|
|
636
|
-
go: "go",
|
|
637
|
-
rb: "ruby",
|
|
638
|
-
json: "json",
|
|
639
|
-
yaml: "yaml",
|
|
640
|
-
yml: "yaml",
|
|
641
|
-
toml: "toml",
|
|
642
|
-
md: "markdown",
|
|
643
|
-
css: "css",
|
|
644
|
-
scss: "scss",
|
|
645
|
-
html: "html",
|
|
646
|
-
sh: "bash",
|
|
647
|
-
bash: "bash",
|
|
648
|
-
zsh: "bash",
|
|
649
|
-
sql: "sql",
|
|
650
|
-
sol: "solidity",
|
|
651
|
-
proto: "protobuf"
|
|
652
|
-
};
|
|
653
|
-
function langFromPath(path) {
|
|
654
|
-
if (!path) return void 0;
|
|
655
|
-
const ext = path.split(".").pop()?.toLowerCase();
|
|
656
|
-
return ext ? EXT_LANG[ext] : void 0;
|
|
657
|
-
}
|
|
658
|
-
function formatOutput(value) {
|
|
659
|
-
if (value == null) return "";
|
|
660
|
-
if (typeof value === "string") return value;
|
|
661
|
-
try {
|
|
662
|
-
return JSON.stringify(value, null, 2);
|
|
663
|
-
} catch {
|
|
664
|
-
return String(value);
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
var ExpandedToolDetail = memo8(({ part }) => {
|
|
668
|
-
const meta = getToolDisplayMetadata(part);
|
|
669
|
-
const { status, input, output, error } = part.state;
|
|
670
|
-
if (meta.displayVariant === "command") {
|
|
671
|
-
return /* @__PURE__ */ jsx9(CommandPreview, { part });
|
|
672
|
-
}
|
|
673
|
-
if (meta.displayVariant === "write-file") {
|
|
674
|
-
return /* @__PURE__ */ jsx9(WriteFilePreview, { part });
|
|
675
|
-
}
|
|
676
|
-
if (meta.displayVariant === "grep") {
|
|
677
|
-
return /* @__PURE__ */ jsx9(GrepResultsPreview, { part });
|
|
678
|
-
}
|
|
679
|
-
if (meta.displayVariant === "glob") {
|
|
680
|
-
return /* @__PURE__ */ jsx9(GlobResultsPreview, { part });
|
|
681
|
-
}
|
|
682
|
-
if (meta.displayVariant === "web-search") {
|
|
683
|
-
return /* @__PURE__ */ jsx9(WebSearchPreview, { part });
|
|
684
|
-
}
|
|
685
|
-
if (meta.displayVariant === "question") {
|
|
686
|
-
return /* @__PURE__ */ jsx9(QuestionPreview, { part });
|
|
687
|
-
}
|
|
688
|
-
if (meta.displayVariant === "diff") {
|
|
689
|
-
return /* @__PURE__ */ jsx9(DiffPreview, { part });
|
|
690
|
-
}
|
|
691
|
-
if (meta.displayVariant === "read-file") {
|
|
692
|
-
return /* @__PURE__ */ jsxs9("div", { className: "overflow-hidden rounded-[var(--radius-lg)] border border-border bg-card shadow-[var(--shadow-card)]", children: [
|
|
693
|
-
/* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-2.5 border-b border-border bg-card px-3 py-2", children: [
|
|
694
|
-
/* @__PURE__ */ jsx9("div", { className: "flex h-7 w-7 shrink-0 items-center justify-center rounded-[var(--radius-sm)] border border-[var(--border-accent)] bg-muted text-primary", children: /* @__PURE__ */ jsx9(FileText2, { className: "h-3.5 w-3.5" }) }),
|
|
695
|
-
/* @__PURE__ */ jsxs9("div", { className: "min-w-0 flex items-center gap-2", children: [
|
|
696
|
-
/* @__PURE__ */ jsx9("span", { className: "text-xs font-semibold text-foreground", children: "Read file" }),
|
|
697
|
-
meta.targetPath ? /* @__PURE__ */ jsx9("span", { className: "truncate text-xs font-mono text-muted-foreground", children: meta.targetPath }) : null
|
|
698
|
-
] })
|
|
699
|
-
] }),
|
|
700
|
-
/* @__PURE__ */ jsxs9("div", { className: "space-y-2 px-3 py-2.5", children: [
|
|
701
|
-
typeof output === "string" ? /* @__PURE__ */ jsx9(CodeBlock, { code: output, language: langFromPath(meta.targetPath) ?? "text", className: "rounded-[var(--radius-md)]" }) : /* @__PURE__ */ jsx9("div", { className: "rounded-[var(--radius-md)] border border-dashed border-border bg-muted px-3 py-4 text-sm text-muted-foreground", children: "No readable file content was returned." }),
|
|
702
|
-
error ? /* @__PURE__ */ jsx9("div", { className: "rounded-[var(--radius-md)] border border-[var(--surface-danger-border)] bg-[var(--surface-danger-bg)] px-3 py-3 text-sm text-[var(--surface-danger-text)]", children: error }) : null
|
|
703
|
-
] })
|
|
704
|
-
] });
|
|
705
|
-
}
|
|
706
|
-
const inputStr = formatOutput(input);
|
|
707
|
-
const outputStr = formatOutput(output);
|
|
708
|
-
return /* @__PURE__ */ jsxs9("div", { className: "space-y-3", children: [
|
|
709
|
-
inputStr && /* @__PURE__ */ jsxs9("div", { className: "overflow-hidden rounded-[var(--radius-lg)] border border-border bg-card", children: [
|
|
710
|
-
/* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-2 border-b border-border bg-background px-3 py-2", children: [
|
|
711
|
-
/* @__PURE__ */ jsx9(ArrowRight, { className: "h-3 w-3 text-primary" }),
|
|
712
|
-
/* @__PURE__ */ jsx9("span", { className: "text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Input" })
|
|
713
|
-
] }),
|
|
714
|
-
/* @__PURE__ */ jsx9(CodeBlock, { code: inputStr, language: "json", className: "rounded-none border-0" })
|
|
715
|
-
] }),
|
|
716
|
-
status === "completed" && outputStr && /* @__PURE__ */ jsxs9("div", { className: "overflow-hidden rounded-[var(--radius-lg)] border border-border bg-card", children: [
|
|
717
|
-
/* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-2 border-b border-border bg-background px-3 py-2", children: [
|
|
718
|
-
/* @__PURE__ */ jsx9(ArrowLeft, { className: "h-3 w-3 text-primary" }),
|
|
719
|
-
/* @__PURE__ */ jsx9("span", { className: "text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Output" })
|
|
720
|
-
] }),
|
|
721
|
-
/* @__PURE__ */ jsx9(
|
|
722
|
-
CodeBlock,
|
|
723
|
-
{
|
|
724
|
-
code: outputStr.length > 2e3 ? outputStr.slice(0, 2e3) + "\n...(truncated)" : outputStr,
|
|
725
|
-
language: "json",
|
|
726
|
-
className: "rounded-none border-0"
|
|
727
|
-
}
|
|
728
|
-
)
|
|
729
|
-
] }),
|
|
730
|
-
error && /* @__PURE__ */ jsxs9("div", { className: "overflow-hidden rounded-[var(--radius-lg)] border border-[var(--surface-danger-border)]", children: [
|
|
731
|
-
/* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-2 border-b border-[var(--surface-danger-border)] bg-[var(--surface-danger-bg)] px-3 py-2", children: [
|
|
732
|
-
/* @__PURE__ */ jsx9(AlertCircle, { className: "h-3 w-3 text-[var(--surface-danger-text)]" }),
|
|
733
|
-
/* @__PURE__ */ jsx9("span", { className: "text-xs font-medium uppercase tracking-[0.08em] text-[var(--surface-danger-text)]", children: "Error" })
|
|
734
|
-
] }),
|
|
735
|
-
/* @__PURE__ */ jsx9("pre", { className: "bg-[var(--surface-danger-bg)] p-3 text-xs font-mono whitespace-pre-wrap break-all text-[var(--surface-danger-text)]", children: error })
|
|
736
|
-
] }),
|
|
737
|
-
(status === "pending" || status === "running") && /* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-2 rounded-[var(--radius-md)] border border-border bg-muted px-3 py-3 text-xs text-muted-foreground", children: [
|
|
738
|
-
/* @__PURE__ */ jsx9(Loader23, { className: cn("h-3 w-3 animate-spin text-primary") }),
|
|
739
|
-
"Running\u2026"
|
|
740
|
-
] })
|
|
741
|
-
] });
|
|
742
|
-
});
|
|
743
|
-
ExpandedToolDetail.displayName = "ExpandedToolDetail";
|
|
744
|
-
|
|
745
|
-
// src/run/run-item-primitives.tsx
|
|
746
|
-
import { useEffect, useState as useState2 } from "react";
|
|
747
|
-
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
748
|
-
function LiveDuration({ startTime }) {
|
|
749
|
-
const [elapsed, setElapsed] = useState2(Date.now() - startTime);
|
|
750
|
-
useEffect(() => {
|
|
751
|
-
const id = setInterval(() => setElapsed(Date.now() - startTime), 100);
|
|
752
|
-
return () => clearInterval(id);
|
|
753
|
-
}, [startTime]);
|
|
754
|
-
return /* @__PURE__ */ jsx10("span", { className: "text-xs font-mono text-neutral-400 dark:text-neutral-500 tabular-nums", children: formatDuration(elapsed) });
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
// src/run/inline-tool-item.tsx
|
|
758
|
-
import { memo as memo9, useState as useState3 } from "react";
|
|
759
|
-
import * as Collapsible from "@radix-ui/react-collapsible";
|
|
760
|
-
import {
|
|
761
|
-
Loader2 as Loader24,
|
|
762
|
-
CheckCircle2,
|
|
763
|
-
AlertCircle as AlertCircle2,
|
|
764
|
-
ChevronDown as ChevronDown2,
|
|
765
|
-
ChevronRight as ChevronRight2,
|
|
766
|
-
Terminal as Terminal2,
|
|
767
|
-
FileEdit as FileEdit2,
|
|
768
|
-
FileSearch,
|
|
769
|
-
Search as Search2,
|
|
770
|
-
PencilLine,
|
|
771
|
-
Bot,
|
|
772
|
-
Globe as Globe2,
|
|
773
|
-
ClipboardList,
|
|
774
|
-
Settings
|
|
775
|
-
} from "lucide-react";
|
|
776
|
-
import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
777
|
-
var TOOL_CATEGORY_ICON_MAP = {
|
|
778
|
-
command: Terminal2,
|
|
779
|
-
write: FileEdit2,
|
|
780
|
-
read: FileSearch,
|
|
781
|
-
search: Search2,
|
|
782
|
-
edit: PencilLine,
|
|
783
|
-
task: Bot,
|
|
784
|
-
web: Globe2,
|
|
785
|
-
todo: ClipboardList,
|
|
786
|
-
other: Settings
|
|
787
|
-
};
|
|
788
|
-
var InlineToolItem = memo9(
|
|
789
|
-
({
|
|
790
|
-
part,
|
|
791
|
-
renderToolDetail,
|
|
792
|
-
groupPosition = "single",
|
|
793
|
-
className,
|
|
794
|
-
contentClassName,
|
|
795
|
-
actions
|
|
796
|
-
}) => {
|
|
797
|
-
const [open, setOpen] = useState3(false);
|
|
798
|
-
const meta = getToolDisplayMetadata(part);
|
|
799
|
-
const { status } = part.state;
|
|
800
|
-
const errorText = getToolErrorText(part);
|
|
801
|
-
const isRunning = status === "pending" || status === "running";
|
|
802
|
-
const isError = status === "error";
|
|
803
|
-
const isComplete = status === "completed";
|
|
804
|
-
const startTime = part.state.time?.start;
|
|
805
|
-
const endTime = part.state.time?.end;
|
|
806
|
-
const durationMs = startTime && endTime ? endTime - startTime : void 0;
|
|
807
|
-
const category = getToolCategory(part.tool);
|
|
808
|
-
const DefaultIcon = TOOL_CATEGORY_ICON_MAP[category] ?? Settings;
|
|
809
|
-
const shapeClass = {
|
|
810
|
-
single: "rounded-[var(--radius-lg)]",
|
|
811
|
-
first: "rounded-t-[var(--radius-lg)] rounded-b-[var(--radius-sm)]",
|
|
812
|
-
middle: "rounded-[var(--radius-sm)]",
|
|
813
|
-
last: "rounded-t-[var(--radius-sm)] rounded-b-[var(--radius-lg)]"
|
|
814
|
-
}[groupPosition];
|
|
815
|
-
return /* @__PURE__ */ jsxs10(Collapsible.Root, { open, onOpenChange: setOpen, children: [
|
|
816
|
-
/* @__PURE__ */ jsxs10("div", { className: "flex items-start gap-2", children: [
|
|
817
|
-
/* @__PURE__ */ jsx11(Collapsible.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs10(
|
|
818
|
-
"button",
|
|
819
|
-
{
|
|
820
|
-
className: cn(
|
|
821
|
-
"w-full border text-left transition-colors",
|
|
822
|
-
"border-border bg-card hover:border-[var(--border-accent-hover)] hover:bg-accent/35",
|
|
823
|
-
open && "border-border bg-accent/30",
|
|
824
|
-
shapeClass,
|
|
825
|
-
className
|
|
826
|
-
),
|
|
827
|
-
children: [
|
|
828
|
-
/* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-2 px-2.5 py-1.5", children: [
|
|
829
|
-
/* @__PURE__ */ jsx11("div", { className: cn(
|
|
830
|
-
"shrink-0",
|
|
831
|
-
isRunning && "text-primary",
|
|
832
|
-
isComplete && "text-[var(--surface-success-text)]",
|
|
833
|
-
isError && "text-[var(--surface-danger-text)]",
|
|
834
|
-
!isRunning && !isComplete && !isError && "text-muted-foreground"
|
|
835
|
-
), children: isRunning ? /* @__PURE__ */ jsx11(Loader24, { className: "h-3.5 w-3.5 animate-spin" }) : isComplete ? /* @__PURE__ */ jsx11(CheckCircle2, { className: "h-3.5 w-3.5" }) : isError ? /* @__PURE__ */ jsx11(AlertCircle2, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ jsx11(DefaultIcon, { className: "h-3.5 w-3.5" }) }),
|
|
836
|
-
/* @__PURE__ */ jsx11("span", { className: "truncate text-xs font-medium text-foreground", children: meta.title }),
|
|
837
|
-
meta.description ? /* @__PURE__ */ jsx11("span", { className: "hidden truncate text-xs font-mono text-muted-foreground sm:inline", children: meta.description }) : null,
|
|
838
|
-
/* @__PURE__ */ jsxs10("div", { className: "ml-auto flex shrink-0 items-center gap-1.5", children: [
|
|
839
|
-
isRunning && startTime ? /* @__PURE__ */ jsx11(LiveDuration, { startTime }) : null,
|
|
840
|
-
!isRunning && durationMs != null ? /* @__PURE__ */ jsx11("span", { className: "text-[10px] font-mono tabular-nums text-muted-foreground", children: formatDuration(durationMs) }) : null,
|
|
841
|
-
isError ? /* @__PURE__ */ jsx11("span", { className: "rounded-full border border-[var(--surface-danger-border)] bg-[var(--surface-danger-bg)] px-1.5 py-px text-[10px] font-semibold uppercase text-[var(--surface-danger-text)]", children: "Failed" }) : null,
|
|
842
|
-
isRunning ? /* @__PURE__ */ jsx11("span", { className: "rounded-full border border-[var(--border-accent)] bg-primary/10 px-1.5 py-px text-[10px] font-semibold uppercase text-primary", children: "Running" }) : null,
|
|
843
|
-
open ? /* @__PURE__ */ jsx11(ChevronDown2, { className: "h-3 w-3 text-muted-foreground" }) : /* @__PURE__ */ jsx11(ChevronRight2, { className: "h-3 w-3 text-muted-foreground" })
|
|
844
|
-
] })
|
|
845
|
-
] }),
|
|
846
|
-
errorText && !open ? /* @__PURE__ */ jsx11("div", { className: "border-t border-border px-3 py-2 text-xs text-red-200", children: errorText }) : null
|
|
847
|
-
]
|
|
848
|
-
}
|
|
849
|
-
) }),
|
|
850
|
-
actions ? /* @__PURE__ */ jsx11(
|
|
851
|
-
"div",
|
|
852
|
-
{
|
|
853
|
-
className: "flex shrink-0 flex-wrap items-center justify-end gap-1.5 pt-1",
|
|
854
|
-
onClick: (event) => event.stopPropagation(),
|
|
855
|
-
children: actions
|
|
856
|
-
}
|
|
857
|
-
) : null
|
|
858
|
-
] }),
|
|
859
|
-
/* @__PURE__ */ jsx11(Collapsible.Content, { className: "overflow-hidden data-[state=open]:animate-slideDown data-[state=closed]:animate-slideUp", children: /* @__PURE__ */ jsx11("div", { className: cn("mt-2 pl-4", contentClassName), children: renderToolDetail?.(part) ?? /* @__PURE__ */ jsx11(ExpandedToolDetail, { part }) }) })
|
|
860
|
-
] });
|
|
861
|
-
}
|
|
862
|
-
);
|
|
863
|
-
InlineToolItem.displayName = "InlineToolItem";
|
|
864
|
-
|
|
865
|
-
// src/run/inline-thinking-item.tsx
|
|
866
|
-
import { memo as memo10, useEffect as useEffect2, useRef, useState as useState4 } from "react";
|
|
867
|
-
import * as Collapsible2 from "@radix-ui/react-collapsible";
|
|
868
|
-
import { Brain, ChevronRight as ChevronRight3 } from "lucide-react";
|
|
869
|
-
import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
870
|
-
var InlineThinkingItem = memo10(
|
|
871
|
-
({
|
|
872
|
-
part,
|
|
873
|
-
defaultOpen = false,
|
|
874
|
-
autoCollapse = true,
|
|
875
|
-
className,
|
|
876
|
-
contentClassName
|
|
877
|
-
}) => {
|
|
878
|
-
const [open, setOpen] = useState4(defaultOpen);
|
|
879
|
-
const autoCollapsedRef = useRef(false);
|
|
880
|
-
const startTime = part.time?.start;
|
|
881
|
-
const endTime = part.time?.end;
|
|
882
|
-
const durationMs = startTime && endTime ? endTime - startTime : void 0;
|
|
883
|
-
const isActive = startTime != null && endTime == null;
|
|
884
|
-
const preview = part.text ? truncateText(part.text, 120) : void 0;
|
|
885
|
-
useEffect2(() => {
|
|
886
|
-
if (isActive) {
|
|
887
|
-
autoCollapsedRef.current = false;
|
|
888
|
-
setOpen(true);
|
|
889
|
-
return;
|
|
890
|
-
}
|
|
891
|
-
if (autoCollapse && !autoCollapsedRef.current && durationMs != null) {
|
|
892
|
-
const timer = window.setTimeout(() => {
|
|
893
|
-
setOpen(false);
|
|
894
|
-
autoCollapsedRef.current = true;
|
|
895
|
-
}, 900);
|
|
896
|
-
return () => window.clearTimeout(timer);
|
|
897
|
-
}
|
|
898
|
-
}, [autoCollapse, durationMs, isActive]);
|
|
899
|
-
return /* @__PURE__ */ jsx12(Collapsible2.Root, { open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxs11(
|
|
900
|
-
"div",
|
|
901
|
-
{
|
|
902
|
-
className: cn(
|
|
903
|
-
"overflow-hidden rounded-[var(--radius-lg)] border bg-card transition-colors",
|
|
904
|
-
isActive ? "border-[var(--border-accent)]" : "border-border hover:border-[var(--border-accent)]",
|
|
905
|
-
className
|
|
906
|
-
),
|
|
907
|
-
children: [
|
|
908
|
-
/* @__PURE__ */ jsx12(Collapsible2.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs11(
|
|
909
|
-
"button",
|
|
910
|
-
{
|
|
911
|
-
className: "flex w-full items-center gap-2.5 px-3 py-2 text-left text-sm cursor-pointer",
|
|
912
|
-
children: [
|
|
913
|
-
/* @__PURE__ */ jsx12(
|
|
914
|
-
"div",
|
|
915
|
-
{
|
|
916
|
-
className: cn(
|
|
917
|
-
"flex h-6 w-6 shrink-0 items-center justify-center rounded-[var(--radius-sm)] border",
|
|
918
|
-
isActive ? "border-[var(--border-accent)] bg-[var(--accent-surface-soft)] text-primary" : "border-border bg-muted text-muted-foreground"
|
|
919
|
-
),
|
|
920
|
-
children: /* @__PURE__ */ jsx12(Brain, { className: cn("h-3 w-3 shrink-0", isActive && "animate-pulse") })
|
|
921
|
-
}
|
|
922
|
-
),
|
|
923
|
-
/* @__PURE__ */ jsx12("p", { className: "min-w-0 flex-1 truncate font-[var(--font-sans)] text-muted-foreground", children: preview ?? (isActive ? "Thinking\u2026" : "Reasoning") }),
|
|
924
|
-
/* @__PURE__ */ jsxs11("div", { className: "flex shrink-0 items-center gap-2", children: [
|
|
925
|
-
isActive && startTime ? /* @__PURE__ */ jsx12(LiveDuration, { startTime }) : null,
|
|
926
|
-
!isActive && durationMs != null ? /* @__PURE__ */ jsx12("span", { className: "shrink-0 text-xs tabular-nums text-muted-foreground", children: formatDuration(durationMs) }) : null,
|
|
927
|
-
/* @__PURE__ */ jsx12(
|
|
928
|
-
ChevronRight3,
|
|
929
|
-
{
|
|
930
|
-
className: cn(
|
|
931
|
-
"h-3 w-3 text-muted-foreground transition-transform shrink-0",
|
|
932
|
-
open && "rotate-90"
|
|
933
|
-
)
|
|
934
|
-
}
|
|
935
|
-
)
|
|
936
|
-
] })
|
|
937
|
-
]
|
|
938
|
-
}
|
|
939
|
-
) }),
|
|
940
|
-
/* @__PURE__ */ jsx12(Collapsible2.Content, { className: "overflow-hidden data-[state=open]:animate-slideDown data-[state=closed]:animate-slideUp", children: part.text ? /* @__PURE__ */ jsx12(
|
|
941
|
-
"div",
|
|
942
|
-
{
|
|
943
|
-
className: cn(
|
|
944
|
-
"max-h-60 overflow-y-auto border-t border-border bg-muted px-3 py-3 text-sm leading-relaxed text-muted-foreground",
|
|
945
|
-
contentClassName
|
|
946
|
-
),
|
|
947
|
-
children: /* @__PURE__ */ jsx12(Markdown, { children: part.text })
|
|
948
|
-
}
|
|
949
|
-
) : /* @__PURE__ */ jsx12("div", { className: "border-t border-border bg-muted px-3 py-2.5 text-xs text-muted-foreground", children: "No reasoning text provided." }) })
|
|
950
|
-
]
|
|
951
|
-
}
|
|
952
|
-
) });
|
|
953
|
-
}
|
|
954
|
-
);
|
|
955
|
-
InlineThinkingItem.displayName = "InlineThinkingItem";
|
|
956
|
-
|
|
957
|
-
// src/run/run-group.tsx
|
|
958
|
-
import { memo as memo11, useMemo as useMemo5 } from "react";
|
|
959
|
-
import * as Collapsible3 from "@radix-ui/react-collapsible";
|
|
960
|
-
import {
|
|
961
|
-
Bot as Bot2,
|
|
962
|
-
Loader2 as Loader25,
|
|
963
|
-
ChevronDown as ChevronDown3,
|
|
964
|
-
ChevronRight as ChevronRight4,
|
|
965
|
-
Terminal as Terminal3,
|
|
966
|
-
FileEdit as FileEdit3,
|
|
967
|
-
FileSearch as FileSearch2,
|
|
968
|
-
Search as Search3,
|
|
969
|
-
PencilLine as PencilLine2,
|
|
970
|
-
Globe as Globe3,
|
|
971
|
-
ClipboardList as ClipboardList2,
|
|
972
|
-
Settings as Settings2,
|
|
973
|
-
Sparkles
|
|
974
|
-
} from "lucide-react";
|
|
975
|
-
import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
976
|
-
var DEFAULT_BRANDING = {
|
|
977
|
-
label: "Agent",
|
|
978
|
-
accentClass: "text-primary",
|
|
979
|
-
bgClass: "bg-[var(--accent-surface-soft)]",
|
|
980
|
-
containerBgClass: "bg-muted",
|
|
981
|
-
borderClass: "border-border",
|
|
982
|
-
iconClass: "",
|
|
983
|
-
textClass: "text-primary"
|
|
984
|
-
};
|
|
985
|
-
var ASSISTANT_SHELL = "min-w-0 flex-1 space-y-3 rounded-[26px] border border-[var(--border-subtle)] bg-[color:color-mix(in_srgb,var(--bg-card)_94%,transparent)] px-5 py-4 shadow-[0_1px_2px_rgba(15,23,42,0.04)]";
|
|
986
|
-
function AssistantShell({
|
|
987
|
-
branding,
|
|
988
|
-
isStreaming,
|
|
989
|
-
children
|
|
990
|
-
}) {
|
|
991
|
-
return /* @__PURE__ */ jsxs12("div", { className: "flex gap-3", children: [
|
|
992
|
-
/* @__PURE__ */ jsx13("div", { className: "mt-1 flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-[var(--brand-primary)] text-white", children: /* @__PURE__ */ jsx13(Bot2, { className: "h-4 w-4" }) }),
|
|
993
|
-
/* @__PURE__ */ jsxs12("div", { className: ASSISTANT_SHELL, children: [
|
|
994
|
-
/* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-2 text-[11px] font-semibold uppercase tracking-[0.14em] text-[var(--text-muted)]", children: [
|
|
995
|
-
/* @__PURE__ */ jsx13("span", { children: branding.label }),
|
|
996
|
-
isStreaming ? /* @__PURE__ */ jsxs12("span", { className: "inline-flex items-center gap-1.5 text-[var(--text-muted)]", children: [
|
|
997
|
-
/* @__PURE__ */ jsx13(Loader25, { className: "h-3 w-3 animate-spin" }),
|
|
998
|
-
"Thinking"
|
|
999
|
-
] }) : null
|
|
1000
|
-
] }),
|
|
1001
|
-
children
|
|
1002
|
-
] })
|
|
1003
|
-
] });
|
|
1004
|
-
}
|
|
1005
|
-
var CATEGORY_ICON_MAP = {
|
|
1006
|
-
command: Terminal3,
|
|
1007
|
-
write: FileEdit3,
|
|
1008
|
-
read: FileSearch2,
|
|
1009
|
-
search: Search3,
|
|
1010
|
-
edit: PencilLine2,
|
|
1011
|
-
task: Bot2,
|
|
1012
|
-
web: Globe3,
|
|
1013
|
-
todo: ClipboardList2,
|
|
1014
|
-
other: Settings2
|
|
1015
|
-
};
|
|
1016
|
-
var CATEGORY_ORDER = [
|
|
1017
|
-
"command",
|
|
1018
|
-
"write",
|
|
1019
|
-
"edit",
|
|
1020
|
-
"read",
|
|
1021
|
-
"search",
|
|
1022
|
-
"web",
|
|
1023
|
-
"task",
|
|
1024
|
-
"todo",
|
|
1025
|
-
"other"
|
|
1026
|
-
];
|
|
1027
|
-
var OPENUI_NODE_TYPES = /* @__PURE__ */ new Set([
|
|
1028
|
-
"heading",
|
|
1029
|
-
"text",
|
|
1030
|
-
"badge",
|
|
1031
|
-
"stat",
|
|
1032
|
-
"key_value",
|
|
1033
|
-
"code",
|
|
1034
|
-
"markdown",
|
|
1035
|
-
"table",
|
|
1036
|
-
"actions",
|
|
1037
|
-
"separator",
|
|
1038
|
-
"stack",
|
|
1039
|
-
"grid",
|
|
1040
|
-
"card"
|
|
1041
|
-
]);
|
|
1042
|
-
function isOpenUINode(value) {
|
|
1043
|
-
return typeof value === "object" && value !== null && "type" in value && typeof value.type === "string" && OPENUI_NODE_TYPES.has(value.type);
|
|
1044
|
-
}
|
|
1045
|
-
function extractOpenUISchema(output) {
|
|
1046
|
-
if (output == null) return null;
|
|
1047
|
-
if (isOpenUINode(output)) return [output];
|
|
1048
|
-
if (Array.isArray(output) && output.length > 0 && output.every(isOpenUINode)) {
|
|
1049
|
-
return output;
|
|
1050
|
-
}
|
|
1051
|
-
if (typeof output === "object" && !Array.isArray(output)) {
|
|
1052
|
-
const obj = output;
|
|
1053
|
-
for (const key of ["openui", "schema", "ui"]) {
|
|
1054
|
-
if (obj[key] == null) continue;
|
|
1055
|
-
const inner = obj[key];
|
|
1056
|
-
if (typeof inner === "string") {
|
|
1057
|
-
try {
|
|
1058
|
-
const parsed = JSON.parse(inner);
|
|
1059
|
-
return extractOpenUISchema(parsed);
|
|
1060
|
-
} catch {
|
|
1061
|
-
continue;
|
|
1062
|
-
}
|
|
1063
|
-
}
|
|
1064
|
-
const nested = extractOpenUISchema(inner);
|
|
1065
|
-
if (nested) return nested;
|
|
1066
|
-
}
|
|
1067
|
-
}
|
|
1068
|
-
if (typeof output === "string") {
|
|
1069
|
-
try {
|
|
1070
|
-
return extractOpenUISchema(JSON.parse(output));
|
|
1071
|
-
} catch {
|
|
1072
|
-
return null;
|
|
1073
|
-
}
|
|
1074
|
-
}
|
|
1075
|
-
return null;
|
|
1076
|
-
}
|
|
1077
|
-
function getOpenUISummary(output) {
|
|
1078
|
-
if (!output || typeof output !== "object" || Array.isArray(output)) {
|
|
1079
|
-
return null;
|
|
1080
|
-
}
|
|
1081
|
-
const summary = output.summary;
|
|
1082
|
-
return typeof summary === "string" && summary.trim() ? summary.trim() : null;
|
|
1083
|
-
}
|
|
1084
|
-
function isOpenUITool(part) {
|
|
1085
|
-
const normalized = part.tool.toLowerCase().replace(/^tool:/, "");
|
|
1086
|
-
return normalized.includes("openui");
|
|
1087
|
-
}
|
|
1088
|
-
function CategoryBadges({ categories }) {
|
|
1089
|
-
const sorted = useMemo5(
|
|
1090
|
-
() => CATEGORY_ORDER.filter((category) => categories.has(category)),
|
|
1091
|
-
[categories]
|
|
1092
|
-
);
|
|
1093
|
-
if (sorted.length === 0) return null;
|
|
1094
|
-
return /* @__PURE__ */ jsx13("div", { className: "flex items-center gap-1", children: sorted.map((cat) => {
|
|
1095
|
-
const Icon = CATEGORY_ICON_MAP[cat] ?? Settings2;
|
|
1096
|
-
return /* @__PURE__ */ jsx13(
|
|
1097
|
-
"span",
|
|
1098
|
-
{
|
|
1099
|
-
title: cat,
|
|
1100
|
-
className: "flex h-5 w-5 items-center justify-center rounded border border-border text-muted-foreground",
|
|
1101
|
-
children: /* @__PURE__ */ jsx13(Icon, { className: "h-3 w-3" })
|
|
1102
|
-
},
|
|
1103
|
-
cat
|
|
1104
|
-
);
|
|
1105
|
-
}) });
|
|
1106
|
-
}
|
|
1107
|
-
function renderSummary(run) {
|
|
1108
|
-
const parts = [];
|
|
1109
|
-
if (run.stats.toolCount > 0) {
|
|
1110
|
-
parts.push(`${run.stats.toolCount} tool${run.stats.toolCount === 1 ? "" : "s"}`);
|
|
1111
|
-
}
|
|
1112
|
-
if (run.stats.textPartCount > 0) {
|
|
1113
|
-
parts.push(`${run.stats.textPartCount} response${run.stats.textPartCount === 1 ? "" : "s"}`);
|
|
1114
|
-
}
|
|
1115
|
-
if (run.stats.thinkingDurationMs > 0) {
|
|
1116
|
-
parts.push(`${formatDuration(run.stats.thinkingDurationMs)} thinking`);
|
|
1117
|
-
}
|
|
1118
|
-
return parts.join(", ");
|
|
1119
|
-
}
|
|
1120
|
-
function getToolGroupPosition(currentIndex, parts) {
|
|
1121
|
-
const previous = parts[currentIndex - 1]?.part;
|
|
1122
|
-
const next = parts[currentIndex + 1]?.part;
|
|
1123
|
-
const previousIsTool = previous?.type === "tool";
|
|
1124
|
-
const nextIsTool = next?.type === "tool";
|
|
1125
|
-
if (previousIsTool && nextIsTool) return "middle";
|
|
1126
|
-
if (previousIsTool) return "last";
|
|
1127
|
-
if (nextIsTool) return "first";
|
|
1128
|
-
return "single";
|
|
1129
|
-
}
|
|
1130
|
-
var RunGroup = memo11(
|
|
1131
|
-
({
|
|
1132
|
-
run,
|
|
1133
|
-
partMap,
|
|
1134
|
-
collapsed,
|
|
1135
|
-
onToggle,
|
|
1136
|
-
branding = DEFAULT_BRANDING,
|
|
1137
|
-
renderToolDetail,
|
|
1138
|
-
headerActions,
|
|
1139
|
-
renderToolActions
|
|
1140
|
-
}) => {
|
|
1141
|
-
const allParts = useMemo5(() => {
|
|
1142
|
-
const parts = [];
|
|
1143
|
-
for (const msg of run.messages) {
|
|
1144
|
-
const msgParts = partMap[msg.id] ?? [];
|
|
1145
|
-
msgParts.forEach((part, index) => {
|
|
1146
|
-
parts.push({ part, msgId: msg.id, index });
|
|
1147
|
-
});
|
|
1148
|
-
}
|
|
1149
|
-
return parts;
|
|
1150
|
-
}, [run.messages, partMap]);
|
|
1151
|
-
const { stats, isStreaming } = run;
|
|
1152
|
-
const hasRenderableParts = allParts.some(({ part }) => {
|
|
1153
|
-
if (part.type === "tool" || part.type === "reasoning") {
|
|
1154
|
-
return true;
|
|
1155
|
-
}
|
|
1156
|
-
return part.type === "text" && !part.synthetic && part.text.trim().length > 0;
|
|
1157
|
-
});
|
|
1158
|
-
if (!hasRenderableParts) {
|
|
1159
|
-
if (!isStreaming) {
|
|
1160
|
-
return null;
|
|
1161
|
-
}
|
|
1162
|
-
return /* @__PURE__ */ jsx13(AssistantShell, { branding, isStreaming: true, children: /* @__PURE__ */ jsx13("div", { className: "flex items-center gap-2 px-0.5 py-0.5 text-sm text-[var(--text-muted)]", children: /* @__PURE__ */ jsxs12("span", { className: "flex gap-[5px]", children: [
|
|
1163
|
-
/* @__PURE__ */ jsx13("span", { className: "h-2 w-2 animate-bounce rounded-full bg-[var(--brand-glow)]", style: { animationDelay: "0ms" } }),
|
|
1164
|
-
/* @__PURE__ */ jsx13("span", { className: "h-2 w-2 animate-bounce rounded-full bg-[var(--brand-glow)]", style: { animationDelay: "150ms" } }),
|
|
1165
|
-
/* @__PURE__ */ jsx13("span", { className: "h-2 w-2 animate-bounce rounded-full bg-[var(--brand-glow)]", style: { animationDelay: "300ms" } })
|
|
1166
|
-
] }) }) });
|
|
1167
|
-
}
|
|
1168
|
-
const showTraceChrome = allParts.some(({ part }) => {
|
|
1169
|
-
if (part.type === "reasoning") {
|
|
1170
|
-
return true;
|
|
1171
|
-
}
|
|
1172
|
-
if (part.type === "tool") {
|
|
1173
|
-
return !isOpenUITool(part);
|
|
1174
|
-
}
|
|
1175
|
-
return false;
|
|
1176
|
-
});
|
|
1177
|
-
if (!showTraceChrome) {
|
|
1178
|
-
return /* @__PURE__ */ jsx13(AssistantShell, { branding, isStreaming, children: allParts.map(({ part, msgId, index }) => {
|
|
1179
|
-
const key = `${msgId}-${index}`;
|
|
1180
|
-
if (part.type === "tool" && isOpenUITool(part)) {
|
|
1181
|
-
const toolPart = part;
|
|
1182
|
-
const schema = extractOpenUISchema(toolPart.state.output);
|
|
1183
|
-
const summary = getOpenUISummary(toolPart.state.output);
|
|
1184
|
-
if (toolPart.state.status === "completed" && schema) {
|
|
1185
|
-
return /* @__PURE__ */ jsxs12(
|
|
1186
|
-
"div",
|
|
1187
|
-
{
|
|
1188
|
-
className: "overflow-hidden rounded-[22px] border border-[var(--border-subtle)] bg-[var(--bg-root)]",
|
|
1189
|
-
children: [
|
|
1190
|
-
summary ? /* @__PURE__ */ jsx13("div", { className: "border-b border-[var(--border-subtle)] px-4 py-3 text-sm leading-6 text-foreground", children: summary }) : null,
|
|
1191
|
-
/* @__PURE__ */ jsx13("div", { className: "p-4", children: /* @__PURE__ */ jsx13(OpenUIArtifactRenderer, { schema }) })
|
|
1192
|
-
]
|
|
1193
|
-
},
|
|
1194
|
-
key
|
|
1195
|
-
);
|
|
1196
|
-
}
|
|
1197
|
-
if (toolPart.state.status === "running") {
|
|
1198
|
-
return /* @__PURE__ */ jsxs12(
|
|
1199
|
-
"div",
|
|
1200
|
-
{
|
|
1201
|
-
className: "flex items-center gap-2 rounded-[18px] border border-[var(--border-subtle)] bg-[var(--bg-root)] px-4 py-3 text-sm text-muted-foreground",
|
|
1202
|
-
children: [
|
|
1203
|
-
/* @__PURE__ */ jsx13(Loader25, { className: "h-4 w-4 animate-spin text-primary" }),
|
|
1204
|
-
"Building view\u2026"
|
|
1205
|
-
]
|
|
1206
|
-
},
|
|
1207
|
-
key
|
|
1208
|
-
);
|
|
1209
|
-
}
|
|
1210
|
-
}
|
|
1211
|
-
if (part.type === "text" && !part.synthetic && part.text.trim()) {
|
|
1212
|
-
return /* @__PURE__ */ jsx13("div", { className: "px-0.5", children: /* @__PURE__ */ jsx13(Markdown, { className: "tangle-prose text-[15px] leading-7 text-[var(--text-primary)]", children: part.text }) }, key);
|
|
1213
|
-
}
|
|
1214
|
-
return null;
|
|
1215
|
-
}) });
|
|
1216
|
-
}
|
|
1217
|
-
return /* @__PURE__ */ jsx13(Collapsible3.Root, { open: !collapsed, onOpenChange: () => onToggle(), children: /* @__PURE__ */ jsxs12("div", { className: "rounded-[28px] border border-[var(--border-subtle)] bg-[var(--bg-card)] shadow-none", children: [
|
|
1218
|
-
/* @__PURE__ */ jsxs12("div", { className: "flex items-start gap-3 px-4 py-3.5", children: [
|
|
1219
|
-
/* @__PURE__ */ jsx13(Collapsible3.Trigger, { asChild: true, children: /* @__PURE__ */ jsx13(
|
|
1220
|
-
"button",
|
|
1221
|
-
{
|
|
1222
|
-
className: cn(
|
|
1223
|
-
"w-full rounded-[20px] px-0 py-0 text-left transition-colors",
|
|
1224
|
-
"bg-transparent hover:bg-transparent"
|
|
1225
|
-
),
|
|
1226
|
-
children: /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-2.5", children: [
|
|
1227
|
-
/* @__PURE__ */ jsx13(
|
|
1228
|
-
"div",
|
|
1229
|
-
{
|
|
1230
|
-
className: cn(
|
|
1231
|
-
"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-[var(--brand-primary)] text-white"
|
|
1232
|
-
),
|
|
1233
|
-
children: /* @__PURE__ */ jsx13(Bot2, { className: "h-4 w-4" })
|
|
1234
|
-
}
|
|
1235
|
-
),
|
|
1236
|
-
/* @__PURE__ */ jsx13("span", { className: cn("text-sm font-semibold", branding.textClass), children: branding.label }),
|
|
1237
|
-
renderSummary(run) ? /* @__PURE__ */ jsx13("span", { className: "text-[11px] text-muted-foreground", children: renderSummary(run) }) : null,
|
|
1238
|
-
collapsed && run.summaryText ? /* @__PURE__ */ jsx13("span", { className: "min-w-0 truncate text-[11px] text-foreground/70", children: run.summaryText }) : null,
|
|
1239
|
-
/* @__PURE__ */ jsxs12("div", { className: "ml-auto flex shrink-0 items-center gap-1.5", children: [
|
|
1240
|
-
/* @__PURE__ */ jsx13(CategoryBadges, { categories: stats.toolCategories }),
|
|
1241
|
-
isStreaming ? /* @__PURE__ */ jsxs12("span", { className: "inline-flex items-center gap-1 rounded-full border border-[var(--border-accent)] bg-[var(--accent-surface-soft)] px-2 py-px text-[10px] font-semibold uppercase text-[var(--accent-text)]", children: [
|
|
1242
|
-
/* @__PURE__ */ jsx13(Loader25, { className: "h-2.5 w-2.5 animate-spin" }),
|
|
1243
|
-
"Running"
|
|
1244
|
-
] }) : /* @__PURE__ */ jsxs12("span", { className: "inline-flex items-center gap-1 rounded-full border border-border px-2 py-px text-[10px] font-semibold uppercase text-muted-foreground", children: [
|
|
1245
|
-
/* @__PURE__ */ jsx13(Sparkles, { className: "h-2.5 w-2.5" }),
|
|
1246
|
-
"Done"
|
|
1247
|
-
] }),
|
|
1248
|
-
!collapsed ? /* @__PURE__ */ jsx13(ChevronDown3, { className: "h-3.5 w-3.5 text-muted-foreground" }) : /* @__PURE__ */ jsx13(ChevronRight4, { className: "h-3.5 w-3.5 text-muted-foreground" })
|
|
1249
|
-
] })
|
|
1250
|
-
] })
|
|
1251
|
-
}
|
|
1252
|
-
) }),
|
|
1253
|
-
headerActions ? /* @__PURE__ */ jsx13("div", { className: "flex shrink-0 flex-wrap items-center justify-end gap-1.5 pt-1", children: headerActions }) : null
|
|
1254
|
-
] }),
|
|
1255
|
-
collapsed && run.summaryText && /* @__PURE__ */ jsx13("div", { className: "px-4 pb-4 text-sm leading-6 text-muted-foreground line-clamp-2", children: run.summaryText }),
|
|
1256
|
-
/* @__PURE__ */ jsx13(Collapsible3.Content, { className: "overflow-hidden data-[state=open]:animate-slideDown data-[state=closed]:animate-slideUp", children: /* @__PURE__ */ jsx13("div", { className: cn("space-y-3 border-t border-[var(--border-subtle)] px-4 pb-4 pt-3"), children: allParts.map(({ part, msgId, index }, partIndex) => {
|
|
1257
|
-
const key = `${msgId}-${index}`;
|
|
1258
|
-
if (part.type === "tool") {
|
|
1259
|
-
if (isOpenUITool(part)) {
|
|
1260
|
-
const toolPart = part;
|
|
1261
|
-
const schema = extractOpenUISchema(toolPart.state.output);
|
|
1262
|
-
const summary = getOpenUISummary(toolPart.state.output);
|
|
1263
|
-
if (toolPart.state.status === "completed" && schema) {
|
|
1264
|
-
return /* @__PURE__ */ jsxs12(
|
|
1265
|
-
"div",
|
|
1266
|
-
{
|
|
1267
|
-
className: "overflow-hidden rounded-[24px] border border-[var(--border-subtle)] bg-[var(--bg-card)]",
|
|
1268
|
-
children: [
|
|
1269
|
-
summary ? /* @__PURE__ */ jsxs12("div", { className: "border-b border-[var(--border-subtle)] px-4 py-3", children: [
|
|
1270
|
-
/* @__PURE__ */ jsx13("div", { className: "text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground", children: "View" }),
|
|
1271
|
-
/* @__PURE__ */ jsx13("div", { className: "mt-1 text-sm leading-6 text-foreground", children: summary })
|
|
1272
|
-
] }) : null,
|
|
1273
|
-
/* @__PURE__ */ jsx13("div", { className: "p-4", children: /* @__PURE__ */ jsx13(OpenUIArtifactRenderer, { schema }) })
|
|
1274
|
-
]
|
|
1275
|
-
},
|
|
1276
|
-
key
|
|
1277
|
-
);
|
|
1278
|
-
}
|
|
1279
|
-
if (toolPart.state.status === "running") {
|
|
1280
|
-
return /* @__PURE__ */ jsxs12(
|
|
1281
|
-
"div",
|
|
1282
|
-
{
|
|
1283
|
-
className: "flex items-center gap-3 rounded-[20px] border border-[var(--border-subtle)] bg-[var(--bg-card)] px-4 py-3 text-sm text-muted-foreground",
|
|
1284
|
-
children: [
|
|
1285
|
-
/* @__PURE__ */ jsx13(Loader25, { className: "h-4 w-4 animate-spin text-primary" }),
|
|
1286
|
-
"Building view\u2026"
|
|
1287
|
-
]
|
|
1288
|
-
},
|
|
1289
|
-
key
|
|
1290
|
-
);
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
return /* @__PURE__ */ jsx13(
|
|
1294
|
-
InlineToolItem,
|
|
1295
|
-
{
|
|
1296
|
-
part,
|
|
1297
|
-
renderToolDetail,
|
|
1298
|
-
groupPosition: getToolGroupPosition(partIndex, allParts),
|
|
1299
|
-
actions: renderToolActions?.(part, {
|
|
1300
|
-
run,
|
|
1301
|
-
messageId: msgId,
|
|
1302
|
-
partIndex: index
|
|
1303
|
-
})
|
|
1304
|
-
},
|
|
1305
|
-
key
|
|
1306
|
-
);
|
|
1307
|
-
}
|
|
1308
|
-
if (part.type === "reasoning") {
|
|
1309
|
-
return /* @__PURE__ */ jsx13(
|
|
1310
|
-
InlineThinkingItem,
|
|
1311
|
-
{
|
|
1312
|
-
part,
|
|
1313
|
-
defaultOpen: isStreaming
|
|
1314
|
-
},
|
|
1315
|
-
key
|
|
1316
|
-
);
|
|
1317
|
-
}
|
|
1318
|
-
if (part.type === "text" && !part.synthetic && part.text.trim()) {
|
|
1319
|
-
return /* @__PURE__ */ jsx13(
|
|
1320
|
-
"div",
|
|
1321
|
-
{
|
|
1322
|
-
className: "px-1 py-1",
|
|
1323
|
-
children: /* @__PURE__ */ jsx13(Markdown, { className: "tangle-prose text-[15px] leading-7", children: part.text })
|
|
1324
|
-
},
|
|
1325
|
-
key
|
|
1326
|
-
);
|
|
1327
|
-
}
|
|
1328
|
-
return null;
|
|
1329
|
-
}) }) })
|
|
1330
|
-
] }) });
|
|
1331
|
-
}
|
|
1332
|
-
);
|
|
1333
|
-
RunGroup.displayName = "RunGroup";
|
|
1334
|
-
|
|
1335
|
-
export {
|
|
1336
|
-
CommandPreview,
|
|
1337
|
-
WriteFilePreview,
|
|
1338
|
-
GrepResultsPreview,
|
|
1339
|
-
GlobResultsPreview,
|
|
1340
|
-
WebSearchPreview,
|
|
1341
|
-
QuestionPreview,
|
|
1342
|
-
DiffPreview,
|
|
1343
|
-
ExpandedToolDetail,
|
|
1344
|
-
LiveDuration,
|
|
1345
|
-
InlineToolItem,
|
|
1346
|
-
InlineThinkingItem,
|
|
1347
|
-
RunGroup
|
|
1348
|
-
};
|