@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.
- package/CHANGELOG.md +30 -0
- package/README.md +14 -0
- package/dist/active-sessions-store-Gt1R0rFG.js +262 -0
- package/dist/{active-sessions-store-CeOmXgv5.d.ts → active-sessions-store-nl70ZnMC.d.ts} +40 -41
- package/dist/artifact-pane-BL_DFWNl.d.ts +32 -0
- package/dist/artifact-pane-DMXT9a8U.js +70 -0
- package/dist/auth-DixfCMCk.js +154 -0
- package/dist/auth.d.ts +2 -74
- package/dist/auth.js +2 -15
- package/dist/branding-26d5ARIr.d.ts +14 -0
- package/dist/button-uhNnwdsD.js +78 -0
- package/dist/button-yoIv77e2.d.ts +16 -0
- package/dist/chat-CPLL0Fd9.js +667 -0
- package/dist/chat.d.ts +2 -201
- package/dist/chat.js +2 -30
- package/dist/code-block-B9miUPht.d.ts +23 -0
- package/dist/code-block-CngSn37j.js +165 -0
- package/dist/diff-preview-cySuqowW.js +533 -0
- package/dist/document-editor-pane-BcoABlhn.d.ts +131 -0
- package/dist/document-editor-pane-Cz6oEF1o.js +1287 -0
- package/dist/dropdown-menu-BpcLa5vF.js +101 -0
- package/dist/editor.d.ts +76 -78
- package/dist/editor.js +2 -33
- package/dist/file-format-BgXbr-Ib.js +160 -0
- package/dist/files-CYlOo0mE.js +743 -0
- package/dist/files.d.ts +2 -243
- package/dist/files.js +3 -40
- package/dist/focus-Cw02pNSr.js +56 -0
- package/dist/format-DfcLWqMa.js +54 -0
- package/dist/hooks.d.ts +30 -37
- package/dist/hooks.js +111 -45
- package/dist/index-2UntyjBb.d.ts +52 -0
- package/dist/index-COgqsFAQ.d.ts +42 -0
- package/dist/index-CPDET_s1.d.ts +549 -0
- package/dist/index-CUhfHT_V.d.ts +204 -0
- package/dist/index-Cg6gYAqh.d.ts +73 -0
- package/dist/index-Cq-EJzqW.d.ts +16 -0
- package/dist/index-DhYmSaLF.d.ts +245 -0
- package/dist/index-DjKxO357.d.ts +128 -0
- package/dist/index-b56ew9aF.d.ts +107 -0
- package/dist/index.d.ts +26 -43
- package/dist/index.js +35 -460
- package/dist/markdown-BprL96Gl.js +45 -0
- package/dist/markdown.d.ts +3 -18
- package/dist/markdown.js +3 -14
- package/dist/message-vhUI0c5G.d.ts +16 -0
- package/dist/nav.d.ts +6 -8
- package/dist/nav.js +29 -11
- package/dist/openui-artifact-renderer-D3E5bIAI.d.ts +114 -0
- package/dist/openui-artifact-renderer-DT4xbvWt.js +266 -0
- package/dist/openui.d.ts +2 -115
- package/dist/openui.js +2 -12
- package/dist/parts-5mhy9yJ3.d.ts +37 -0
- package/dist/primitives-DE-blUz-.js +1239 -0
- package/dist/primitives.d.ts +5 -523
- package/dist/primitives.js +9 -211
- package/dist/redaction-CGGB2ENG.js +74 -0
- package/dist/redaction.d.ts +2 -42
- package/dist/redaction.js +2 -7
- package/dist/run-OyWmIDqu.d.ts +41 -0
- package/dist/run-ZsIKPA6J.js +17 -0
- package/dist/run-group-D1InSdQu.js +410 -0
- package/dist/run.d.ts +3 -126
- package/dist/run.js +5 -39
- package/dist/sdk-hooks.d.ts +2 -285
- package/dist/sdk-hooks.js +3 -35
- package/dist/stores.d.ts +13 -14
- package/dist/stores.js +34 -76
- package/dist/table-DHyqDPbU.js +146 -0
- package/dist/tabs-ujuqAdtb.js +40 -0
- package/dist/text-shimmer-BUUo6I-g.js +64 -0
- package/dist/tool-call-feed-BeB1_4pX.d.ts +47 -0
- package/dist/tool-call-feed-C1W1N54c.js +109 -0
- package/dist/tool-call-step-Bi3_YJRV.js +434 -0
- package/dist/tool-display-BAuAVa43.js +158 -0
- package/dist/{tool-display-z4JcDmMQ.d.ts → tool-display-DgmL5rIU.d.ts} +16 -16
- package/dist/tool-previews.d.ts +2 -48
- package/dist/tool-previews.js +2 -22
- package/dist/types.d.ts +6 -19
- package/dist/types.js +0 -1
- package/dist/use-auto-scroll-C5Pjeqon.js +153 -0
- package/dist/use-sse-stream-BjVBDbxK.js +884 -0
- package/dist/use-sse-stream-Dm6R5YWz.d.ts +282 -0
- package/dist/utils-Bl_CZ0Qp.js +37 -0
- package/dist/{chunk-RQHJBTEU.js → utils-C_uf36nf.js} +4 -6
- package/dist/utils.d.ts +2 -51
- package/dist/utils.js +6 -32
- package/package.json +39 -41
- package/src/auth/auth.tsx +5 -1
- package/src/chat/agent-timeline.tsx +6 -1
- package/src/chat/chat-container.tsx +2 -1
- package/src/editor/document-editor-pane.test.tsx +3 -1
- package/src/editor/document-editor-pane.tsx +5 -1
- package/src/editor/markdown-document-editor.test.tsx +9 -4
- package/src/files/file-artifact-pane.tsx +3 -2
- package/src/files/file-preview.tsx +3 -1
- package/src/files/file-tabs.tsx +9 -2
- package/src/lib/focus.ts +63 -0
- package/src/markdown/code-block.tsx +5 -1
- package/src/primitives/badge.tsx +2 -1
- package/src/primitives/button.tsx +2 -1
- package/src/primitives/card.tsx +1 -2
- package/src/primitives/dialog.tsx +7 -1
- package/src/primitives/input.tsx +15 -14
- package/src/primitives/segmented-control.tsx +5 -3
- package/src/primitives/select.tsx +3 -1
- package/src/primitives/switch.tsx +3 -1
- package/src/primitives/tabs.tsx +6 -4
- package/src/primitives/terminal-display.tsx +6 -8
- package/src/primitives/toast.tsx +5 -1
- package/src/tool-previews/command-preview.tsx +5 -1
- package/src/tool-previews/web-search-preview.tsx +2 -1
- package/src/utils/index.ts +7 -0
- package/dist/artifact-pane-DpuWcAiF.d.ts +0 -33
- package/dist/button-CMQuQEW_.d.ts +0 -17
- package/dist/chunk-34A66VBG.js +0 -214
- package/dist/chunk-3OI2QKFD.js +0 -0
- package/dist/chunk-3TI5DEHV.js +0 -299
- package/dist/chunk-4CLN43XT.js +0 -45
- package/dist/chunk-565EATZZ.js +0 -156
- package/dist/chunk-5Z5ZYMOJ.js +0 -0
- package/dist/chunk-6BGQA4BQ.js +0 -0
- package/dist/chunk-7YOCS6IF.js +0 -728
- package/dist/chunk-EOAX2ENE.js +0 -60
- package/dist/chunk-GYPQXTJU.js +0 -230
- package/dist/chunk-HFL6R6IF.js +0 -37
- package/dist/chunk-HGML45QH.js +0 -104
- package/dist/chunk-KNYSKNZX.js +0 -550
- package/dist/chunk-L57WRIND.js +0 -59
- package/dist/chunk-LDLOJKPC.js +0 -1585
- package/dist/chunk-LTEKI7YJ.js +0 -59
- package/dist/chunk-MKTSMWVD.js +0 -109
- package/dist/chunk-ND3ZFXQK.js +0 -179
- package/dist/chunk-NKDZ7GZE.js +0 -192
- package/dist/chunk-NWECTSOH.js +0 -589
- package/dist/chunk-OEX7NZE3.js +0 -321
- package/dist/chunk-Q56BYXQF.js +0 -61
- package/dist/chunk-REJESC5U.js +0 -117
- package/dist/chunk-RQGKSCEZ.js +0 -0
- package/dist/chunk-TN4FUEWY.js +0 -437
- package/dist/chunk-VPWY4I5O.js +0 -1048
- package/dist/chunk-WUQDUBJG.js +0 -168
- package/dist/chunk-XGKULLYE.js +0 -40
- package/dist/chunk-XU3HB5QL.js +0 -127
- package/dist/chunk-XYAIX4SU.js +0 -133
- package/dist/chunk-YJ6RE5WV.js +0 -875
- package/dist/chunk-YTO5V6QS.js +0 -19
- package/dist/chunk-ZKCEAIIZ.js +0 -1395
- package/dist/code-block-0kSpWMnf.d.ts +0 -25
- package/dist/document-editor-pane-EX25CEYW.js +0 -12
- package/dist/document-editor-pane-IAEQn_Dl.d.ts +0 -128
- package/dist/message-BHWbxBtT.d.ts +0 -15
- package/dist/parts-dj7AcUg0.d.ts +0 -36
- package/dist/run-PfLmDAox.d.ts +0 -41
- package/dist/tool-call-feed-D9iofJgW.d.ts +0 -46
package/dist/chunk-WUQDUBJG.js
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
cn
|
|
3
|
-
} from "./chunk-RQHJBTEU.js";
|
|
4
|
-
|
|
5
|
-
// src/markdown/code-block.tsx
|
|
6
|
-
import {
|
|
7
|
-
memo,
|
|
8
|
-
useCallback,
|
|
9
|
-
useEffect,
|
|
10
|
-
useRef,
|
|
11
|
-
useState
|
|
12
|
-
} from "react";
|
|
13
|
-
import SyntaxHighlighter from "react-syntax-highlighter";
|
|
14
|
-
import { Check, Copy } from "lucide-react";
|
|
15
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
16
|
-
function getSyntaxTheme() {
|
|
17
|
-
const el = typeof document !== "undefined" ? document.documentElement : null;
|
|
18
|
-
const v = (name, fallback) => el ? getComputedStyle(el).getPropertyValue(name).trim() || fallback : fallback;
|
|
19
|
-
const comment = v("--syntax-comment", "#6B7094");
|
|
20
|
-
const keyword = v("--syntax-keyword", "#A78FFF");
|
|
21
|
-
const string = v("--syntax-string", "#10b981");
|
|
22
|
-
const fn = v("--syntax-function", "#6D9FFF");
|
|
23
|
-
const number = v("--syntax-number", "#FFB347");
|
|
24
|
-
const meta = v("--syntax-meta", "#8263FF");
|
|
25
|
-
const error = v("--syntax-error", "#FF4D6D");
|
|
26
|
-
const variable = v("--syntax-variable", "#C4C0D8");
|
|
27
|
-
const fg = v("--syntax-foreground", "#E8E6F6");
|
|
28
|
-
return {
|
|
29
|
-
"hljs-comment": { color: comment, fontStyle: "italic" },
|
|
30
|
-
"hljs-quote": { color: comment, fontStyle: "italic" },
|
|
31
|
-
"hljs-doctag": { color: comment },
|
|
32
|
-
"hljs-keyword": { color: keyword },
|
|
33
|
-
"hljs-selector-tag": { color: keyword },
|
|
34
|
-
"hljs-literal": { color: keyword },
|
|
35
|
-
"hljs-type": { color: keyword },
|
|
36
|
-
"hljs-class": { color: keyword },
|
|
37
|
-
"hljs-string": { color: string },
|
|
38
|
-
"hljs-template-tag": { color: string },
|
|
39
|
-
"hljs-template-variable": { color: string },
|
|
40
|
-
"hljs-addition": { color: string },
|
|
41
|
-
"hljs-regexp": { color: string },
|
|
42
|
-
"hljs-title": { color: fn },
|
|
43
|
-
"hljs-section": { color: fn },
|
|
44
|
-
"hljs-built_in": { color: fn },
|
|
45
|
-
"hljs-name": { color: fn },
|
|
46
|
-
"hljs-function": { color: fn },
|
|
47
|
-
"hljs-selector-id": { color: fn },
|
|
48
|
-
"hljs-selector-class": { color: fn },
|
|
49
|
-
"hljs-attribute": { color: fn },
|
|
50
|
-
"hljs-number": { color: number },
|
|
51
|
-
"hljs-symbol": { color: number },
|
|
52
|
-
"hljs-bullet": { color: number },
|
|
53
|
-
"hljs-link": { color: number, textDecoration: "underline" },
|
|
54
|
-
"hljs-meta": { color: meta },
|
|
55
|
-
"hljs-selector-pseudo": { color: meta },
|
|
56
|
-
"hljs-deletion": { color: error },
|
|
57
|
-
"hljs-params": { color: variable },
|
|
58
|
-
"hljs-variable": { color: variable },
|
|
59
|
-
"hljs-tag": { color: variable },
|
|
60
|
-
"hljs-attr": { color: variable },
|
|
61
|
-
"hljs-subst": { color: variable },
|
|
62
|
-
"hljs-strong": { fontWeight: "bold" },
|
|
63
|
-
"hljs-emphasis": { fontStyle: "italic" },
|
|
64
|
-
"hljs": { color: fg, background: "transparent" }
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
var LIGHT_THEMES = /* @__PURE__ */ new Set(["vault", "dawn"]);
|
|
68
|
-
function detectLightTheme() {
|
|
69
|
-
return typeof document !== "undefined" && LIGHT_THEMES.has(document.documentElement.getAttribute("data-sandbox-theme") ?? "");
|
|
70
|
-
}
|
|
71
|
-
function useIsLightTheme() {
|
|
72
|
-
const [isLight, setIsLight] = useState(detectLightTheme);
|
|
73
|
-
useEffect(() => {
|
|
74
|
-
if (typeof document === "undefined") return;
|
|
75
|
-
setIsLight(detectLightTheme());
|
|
76
|
-
const observer = new MutationObserver(() => setIsLight(detectLightTheme()));
|
|
77
|
-
observer.observe(document.documentElement, {
|
|
78
|
-
attributes: true,
|
|
79
|
-
attributeFilter: ["data-sandbox-theme"]
|
|
80
|
-
});
|
|
81
|
-
return () => observer.disconnect();
|
|
82
|
-
}, []);
|
|
83
|
-
return isLight;
|
|
84
|
-
}
|
|
85
|
-
var CodeBlock = memo(
|
|
86
|
-
({ code, language, label, showLineNumbers = false, light: lightProp, className, children, ...props }) => {
|
|
87
|
-
const isLight = useIsLightTheme();
|
|
88
|
-
const light = lightProp ?? isLight;
|
|
89
|
-
const theme = getSyntaxTheme();
|
|
90
|
-
const bg = "bg-card border-border";
|
|
91
|
-
const headerBg = light ? "bg-muted/50 border-border" : "bg-background border-border";
|
|
92
|
-
const langColor = "text-muted-foreground";
|
|
93
|
-
const headerLabel = label ?? language;
|
|
94
|
-
return /* @__PURE__ */ jsxs(
|
|
95
|
-
"div",
|
|
96
|
-
{
|
|
97
|
-
className: cn("group relative overflow-hidden rounded-lg border font-mono", bg, className),
|
|
98
|
-
...props,
|
|
99
|
-
children: [
|
|
100
|
-
headerLabel && /* @__PURE__ */ jsxs("div", { className: cn("flex items-center justify-between border-b px-3 py-1", headerBg), children: [
|
|
101
|
-
/* @__PURE__ */ jsx("span", { className: cn("text-[calc(var(--font-size-xs)-1px)] font-mono font-medium uppercase tracking-widest", langColor), children: headerLabel }),
|
|
102
|
-
children
|
|
103
|
-
] }),
|
|
104
|
-
!headerLabel && children && /* @__PURE__ */ jsx("div", { className: "absolute right-2 top-2 z-10 flex items-center gap-2 opacity-0 transition-opacity group-hover:opacity-100", children }),
|
|
105
|
-
/* @__PURE__ */ jsx(
|
|
106
|
-
SyntaxHighlighter,
|
|
107
|
-
{
|
|
108
|
-
language: language ?? "text",
|
|
109
|
-
style: theme,
|
|
110
|
-
showLineNumbers,
|
|
111
|
-
lineNumberStyle: {
|
|
112
|
-
color: light ? "#8B92B8" : "#4A4D6A",
|
|
113
|
-
minWidth: "2.5em",
|
|
114
|
-
paddingRight: "1em"
|
|
115
|
-
},
|
|
116
|
-
customStyle: {
|
|
117
|
-
margin: 0,
|
|
118
|
-
padding: "var(--code-padding-y, 0.625rem) var(--code-padding-x, 0.75rem)",
|
|
119
|
-
background: "transparent",
|
|
120
|
-
fontSize: "var(--code-font-size, 0.8125rem)",
|
|
121
|
-
lineHeight: "var(--code-line-height, 1.5)",
|
|
122
|
-
overflowX: "auto"
|
|
123
|
-
},
|
|
124
|
-
codeTagProps: { style: { fontFamily: "var(--font-mono, 'JetBrains Mono', ui-monospace, monospace)" } },
|
|
125
|
-
wrapLines: false,
|
|
126
|
-
children: code
|
|
127
|
-
}
|
|
128
|
-
)
|
|
129
|
-
]
|
|
130
|
-
}
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
);
|
|
134
|
-
CodeBlock.displayName = "CodeBlock";
|
|
135
|
-
var CopyButton = memo(({ text }) => {
|
|
136
|
-
const [copied, setCopied] = useState(false);
|
|
137
|
-
const timerRef = useRef(null);
|
|
138
|
-
useEffect(() => {
|
|
139
|
-
return () => {
|
|
140
|
-
if (timerRef.current) clearTimeout(timerRef.current);
|
|
141
|
-
};
|
|
142
|
-
}, []);
|
|
143
|
-
const handleCopy = useCallback(async () => {
|
|
144
|
-
try {
|
|
145
|
-
await navigator.clipboard.writeText(text);
|
|
146
|
-
setCopied(true);
|
|
147
|
-
if (timerRef.current) clearTimeout(timerRef.current);
|
|
148
|
-
timerRef.current = setTimeout(() => setCopied(false), 2e3);
|
|
149
|
-
} catch (err) {
|
|
150
|
-
console.warn("Clipboard write failed:", err);
|
|
151
|
-
}
|
|
152
|
-
}, [text]);
|
|
153
|
-
return /* @__PURE__ */ jsx(
|
|
154
|
-
"button",
|
|
155
|
-
{
|
|
156
|
-
onClick: handleCopy,
|
|
157
|
-
className: "flex items-center justify-center w-6 h-6 rounded-md bg-muted border border-border hover:border-primary/20 transition-colors",
|
|
158
|
-
title: "Copy to clipboard",
|
|
159
|
-
children: copied ? /* @__PURE__ */ jsx(Check, { className: "w-3.5 h-3.5 text-emerald-500" }) : /* @__PURE__ */ jsx(Copy, { className: "w-3.5 h-3.5 text-muted-foreground" })
|
|
160
|
-
}
|
|
161
|
-
);
|
|
162
|
-
});
|
|
163
|
-
CopyButton.displayName = "CopyButton";
|
|
164
|
-
|
|
165
|
-
export {
|
|
166
|
-
CodeBlock,
|
|
167
|
-
CopyButton
|
|
168
|
-
};
|
package/dist/chunk-XGKULLYE.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
// src/utils/copy-text.ts
|
|
2
|
-
async function copyText(text) {
|
|
3
|
-
if (typeof navigator !== "undefined" && navigator.clipboard?.writeText) {
|
|
4
|
-
try {
|
|
5
|
-
await navigator.clipboard.writeText(text);
|
|
6
|
-
return true;
|
|
7
|
-
} catch {
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
if (typeof document === "undefined") return false;
|
|
11
|
-
try {
|
|
12
|
-
const textarea = document.createElement("textarea");
|
|
13
|
-
textarea.value = text;
|
|
14
|
-
textarea.style.position = "fixed";
|
|
15
|
-
textarea.style.opacity = "0";
|
|
16
|
-
document.body.appendChild(textarea);
|
|
17
|
-
textarea.select();
|
|
18
|
-
const copied = document.execCommand("copy");
|
|
19
|
-
document.body.removeChild(textarea);
|
|
20
|
-
return copied;
|
|
21
|
-
} catch {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// src/utils/time-ago.ts
|
|
27
|
-
function timeAgo(ts) {
|
|
28
|
-
const secs = Math.floor((Date.now() - ts) / 1e3);
|
|
29
|
-
if (secs < 5) return "just now";
|
|
30
|
-
if (secs < 60) return `${secs}s ago`;
|
|
31
|
-
const mins = Math.floor(secs / 60);
|
|
32
|
-
if (mins < 60) return `${mins}m ago`;
|
|
33
|
-
const hrs = Math.floor(mins / 60);
|
|
34
|
-
return `${hrs}h ago`;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export {
|
|
38
|
-
copyText,
|
|
39
|
-
timeAgo
|
|
40
|
-
};
|
package/dist/chunk-XU3HB5QL.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
// src/files/file-format.ts
|
|
2
|
-
var IMAGE_EXTENSIONS = ["png", "jpg", "jpeg", "gif", "svg", "webp", "avif"];
|
|
3
|
-
var VIDEO_EXTENSIONS = ["mp4", "webm", "mov"];
|
|
4
|
-
var AUDIO_EXTENSIONS = ["mp3", "wav", "ogg", "m4a"];
|
|
5
|
-
var SPREADSHEET_MIME_TYPES = [
|
|
6
|
-
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
7
|
-
"application/vnd.ms-excel"
|
|
8
|
-
];
|
|
9
|
-
var EXTENSION_TO_SYNTAX_LANGUAGE = {
|
|
10
|
-
ts: "typescript",
|
|
11
|
-
tsx: "tsx",
|
|
12
|
-
js: "javascript",
|
|
13
|
-
jsx: "jsx",
|
|
14
|
-
mjs: "javascript",
|
|
15
|
-
cjs: "javascript",
|
|
16
|
-
rs: "rust",
|
|
17
|
-
py: "python",
|
|
18
|
-
go: "go",
|
|
19
|
-
rb: "ruby",
|
|
20
|
-
json: "json",
|
|
21
|
-
yaml: "yaml",
|
|
22
|
-
yml: "yaml",
|
|
23
|
-
toml: "toml",
|
|
24
|
-
md: "markdown",
|
|
25
|
-
markdown: "markdown",
|
|
26
|
-
css: "css",
|
|
27
|
-
scss: "scss",
|
|
28
|
-
html: "html",
|
|
29
|
-
sh: "bash",
|
|
30
|
-
bash: "bash",
|
|
31
|
-
zsh: "bash",
|
|
32
|
-
bashrc: "bash",
|
|
33
|
-
bash_logout: "bash",
|
|
34
|
-
profile: "bash",
|
|
35
|
-
sql: "sql",
|
|
36
|
-
sol: "solidity",
|
|
37
|
-
proto: "protobuf"
|
|
38
|
-
};
|
|
39
|
-
var NON_CODE_SYNTAX_EXTENSIONS = /* @__PURE__ */ new Set(["json", "yaml", "yml", "md", "markdown"]);
|
|
40
|
-
var PLAIN_CODE_EXTENSIONS = ["env", "gitignore"];
|
|
41
|
-
var CODE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
42
|
-
...Object.keys(EXTENSION_TO_SYNTAX_LANGUAGE).filter((ext) => !NON_CODE_SYNTAX_EXTENSIONS.has(ext)),
|
|
43
|
-
...PLAIN_CODE_EXTENSIONS
|
|
44
|
-
]);
|
|
45
|
-
function fileExtension(filename) {
|
|
46
|
-
const base = filename.slice(filename.lastIndexOf("/") + 1);
|
|
47
|
-
const dot = base.lastIndexOf(".");
|
|
48
|
-
if (dot < 0) return "";
|
|
49
|
-
return base.slice(dot + 1).toLowerCase();
|
|
50
|
-
}
|
|
51
|
-
function mimeEssence(mimeType) {
|
|
52
|
-
return mimeType?.split(";")[0]?.trim().toLowerCase() ?? "";
|
|
53
|
-
}
|
|
54
|
-
function detectFileFormat(filename, mimeType) {
|
|
55
|
-
const ext = fileExtension(filename);
|
|
56
|
-
const mime = mimeEssence(mimeType);
|
|
57
|
-
if (mime === "application/pdf") return "pdf";
|
|
58
|
-
if (mime.startsWith("image/")) return "image";
|
|
59
|
-
if (mime.startsWith("video/")) return "video";
|
|
60
|
-
if (mime.startsWith("audio/")) return "audio";
|
|
61
|
-
if (mime === "text/markdown") return "markdown";
|
|
62
|
-
if (mime === "application/json") return "json";
|
|
63
|
-
if (mime === "text/csv" || mime === "application/csv") return "csv";
|
|
64
|
-
if (SPREADSHEET_MIME_TYPES.includes(mime)) return "spreadsheet";
|
|
65
|
-
if (mime === "application/yaml" || mime === "application/x-yaml" || mime === "text/yaml") return "yaml";
|
|
66
|
-
if (ext === "pdf") return "pdf";
|
|
67
|
-
if (IMAGE_EXTENSIONS.includes(ext)) return "image";
|
|
68
|
-
if (VIDEO_EXTENSIONS.includes(ext)) return "video";
|
|
69
|
-
if (AUDIO_EXTENSIONS.includes(ext)) return "audio";
|
|
70
|
-
if (ext === "csv") return "csv";
|
|
71
|
-
if (ext === "xlsx" || ext === "xls") return "spreadsheet";
|
|
72
|
-
if (CODE_EXTENSIONS.has(ext)) return "code";
|
|
73
|
-
if (ext === "json") return "json";
|
|
74
|
-
if (ext === "yaml" || ext === "yml") return "yaml";
|
|
75
|
-
if (ext === "md" || ext === "markdown") return "markdown";
|
|
76
|
-
if (["txt", "log", "text"].includes(ext)) return "text";
|
|
77
|
-
if (mime === "text/plain") return "text";
|
|
78
|
-
return "unknown";
|
|
79
|
-
}
|
|
80
|
-
function resolveFilePreviewKind(filename, mimeType) {
|
|
81
|
-
const format = detectFileFormat(filename, mimeType);
|
|
82
|
-
return format === "unknown" ? "binary" : format;
|
|
83
|
-
}
|
|
84
|
-
function getFormatLabel(format) {
|
|
85
|
-
switch (format) {
|
|
86
|
-
case "pdf":
|
|
87
|
-
return "PDF";
|
|
88
|
-
case "image":
|
|
89
|
-
return "Image";
|
|
90
|
-
case "video":
|
|
91
|
-
return "Video";
|
|
92
|
-
case "audio":
|
|
93
|
-
return "Audio";
|
|
94
|
-
case "csv":
|
|
95
|
-
return "CSV";
|
|
96
|
-
case "spreadsheet":
|
|
97
|
-
return "Spreadsheet";
|
|
98
|
-
case "code":
|
|
99
|
-
return "Code";
|
|
100
|
-
case "json":
|
|
101
|
-
return "JSON";
|
|
102
|
-
case "yaml":
|
|
103
|
-
return "YAML";
|
|
104
|
-
case "markdown":
|
|
105
|
-
return "Markdown";
|
|
106
|
-
case "text":
|
|
107
|
-
return "Text";
|
|
108
|
-
default:
|
|
109
|
-
return "File";
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
function getSyntaxLanguage(filename) {
|
|
113
|
-
return EXTENSION_TO_SYNTAX_LANGUAGE[fileExtension(filename)];
|
|
114
|
-
}
|
|
115
|
-
function getCodeLanguage(filename, format) {
|
|
116
|
-
if (format === "json" || format === "yaml") return format;
|
|
117
|
-
return getSyntaxLanguage(filename);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export {
|
|
121
|
-
fileExtension,
|
|
122
|
-
detectFileFormat,
|
|
123
|
-
resolveFilePreviewKind,
|
|
124
|
-
getFormatLabel,
|
|
125
|
-
getSyntaxLanguage,
|
|
126
|
-
getCodeLanguage
|
|
127
|
-
};
|
package/dist/chunk-XYAIX4SU.js
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ToolCallGroup,
|
|
3
|
-
ToolCallStep
|
|
4
|
-
} from "./chunk-KNYSKNZX.js";
|
|
5
|
-
import {
|
|
6
|
-
Markdown
|
|
7
|
-
} from "./chunk-EOAX2ENE.js";
|
|
8
|
-
import {
|
|
9
|
-
cn
|
|
10
|
-
} from "./chunk-RQHJBTEU.js";
|
|
11
|
-
|
|
12
|
-
// src/run/tool-call-feed.tsx
|
|
13
|
-
import { jsx } from "react/jsx-runtime";
|
|
14
|
-
function ToolCallFeed({ segments, className }) {
|
|
15
|
-
if (segments.length === 0) return null;
|
|
16
|
-
return /* @__PURE__ */ jsx("div", { className: cn("space-y-1", className), children: segments.map((segment, i) => {
|
|
17
|
-
if (segment.kind === "text") {
|
|
18
|
-
return segment.content.trim() ? /* @__PURE__ */ jsx(Markdown, { children: segment.content }, i) : null;
|
|
19
|
-
}
|
|
20
|
-
if (segment.kind === "tool_call") {
|
|
21
|
-
return /* @__PURE__ */ jsx(
|
|
22
|
-
ToolCallStep,
|
|
23
|
-
{
|
|
24
|
-
type: segment.call.type,
|
|
25
|
-
label: segment.call.label,
|
|
26
|
-
status: segment.call.status,
|
|
27
|
-
detail: segment.call.detail,
|
|
28
|
-
output: segment.call.output,
|
|
29
|
-
duration: segment.call.duration
|
|
30
|
-
},
|
|
31
|
-
segment.call.id || i
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
if (segment.kind === "tool_group") {
|
|
35
|
-
return /* @__PURE__ */ jsx(ToolCallGroup, { title: segment.title, children: segment.calls.map((call) => /* @__PURE__ */ jsx(
|
|
36
|
-
ToolCallStep,
|
|
37
|
-
{
|
|
38
|
-
type: call.type,
|
|
39
|
-
label: call.label,
|
|
40
|
-
status: call.status,
|
|
41
|
-
detail: call.detail,
|
|
42
|
-
output: call.output,
|
|
43
|
-
duration: call.duration
|
|
44
|
-
},
|
|
45
|
-
call.id
|
|
46
|
-
)) }, i);
|
|
47
|
-
}
|
|
48
|
-
return null;
|
|
49
|
-
}) });
|
|
50
|
-
}
|
|
51
|
-
function parseToolEvent(event) {
|
|
52
|
-
const { type, data } = event;
|
|
53
|
-
if (type === "tool.invocation" || type === "tool_use") {
|
|
54
|
-
const toolName = data.name || data.tool || "unknown";
|
|
55
|
-
const input = data.input;
|
|
56
|
-
return {
|
|
57
|
-
id: data.id || data.toolUseId || createId(),
|
|
58
|
-
type: mapToolName(toolName),
|
|
59
|
-
label: formatToolLabel(toolName, input),
|
|
60
|
-
status: "running",
|
|
61
|
-
detail: input ? formatToolInput(toolName, input) : void 0
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
if (type === "tool.result" || type === "tool_result") {
|
|
65
|
-
return {
|
|
66
|
-
id: data.id || data.toolUseId || "",
|
|
67
|
-
type: mapToolName(data.name || data.tool || "unknown"),
|
|
68
|
-
label: formatToolLabel(data.name || data.tool || "unknown"),
|
|
69
|
-
status: data.error ? "error" : "success",
|
|
70
|
-
output: truncate(data.output || data.result || "", 500),
|
|
71
|
-
duration: data.duration
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
function createId() {
|
|
77
|
-
if (typeof globalThis.crypto !== "undefined" && typeof globalThis.crypto.randomUUID === "function") {
|
|
78
|
-
try {
|
|
79
|
-
return globalThis.crypto.randomUUID();
|
|
80
|
-
} catch {
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return `tool_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
|
|
84
|
-
}
|
|
85
|
-
function mapToolName(name) {
|
|
86
|
-
const lower = name.toLowerCase();
|
|
87
|
-
if (lower.includes("bash") || lower.includes("terminal") || lower.includes("exec")) return "bash";
|
|
88
|
-
if (lower.includes("read") || lower.includes("cat")) return "read";
|
|
89
|
-
if (lower.includes("write") || lower.includes("create")) return "write";
|
|
90
|
-
if (lower.includes("edit") || lower.includes("replace")) return "edit";
|
|
91
|
-
if (lower.includes("glob") || lower.includes("find")) return "glob";
|
|
92
|
-
if (lower.includes("grep") || lower.includes("search")) return "grep";
|
|
93
|
-
if (lower.includes("list") || lower.includes("ls")) return "list";
|
|
94
|
-
if (lower.includes("inspect")) return "inspect";
|
|
95
|
-
if (lower.includes("audit")) return "audit";
|
|
96
|
-
return "unknown";
|
|
97
|
-
}
|
|
98
|
-
function formatToolLabel(toolName, input) {
|
|
99
|
-
const lower = toolName.toLowerCase();
|
|
100
|
-
if (lower.includes("bash") && input?.command) {
|
|
101
|
-
const cmd = String(input.command);
|
|
102
|
-
return cmd.length > 80 ? `${cmd.slice(0, 77)}...` : cmd;
|
|
103
|
-
}
|
|
104
|
-
if ((lower.includes("read") || lower.includes("cat")) && input?.path) {
|
|
105
|
-
return `Read ${input.path}`;
|
|
106
|
-
}
|
|
107
|
-
if (lower.includes("write") && input?.path) {
|
|
108
|
-
return `Write ${input.path}`;
|
|
109
|
-
}
|
|
110
|
-
if (lower.includes("edit") && input?.path) {
|
|
111
|
-
return `Edit ${input.path}`;
|
|
112
|
-
}
|
|
113
|
-
if (lower.includes("glob") && input?.pattern) {
|
|
114
|
-
return `Find ${input.pattern}`;
|
|
115
|
-
}
|
|
116
|
-
if (lower.includes("grep") && input?.pattern) {
|
|
117
|
-
return `Search for ${input.pattern}`;
|
|
118
|
-
}
|
|
119
|
-
return toolName;
|
|
120
|
-
}
|
|
121
|
-
function formatToolInput(toolName, input) {
|
|
122
|
-
if (input.command) return String(input.command);
|
|
123
|
-
if (input.path) return String(input.path);
|
|
124
|
-
return JSON.stringify(input, null, 2).slice(0, 300);
|
|
125
|
-
}
|
|
126
|
-
function truncate(text, max) {
|
|
127
|
-
return text.length > max ? text.slice(0, max - 3) + "..." : text;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export {
|
|
131
|
-
ToolCallFeed,
|
|
132
|
-
parseToolEvent
|
|
133
|
-
};
|