@tangle-network/ui 11.10.0 → 11.11.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.
Files changed (132) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +4 -1
  3. package/dist/active-sessions-store-Gt1R0rFG.js +262 -0
  4. package/dist/{active-sessions-store-CeOmXgv5.d.ts → active-sessions-store-nl70ZnMC.d.ts} +40 -41
  5. package/dist/artifact-pane-BL_DFWNl.d.ts +32 -0
  6. package/dist/artifact-pane-DMXT9a8U.js +70 -0
  7. package/dist/auth-DOETfnd9.js +154 -0
  8. package/dist/auth.d.ts +2 -74
  9. package/dist/auth.js +2 -16
  10. package/dist/branding-26d5ARIr.d.ts +14 -0
  11. package/dist/button-C87nEe2R.js +78 -0
  12. package/dist/button-yoIv77e2.d.ts +16 -0
  13. package/dist/chat-D4jAfEmj.js +667 -0
  14. package/dist/chat.d.ts +2 -201
  15. package/dist/chat.js +2 -31
  16. package/dist/code-block-B36KVUSN.js +165 -0
  17. package/dist/code-block-B9miUPht.d.ts +23 -0
  18. package/dist/diff-preview-BcK3nRXb.js +533 -0
  19. package/dist/document-editor-pane-BcoABlhn.d.ts +131 -0
  20. package/dist/document-editor-pane-BxlPjaTP.js +1287 -0
  21. package/dist/dropdown-menu-BpcLa5vF.js +101 -0
  22. package/dist/editor.d.ts +76 -78
  23. package/dist/editor.js +2 -34
  24. package/dist/file-format-BgXbr-Ib.js +160 -0
  25. package/dist/files-Bug33qCl.js +743 -0
  26. package/dist/files.d.ts +2 -243
  27. package/dist/files.js +3 -41
  28. package/dist/focus-BcE_SHqz.js +57 -0
  29. package/dist/format-DfcLWqMa.js +54 -0
  30. package/dist/hooks.d.ts +30 -37
  31. package/dist/hooks.js +111 -46
  32. package/dist/index-2UntyjBb.d.ts +52 -0
  33. package/dist/index-BgUHilZm.d.ts +108 -0
  34. package/dist/index-COgqsFAQ.d.ts +42 -0
  35. package/dist/index-CPDET_s1.d.ts +549 -0
  36. package/dist/index-CUhfHT_V.d.ts +204 -0
  37. package/dist/index-Cg6gYAqh.d.ts +73 -0
  38. package/dist/index-Cq-EJzqW.d.ts +16 -0
  39. package/dist/index-DhYmSaLF.d.ts +245 -0
  40. package/dist/index-DjKxO357.d.ts +128 -0
  41. package/dist/index.d.ts +26 -43
  42. package/dist/index.js +35 -472
  43. package/dist/markdown-BGqicV82.js +45 -0
  44. package/dist/markdown.d.ts +3 -18
  45. package/dist/markdown.js +3 -15
  46. package/dist/message-vhUI0c5G.d.ts +16 -0
  47. package/dist/nav.d.ts +6 -8
  48. package/dist/nav.js +29 -11
  49. package/dist/openui-artifact-renderer-D3E5bIAI.d.ts +114 -0
  50. package/dist/openui-artifact-renderer-DrU1AdVk.js +266 -0
  51. package/dist/openui.d.ts +2 -115
  52. package/dist/openui.js +2 -13
  53. package/dist/parts-5mhy9yJ3.d.ts +37 -0
  54. package/dist/primitives-Cb8GGVKr.js +1239 -0
  55. package/dist/primitives.d.ts +5 -525
  56. package/dist/primitives.js +9 -212
  57. package/dist/redaction-CGGB2ENG.js +74 -0
  58. package/dist/redaction.d.ts +2 -42
  59. package/dist/redaction.js +2 -7
  60. package/dist/run-OyWmIDqu.d.ts +41 -0
  61. package/dist/run-ZsIKPA6J.js +17 -0
  62. package/dist/run-group-BACLbCFl.js +410 -0
  63. package/dist/run.d.ts +3 -126
  64. package/dist/run.js +5 -40
  65. package/dist/sdk-hooks.d.ts +2 -285
  66. package/dist/sdk-hooks.js +3 -36
  67. package/dist/stores.d.ts +13 -14
  68. package/dist/stores.js +34 -76
  69. package/dist/table-Bss73DhB.js +146 -0
  70. package/dist/tabs-BVHR6NkO.js +40 -0
  71. package/dist/text-shimmer-BUUo6I-g.js +64 -0
  72. package/dist/tool-call-feed-BeB1_4pX.d.ts +47 -0
  73. package/dist/tool-call-feed-Djt2q11V.js +109 -0
  74. package/dist/tool-call-step-DNebqhmX.js +434 -0
  75. package/dist/tool-display-BAuAVa43.js +158 -0
  76. package/dist/{tool-display-z4JcDmMQ.d.ts → tool-display-DgmL5rIU.d.ts} +16 -16
  77. package/dist/tool-previews.d.ts +2 -48
  78. package/dist/tool-previews.js +2 -23
  79. package/dist/types.d.ts +6 -19
  80. package/dist/types.js +0 -1
  81. package/dist/use-auto-scroll-C5Pjeqon.js +153 -0
  82. package/dist/use-sse-stream-BVgO1QBN.js +884 -0
  83. package/dist/use-sse-stream-Dm6R5YWz.d.ts +282 -0
  84. package/dist/utils-Bl_CZ0Qp.js +37 -0
  85. package/dist/{chunk-RQHJBTEU.js → utils-C_uf36nf.js} +4 -6
  86. package/dist/utils.d.ts +2 -104
  87. package/dist/utils.js +6 -44
  88. package/package.json +39 -41
  89. package/src/lib/focus.ts +2 -1
  90. package/dist/artifact-pane-DpuWcAiF.d.ts +0 -33
  91. package/dist/button-CMQuQEW_.d.ts +0 -17
  92. package/dist/chunk-34A66VBG.js +0 -214
  93. package/dist/chunk-3OI2QKFD.js +0 -0
  94. package/dist/chunk-3XXBZL53.js +0 -174
  95. package/dist/chunk-42PAH5D2.js +0 -112
  96. package/dist/chunk-4CLN43XT.js +0 -45
  97. package/dist/chunk-55WHV7SS.js +0 -1604
  98. package/dist/chunk-565EATZZ.js +0 -156
  99. package/dist/chunk-5Z5ZYMOJ.js +0 -0
  100. package/dist/chunk-6BGQA4BQ.js +0 -0
  101. package/dist/chunk-BEBXZPHW.js +0 -299
  102. package/dist/chunk-C5WF4WMV.js +0 -734
  103. package/dist/chunk-HFL6R6IF.js +0 -37
  104. package/dist/chunk-HGML45QH.js +0 -104
  105. package/dist/chunk-HMAPIH7L.js +0 -595
  106. package/dist/chunk-K5XFRUS4.js +0 -1401
  107. package/dist/chunk-KFQGHD73.js +0 -198
  108. package/dist/chunk-L57WRIND.js +0 -59
  109. package/dist/chunk-LTEKI7YJ.js +0 -59
  110. package/dist/chunk-M3QZK62R.js +0 -233
  111. package/dist/chunk-ND3ZFXQK.js +0 -179
  112. package/dist/chunk-OEX7NZE3.js +0 -321
  113. package/dist/chunk-OL5GYLHV.js +0 -60
  114. package/dist/chunk-QGFYBNSO.js +0 -133
  115. package/dist/chunk-R7B3UWPF.js +0 -550
  116. package/dist/chunk-R7SUY4E3.js +0 -65
  117. package/dist/chunk-REJESC5U.js +0 -117
  118. package/dist/chunk-RQGKSCEZ.js +0 -0
  119. package/dist/chunk-SNLR2AEA.js +0 -40
  120. package/dist/chunk-WKWBTL2V.js +0 -15
  121. package/dist/chunk-X7CU776B.js +0 -1048
  122. package/dist/chunk-XU3HB5QL.js +0 -127
  123. package/dist/chunk-YTO5V6QS.js +0 -19
  124. package/dist/chunk-YU4E5J2N.js +0 -437
  125. package/dist/chunk-YZ6AK25N.js +0 -886
  126. package/dist/code-block-0kSpWMnf.d.ts +0 -25
  127. package/dist/document-editor-pane-IAEQn_Dl.d.ts +0 -128
  128. package/dist/document-editor-pane-QHDOBA43.js +0 -13
  129. package/dist/message-BHWbxBtT.d.ts +0 -15
  130. package/dist/parts-dj7AcUg0.d.ts +0 -36
  131. package/dist/run-PfLmDAox.d.ts +0 -41
  132. package/dist/tool-call-feed-D9iofJgW.d.ts +0 -46
@@ -1,595 +0,0 @@
1
- import {
2
- getSyntaxLanguage
3
- } from "./chunk-XU3HB5QL.js";
4
- import {
5
- CodeBlock,
6
- CopyButton
7
- } from "./chunk-3XXBZL53.js";
8
- import {
9
- focusRing
10
- } from "./chunk-WKWBTL2V.js";
11
- import {
12
- cn
13
- } from "./chunk-RQHJBTEU.js";
14
-
15
- // src/tool-previews/command-preview.tsx
16
- import { memo, useState } from "react";
17
- import {
18
- Terminal,
19
- ChevronDown,
20
- ChevronRight
21
- } from "lucide-react";
22
-
23
- // src/tool-previews/preview-primitives.tsx
24
- import { Loader2 } from "lucide-react";
25
- import { jsx, jsxs } from "react/jsx-runtime";
26
- function PreviewCard({
27
- icon,
28
- title,
29
- description,
30
- meta,
31
- children,
32
- className
33
- }) {
34
- return /* @__PURE__ */ jsxs(
35
- "div",
36
- {
37
- className: cn(
38
- "overflow-hidden rounded-[var(--radius-lg)] border border-border bg-card shadow-[var(--shadow-card)]",
39
- className
40
- ),
41
- children: [
42
- /* @__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: [
43
- /* @__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 }),
44
- /* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
45
- /* @__PURE__ */ jsx("span", { className: "text-xs font-semibold text-foreground", children: title }),
46
- description ? /* @__PURE__ */ jsx("span", { className: "truncate text-xs font-mono text-muted-foreground", children: description }) : null
47
- ] }) }),
48
- meta ? /* @__PURE__ */ jsx("div", { className: "shrink-0 text-xs text-muted-foreground", children: meta }) : null
49
- ] }),
50
- children ? /* @__PURE__ */ jsx("div", { className: "space-y-2 px-[var(--tool-card-px)] py-[var(--tool-card-py)]", children }) : null
51
- ]
52
- }
53
- );
54
- }
55
- function PreviewEmpty({
56
- label,
57
- className
58
- }) {
59
- return /* @__PURE__ */ jsx(
60
- "div",
61
- {
62
- className: cn(
63
- "rounded-[var(--radius-md)] border border-dashed border-border bg-muted px-3 py-2.5 text-xs text-muted-foreground",
64
- className
65
- ),
66
- children: label
67
- }
68
- );
69
- }
70
- function PreviewError({ error }) {
71
- 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 });
72
- }
73
- function PreviewLoading({ label = "Running\u2026" }) {
74
- 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: [
75
- /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin text-primary" }),
76
- /* @__PURE__ */ jsx("span", { children: label })
77
- ] });
78
- }
79
-
80
- // src/tool-previews/command-preview.tsx
81
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
82
- function extractCommandOutput(output) {
83
- if (!output) return { stdout: "", stderr: "", exitCode: 0 };
84
- if (typeof output === "string") return { stdout: output, stderr: "", exitCode: 0 };
85
- if (typeof output === "object" && output !== null) {
86
- const obj = output;
87
- return {
88
- stdout: String(obj.stdout ?? obj.output ?? ""),
89
- stderr: String(obj.stderr ?? ""),
90
- exitCode: Number(obj.exitCode ?? obj.exit_code ?? obj.code ?? 0)
91
- };
92
- }
93
- return { stdout: String(output), stderr: "", exitCode: 0 };
94
- }
95
- var CommandPreview = memo(({ part }) => {
96
- const [expanded, setExpanded] = useState(true);
97
- const input = part.state.input;
98
- const command = typeof input?.command === "string" ? input.command : String(input ?? "");
99
- const output = part.state.status === "completed" ? extractCommandOutput(part.state.output) : null;
100
- const isError = output ? output.exitCode !== 0 : part.state.status === "error";
101
- const errorText = part.state.error;
102
- const lineCount = output?.stdout ? output.stdout.split("\n").length : 0;
103
- return /* @__PURE__ */ jsxs2(
104
- PreviewCard,
105
- {
106
- icon: /* @__PURE__ */ jsx2(Terminal, { className: "h-4 w-4" }),
107
- title: "Command",
108
- description: command,
109
- meta: output ? /* @__PURE__ */ jsxs2(
110
- "span",
111
- {
112
- className: cn(
113
- "inline-flex items-center rounded-full border px-2 py-0.5 font-mono",
114
- 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)]"
115
- ),
116
- children: [
117
- "exit ",
118
- output.exitCode
119
- ]
120
- }
121
- ) : null,
122
- children: [
123
- /* @__PURE__ */ jsxs2(
124
- "button",
125
- {
126
- onClick: () => setExpanded((value) => !value),
127
- className: cn(
128
- "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-strong)] hover:bg-accent/45",
129
- focusRing
130
- ),
131
- children: [
132
- /* @__PURE__ */ jsx2("code", { className: "min-w-0 flex-1 truncate text-xs font-mono text-foreground", children: command }),
133
- lineCount > 0 ? /* @__PURE__ */ jsxs2("span", { className: "shrink-0 text-xs text-muted-foreground", children: [
134
- lineCount,
135
- " line",
136
- lineCount === 1 ? "" : "s"
137
- ] }) : null,
138
- 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" })
139
- ]
140
- }
141
- ),
142
- part.state.status === "running" ? /* @__PURE__ */ jsx2(PreviewLoading, {}) : null,
143
- errorText ? /* @__PURE__ */ jsx2(PreviewError, { error: errorText }) : null,
144
- expanded && output ? /* @__PURE__ */ jsxs2("div", { className: "overflow-hidden rounded-[var(--radius-md)] border border-border bg-muted", children: [
145
- 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,
146
- 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
147
- ] }) : null
148
- ]
149
- }
150
- );
151
- });
152
- CommandPreview.displayName = "CommandPreview";
153
-
154
- // src/tool-previews/write-file-preview.tsx
155
- import { memo as memo2 } from "react";
156
- import { FileEdit } from "lucide-react";
157
- import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
158
- function extractWriteContent(input) {
159
- if (!input || typeof input !== "object") return null;
160
- const obj = input;
161
- const path = String(obj.file_path ?? obj.path ?? obj.filePath ?? "unknown");
162
- const content = String(obj.content ?? obj.contents ?? obj.data ?? "");
163
- return { path, content };
164
- }
165
- var WriteFilePreview = memo2(({ part }) => {
166
- const write = extractWriteContent(part.state.input);
167
- if (!write) return null;
168
- const lineCount = write.content.split("\n").length;
169
- const language = getSyntaxLanguage(write.path);
170
- return /* @__PURE__ */ jsxs3(
171
- PreviewCard,
172
- {
173
- icon: /* @__PURE__ */ jsx3(FileEdit, { className: "h-4 w-4" }),
174
- title: "Write file",
175
- description: write.path,
176
- meta: /* @__PURE__ */ jsxs3("span", { className: "text-xs text-muted-foreground", children: [
177
- "+",
178
- lineCount,
179
- " line",
180
- lineCount !== 1 ? "s" : ""
181
- ] }),
182
- children: [
183
- part.state.status === "running" ? /* @__PURE__ */ jsx3(PreviewLoading, { label: "Writing file\u2026" }) : null,
184
- part.state.error ? /* @__PURE__ */ jsx3(PreviewError, { error: part.state.error }) : null,
185
- /* @__PURE__ */ jsx3(CodeBlock, { code: write.content, language, className: "rounded-[var(--radius-md)]", children: /* @__PURE__ */ jsx3(CopyButton, { text: write.content }) })
186
- ]
187
- }
188
- );
189
- });
190
- WriteFilePreview.displayName = "WriteFilePreview";
191
-
192
- // src/tool-previews/grep-results-preview.tsx
193
- import { memo as memo3, useMemo } from "react";
194
- import { Search } from "lucide-react";
195
- import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
196
- function coerceString(value) {
197
- return typeof value === "string" && value.trim() ? value : void 0;
198
- }
199
- function parseMatch(value) {
200
- if (typeof value === "string") {
201
- const [path2, maybeLine, ...rest] = value.split(":");
202
- const line2 = Number(maybeLine);
203
- if (rest.length > 0 && Number.isFinite(line2)) {
204
- return {
205
- path: path2,
206
- line: line2,
207
- text: rest.join(":").trim()
208
- };
209
- }
210
- return {
211
- path: "match",
212
- text: value
213
- };
214
- }
215
- if (!value || typeof value !== "object") {
216
- return null;
217
- }
218
- const record = value;
219
- const path = coerceString(record.path) ?? coerceString(record.file) ?? coerceString(record.filePath) ?? "match";
220
- const lineValue = record.line ?? record.lineNumber ?? record.line_number;
221
- const line = typeof lineValue === "number" ? lineValue : Number(lineValue);
222
- const text = coerceString(record.text) ?? coerceString(record.content) ?? coerceString(record.lineText) ?? coerceString(record.preview);
223
- if (!text) {
224
- return null;
225
- }
226
- return {
227
- path,
228
- line: Number.isFinite(line) ? line : void 0,
229
- text
230
- };
231
- }
232
- function extractPattern(input) {
233
- if (!input || typeof input !== "object") {
234
- return void 0;
235
- }
236
- const record = input;
237
- return coerceString(record.pattern) ?? coerceString(record.query);
238
- }
239
- function extractMatches(output) {
240
- if (Array.isArray(output)) {
241
- return output.map(parseMatch).filter((value) => value !== null);
242
- }
243
- if (output && typeof output === "object") {
244
- const record = output;
245
- const candidates = [record.matches, record.results, record.output];
246
- for (const candidate of candidates) {
247
- if (Array.isArray(candidate)) {
248
- return candidate.map(parseMatch).filter((value) => value !== null);
249
- }
250
- }
251
- }
252
- if (typeof output === "string") {
253
- return output.split("\n").map((line) => line.trim()).filter(Boolean).map(parseMatch).filter((value) => value !== null);
254
- }
255
- return [];
256
- }
257
- var GrepResultsPreview = memo3(({ part }) => {
258
- const pattern = extractPattern(part.state.input);
259
- const matches = useMemo(() => extractMatches(part.state.output), [part.state.output]);
260
- const groupedMatches = useMemo(() => {
261
- const groups = /* @__PURE__ */ new Map();
262
- for (const match of matches) {
263
- const list = groups.get(match.path) ?? [];
264
- list.push(match);
265
- groups.set(match.path, list);
266
- }
267
- return [...groups.entries()];
268
- }, [matches]);
269
- return /* @__PURE__ */ jsxs4(
270
- PreviewCard,
271
- {
272
- icon: /* @__PURE__ */ jsx4(Search, { className: "h-4 w-4" }),
273
- title: pattern ? `Search results for "${pattern}"` : "Search results",
274
- description: matches.length > 0 ? `${matches.length} match${matches.length === 1 ? "" : "es"}` : void 0,
275
- children: [
276
- part.state.status === "running" ? /* @__PURE__ */ jsx4(PreviewLoading, { label: "Searching files\u2026" }) : null,
277
- part.state.error ? /* @__PURE__ */ jsx4(PreviewError, { error: part.state.error }) : null,
278
- part.state.status === "completed" && matches.length === 0 ? /* @__PURE__ */ jsx4(PreviewEmpty, { label: "No matching files or lines were returned." }) : null,
279
- groupedMatches.map(([path, pathMatches]) => /* @__PURE__ */ jsxs4(
280
- "div",
281
- {
282
- className: "rounded-[var(--radius-md)] border border-border bg-muted/55",
283
- children: [
284
- /* @__PURE__ */ jsx4("div", { className: "border-b border-border px-3 py-2 text-xs font-medium text-foreground", children: path }),
285
- /* @__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: [
286
- /* @__PURE__ */ jsx4("div", { className: "pt-0.5 text-xs font-mono text-muted-foreground", children: match.line ?? "\xB7" }),
287
- /* @__PURE__ */ jsx4("pre", { className: "overflow-x-auto whitespace-pre-wrap break-words text-xs font-mono text-foreground", children: match.text })
288
- ] }, `${path}-${match.line ?? index}-${index}`)) })
289
- ]
290
- },
291
- path
292
- ))
293
- ]
294
- }
295
- );
296
- });
297
- GrepResultsPreview.displayName = "GrepResultsPreview";
298
-
299
- // src/tool-previews/glob-results-preview.tsx
300
- import { memo as memo4, useMemo as useMemo2 } from "react";
301
- import { FileText, FolderOpen } from "lucide-react";
302
- import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
303
- function coerceString2(value) {
304
- return typeof value === "string" && value.trim() ? value : void 0;
305
- }
306
- function extractPattern2(input) {
307
- if (!input || typeof input !== "object") {
308
- return void 0;
309
- }
310
- const record = input;
311
- return coerceString2(record.pattern) ?? coerceString2(record.path);
312
- }
313
- function extractFiles(output) {
314
- if (Array.isArray(output)) {
315
- return output.map((item) => String(item)).filter(Boolean);
316
- }
317
- if (output && typeof output === "object") {
318
- const record = output;
319
- const candidate = record.files ?? record.matches ?? record.paths ?? record.results;
320
- if (Array.isArray(candidate)) {
321
- return candidate.map(
322
- (item) => typeof item === "string" ? item : item && typeof item === "object" ? String(
323
- item.path ?? item.file ?? ""
324
- ) : ""
325
- ).filter(Boolean);
326
- }
327
- }
328
- if (typeof output === "string") {
329
- return output.split("\n").map((line) => line.trim()).filter(Boolean);
330
- }
331
- return [];
332
- }
333
- var GlobResultsPreview = memo4(({ part }) => {
334
- const pattern = extractPattern2(part.state.input);
335
- const files = useMemo2(() => extractFiles(part.state.output), [part.state.output]);
336
- return /* @__PURE__ */ jsxs5(
337
- PreviewCard,
338
- {
339
- icon: /* @__PURE__ */ jsx5(FolderOpen, { className: "h-4 w-4" }),
340
- title: pattern ? `Files for ${pattern}` : "File results",
341
- description: files.length > 0 ? `${files.length} path${files.length === 1 ? "" : "s"}` : void 0,
342
- children: [
343
- part.state.status === "running" ? /* @__PURE__ */ jsx5(PreviewLoading, { label: "Collecting files\u2026" }) : null,
344
- part.state.error ? /* @__PURE__ */ jsx5(PreviewError, { error: part.state.error }) : null,
345
- part.state.status === "completed" && files.length === 0 ? /* @__PURE__ */ jsx5(PreviewEmpty, { label: "No matching files were returned." }) : null,
346
- files.length > 0 ? /* @__PURE__ */ jsx5("div", { className: "grid gap-2 sm:grid-cols-2", children: files.map((file) => {
347
- const isDirectory = file.endsWith("/");
348
- const Icon = isDirectory ? FolderOpen : FileText;
349
- return /* @__PURE__ */ jsxs5(
350
- "div",
351
- {
352
- className: "flex items-center gap-2 rounded-[var(--radius-md)] border border-border bg-muted/55 px-3 py-2",
353
- children: [
354
- /* @__PURE__ */ jsx5(Icon, { className: "h-4 w-4 shrink-0 text-primary" }),
355
- /* @__PURE__ */ jsx5("span", { className: "min-w-0 truncate text-xs font-mono text-foreground", children: file })
356
- ]
357
- },
358
- file
359
- );
360
- }) }) : null
361
- ]
362
- }
363
- );
364
- });
365
- GlobResultsPreview.displayName = "GlobResultsPreview";
366
-
367
- // src/tool-previews/web-search-preview.tsx
368
- import { memo as memo5, useMemo as useMemo3 } from "react";
369
- import { Globe } from "lucide-react";
370
- import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
371
- function coerceString3(value) {
372
- return typeof value === "string" && value.trim() ? value : void 0;
373
- }
374
- function extractQuery(input, output) {
375
- if (input && typeof input === "object") {
376
- const record = input;
377
- const query = coerceString3(record.query) ?? coerceString3(record.url);
378
- if (query) return query;
379
- }
380
- if (output && typeof output === "object") {
381
- const record = output;
382
- return coerceString3(record.query);
383
- }
384
- return void 0;
385
- }
386
- function parseResult(value) {
387
- if (!value || typeof value !== "object") {
388
- return null;
389
- }
390
- const record = value;
391
- const title = coerceString3(record.title) ?? coerceString3(record.name) ?? "Untitled result";
392
- const url = coerceString3(record.url) ?? coerceString3(record.link);
393
- if (!url) {
394
- return null;
395
- }
396
- return {
397
- title,
398
- url,
399
- snippet: coerceString3(record.snippet) ?? coerceString3(record.description) ?? coerceString3(record.text)
400
- };
401
- }
402
- function extractResults(output) {
403
- if (output && typeof output === "object") {
404
- const record = output;
405
- const candidate = record.results ?? record.items ?? record.output;
406
- if (Array.isArray(candidate)) {
407
- return candidate.map(parseResult).filter((value) => value !== null);
408
- }
409
- }
410
- if (Array.isArray(output)) {
411
- return output.map(parseResult).filter((value) => value !== null);
412
- }
413
- return [];
414
- }
415
- var WebSearchPreview = memo5(({ part }) => {
416
- const query = extractQuery(part.state.input, part.state.output);
417
- const results = useMemo3(() => extractResults(part.state.output), [part.state.output]);
418
- return /* @__PURE__ */ jsxs6(
419
- PreviewCard,
420
- {
421
- icon: /* @__PURE__ */ jsx6(Globe, { className: "h-4 w-4" }),
422
- title: query ? `Web results for ${query}` : "Web results",
423
- description: results.length > 0 ? `${results.length} result${results.length === 1 ? "" : "s"}` : void 0,
424
- children: [
425
- part.state.status === "running" ? /* @__PURE__ */ jsx6(PreviewLoading, { label: "Searching the web\u2026" }) : null,
426
- part.state.error ? /* @__PURE__ */ jsx6(PreviewError, { error: part.state.error }) : null,
427
- part.state.status === "completed" && results.length === 0 ? /* @__PURE__ */ jsx6(PreviewEmpty, { label: "No web results were returned." }) : null,
428
- /* @__PURE__ */ jsx6("div", { className: "space-y-2", children: results.map((result) => /* @__PURE__ */ jsxs6(
429
- "a",
430
- {
431
- href: result.url,
432
- target: "_blank",
433
- rel: "noreferrer",
434
- className: `block rounded-[var(--radius-md)] border border-border bg-muted/55 px-3 py-3 transition-colors hover:border-[var(--border-strong)] hover:bg-accent/50 ${focusRing}`,
435
- children: [
436
- /* @__PURE__ */ jsx6("div", { className: "text-sm font-medium text-foreground", children: result.title }),
437
- /* @__PURE__ */ jsx6("div", { className: "mt-1 truncate text-xs text-primary", children: result.url }),
438
- result.snippet ? /* @__PURE__ */ jsx6("p", { className: "mt-2 text-sm leading-relaxed text-muted-foreground", children: result.snippet }) : null
439
- ]
440
- },
441
- result.url
442
- )) })
443
- ]
444
- }
445
- );
446
- });
447
- WebSearchPreview.displayName = "WebSearchPreview";
448
-
449
- // src/tool-previews/question-preview.tsx
450
- import { memo as memo6, useMemo as useMemo4 } from "react";
451
- import { MessageSquareQuote } from "lucide-react";
452
- import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
453
- function toQuestionList(input) {
454
- if (!input) {
455
- return [];
456
- }
457
- if (typeof input === "string") {
458
- return [input];
459
- }
460
- if (Array.isArray(input)) {
461
- return input.map((item) => String(item)).filter(Boolean);
462
- }
463
- if (typeof input === "object") {
464
- const record = input;
465
- const value = record.questions ?? record.question ?? record.prompt;
466
- if (Array.isArray(value)) {
467
- return value.map((item) => String(item)).filter(Boolean);
468
- }
469
- if (typeof value === "string") {
470
- return [value];
471
- }
472
- }
473
- return [];
474
- }
475
- function toAnswerList(output) {
476
- if (!output) {
477
- return [];
478
- }
479
- if (typeof output === "string") {
480
- return [output];
481
- }
482
- if (Array.isArray(output)) {
483
- return output.map((item) => String(item)).filter(Boolean);
484
- }
485
- if (typeof output === "object") {
486
- const record = output;
487
- const value = record.answers ?? record.answer ?? record.response;
488
- if (Array.isArray(value)) {
489
- return value.map((item) => String(item)).filter(Boolean);
490
- }
491
- if (typeof value === "string") {
492
- return [value];
493
- }
494
- }
495
- return [];
496
- }
497
- var QuestionPreview = memo6(({ part }) => {
498
- const questions = useMemo4(() => toQuestionList(part.state.input), [part.state.input]);
499
- const answers = useMemo4(() => toAnswerList(part.state.output), [part.state.output]);
500
- return /* @__PURE__ */ jsxs7(
501
- PreviewCard,
502
- {
503
- icon: /* @__PURE__ */ jsx7(MessageSquareQuote, { className: "h-4 w-4" }),
504
- title: "Agent question",
505
- description: questions.length > 1 ? `${questions.length} questions require attention` : void 0,
506
- children: [
507
- part.state.status === "running" ? /* @__PURE__ */ jsx7(PreviewLoading, { label: "Waiting for an answer\u2026" }) : null,
508
- part.state.error ? /* @__PURE__ */ jsx7(PreviewError, { error: part.state.error }) : null,
509
- questions.length === 0 ? /* @__PURE__ */ jsx7(PreviewEmpty, { label: "No question text was provided." }) : null,
510
- questions.map((question, index) => /* @__PURE__ */ jsxs7(
511
- "div",
512
- {
513
- className: "rounded-[var(--radius-md)] border border-border bg-muted px-3 py-3",
514
- children: [
515
- /* @__PURE__ */ jsxs7("div", { className: "text-xs font-semibold uppercase tracking-[0.08em] text-muted-foreground", children: [
516
- "Question ",
517
- index + 1
518
- ] }),
519
- /* @__PURE__ */ jsx7("div", { className: "mt-2 text-sm leading-relaxed text-foreground", children: question }),
520
- /* @__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") })
521
- ]
522
- },
523
- `${question}-${index}`
524
- ))
525
- ]
526
- }
527
- );
528
- });
529
- QuestionPreview.displayName = "QuestionPreview";
530
-
531
- // src/tool-previews/diff-preview.tsx
532
- import { memo as memo7 } from "react";
533
- import { GitCompareArrows } from "lucide-react";
534
- import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
535
- function extractString(record, ...keys) {
536
- for (const key of keys) {
537
- const value = record[key];
538
- if (typeof value === "string" && value.length > 0) {
539
- return value;
540
- }
541
- }
542
- return void 0;
543
- }
544
- function extractDiffPayload(part) {
545
- const sources = [part.state.input, part.state.output, part.state.metadata];
546
- for (const source of sources) {
547
- if (!source || typeof source !== "object") {
548
- continue;
549
- }
550
- const record = source;
551
- const diff = extractString(record, "diff", "patch", "unifiedDiff", "unified_diff");
552
- const before = extractString(record, "oldString", "old_string", "before", "previous");
553
- const after = extractString(record, "newString", "new_string", "after", "updated");
554
- const path = extractString(record, "file_path", "filePath", "path");
555
- if (diff || before || after) {
556
- return { path, diff, before, after };
557
- }
558
- }
559
- return {};
560
- }
561
- var DiffPreview = memo7(({ part }) => {
562
- const payload = extractDiffPayload(part);
563
- return /* @__PURE__ */ jsxs8(
564
- PreviewCard,
565
- {
566
- icon: /* @__PURE__ */ jsx8(GitCompareArrows, { className: "h-4 w-4" }),
567
- title: payload.path ? `Changes for ${payload.path}` : "File changes",
568
- children: [
569
- part.state.status === "running" ? /* @__PURE__ */ jsx8(PreviewLoading, { label: "Computing changes\u2026" }) : null,
570
- part.state.error ? /* @__PURE__ */ jsx8(PreviewError, { error: part.state.error }) : null,
571
- !payload.diff && !payload.before && !payload.after ? /* @__PURE__ */ jsx8(PreviewEmpty, { label: "No structured diff payload was provided." }) : null,
572
- payload.diff ? /* @__PURE__ */ jsx8(CodeBlock, { code: payload.diff, language: "diff", className: "rounded-[var(--radius-md)]" }) : null,
573
- !payload.diff && payload.before ? /* @__PURE__ */ jsxs8("div", { className: "space-y-2", children: [
574
- /* @__PURE__ */ jsx8("div", { className: "text-xs font-semibold uppercase tracking-[0.08em] text-muted-foreground", children: "Before" }),
575
- /* @__PURE__ */ jsx8(CodeBlock, { code: payload.before, language: "text", className: "rounded-[var(--radius-md)]" })
576
- ] }) : null,
577
- !payload.diff && payload.after ? /* @__PURE__ */ jsxs8("div", { className: "space-y-2", children: [
578
- /* @__PURE__ */ jsx8("div", { className: "text-xs font-semibold uppercase tracking-[0.08em] text-muted-foreground", children: "After" }),
579
- /* @__PURE__ */ jsx8(CodeBlock, { code: payload.after, language: "text", className: "rounded-[var(--radius-md)]" })
580
- ] }) : null
581
- ]
582
- }
583
- );
584
- });
585
- DiffPreview.displayName = "DiffPreview";
586
-
587
- export {
588
- CommandPreview,
589
- WriteFilePreview,
590
- GrepResultsPreview,
591
- GlobResultsPreview,
592
- WebSearchPreview,
593
- QuestionPreview,
594
- DiffPreview
595
- };