@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.
- package/CHANGELOG.md +14 -0
- package/README.md +4 -1
- 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-DOETfnd9.js +154 -0
- package/dist/auth.d.ts +2 -74
- package/dist/auth.js +2 -16
- package/dist/branding-26d5ARIr.d.ts +14 -0
- package/dist/button-C87nEe2R.js +78 -0
- package/dist/button-yoIv77e2.d.ts +16 -0
- package/dist/chat-D4jAfEmj.js +667 -0
- package/dist/chat.d.ts +2 -201
- package/dist/chat.js +2 -31
- package/dist/code-block-B36KVUSN.js +165 -0
- package/dist/code-block-B9miUPht.d.ts +23 -0
- package/dist/diff-preview-BcK3nRXb.js +533 -0
- package/dist/document-editor-pane-BcoABlhn.d.ts +131 -0
- package/dist/document-editor-pane-BxlPjaTP.js +1287 -0
- package/dist/dropdown-menu-BpcLa5vF.js +101 -0
- package/dist/editor.d.ts +76 -78
- package/dist/editor.js +2 -34
- package/dist/file-format-BgXbr-Ib.js +160 -0
- package/dist/files-Bug33qCl.js +743 -0
- package/dist/files.d.ts +2 -243
- package/dist/files.js +3 -41
- package/dist/focus-BcE_SHqz.js +57 -0
- package/dist/format-DfcLWqMa.js +54 -0
- package/dist/hooks.d.ts +30 -37
- package/dist/hooks.js +111 -46
- package/dist/index-2UntyjBb.d.ts +52 -0
- package/dist/index-BgUHilZm.d.ts +108 -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.d.ts +26 -43
- package/dist/index.js +35 -472
- package/dist/markdown-BGqicV82.js +45 -0
- package/dist/markdown.d.ts +3 -18
- package/dist/markdown.js +3 -15
- 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-DrU1AdVk.js +266 -0
- package/dist/openui.d.ts +2 -115
- package/dist/openui.js +2 -13
- package/dist/parts-5mhy9yJ3.d.ts +37 -0
- package/dist/primitives-Cb8GGVKr.js +1239 -0
- package/dist/primitives.d.ts +5 -525
- package/dist/primitives.js +9 -212
- 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-BACLbCFl.js +410 -0
- package/dist/run.d.ts +3 -126
- package/dist/run.js +5 -40
- package/dist/sdk-hooks.d.ts +2 -285
- package/dist/sdk-hooks.js +3 -36
- package/dist/stores.d.ts +13 -14
- package/dist/stores.js +34 -76
- package/dist/table-Bss73DhB.js +146 -0
- package/dist/tabs-BVHR6NkO.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-Djt2q11V.js +109 -0
- package/dist/tool-call-step-DNebqhmX.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 -23
- 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-BVgO1QBN.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 -104
- package/dist/utils.js +6 -44
- package/package.json +39 -41
- package/src/lib/focus.ts +2 -1
- 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-3XXBZL53.js +0 -174
- package/dist/chunk-42PAH5D2.js +0 -112
- package/dist/chunk-4CLN43XT.js +0 -45
- package/dist/chunk-55WHV7SS.js +0 -1604
- package/dist/chunk-565EATZZ.js +0 -156
- package/dist/chunk-5Z5ZYMOJ.js +0 -0
- package/dist/chunk-6BGQA4BQ.js +0 -0
- package/dist/chunk-BEBXZPHW.js +0 -299
- package/dist/chunk-C5WF4WMV.js +0 -734
- package/dist/chunk-HFL6R6IF.js +0 -37
- package/dist/chunk-HGML45QH.js +0 -104
- package/dist/chunk-HMAPIH7L.js +0 -595
- package/dist/chunk-K5XFRUS4.js +0 -1401
- package/dist/chunk-KFQGHD73.js +0 -198
- package/dist/chunk-L57WRIND.js +0 -59
- package/dist/chunk-LTEKI7YJ.js +0 -59
- package/dist/chunk-M3QZK62R.js +0 -233
- package/dist/chunk-ND3ZFXQK.js +0 -179
- package/dist/chunk-OEX7NZE3.js +0 -321
- package/dist/chunk-OL5GYLHV.js +0 -60
- package/dist/chunk-QGFYBNSO.js +0 -133
- package/dist/chunk-R7B3UWPF.js +0 -550
- package/dist/chunk-R7SUY4E3.js +0 -65
- package/dist/chunk-REJESC5U.js +0 -117
- package/dist/chunk-RQGKSCEZ.js +0 -0
- package/dist/chunk-SNLR2AEA.js +0 -40
- package/dist/chunk-WKWBTL2V.js +0 -15
- package/dist/chunk-X7CU776B.js +0 -1048
- package/dist/chunk-XU3HB5QL.js +0 -127
- package/dist/chunk-YTO5V6QS.js +0 -19
- package/dist/chunk-YU4E5J2N.js +0 -437
- package/dist/chunk-YZ6AK25N.js +0 -886
- package/dist/code-block-0kSpWMnf.d.ts +0 -25
- package/dist/document-editor-pane-IAEQn_Dl.d.ts +0 -128
- package/dist/document-editor-pane-QHDOBA43.js +0 -13
- 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
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
//#region src/utils/tool-display.ts
|
|
2
|
+
const TOOL_NAME_PREFIX = "tool:";
|
|
3
|
+
function normalizeToolName(tool) {
|
|
4
|
+
const n = tool?.toLowerCase() ?? "";
|
|
5
|
+
return n.startsWith(TOOL_NAME_PREFIX) ? n.slice(5) : n;
|
|
6
|
+
}
|
|
7
|
+
function extractString(obj, key) {
|
|
8
|
+
if (typeof obj === "object" && obj !== null && key in obj) {
|
|
9
|
+
const val = obj[key];
|
|
10
|
+
if (typeof val === "string") return val;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function extractCommand(input) {
|
|
14
|
+
if (typeof input === "string") return input;
|
|
15
|
+
return extractString(input, "command") ?? extractString(input, "cmd");
|
|
16
|
+
}
|
|
17
|
+
function extractFilePath(input) {
|
|
18
|
+
return extractString(input, "file_path") ?? extractString(input, "path") ?? extractString(input, "filePath") ?? extractString(input, "file");
|
|
19
|
+
}
|
|
20
|
+
const TOOL_CATEGORY_ICONS = {
|
|
21
|
+
command: "terminal",
|
|
22
|
+
write: "file-plus",
|
|
23
|
+
read: "file-text",
|
|
24
|
+
search: "search",
|
|
25
|
+
edit: "file-edit",
|
|
26
|
+
task: "cpu",
|
|
27
|
+
web: "globe",
|
|
28
|
+
todo: "check-square",
|
|
29
|
+
other: "box"
|
|
30
|
+
};
|
|
31
|
+
function getToolCategory(toolName) {
|
|
32
|
+
switch (normalizeToolName(toolName)) {
|
|
33
|
+
case "bash":
|
|
34
|
+
case "shell":
|
|
35
|
+
case "command":
|
|
36
|
+
case "execute": return "command";
|
|
37
|
+
case "write":
|
|
38
|
+
case "write_file":
|
|
39
|
+
case "create_file": return "write";
|
|
40
|
+
case "read":
|
|
41
|
+
case "read_file":
|
|
42
|
+
case "cat": return "read";
|
|
43
|
+
case "grep":
|
|
44
|
+
case "search":
|
|
45
|
+
case "rg": return "search";
|
|
46
|
+
case "edit":
|
|
47
|
+
case "patch":
|
|
48
|
+
case "sed": return "edit";
|
|
49
|
+
case "glob":
|
|
50
|
+
case "find":
|
|
51
|
+
case "ls": return "search";
|
|
52
|
+
case "web_search":
|
|
53
|
+
case "web_fetch":
|
|
54
|
+
case "fetch": return "web";
|
|
55
|
+
case "task":
|
|
56
|
+
case "agent":
|
|
57
|
+
case "spawn": return "task";
|
|
58
|
+
case "todo":
|
|
59
|
+
case "todo_write": return "todo";
|
|
60
|
+
default: return "other";
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Title is the bare verb ("Read", "Edit", "Shell"); the path, command, pattern
|
|
65
|
+
* or query lives in `description` only, so a row prints its subject once.
|
|
66
|
+
* `targetPath` / `commandSnippet` carry the untruncated value for consumers
|
|
67
|
+
* that need it (diff headers, expanded detail).
|
|
68
|
+
*/
|
|
69
|
+
function getToolDisplayMetadata(part) {
|
|
70
|
+
const name = normalizeToolName(part.tool);
|
|
71
|
+
const input = part.state.status !== "pending" ? part.state.input : void 0;
|
|
72
|
+
const filePath = extractFilePath(input);
|
|
73
|
+
const command = extractCommand(input);
|
|
74
|
+
switch (name) {
|
|
75
|
+
case "bash":
|
|
76
|
+
case "shell":
|
|
77
|
+
case "command":
|
|
78
|
+
case "execute": return {
|
|
79
|
+
title: "Shell",
|
|
80
|
+
description: command ? truncateCommand(command) : void 0,
|
|
81
|
+
displayVariant: "command",
|
|
82
|
+
commandSnippet: command
|
|
83
|
+
};
|
|
84
|
+
case "write":
|
|
85
|
+
case "write_file":
|
|
86
|
+
case "create_file": return {
|
|
87
|
+
title: "Write",
|
|
88
|
+
description: filePath,
|
|
89
|
+
displayVariant: "write-file",
|
|
90
|
+
targetPath: filePath
|
|
91
|
+
};
|
|
92
|
+
case "edit":
|
|
93
|
+
case "patch": return {
|
|
94
|
+
title: "Edit",
|
|
95
|
+
description: filePath,
|
|
96
|
+
hasDiffOutput: true,
|
|
97
|
+
diffFilePath: filePath,
|
|
98
|
+
displayVariant: "diff",
|
|
99
|
+
targetPath: filePath
|
|
100
|
+
};
|
|
101
|
+
case "read":
|
|
102
|
+
case "read_file":
|
|
103
|
+
case "cat": return {
|
|
104
|
+
title: "Read",
|
|
105
|
+
description: filePath,
|
|
106
|
+
displayVariant: "read-file",
|
|
107
|
+
targetPath: filePath
|
|
108
|
+
};
|
|
109
|
+
case "grep":
|
|
110
|
+
case "search":
|
|
111
|
+
case "rg": return {
|
|
112
|
+
title: "Search",
|
|
113
|
+
description: extractString(input, "pattern"),
|
|
114
|
+
displayVariant: "grep"
|
|
115
|
+
};
|
|
116
|
+
case "glob":
|
|
117
|
+
case "find":
|
|
118
|
+
case "ls": return {
|
|
119
|
+
title: "Find",
|
|
120
|
+
description: extractString(input, "pattern"),
|
|
121
|
+
displayVariant: "glob"
|
|
122
|
+
};
|
|
123
|
+
case "web_search":
|
|
124
|
+
case "web_fetch":
|
|
125
|
+
case "fetch": {
|
|
126
|
+
const query = extractString(input, "query") ?? extractString(input, "url");
|
|
127
|
+
return {
|
|
128
|
+
title: name === "web_search" ? "Web search" : "Fetch",
|
|
129
|
+
description: query ? truncateCommand(query) : void 0,
|
|
130
|
+
displayVariant: "web-search"
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
case "task":
|
|
134
|
+
case "agent":
|
|
135
|
+
case "spawn": {
|
|
136
|
+
const desc = extractString(input, "description") ?? extractString(input, "prompt");
|
|
137
|
+
return {
|
|
138
|
+
title: "Task",
|
|
139
|
+
description: desc ? truncateCommand(desc) : void 0
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
default: return {
|
|
143
|
+
title: part.tool || "Tool",
|
|
144
|
+
description: command ?? filePath ?? extractString(input, "pattern") ?? extractString(input, "query")
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function truncateCommand(cmd) {
|
|
149
|
+
const first = cmd.split("\n")[0];
|
|
150
|
+
return first.length > 60 ? first.slice(0, 57) + "..." : first;
|
|
151
|
+
}
|
|
152
|
+
/** Extract error text from a tool part, if any. */
|
|
153
|
+
function getToolErrorText(part, fallback) {
|
|
154
|
+
if (part.state.status !== "error") return void 0;
|
|
155
|
+
return part.state.error || fallback;
|
|
156
|
+
}
|
|
157
|
+
//#endregion
|
|
158
|
+
export { getToolErrorText as i, getToolCategory as n, getToolDisplayMetadata as r, TOOL_CATEGORY_ICONS as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ReactNode } from
|
|
3
|
-
|
|
1
|
+
import { i as ToolPart } from "./parts-5mhy9yJ3.js";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
//#region src/types/tool-display.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Variant-specific rendering instructions for tool output.
|
|
6
6
|
* Maps directly to specialised preview components.
|
|
@@ -16,17 +16,17 @@ type CustomToolRenderer = (part: ToolPart) => ReactNode | null;
|
|
|
16
16
|
* input, and output by `getToolDisplayMetadata()`.
|
|
17
17
|
*/
|
|
18
18
|
interface ToolDisplayMetadata {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
title: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
inputTitle?: string;
|
|
22
|
+
outputTitle?: string;
|
|
23
|
+
inputLanguage?: string;
|
|
24
|
+
outputLanguage?: string;
|
|
25
|
+
hasDiffOutput?: boolean;
|
|
26
|
+
diffFilePath?: string;
|
|
27
|
+
displayVariant?: DisplayVariant;
|
|
28
|
+
commandSnippet?: string;
|
|
29
|
+
targetPath?: string;
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
export
|
|
31
|
+
//#endregion
|
|
32
|
+
export { DisplayVariant as n, ToolDisplayMetadata as r, CustomToolRenderer as t };
|
package/dist/tool-previews.d.ts
CHANGED
|
@@ -1,48 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { a as ToolPart } from './parts-dj7AcUg0.js';
|
|
4
|
-
|
|
5
|
-
interface CommandPreviewProps {
|
|
6
|
-
part: ToolPart;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Terminal-style command output preview.
|
|
10
|
-
* Shows the command, exit code, and stdout/stderr with expand/collapse.
|
|
11
|
-
*/
|
|
12
|
-
declare const CommandPreview: React.MemoExoticComponent<({ part }: CommandPreviewProps) => react_jsx_runtime.JSX.Element>;
|
|
13
|
-
|
|
14
|
-
interface WriteFilePreviewProps {
|
|
15
|
-
part: ToolPart;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Preview for file write/create operations.
|
|
19
|
-
* Shows file path, line count, and the written content.
|
|
20
|
-
*/
|
|
21
|
-
declare const WriteFilePreview: React.MemoExoticComponent<({ part }: WriteFilePreviewProps) => react_jsx_runtime.JSX.Element | null>;
|
|
22
|
-
|
|
23
|
-
interface GrepResultsPreviewProps {
|
|
24
|
-
part: ToolPart;
|
|
25
|
-
}
|
|
26
|
-
declare const GrepResultsPreview: React.MemoExoticComponent<({ part }: GrepResultsPreviewProps) => react_jsx_runtime.JSX.Element>;
|
|
27
|
-
|
|
28
|
-
interface GlobResultsPreviewProps {
|
|
29
|
-
part: ToolPart;
|
|
30
|
-
}
|
|
31
|
-
declare const GlobResultsPreview: React.MemoExoticComponent<({ part }: GlobResultsPreviewProps) => react_jsx_runtime.JSX.Element>;
|
|
32
|
-
|
|
33
|
-
interface WebSearchPreviewProps {
|
|
34
|
-
part: ToolPart;
|
|
35
|
-
}
|
|
36
|
-
declare const WebSearchPreview: React.MemoExoticComponent<({ part }: WebSearchPreviewProps) => react_jsx_runtime.JSX.Element>;
|
|
37
|
-
|
|
38
|
-
interface QuestionPreviewProps {
|
|
39
|
-
part: ToolPart;
|
|
40
|
-
}
|
|
41
|
-
declare const QuestionPreview: React.MemoExoticComponent<({ part }: QuestionPreviewProps) => react_jsx_runtime.JSX.Element>;
|
|
42
|
-
|
|
43
|
-
interface DiffPreviewProps {
|
|
44
|
-
part: ToolPart;
|
|
45
|
-
}
|
|
46
|
-
declare const DiffPreview: React.MemoExoticComponent<({ part }: DiffPreviewProps) => react_jsx_runtime.JSX.Element>;
|
|
47
|
-
|
|
48
|
-
export { CommandPreview, type CommandPreviewProps, DiffPreview, type DiffPreviewProps, GlobResultsPreview, type GlobResultsPreviewProps, GrepResultsPreview, type GrepResultsPreviewProps, QuestionPreview, type QuestionPreviewProps, WebSearchPreview, type WebSearchPreviewProps, WriteFilePreview, type WriteFilePreviewProps };
|
|
1
|
+
import { a as WebSearchPreview, c as GlobResultsPreviewProps, d as WriteFilePreview, f as WriteFilePreviewProps, i as QuestionPreviewProps, l as GrepResultsPreview, m as CommandPreviewProps, n as DiffPreviewProps, o as WebSearchPreviewProps, p as CommandPreview, r as QuestionPreview, s as GlobResultsPreview, t as DiffPreview, u as GrepResultsPreviewProps } from "./index-2UntyjBb.js";
|
|
2
|
+
export { CommandPreview, type CommandPreviewProps, DiffPreview, type DiffPreviewProps, GlobResultsPreview, type GlobResultsPreviewProps, GrepResultsPreview, type GrepResultsPreviewProps, QuestionPreview, type QuestionPreviewProps, WebSearchPreview, type WebSearchPreviewProps, WriteFilePreview, type WriteFilePreviewProps };
|
package/dist/tool-previews.js
CHANGED
|
@@ -1,23 +1,2 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
|
|
3
|
-
CommandPreview,
|
|
4
|
-
DiffPreview,
|
|
5
|
-
GlobResultsPreview,
|
|
6
|
-
GrepResultsPreview,
|
|
7
|
-
QuestionPreview,
|
|
8
|
-
WebSearchPreview,
|
|
9
|
-
WriteFilePreview
|
|
10
|
-
} from "./chunk-HMAPIH7L.js";
|
|
11
|
-
import "./chunk-XU3HB5QL.js";
|
|
12
|
-
import "./chunk-3XXBZL53.js";
|
|
13
|
-
import "./chunk-WKWBTL2V.js";
|
|
14
|
-
import "./chunk-RQHJBTEU.js";
|
|
15
|
-
export {
|
|
16
|
-
CommandPreview,
|
|
17
|
-
DiffPreview,
|
|
18
|
-
GlobResultsPreview,
|
|
19
|
-
GrepResultsPreview,
|
|
20
|
-
QuestionPreview,
|
|
21
|
-
WebSearchPreview,
|
|
22
|
-
WriteFilePreview
|
|
23
|
-
};
|
|
1
|
+
import { a as GrepResultsPreview, i as GlobResultsPreview, n as QuestionPreview, o as WriteFilePreview, r as WebSearchPreview, s as CommandPreview, t as DiffPreview } from "./diff-preview-BcK3nRXb.js";
|
|
2
|
+
export { CommandPreview, DiffPreview, GlobResultsPreview, GrepResultsPreview, QuestionPreview, WebSearchPreview, WriteFilePreview };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,19 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
/** Visual branding for a run group header — injected by consuming app. */
|
|
8
|
-
interface AgentBranding {
|
|
9
|
-
label: string;
|
|
10
|
-
accentClass: string;
|
|
11
|
-
bgClass: string;
|
|
12
|
-
containerBgClass: string;
|
|
13
|
-
borderClass: string;
|
|
14
|
-
/** CSS class for the agent icon (legacy). Ignored when using lucide-react icons. */
|
|
15
|
-
iconClass: string;
|
|
16
|
-
textClass: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type { AgentBranding };
|
|
1
|
+
import { t as SessionMessage } from "./message-vhUI0c5G.js";
|
|
2
|
+
import { a as ToolState, i as ToolPart, n as SessionPart, o as ToolStatus, r as TextPart, s as ToolTime, t as ReasoningPart } from "./parts-5mhy9yJ3.js";
|
|
3
|
+
import { t as AgentBranding } from "./branding-26d5ARIr.js";
|
|
4
|
+
import { n as DisplayVariant, r as ToolDisplayMetadata, t as CustomToolRenderer } from "./tool-display-DgmL5rIU.js";
|
|
5
|
+
import { a as Run, i as MessageUser, n as GroupedMessage, o as RunStats, r as MessageRun, s as ToolCategory, t as FinalTextPart } from "./run-OyWmIDqu.js";
|
|
6
|
+
export { AgentBranding, CustomToolRenderer, DisplayVariant, FinalTextPart, GroupedMessage, MessageRun, MessageUser, ReasoningPart, Run, RunStats, SessionMessage, SessionPart, TextPart, ToolCategory, ToolDisplayMetadata, ToolPart, ToolState, ToolStatus, ToolTime };
|
package/dist/types.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "./chunk-6BGQA4BQ.js";
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { n as getToolCategory } from "./tool-display-BAuAVa43.js";
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
//#region src/hooks/use-run-groups.ts
|
|
4
|
+
function computeRunStats(messages, partMap) {
|
|
5
|
+
const stats = {
|
|
6
|
+
toolCount: 0,
|
|
7
|
+
messageCount: messages.length,
|
|
8
|
+
thinkingDurationMs: 0,
|
|
9
|
+
textPartCount: 0,
|
|
10
|
+
toolCategories: /* @__PURE__ */ new Set()
|
|
11
|
+
};
|
|
12
|
+
for (const msg of messages) {
|
|
13
|
+
const parts = partMap[msg.id] ?? [];
|
|
14
|
+
for (const part of parts) switch (part.type) {
|
|
15
|
+
case "tool":
|
|
16
|
+
stats.toolCount++;
|
|
17
|
+
stats.toolCategories.add(getToolCategory(part.tool));
|
|
18
|
+
break;
|
|
19
|
+
case "text":
|
|
20
|
+
if (!part.synthetic) stats.textPartCount++;
|
|
21
|
+
break;
|
|
22
|
+
case "reasoning": {
|
|
23
|
+
const start = part.time?.start;
|
|
24
|
+
const end = part.time?.end;
|
|
25
|
+
if (start && end) stats.thinkingDurationMs += end - start;
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return stats;
|
|
31
|
+
}
|
|
32
|
+
function getLastTextContent(messages, partMap) {
|
|
33
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
34
|
+
const parts = partMap[messages[i].id] ?? [];
|
|
35
|
+
for (let j = parts.length - 1; j >= 0; j--) {
|
|
36
|
+
const part = parts[j];
|
|
37
|
+
if (part.type === "text" && !part.synthetic && part.text.trim()) return part.text.trim();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
function useRunGroups({ messages, partMap, isStreaming }) {
|
|
43
|
+
return useMemo(() => {
|
|
44
|
+
const groups = [];
|
|
45
|
+
let currentRunMessages = [];
|
|
46
|
+
function flushRun(streaming) {
|
|
47
|
+
if (currentRunMessages.length === 0) return;
|
|
48
|
+
const msgs = [...currentRunMessages];
|
|
49
|
+
const stats = computeRunStats(msgs, partMap);
|
|
50
|
+
const summaryText = getLastTextContent(msgs, partMap);
|
|
51
|
+
const isComplete = !streaming;
|
|
52
|
+
groups.push({
|
|
53
|
+
type: "run",
|
|
54
|
+
run: {
|
|
55
|
+
id: msgs[0].id,
|
|
56
|
+
messages: msgs,
|
|
57
|
+
isComplete,
|
|
58
|
+
isStreaming: streaming,
|
|
59
|
+
stats,
|
|
60
|
+
summaryText,
|
|
61
|
+
finalTextPart: null
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
currentRunMessages = [];
|
|
65
|
+
}
|
|
66
|
+
for (let i = 0; i < messages.length; i++) {
|
|
67
|
+
const msg = messages[i];
|
|
68
|
+
if (msg.role === "user") {
|
|
69
|
+
flushRun(false);
|
|
70
|
+
groups.push({
|
|
71
|
+
type: "user",
|
|
72
|
+
message: msg
|
|
73
|
+
});
|
|
74
|
+
} else currentRunMessages.push(msg);
|
|
75
|
+
}
|
|
76
|
+
if (currentRunMessages.length > 0) flushRun(isStreaming);
|
|
77
|
+
return groups;
|
|
78
|
+
}, [
|
|
79
|
+
messages,
|
|
80
|
+
partMap,
|
|
81
|
+
isStreaming
|
|
82
|
+
]);
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src/hooks/use-run-collapse-state.ts
|
|
86
|
+
/**
|
|
87
|
+
* Manages per-run collapse state with auto-collapse after run completion.
|
|
88
|
+
*
|
|
89
|
+
* - Runs stay expanded by default
|
|
90
|
+
* - Collapse is manual only
|
|
91
|
+
*/
|
|
92
|
+
function useRunCollapseState(runs) {
|
|
93
|
+
const [collapsedMap, setCollapsedMap] = useState({});
|
|
94
|
+
return {
|
|
95
|
+
isCollapsed: useCallback((runId) => {
|
|
96
|
+
return collapsedMap[runId] ?? false;
|
|
97
|
+
}, [collapsedMap]),
|
|
98
|
+
toggleCollapse: useCallback((runId) => {
|
|
99
|
+
setCollapsedMap((prev) => ({
|
|
100
|
+
...prev,
|
|
101
|
+
[runId]: !prev[runId]
|
|
102
|
+
}));
|
|
103
|
+
}, [])
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/hooks/use-auto-scroll.ts
|
|
108
|
+
const BOTTOM_THRESHOLD = 40;
|
|
109
|
+
/**
|
|
110
|
+
* Scroll-to-bottom behaviour: sticks to the bottom while streaming,
|
|
111
|
+
* pauses when user scrolls up, resumes when user scrolls back down.
|
|
112
|
+
*/
|
|
113
|
+
function useAutoScroll(containerRef, deps = []) {
|
|
114
|
+
const [isAtBottom, setIsAtBottom] = useState(true);
|
|
115
|
+
const userScrolledUp = useRef(false);
|
|
116
|
+
const checkBottom = useCallback(() => {
|
|
117
|
+
const el = containerRef.current;
|
|
118
|
+
if (!el) return true;
|
|
119
|
+
return el.scrollHeight - el.scrollTop - el.clientHeight < BOTTOM_THRESHOLD;
|
|
120
|
+
}, [containerRef]);
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
const el = containerRef.current;
|
|
123
|
+
if (!el) return;
|
|
124
|
+
const onScroll = () => {
|
|
125
|
+
const atBottom = checkBottom();
|
|
126
|
+
setIsAtBottom(atBottom);
|
|
127
|
+
userScrolledUp.current = !atBottom;
|
|
128
|
+
};
|
|
129
|
+
el.addEventListener("scroll", onScroll, { passive: true });
|
|
130
|
+
return () => el.removeEventListener("scroll", onScroll);
|
|
131
|
+
}, [containerRef, checkBottom]);
|
|
132
|
+
useEffect(() => {
|
|
133
|
+
if (userScrolledUp.current) return;
|
|
134
|
+
const el = containerRef.current;
|
|
135
|
+
if (!el) return;
|
|
136
|
+
el.scrollTop = el.scrollHeight;
|
|
137
|
+
}, deps);
|
|
138
|
+
return {
|
|
139
|
+
isAtBottom,
|
|
140
|
+
scrollToBottom: useCallback(() => {
|
|
141
|
+
const el = containerRef.current;
|
|
142
|
+
if (!el) return;
|
|
143
|
+
userScrolledUp.current = false;
|
|
144
|
+
el.scrollTo({
|
|
145
|
+
top: el.scrollHeight,
|
|
146
|
+
behavior: "smooth"
|
|
147
|
+
});
|
|
148
|
+
setIsAtBottom(true);
|
|
149
|
+
}, [containerRef])
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
//#endregion
|
|
153
|
+
export { useRunCollapseState as n, useRunGroups as r, useAutoScroll as t };
|