@tangle-network/ui 11.9.0 → 11.11.0

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