@townco/ui 0.1.0 → 0.1.3
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/core/hooks/use-chat-input.d.ts +17 -17
- package/dist/core/hooks/use-chat-input.js +64 -55
- package/dist/core/hooks/use-chat-messages.d.ts +11 -11
- package/dist/core/hooks/use-chat-messages.js +121 -114
- package/dist/core/hooks/use-chat-session.d.ts +5 -5
- package/dist/core/hooks/use-chat-session.js +78 -80
- package/dist/core/hooks/use-media-query.d.ts +5 -5
- package/dist/core/hooks/use-media-query.js +38 -38
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/schemas/chat.d.ts +83 -56
- package/dist/core/schemas/chat.js +27 -25
- package/dist/core/store/chat-store.d.ts +28 -22
- package/dist/core/store/chat-store.js +59 -50
- package/dist/gui/components/Button.d.ts +23 -7
- package/dist/gui/components/Button.js +40 -27
- package/dist/gui/components/Card.d.ts +26 -7
- package/dist/gui/components/Card.js +54 -8
- package/dist/gui/components/ChatHeader.d.ts +58 -31
- package/dist/gui/components/ChatHeader.js +171 -66
- package/dist/gui/components/ChatInput.d.ts +58 -36
- package/dist/gui/components/ChatInput.js +191 -121
- package/dist/gui/components/ChatInterface.d.ts +9 -6
- package/dist/gui/components/ChatInterface.js +162 -90
- package/dist/gui/components/ChatLayout.d.ts +71 -41
- package/dist/gui/components/ChatLayout.js +214 -87
- package/dist/gui/components/ChatPanelTabContent.d.ts +18 -9
- package/dist/gui/components/ChatPanelTabContent.js +88 -10
- package/dist/gui/components/ChatPreview.d.ts +9 -6
- package/dist/gui/components/ChatPreview.js +212 -162
- package/dist/gui/components/ChatSecondaryPanel.d.ts +14 -11
- package/dist/gui/components/ChatSecondaryPanel.js +115 -38
- package/dist/gui/components/ChatSidebar.d.ts +26 -13
- package/dist/gui/components/ChatSidebar.js +48 -14
- package/dist/gui/components/ChatStatus.d.ts +4 -2
- package/dist/gui/components/ChatStatus.js +45 -34
- package/dist/gui/components/ChatView.d.ts +5 -3
- package/dist/gui/components/ChatView.js +38 -9
- package/dist/gui/components/ConfigPanel.d.ts +16 -12
- package/dist/gui/components/ConfigPanel.js +218 -41
- package/dist/gui/components/Conversation.d.ts +17 -14
- package/dist/gui/components/Conversation.js +143 -83
- package/dist/gui/components/Dialog.d.ts +57 -11
- package/dist/gui/components/Dialog.js +84 -8
- package/dist/gui/components/DropdownMenu.d.ts +101 -20
- package/dist/gui/components/DropdownMenu.js +161 -14
- package/dist/gui/components/HeightTransition.d.ts +12 -7
- package/dist/gui/components/HeightTransition.js +88 -77
- package/dist/gui/components/Input.d.ts +13 -6
- package/dist/gui/components/Input.js +27 -16
- package/dist/gui/components/InputBox.d.ts +19 -12
- package/dist/gui/components/InputBox.js +86 -14
- package/dist/gui/components/Label.d.ts +7 -1
- package/dist/gui/components/Label.js +12 -2
- package/dist/gui/components/MarkdownRenderer.d.ts +6 -4
- package/dist/gui/components/MarkdownRenderer.js +178 -81
- package/dist/gui/components/Message.d.ts +25 -18
- package/dist/gui/components/Message.js +44 -23
- package/dist/gui/components/MessageContent.d.ts +29 -22
- package/dist/gui/components/MessageContent.js +157 -85
- package/dist/gui/components/PlaygroundLayout.d.ts +9 -5
- package/dist/gui/components/PlaygroundLayout.js +43 -12
- package/dist/gui/components/Reasoning.d.ts +30 -24
- package/dist/gui/components/Reasoning.js +187 -60
- package/dist/gui/components/Response.d.ts +11 -9
- package/dist/gui/components/Response.js +229 -90
- package/dist/gui/components/Select.d.ts +69 -10
- package/dist/gui/components/Select.js +118 -12
- package/dist/gui/components/Sonner.d.ts +3 -1
- package/dist/gui/components/Sonner.js +29 -18
- package/dist/gui/components/StatusBar.d.ts +9 -5
- package/dist/gui/components/StatusBar.js +56 -9
- package/dist/gui/components/Tabs.d.ts +24 -4
- package/dist/gui/components/Tabs.js +32 -4
- package/dist/gui/components/Task.d.ts +28 -24
- package/dist/gui/components/Task.js +164 -31
- package/dist/gui/components/Textarea.d.ts +15 -7
- package/dist/gui/components/Textarea.js +63 -46
- package/dist/gui/components/ThinkingBlock.d.ts +20 -10
- package/dist/gui/components/ThinkingBlock.js +134 -35
- package/dist/gui/components/TodoList.d.ts +12 -10
- package/dist/gui/components/TodoList.js +22 -7
- package/dist/gui/components/TodoListItem.d.ts +9 -6
- package/dist/gui/components/TodoListItem.js +18 -4
- package/dist/gui/components/index.d.ts +59 -8
- package/dist/gui/components/index.js +42 -8
- package/dist/gui/lib/utils.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.test.js +0 -1
- package/dist/sdk/client/acp-client.d.ts +88 -76
- package/dist/sdk/client/acp-client.js +215 -217
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/index.js +1 -1
- package/dist/sdk/schemas/agent.d.ts +111 -64
- package/dist/sdk/schemas/agent.js +24 -24
- package/dist/sdk/schemas/message.d.ts +245 -147
- package/dist/sdk/schemas/message.js +40 -40
- package/dist/sdk/schemas/session.d.ts +219 -135
- package/dist/sdk/schemas/session.js +27 -27
- package/dist/sdk/transports/http.d.ts +55 -55
- package/dist/sdk/transports/http.js +472 -469
- package/dist/sdk/transports/stdio.d.ts +20 -20
- package/dist/sdk/transports/stdio.js +289 -286
- package/dist/sdk/transports/types.d.ts +42 -42
- package/dist/sdk/transports/websocket.d.ts +12 -12
- package/dist/sdk/transports/websocket.js +52 -46
- package/dist/tui/components/ChatView.d.ts +4 -2
- package/dist/tui/components/ChatView.js +51 -18
- package/dist/tui/components/GameOfLife.js +64 -35
- package/dist/tui/components/InputBox.d.ts +18 -11
- package/dist/tui/components/InputBox.js +70 -10
- package/dist/tui/components/MessageList.d.ts +4 -2
- package/dist/tui/components/MessageList.js +37 -10
- package/dist/tui/components/MultiSelect.d.ts +15 -9
- package/dist/tui/components/MultiSelect.js +116 -69
- package/dist/tui/components/ReadlineInput.d.ts +12 -6
- package/dist/tui/components/ReadlineInput.js +252 -237
- package/dist/tui/components/SingleSelect.d.ts +15 -9
- package/dist/tui/components/SingleSelect.js +84 -43
- package/dist/tui/components/StatusBar.d.ts +11 -6
- package/dist/tui/components/StatusBar.js +102 -67
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +1 -1
- package/package.json +2 -3
|
@@ -1,46 +1,87 @@
|
|
|
1
|
-
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
1
|
import { Box, Text, useInput } from "ink";
|
|
3
2
|
import { useState } from "react";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
3
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
+
export function SingleSelect({
|
|
5
|
+
options,
|
|
6
|
+
selected: _selected,
|
|
7
|
+
onChange,
|
|
8
|
+
onSubmit,
|
|
9
|
+
onCancel,
|
|
10
|
+
}) {
|
|
11
|
+
const [focusedIndex, setFocusedIndex] = useState(0);
|
|
12
|
+
const totalItems = options.length;
|
|
13
|
+
useInput((input, key) => {
|
|
14
|
+
// Handle Escape: Cancel
|
|
15
|
+
if (key.escape) {
|
|
16
|
+
onCancel?.();
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
// Handle Enter: Select option and submit immediately
|
|
20
|
+
if (key.return) {
|
|
21
|
+
const currentOption = options[focusedIndex];
|
|
22
|
+
if (currentOption) {
|
|
23
|
+
onChange(currentOption.value);
|
|
24
|
+
onSubmit(currentOption.value);
|
|
25
|
+
}
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
// Handle Arrow Up: Move focus up
|
|
29
|
+
if (key.upArrow) {
|
|
30
|
+
setFocusedIndex((prev) => (prev > 0 ? prev - 1 : totalItems - 1));
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
// Handle Arrow Down: Move focus down
|
|
34
|
+
if (key.downArrow) {
|
|
35
|
+
setFocusedIndex((prev) => (prev < totalItems - 1 ? prev + 1 : 0));
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
// Handle Spacebar: Select option and submit immediately
|
|
39
|
+
if (input === " ") {
|
|
40
|
+
const currentOption = options[focusedIndex];
|
|
41
|
+
if (currentOption) {
|
|
42
|
+
onChange(currentOption.value);
|
|
43
|
+
onSubmit(currentOption.value);
|
|
44
|
+
}
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
return _jsxs(Box, {
|
|
49
|
+
flexDirection: "column",
|
|
50
|
+
children: [
|
|
51
|
+
options.map((option, index) => {
|
|
52
|
+
const isFocused = index === focusedIndex;
|
|
53
|
+
return _jsxs(
|
|
54
|
+
Box,
|
|
55
|
+
{
|
|
56
|
+
flexDirection: "column",
|
|
57
|
+
children: [
|
|
58
|
+
_jsx(Box, {
|
|
59
|
+
children: _jsxs(Text, {
|
|
60
|
+
inverse: isFocused,
|
|
61
|
+
children: [isFocused ? ">" : " ", " ", option.label],
|
|
62
|
+
}),
|
|
63
|
+
}),
|
|
64
|
+
option.description &&
|
|
65
|
+
_jsx(Box, {
|
|
66
|
+
paddingLeft: 2,
|
|
67
|
+
children: _jsx(Text, {
|
|
68
|
+
dimColor: true,
|
|
69
|
+
children: option.description,
|
|
70
|
+
}),
|
|
71
|
+
}),
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
option.value,
|
|
75
|
+
);
|
|
76
|
+
}),
|
|
77
|
+
_jsx(Box, {
|
|
78
|
+
marginTop: 1,
|
|
79
|
+
children: _jsx(Text, {
|
|
80
|
+
dimColor: true,
|
|
81
|
+
children:
|
|
82
|
+
"\u2191/\u2193: Navigate \u2022 Space/Enter: Select and continue \u2022 Esc: Cancel",
|
|
83
|
+
}),
|
|
84
|
+
}),
|
|
85
|
+
],
|
|
86
|
+
});
|
|
46
87
|
}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import type { ConnectionStatus } from "../../core/index.js";
|
|
2
2
|
export interface StatusBarProps {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
connectionStatus: ConnectionStatus;
|
|
4
|
+
sessionId: string | null;
|
|
5
|
+
isStreaming: boolean;
|
|
6
|
+
streamingStartTime: number | null;
|
|
7
|
+
hasStreamingContent: boolean;
|
|
8
8
|
}
|
|
9
|
-
export declare function StatusBar({
|
|
9
|
+
export declare function StatusBar({
|
|
10
|
+
connectionStatus,
|
|
11
|
+
isStreaming,
|
|
12
|
+
streamingStartTime,
|
|
13
|
+
hasStreamingContent,
|
|
14
|
+
}: StatusBarProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,82 +1,117 @@
|
|
|
1
|
-
import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
1
|
import { Box, Text } from "ink";
|
|
3
2
|
import { useEffect, useState } from "react";
|
|
3
|
+
import {
|
|
4
|
+
Fragment as _Fragment,
|
|
5
|
+
jsx as _jsx,
|
|
6
|
+
jsxs as _jsxs,
|
|
7
|
+
} from "react/jsx-runtime";
|
|
8
|
+
|
|
4
9
|
// Synonyms of "thinking" in multiple languages
|
|
5
10
|
const THINKING_WORDS = [
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
11
|
+
"Thinking", // English
|
|
12
|
+
"Pensando", // Spanish/Portuguese
|
|
13
|
+
"Pensant", // French
|
|
14
|
+
"Denkend", // German
|
|
15
|
+
"Pensando", // Italian
|
|
16
|
+
"考えている", // Japanese (kangaeteiru)
|
|
17
|
+
"생각 중", // Korean (saenggak jung)
|
|
18
|
+
"思考中", // Chinese (sīkǎo zhōng)
|
|
19
|
+
"Размышляя", // Russian (razmyshlyaya)
|
|
20
|
+
"Düşünüyor", // Turkish
|
|
21
|
+
"Myślący", // Polish
|
|
22
|
+
"Tänkande", // Swedish
|
|
23
|
+
"Pensando", // Dutch
|
|
24
|
+
"Ajatellen", // Finnish
|
|
25
|
+
"Σκεπτόμενος", // Greek (skeptomenos)
|
|
26
|
+
"חושב", // Hebrew (choshev)
|
|
27
|
+
"सोच रहा है", // Hindi (soch raha hai)
|
|
28
|
+
"Berpikir", // Indonesian
|
|
24
29
|
];
|
|
25
30
|
// Animated dot patterns for bouncing/jumping effect
|
|
26
31
|
// Using regular dots (.) and middle dots (·) to create height illusion
|
|
27
32
|
const DOT_ANIMATIONS = [
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
"...", // All dots down
|
|
34
|
+
"·..", // First dot up
|
|
35
|
+
".·.", // Middle dot up
|
|
36
|
+
"..·", // Last dot up
|
|
37
|
+
".·.", // Middle dot up
|
|
38
|
+
"·..", // First dot up
|
|
34
39
|
];
|
|
35
40
|
/**
|
|
36
41
|
* Component that displays elapsed time for waiting/streaming
|
|
37
42
|
*/
|
|
38
43
|
function WaitingElapsedTime({ startTime }) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
44
|
+
const [elapsed, setElapsed] = useState(0);
|
|
45
|
+
const [thinkingWord, setThinkingWord] = useState(
|
|
46
|
+
() => THINKING_WORDS[Math.floor(Math.random() * THINKING_WORDS.length)],
|
|
47
|
+
);
|
|
48
|
+
const [dotIndex, setDotIndex] = useState(0);
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
// Update elapsed time every 100ms for smooth updates
|
|
51
|
+
const interval = setInterval(() => {
|
|
52
|
+
const now = Date.now();
|
|
53
|
+
const elapsedMs = now - startTime;
|
|
54
|
+
setElapsed(elapsedMs);
|
|
55
|
+
}, 100);
|
|
56
|
+
return () => clearInterval(interval);
|
|
57
|
+
}, [startTime]);
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
// Change to random thinking word every 1.5 seconds
|
|
60
|
+
const wordInterval = setInterval(() => {
|
|
61
|
+
const randomIndex = Math.floor(Math.random() * THINKING_WORDS.length);
|
|
62
|
+
setThinkingWord(THINKING_WORDS[randomIndex]);
|
|
63
|
+
}, 1500);
|
|
64
|
+
return () => clearInterval(wordInterval);
|
|
65
|
+
}, []);
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
// Animate dots every 100ms for bouncing effect
|
|
68
|
+
const dotInterval = setInterval(() => {
|
|
69
|
+
setDotIndex((prev) => (prev + 1) % DOT_ANIMATIONS.length);
|
|
70
|
+
}, 100);
|
|
71
|
+
return () => clearInterval(dotInterval);
|
|
72
|
+
}, []);
|
|
73
|
+
// Format elapsed time as seconds with 1 decimal place
|
|
74
|
+
const seconds = (elapsed / 1000).toFixed(1);
|
|
75
|
+
const animatedDots = DOT_ANIMATIONS[dotIndex];
|
|
76
|
+
return _jsxs(Text, {
|
|
77
|
+
color: "red",
|
|
78
|
+
children: [thinkingWord, animatedDots, " ", seconds, "s"],
|
|
79
|
+
});
|
|
70
80
|
}
|
|
71
|
-
export function StatusBar({
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
export function StatusBar({
|
|
82
|
+
connectionStatus,
|
|
83
|
+
isStreaming,
|
|
84
|
+
streamingStartTime,
|
|
85
|
+
hasStreamingContent,
|
|
86
|
+
}) {
|
|
87
|
+
const statusColor =
|
|
88
|
+
connectionStatus === "connected"
|
|
89
|
+
? "green"
|
|
90
|
+
: connectionStatus === "connecting"
|
|
91
|
+
? "yellow"
|
|
92
|
+
: connectionStatus === "error"
|
|
93
|
+
? "red"
|
|
94
|
+
: "gray";
|
|
95
|
+
// Only show waiting indicator when streaming but haven't received content yet
|
|
96
|
+
const showWaiting = isStreaming && streamingStartTime && !hasStreamingContent;
|
|
97
|
+
return _jsxs(Box, {
|
|
98
|
+
flexDirection: "row",
|
|
99
|
+
gap: 2,
|
|
100
|
+
paddingY: 1,
|
|
101
|
+
children: [
|
|
102
|
+
_jsxs(Text, {
|
|
103
|
+
children: [
|
|
104
|
+
"Status: ",
|
|
105
|
+
_jsx(Text, { color: statusColor, children: connectionStatus }),
|
|
106
|
+
],
|
|
107
|
+
}),
|
|
108
|
+
showWaiting &&
|
|
109
|
+
_jsxs(_Fragment, {
|
|
110
|
+
children: [
|
|
111
|
+
_jsx(Text, { children: " " }),
|
|
112
|
+
_jsx(WaitingElapsedTime, { startTime: streamingStartTime }),
|
|
113
|
+
],
|
|
114
|
+
}),
|
|
115
|
+
],
|
|
116
|
+
});
|
|
82
117
|
}
|
package/dist/tui/index.d.ts
CHANGED
package/dist/tui/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@townco/ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
"type": "git",
|
|
14
14
|
"url": "git+https://github.com/federicoweber/agent_hub.git"
|
|
15
15
|
},
|
|
16
|
-
"author": "Federico Weber",
|
|
17
16
|
"exports": {
|
|
18
17
|
".": {
|
|
19
18
|
"import": "./dist/index.js",
|
|
@@ -58,7 +57,7 @@
|
|
|
58
57
|
},
|
|
59
58
|
"devDependencies": {
|
|
60
59
|
"@tailwindcss/postcss": "^4.1.17",
|
|
61
|
-
"@townco/tsconfig": "
|
|
60
|
+
"@townco/tsconfig": "workspace:*",
|
|
62
61
|
"@types/node": "^24.10.0",
|
|
63
62
|
"@types/react": "^19.2.2",
|
|
64
63
|
"ink": "^6.4.0",
|