@ash-ai/ui 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +54 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -3
- package/dist/index.d.ts +9 -3
- package/dist/index.js +53 -3
- package/dist/index.js.map +1 -1
- package/dist/styles-full.css +22 -0
- package/dist/styles.css +28 -0
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -22,6 +22,7 @@ interface ChatMessage$1 {
|
|
|
22
22
|
role: 'user' | 'assistant' | 'system';
|
|
23
23
|
content: string;
|
|
24
24
|
toolCalls?: ToolCall[];
|
|
25
|
+
thinking?: string[];
|
|
25
26
|
timestamp?: string;
|
|
26
27
|
isStreaming?: boolean;
|
|
27
28
|
}
|
|
@@ -89,6 +90,9 @@ interface ChatMessageProps {
|
|
|
89
90
|
}
|
|
90
91
|
declare function ChatMessage({ message: msg }: ChatMessageProps): react_jsx_runtime.JSX.Element;
|
|
91
92
|
|
|
93
|
+
declare function ThinkingBlock({ thinking }: {
|
|
94
|
+
thinking: string[];
|
|
95
|
+
}): react_jsx_runtime.JSX.Element;
|
|
92
96
|
declare function ToolCallBlock({ tool }: {
|
|
93
97
|
tool: ToolCall;
|
|
94
98
|
}): react_jsx_runtime.JSX.Element;
|
|
@@ -309,14 +313,16 @@ declare function buildFileTree(files: Array<{
|
|
|
309
313
|
modifiedAt: string;
|
|
310
314
|
}>): TreeNode[];
|
|
311
315
|
/**
|
|
312
|
-
* Parse content blocks (from Anthropic SDK format) into text + tool calls.
|
|
313
|
-
* Handles both JSON string content and pre-parsed arrays
|
|
316
|
+
* Parse content blocks (from Anthropic SDK format) into text + tool calls + thinking.
|
|
317
|
+
* Handles both JSON string content and pre-parsed arrays, as well as
|
|
318
|
+
* wrapped message envelopes from Claude Code conversations.
|
|
314
319
|
*/
|
|
315
320
|
declare function parseContentBlocks(content: unknown): {
|
|
316
321
|
text: string;
|
|
317
322
|
toolCalls: ToolCall[];
|
|
323
|
+
thinking: string[];
|
|
318
324
|
};
|
|
319
325
|
declare function isImageFile(name: string): boolean;
|
|
320
326
|
declare function getFileLanguage(name: string): string;
|
|
321
327
|
|
|
322
|
-
export { type AttachedFile, BottomPanels, type BottomPanelsProps, Chat, ChatInput, type ChatInputProps, ChatMessage, type ChatMessageProps, type ChatMessage$1 as ChatMessageType, ChatMessages, type ChatMessagesProps, type ChatProps, FileBrowser, type FileBrowserProps, FileTree, type FileTreeProps, type LogEntry, Playground, type PlaygroundContextValue, PlaygroundHeader, type PlaygroundHeaderProps, type PlaygroundProps, PlaygroundProvider, type PlaygroundProviderProps, SessionHistory, type SessionHistoryProps, StatusIndicator, type StatusIndicatorProps, Terminal, type TerminalProps, type ToolCall, ToolCallBlock, type TreeNode, type UseAgentsOptions, type UseAgentsReturn, type UseFileBrowserOptions, type UseFileBrowserReturn, type UseFileUploadOptions, type UseFileUploadReturn, type UseHealthCheckOptions, type UseHealthCheckReturn, type UsePlaygroundChatOptions, type UsePlaygroundChatReturn, type UseSessionsOptions, type UseSessionsReturn, type UseTerminalOptions, type UseTerminalReturn, buildFileTree, cn, formatBytes, formatTime, getFileLanguage, isImageFile, parseContentBlocks, useAgents, useFileBrowser, useFileUpload, useHealthCheck, usePlaygroundChat, usePlaygroundContext, useSessions, useTerminal };
|
|
328
|
+
export { type AttachedFile, BottomPanels, type BottomPanelsProps, Chat, ChatInput, type ChatInputProps, ChatMessage, type ChatMessageProps, type ChatMessage$1 as ChatMessageType, ChatMessages, type ChatMessagesProps, type ChatProps, FileBrowser, type FileBrowserProps, FileTree, type FileTreeProps, type LogEntry, Playground, type PlaygroundContextValue, PlaygroundHeader, type PlaygroundHeaderProps, type PlaygroundProps, PlaygroundProvider, type PlaygroundProviderProps, SessionHistory, type SessionHistoryProps, StatusIndicator, type StatusIndicatorProps, Terminal, type TerminalProps, ThinkingBlock, type ToolCall, ToolCallBlock, type TreeNode, type UseAgentsOptions, type UseAgentsReturn, type UseFileBrowserOptions, type UseFileBrowserReturn, type UseFileUploadOptions, type UseFileUploadReturn, type UseHealthCheckOptions, type UseHealthCheckReturn, type UsePlaygroundChatOptions, type UsePlaygroundChatReturn, type UseSessionsOptions, type UseSessionsReturn, type UseTerminalOptions, type UseTerminalReturn, buildFileTree, cn, formatBytes, formatTime, getFileLanguage, isImageFile, parseContentBlocks, useAgents, useFileBrowser, useFileUpload, useHealthCheck, usePlaygroundChat, usePlaygroundContext, useSessions, useTerminal };
|
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ interface ChatMessage$1 {
|
|
|
22
22
|
role: 'user' | 'assistant' | 'system';
|
|
23
23
|
content: string;
|
|
24
24
|
toolCalls?: ToolCall[];
|
|
25
|
+
thinking?: string[];
|
|
25
26
|
timestamp?: string;
|
|
26
27
|
isStreaming?: boolean;
|
|
27
28
|
}
|
|
@@ -89,6 +90,9 @@ interface ChatMessageProps {
|
|
|
89
90
|
}
|
|
90
91
|
declare function ChatMessage({ message: msg }: ChatMessageProps): react_jsx_runtime.JSX.Element;
|
|
91
92
|
|
|
93
|
+
declare function ThinkingBlock({ thinking }: {
|
|
94
|
+
thinking: string[];
|
|
95
|
+
}): react_jsx_runtime.JSX.Element;
|
|
92
96
|
declare function ToolCallBlock({ tool }: {
|
|
93
97
|
tool: ToolCall;
|
|
94
98
|
}): react_jsx_runtime.JSX.Element;
|
|
@@ -309,14 +313,16 @@ declare function buildFileTree(files: Array<{
|
|
|
309
313
|
modifiedAt: string;
|
|
310
314
|
}>): TreeNode[];
|
|
311
315
|
/**
|
|
312
|
-
* Parse content blocks (from Anthropic SDK format) into text + tool calls.
|
|
313
|
-
* Handles both JSON string content and pre-parsed arrays
|
|
316
|
+
* Parse content blocks (from Anthropic SDK format) into text + tool calls + thinking.
|
|
317
|
+
* Handles both JSON string content and pre-parsed arrays, as well as
|
|
318
|
+
* wrapped message envelopes from Claude Code conversations.
|
|
314
319
|
*/
|
|
315
320
|
declare function parseContentBlocks(content: unknown): {
|
|
316
321
|
text: string;
|
|
317
322
|
toolCalls: ToolCall[];
|
|
323
|
+
thinking: string[];
|
|
318
324
|
};
|
|
319
325
|
declare function isImageFile(name: string): boolean;
|
|
320
326
|
declare function getFileLanguage(name: string): string;
|
|
321
327
|
|
|
322
|
-
export { type AttachedFile, BottomPanels, type BottomPanelsProps, Chat, ChatInput, type ChatInputProps, ChatMessage, type ChatMessageProps, type ChatMessage$1 as ChatMessageType, ChatMessages, type ChatMessagesProps, type ChatProps, FileBrowser, type FileBrowserProps, FileTree, type FileTreeProps, type LogEntry, Playground, type PlaygroundContextValue, PlaygroundHeader, type PlaygroundHeaderProps, type PlaygroundProps, PlaygroundProvider, type PlaygroundProviderProps, SessionHistory, type SessionHistoryProps, StatusIndicator, type StatusIndicatorProps, Terminal, type TerminalProps, type ToolCall, ToolCallBlock, type TreeNode, type UseAgentsOptions, type UseAgentsReturn, type UseFileBrowserOptions, type UseFileBrowserReturn, type UseFileUploadOptions, type UseFileUploadReturn, type UseHealthCheckOptions, type UseHealthCheckReturn, type UsePlaygroundChatOptions, type UsePlaygroundChatReturn, type UseSessionsOptions, type UseSessionsReturn, type UseTerminalOptions, type UseTerminalReturn, buildFileTree, cn, formatBytes, formatTime, getFileLanguage, isImageFile, parseContentBlocks, useAgents, useFileBrowser, useFileUpload, useHealthCheck, usePlaygroundChat, usePlaygroundContext, useSessions, useTerminal };
|
|
328
|
+
export { type AttachedFile, BottomPanels, type BottomPanelsProps, Chat, ChatInput, type ChatInputProps, ChatMessage, type ChatMessageProps, type ChatMessage$1 as ChatMessageType, ChatMessages, type ChatMessagesProps, type ChatProps, FileBrowser, type FileBrowserProps, FileTree, type FileTreeProps, type LogEntry, Playground, type PlaygroundContextValue, PlaygroundHeader, type PlaygroundHeaderProps, type PlaygroundProps, PlaygroundProvider, type PlaygroundProviderProps, SessionHistory, type SessionHistoryProps, StatusIndicator, type StatusIndicatorProps, Terminal, type TerminalProps, ThinkingBlock, type ToolCall, ToolCallBlock, type TreeNode, type UseAgentsOptions, type UseAgentsReturn, type UseFileBrowserOptions, type UseFileBrowserReturn, type UseFileUploadOptions, type UseFileUploadReturn, type UseHealthCheckOptions, type UseHealthCheckReturn, type UsePlaygroundChatOptions, type UsePlaygroundChatReturn, type UseSessionsOptions, type UseSessionsReturn, type UseTerminalOptions, type UseTerminalReturn, buildFileTree, cn, formatBytes, formatTime, getFileLanguage, isImageFile, parseContentBlocks, useAgents, useFileBrowser, useFileUpload, useHealthCheck, usePlaygroundChat, usePlaygroundContext, useSessions, useTerminal };
|
package/dist/index.js
CHANGED
|
@@ -58,6 +58,16 @@ function buildFileTree(files) {
|
|
|
58
58
|
sortNodes(root);
|
|
59
59
|
return root;
|
|
60
60
|
}
|
|
61
|
+
function unwrapMessageObject(obj) {
|
|
62
|
+
if (obj.message && typeof obj.message === "object") {
|
|
63
|
+
const msg = obj.message;
|
|
64
|
+
if (Array.isArray(msg.content)) return msg.content;
|
|
65
|
+
}
|
|
66
|
+
if (Array.isArray(obj.content)) return obj.content;
|
|
67
|
+
if (typeof obj.content === "string") return obj.content;
|
|
68
|
+
if (typeof obj.result === "string") return obj.result;
|
|
69
|
+
return "";
|
|
70
|
+
}
|
|
61
71
|
function parseContentBlocks(content) {
|
|
62
72
|
let blocks = null;
|
|
63
73
|
if (typeof content === "string") {
|
|
@@ -65,18 +75,23 @@ function parseContentBlocks(content) {
|
|
|
65
75
|
const parsed = JSON.parse(content);
|
|
66
76
|
if (Array.isArray(parsed)) {
|
|
67
77
|
blocks = parsed;
|
|
78
|
+
} else if (parsed && typeof parsed === "object") {
|
|
79
|
+
return parseContentBlocks(unwrapMessageObject(parsed));
|
|
68
80
|
}
|
|
69
81
|
} catch {
|
|
70
|
-
return { text: content, toolCalls: [] };
|
|
82
|
+
return { text: content, toolCalls: [], thinking: [] };
|
|
71
83
|
}
|
|
72
84
|
} else if (Array.isArray(content)) {
|
|
73
85
|
blocks = content;
|
|
86
|
+
} else if (content && typeof content === "object") {
|
|
87
|
+
return parseContentBlocks(unwrapMessageObject(content));
|
|
74
88
|
}
|
|
75
89
|
if (!blocks) {
|
|
76
|
-
return { text: typeof content === "string" ? content : "", toolCalls: [] };
|
|
90
|
+
return { text: typeof content === "string" ? content : "", toolCalls: [], thinking: [] };
|
|
77
91
|
}
|
|
78
92
|
let text = "";
|
|
79
93
|
const toolCalls = [];
|
|
94
|
+
const thinking = [];
|
|
80
95
|
for (const block of blocks) {
|
|
81
96
|
const b = block;
|
|
82
97
|
if (b.type === "text" && typeof b.text === "string") {
|
|
@@ -95,9 +110,12 @@ function parseContentBlocks(content) {
|
|
|
95
110
|
match.isError = b.is_error ?? false;
|
|
96
111
|
match.state = b.is_error ? "error" : "completed";
|
|
97
112
|
}
|
|
113
|
+
} else if (b.type === "thinking") {
|
|
114
|
+
const t = b.thinking || b.text || "";
|
|
115
|
+
if (t) thinking.push(t);
|
|
98
116
|
}
|
|
99
117
|
}
|
|
100
|
-
return { text, toolCalls };
|
|
118
|
+
return { text, toolCalls, thinking };
|
|
101
119
|
}
|
|
102
120
|
var IMAGE_EXTS = /* @__PURE__ */ new Set(["png", "jpg", "jpeg", "gif", "svg", "webp", "ico"]);
|
|
103
121
|
function isImageFile(name) {
|
|
@@ -566,6 +584,17 @@ function icon(d, opts) {
|
|
|
566
584
|
);
|
|
567
585
|
return Component;
|
|
568
586
|
}
|
|
587
|
+
var Brain = (props) => /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", ...props, children: [
|
|
588
|
+
/* @__PURE__ */ jsx2("path", { d: "M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z" }),
|
|
589
|
+
/* @__PURE__ */ jsx2("path", { d: "M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z" }),
|
|
590
|
+
/* @__PURE__ */ jsx2("path", { d: "M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4" }),
|
|
591
|
+
/* @__PURE__ */ jsx2("path", { d: "M17.599 6.5a3 3 0 0 0 .399-1.375" }),
|
|
592
|
+
/* @__PURE__ */ jsx2("path", { d: "M6.003 5.125A3 3 0 0 0 6.401 6.5" }),
|
|
593
|
+
/* @__PURE__ */ jsx2("path", { d: "M3.477 10.896a4 4 0 0 1 .585-.396" }),
|
|
594
|
+
/* @__PURE__ */ jsx2("path", { d: "M19.938 10.5a4 4 0 0 1 .585.396" }),
|
|
595
|
+
/* @__PURE__ */ jsx2("path", { d: "M6 18a4 4 0 0 1-1.967-.516" }),
|
|
596
|
+
/* @__PURE__ */ jsx2("path", { d: "M19.967 17.484A4 4 0 0 1 18 18" })
|
|
597
|
+
] });
|
|
569
598
|
var Bot = (props) => /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", ...props, children: [
|
|
570
599
|
/* @__PURE__ */ jsx2("path", { d: "M12 8V4H8" }),
|
|
571
600
|
/* @__PURE__ */ jsx2("rect", { width: "16", height: "12", x: "4", y: "8", rx: "2" }),
|
|
@@ -775,6 +804,25 @@ import { useEffect as useEffect4, useRef as useRef2 } from "react";
|
|
|
775
804
|
// src/components/ToolCallBlock.tsx
|
|
776
805
|
import { useState as useState6 } from "react";
|
|
777
806
|
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
807
|
+
function ThinkingBlock({ thinking }) {
|
|
808
|
+
const [open, setOpen] = useState6(false);
|
|
809
|
+
const combined = thinking.join("\n\n");
|
|
810
|
+
return /* @__PURE__ */ jsxs4("div", { className: "my-2 rounded-lg border border-amber-500/20 bg-amber-500/[0.03] overflow-hidden", children: [
|
|
811
|
+
/* @__PURE__ */ jsxs4(
|
|
812
|
+
"button",
|
|
813
|
+
{
|
|
814
|
+
onClick: () => setOpen(!open),
|
|
815
|
+
className: "flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-amber-500/5 transition-colors",
|
|
816
|
+
children: [
|
|
817
|
+
/* @__PURE__ */ jsx5(Brain, { className: "h-3.5 w-3.5 shrink-0 text-amber-500/60" }),
|
|
818
|
+
/* @__PURE__ */ jsx5("span", { className: "text-xs font-medium text-amber-400/70", children: "Thinking" }),
|
|
819
|
+
/* @__PURE__ */ jsx5("span", { className: "ml-auto flex items-center gap-1.5", children: open ? /* @__PURE__ */ jsx5(ChevronDown, { className: "h-3 w-3 text-white/30" }) : /* @__PURE__ */ jsx5(ChevronRight, { className: "h-3 w-3 text-white/30" }) })
|
|
820
|
+
]
|
|
821
|
+
}
|
|
822
|
+
),
|
|
823
|
+
open && /* @__PURE__ */ jsx5("div", { className: "border-t border-amber-500/10 px-3 py-2", children: /* @__PURE__ */ jsx5("pre", { className: "whitespace-pre-wrap text-xs text-white/50 leading-relaxed max-h-96 overflow-y-auto", children: combined }) })
|
|
824
|
+
] });
|
|
825
|
+
}
|
|
778
826
|
function ToolCallBlock({ tool }) {
|
|
779
827
|
const [open, setOpen] = useState6(false);
|
|
780
828
|
const isRunning = tool.state === "running" || tool.state === "pending";
|
|
@@ -846,6 +894,7 @@ function ChatMessage({ message: msg }) {
|
|
|
846
894
|
"max-w-[75%] rounded-2xl px-4 py-2.5",
|
|
847
895
|
isUser ? "bg-accent/10 border border-accent/20 text-white" : "bg-white/5 border border-white/10 text-white/80"
|
|
848
896
|
), children: [
|
|
897
|
+
msg.thinking && msg.thinking.length > 0 && /* @__PURE__ */ jsx6(ThinkingBlock, { thinking: msg.thinking }),
|
|
849
898
|
msg.content && /* @__PURE__ */ jsxs5("div", { className: "whitespace-pre-wrap text-sm leading-relaxed", children: [
|
|
850
899
|
msg.content,
|
|
851
900
|
msg.isStreaming && !msg.toolCalls?.some((tc) => tc.state === "running") && /* @__PURE__ */ jsx6("span", { className: "ml-1 inline-block h-4 w-0.5 animate-pulse bg-accent align-text-bottom" })
|
|
@@ -1706,6 +1755,7 @@ export {
|
|
|
1706
1755
|
SessionHistory,
|
|
1707
1756
|
StatusIndicator,
|
|
1708
1757
|
Terminal2 as Terminal,
|
|
1758
|
+
ThinkingBlock,
|
|
1709
1759
|
ToolCallBlock,
|
|
1710
1760
|
buildFileTree,
|
|
1711
1761
|
cn,
|