@townco/ui 0.1.0 → 0.1.6

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 (125) hide show
  1. package/dist/core/hooks/use-chat-input.d.ts +17 -17
  2. package/dist/core/hooks/use-chat-input.js +64 -55
  3. package/dist/core/hooks/use-chat-messages.d.ts +11 -11
  4. package/dist/core/hooks/use-chat-messages.js +121 -114
  5. package/dist/core/hooks/use-chat-session.d.ts +5 -5
  6. package/dist/core/hooks/use-chat-session.js +78 -80
  7. package/dist/core/hooks/use-media-query.d.ts +5 -5
  8. package/dist/core/hooks/use-media-query.js +38 -38
  9. package/dist/core/index.d.ts +1 -1
  10. package/dist/core/index.js +1 -1
  11. package/dist/core/schemas/chat.d.ts +83 -56
  12. package/dist/core/schemas/chat.js +27 -25
  13. package/dist/core/store/chat-store.d.ts +28 -22
  14. package/dist/core/store/chat-store.js +59 -50
  15. package/dist/gui/components/Button.d.ts +23 -7
  16. package/dist/gui/components/Button.js +40 -27
  17. package/dist/gui/components/Card.d.ts +26 -7
  18. package/dist/gui/components/Card.js +54 -8
  19. package/dist/gui/components/ChatHeader.d.ts +58 -31
  20. package/dist/gui/components/ChatHeader.js +171 -66
  21. package/dist/gui/components/ChatInput.d.ts +58 -36
  22. package/dist/gui/components/ChatInput.js +191 -121
  23. package/dist/gui/components/ChatInterface.d.ts +9 -6
  24. package/dist/gui/components/ChatInterface.js +162 -90
  25. package/dist/gui/components/ChatLayout.d.ts +71 -41
  26. package/dist/gui/components/ChatLayout.js +214 -87
  27. package/dist/gui/components/ChatPanelTabContent.d.ts +18 -9
  28. package/dist/gui/components/ChatPanelTabContent.js +88 -10
  29. package/dist/gui/components/ChatPreview.d.ts +9 -6
  30. package/dist/gui/components/ChatPreview.js +212 -162
  31. package/dist/gui/components/ChatSecondaryPanel.d.ts +14 -11
  32. package/dist/gui/components/ChatSecondaryPanel.js +115 -38
  33. package/dist/gui/components/ChatSidebar.d.ts +26 -13
  34. package/dist/gui/components/ChatSidebar.js +48 -14
  35. package/dist/gui/components/ChatStatus.d.ts +4 -2
  36. package/dist/gui/components/ChatStatus.js +45 -34
  37. package/dist/gui/components/ChatView.d.ts +5 -3
  38. package/dist/gui/components/ChatView.js +38 -9
  39. package/dist/gui/components/ConfigPanel.d.ts +16 -12
  40. package/dist/gui/components/ConfigPanel.js +218 -41
  41. package/dist/gui/components/Conversation.d.ts +17 -14
  42. package/dist/gui/components/Conversation.js +143 -83
  43. package/dist/gui/components/Dialog.d.ts +57 -11
  44. package/dist/gui/components/Dialog.js +84 -8
  45. package/dist/gui/components/DropdownMenu.d.ts +101 -20
  46. package/dist/gui/components/DropdownMenu.js +161 -14
  47. package/dist/gui/components/HeightTransition.d.ts +12 -7
  48. package/dist/gui/components/HeightTransition.js +88 -77
  49. package/dist/gui/components/Input.d.ts +13 -6
  50. package/dist/gui/components/Input.js +27 -16
  51. package/dist/gui/components/InputBox.d.ts +19 -12
  52. package/dist/gui/components/InputBox.js +86 -14
  53. package/dist/gui/components/Label.d.ts +7 -1
  54. package/dist/gui/components/Label.js +12 -2
  55. package/dist/gui/components/MarkdownRenderer.d.ts +6 -4
  56. package/dist/gui/components/MarkdownRenderer.js +178 -81
  57. package/dist/gui/components/Message.d.ts +25 -18
  58. package/dist/gui/components/Message.js +44 -23
  59. package/dist/gui/components/MessageContent.d.ts +29 -22
  60. package/dist/gui/components/MessageContent.js +157 -85
  61. package/dist/gui/components/PlaygroundLayout.d.ts +9 -5
  62. package/dist/gui/components/PlaygroundLayout.js +43 -12
  63. package/dist/gui/components/Reasoning.d.ts +30 -24
  64. package/dist/gui/components/Reasoning.js +187 -60
  65. package/dist/gui/components/Response.d.ts +11 -9
  66. package/dist/gui/components/Response.js +229 -90
  67. package/dist/gui/components/Select.d.ts +69 -10
  68. package/dist/gui/components/Select.js +118 -12
  69. package/dist/gui/components/Sonner.d.ts +3 -1
  70. package/dist/gui/components/Sonner.js +29 -18
  71. package/dist/gui/components/StatusBar.d.ts +9 -5
  72. package/dist/gui/components/StatusBar.js +56 -9
  73. package/dist/gui/components/Tabs.d.ts +24 -4
  74. package/dist/gui/components/Tabs.js +32 -4
  75. package/dist/gui/components/Task.d.ts +28 -24
  76. package/dist/gui/components/Task.js +164 -31
  77. package/dist/gui/components/Textarea.d.ts +15 -7
  78. package/dist/gui/components/Textarea.js +63 -46
  79. package/dist/gui/components/ThinkingBlock.d.ts +20 -10
  80. package/dist/gui/components/ThinkingBlock.js +134 -35
  81. package/dist/gui/components/TodoList.d.ts +12 -10
  82. package/dist/gui/components/TodoList.js +22 -7
  83. package/dist/gui/components/TodoListItem.d.ts +9 -6
  84. package/dist/gui/components/TodoListItem.js +18 -4
  85. package/dist/gui/components/index.d.ts +59 -8
  86. package/dist/gui/components/index.js +42 -8
  87. package/dist/gui/lib/utils.js +1 -1
  88. package/dist/index.d.ts +1 -1
  89. package/dist/index.js +1 -1
  90. package/dist/index.test.js +0 -1
  91. package/dist/sdk/client/acp-client.d.ts +88 -76
  92. package/dist/sdk/client/acp-client.js +215 -217
  93. package/dist/sdk/index.d.ts +1 -1
  94. package/dist/sdk/index.js +1 -1
  95. package/dist/sdk/schemas/agent.d.ts +111 -64
  96. package/dist/sdk/schemas/agent.js +24 -24
  97. package/dist/sdk/schemas/message.d.ts +245 -147
  98. package/dist/sdk/schemas/message.js +40 -40
  99. package/dist/sdk/schemas/session.d.ts +219 -135
  100. package/dist/sdk/schemas/session.js +27 -27
  101. package/dist/sdk/transports/http.d.ts +55 -55
  102. package/dist/sdk/transports/http.js +472 -469
  103. package/dist/sdk/transports/stdio.d.ts +20 -20
  104. package/dist/sdk/transports/stdio.js +289 -286
  105. package/dist/sdk/transports/types.d.ts +42 -42
  106. package/dist/sdk/transports/websocket.d.ts +12 -12
  107. package/dist/sdk/transports/websocket.js +52 -46
  108. package/dist/tui/components/ChatView.d.ts +4 -2
  109. package/dist/tui/components/ChatView.js +51 -18
  110. package/dist/tui/components/GameOfLife.js +64 -35
  111. package/dist/tui/components/InputBox.d.ts +18 -11
  112. package/dist/tui/components/InputBox.js +70 -10
  113. package/dist/tui/components/MessageList.d.ts +4 -2
  114. package/dist/tui/components/MessageList.js +37 -10
  115. package/dist/tui/components/MultiSelect.d.ts +15 -9
  116. package/dist/tui/components/MultiSelect.js +116 -69
  117. package/dist/tui/components/ReadlineInput.d.ts +12 -6
  118. package/dist/tui/components/ReadlineInput.js +252 -237
  119. package/dist/tui/components/SingleSelect.d.ts +15 -9
  120. package/dist/tui/components/SingleSelect.js +84 -43
  121. package/dist/tui/components/StatusBar.d.ts +11 -6
  122. package/dist/tui/components/StatusBar.js +102 -67
  123. package/dist/tui/index.d.ts +1 -1
  124. package/dist/tui/index.js +1 -1
  125. package/package.json +2 -3
@@ -1,137 +1,207 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
1
  import { Slot } from "@radix-ui/react-slot";
3
2
  import * as React from "react";
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
4
  import { useChatInput as useCoreChatInput } from "../../core/hooks/use-chat-input.js";
5
5
  import { useChatStore } from "../../core/store/chat-store.js";
6
6
  import { cn } from "../lib/utils.js";
7
7
  import { Button } from "./Button.js";
8
+
8
9
  const ChatInputContext = React.createContext(undefined);
9
10
  const useChatInputContext = () => {
10
- const context = React.useContext(ChatInputContext);
11
- if (!context) {
12
- throw new Error("ChatInput components must be used within ChatInput.Root");
13
- }
14
- return context;
11
+ const context = React.useContext(ChatInputContext);
12
+ if (!context) {
13
+ throw new Error("ChatInput components must be used within ChatInput.Root");
14
+ }
15
+ return context;
15
16
  };
16
- const ChatInputRoot = React.forwardRef(({ client, value: valueProp, onChange: onChangeProp, onSubmit: onSubmitProp, disabled = false, isSubmitting: isSubmittingProp, submitOnEnter = true, className, children, ...props }, ref) => {
17
- const textareaRef = React.useRef(null);
18
- // Always call hooks unconditionally (React rules)
19
- const hookData = useCoreChatInput(client ?? null);
20
- const storeIsStreaming = useChatStore((state) => state.isStreaming);
21
- // Choose data source based on whether client is provided
22
- const value = hookData ? hookData.value : valueProp || "";
23
- const onChange = hookData ? hookData.onChange : onChangeProp || (() => { });
24
- const onSubmit = hookData
25
- ? hookData.onSubmit
26
- : onSubmitProp || (async () => { });
27
- const isSubmitting = hookData
28
- ? hookData.isSubmitting || storeIsStreaming
29
- : isSubmittingProp || false;
30
- const handleSubmit = async (e) => {
31
- e.preventDefault();
32
- if (value.trim() && !isSubmitting && !disabled) {
33
- await onSubmit();
34
- // Restore focus to textarea after submit
35
- setTimeout(() => {
36
- textareaRef.current?.focus();
37
- }, 0);
38
- }
39
- };
40
- // Expose textarea ref to children via context
41
- React.useEffect(() => {
42
- const textarea = document.querySelector('textarea[name="chat-input"]');
43
- if (textarea && textareaRef.current !== textarea) {
44
- textareaRef.current = textarea;
45
- }
46
- }, []);
47
- // Reset textarea height when value becomes empty (after submit)
48
- React.useEffect(() => {
49
- if (!value && textareaRef.current) {
50
- textareaRef.current.style.height = "auto";
51
- textareaRef.current.style.overflowY = "hidden";
52
- }
53
- }, [value]);
54
- return (_jsx(ChatInputContext.Provider, { value: {
55
- value,
56
- onChange,
57
- onSubmit,
58
- disabled,
59
- isSubmitting,
60
- submitOnEnter,
61
- }, children: _jsx("form", { ref: ref, onSubmit: handleSubmit, className: cn("w-full divide-y overflow-hidden rounded-xl border bg-background shadow-sm", className), ...props, children: children }) }));
62
- });
17
+ const ChatInputRoot = React.forwardRef(
18
+ (
19
+ {
20
+ client,
21
+ value: valueProp,
22
+ onChange: onChangeProp,
23
+ onSubmit: onSubmitProp,
24
+ disabled = false,
25
+ isSubmitting: isSubmittingProp,
26
+ submitOnEnter = true,
27
+ className,
28
+ children,
29
+ ...props
30
+ },
31
+ ref,
32
+ ) => {
33
+ const textareaRef = React.useRef(null);
34
+ // Always call hooks unconditionally (React rules)
35
+ const hookData = useCoreChatInput(client ?? null);
36
+ const storeIsStreaming = useChatStore((state) => state.isStreaming);
37
+ // Choose data source based on whether client is provided
38
+ const value = hookData ? hookData.value : valueProp || "";
39
+ const onChange = hookData ? hookData.onChange : onChangeProp || (() => {});
40
+ const onSubmit = hookData
41
+ ? hookData.onSubmit
42
+ : onSubmitProp || (async () => {});
43
+ const isSubmitting = hookData
44
+ ? hookData.isSubmitting || storeIsStreaming
45
+ : isSubmittingProp || false;
46
+ const handleSubmit = async (e) => {
47
+ e.preventDefault();
48
+ if (value.trim() && !isSubmitting && !disabled) {
49
+ await onSubmit();
50
+ // Restore focus to textarea after submit
51
+ setTimeout(() => {
52
+ textareaRef.current?.focus();
53
+ }, 0);
54
+ }
55
+ };
56
+ // Expose textarea ref to children via context
57
+ React.useEffect(() => {
58
+ const textarea = document.querySelector('textarea[name="chat-input"]');
59
+ if (textarea && textareaRef.current !== textarea) {
60
+ textareaRef.current = textarea;
61
+ }
62
+ }, []);
63
+ // Reset textarea height when value becomes empty (after submit)
64
+ React.useEffect(() => {
65
+ if (!value && textareaRef.current) {
66
+ textareaRef.current.style.height = "auto";
67
+ textareaRef.current.style.overflowY = "hidden";
68
+ }
69
+ }, [value]);
70
+ return _jsx(ChatInputContext.Provider, {
71
+ value: {
72
+ value,
73
+ onChange,
74
+ onSubmit,
75
+ disabled,
76
+ isSubmitting,
77
+ submitOnEnter,
78
+ },
79
+ children: _jsx("form", {
80
+ ref: ref,
81
+ onSubmit: handleSubmit,
82
+ className: cn(
83
+ "w-full divide-y overflow-hidden rounded-xl border bg-background shadow-sm",
84
+ className,
85
+ ),
86
+ ...props,
87
+ children: children,
88
+ }),
89
+ });
90
+ },
91
+ );
63
92
  ChatInputRoot.displayName = "ChatInput.Root";
64
- const ChatInputField = React.forwardRef(({ asChild = false, className, onKeyDown, children, ...props }, ref) => {
65
- const { value, onChange, onSubmit, disabled, isSubmitting, submitOnEnter } = useChatInputContext();
66
- const textareaRef = React.useRef(null);
67
- const handleRef = React.useCallback((node) => {
68
- textareaRef.current = node;
69
- if (typeof ref === "function") {
70
- ref(node);
71
- }
72
- else if (ref) {
73
- ref.current = node;
74
- }
75
- }, [ref]);
76
- const handleKeyDown = (e) => {
77
- // Handle Enter without Shift - only submit if not already submitting
78
- if (submitOnEnter && e.key === "Enter" && !e.shiftKey) {
79
- // Only prevent default and submit if conditions are met
80
- if (value.trim() && !isSubmitting && !disabled) {
81
- e.preventDefault();
82
- onSubmit();
83
- }
84
- else if (isSubmitting || disabled) {
85
- // Block Enter when submitting or disabled - don't add newline
86
- e.preventDefault();
87
- }
88
- }
89
- onKeyDown?.(e);
90
- };
91
- const handleChange = (e) => {
92
- onChange(e.target.value);
93
- // Auto-resize
94
- const textarea = textareaRef.current;
95
- if (!textarea)
96
- return;
97
- textarea.style.height = "auto";
98
- const newHeight = Math.min(textarea.scrollHeight, 164);
99
- textarea.style.height = `${newHeight}px`;
100
- if (textarea.scrollHeight > 164) {
101
- textarea.style.overflowY = "auto";
102
- }
103
- else {
104
- textarea.style.overflowY = "hidden";
105
- }
106
- };
107
- const fieldProps = {
108
- ref: handleRef,
109
- name: "chat-input",
110
- value,
111
- onChange: handleChange,
112
- onKeyDown: handleKeyDown,
113
- disabled: disabled,
114
- ...props,
115
- };
116
- if (asChild && React.isValidElement(children)) {
117
- return React.cloneElement(children, fieldProps);
118
- }
119
- return (_jsx("textarea", { ...fieldProps, className: cn("w-full resize-none rounded-none border-none p-3 shadow-none", "outline-none ring-0 field-sizing-content max-h-[6lh]", "bg-transparent dark:bg-transparent focus-visible:ring-0", "text-sm placeholder:text-muted-foreground", "disabled:cursor-not-allowed disabled:opacity-50", className) }));
120
- });
93
+ const ChatInputField = React.forwardRef(
94
+ ({ asChild = false, className, onKeyDown, children, ...props }, ref) => {
95
+ const { value, onChange, onSubmit, disabled, isSubmitting, submitOnEnter } =
96
+ useChatInputContext();
97
+ const textareaRef = React.useRef(null);
98
+ const handleRef = React.useCallback(
99
+ (node) => {
100
+ textareaRef.current = node;
101
+ if (typeof ref === "function") {
102
+ ref(node);
103
+ } else if (ref) {
104
+ ref.current = node;
105
+ }
106
+ },
107
+ [ref],
108
+ );
109
+ const handleKeyDown = (e) => {
110
+ // Handle Enter without Shift - only submit if not already submitting
111
+ if (submitOnEnter && e.key === "Enter" && !e.shiftKey) {
112
+ // Only prevent default and submit if conditions are met
113
+ if (value.trim() && !isSubmitting && !disabled) {
114
+ e.preventDefault();
115
+ onSubmit();
116
+ } else if (isSubmitting || disabled) {
117
+ // Block Enter when submitting or disabled - don't add newline
118
+ e.preventDefault();
119
+ }
120
+ }
121
+ onKeyDown?.(e);
122
+ };
123
+ const handleChange = (e) => {
124
+ onChange(e.target.value);
125
+ // Auto-resize
126
+ const textarea = textareaRef.current;
127
+ if (!textarea) return;
128
+ textarea.style.height = "auto";
129
+ const newHeight = Math.min(textarea.scrollHeight, 164);
130
+ textarea.style.height = `${newHeight}px`;
131
+ if (textarea.scrollHeight > 164) {
132
+ textarea.style.overflowY = "auto";
133
+ } else {
134
+ textarea.style.overflowY = "hidden";
135
+ }
136
+ };
137
+ const fieldProps = {
138
+ ref: handleRef,
139
+ name: "chat-input",
140
+ value,
141
+ onChange: handleChange,
142
+ onKeyDown: handleKeyDown,
143
+ disabled: disabled,
144
+ ...props,
145
+ };
146
+ if (asChild && React.isValidElement(children)) {
147
+ return React.cloneElement(children, fieldProps);
148
+ }
149
+ return _jsx("textarea", {
150
+ ...fieldProps,
151
+ className: cn(
152
+ "w-full resize-none rounded-none border-none p-3 shadow-none",
153
+ "outline-none ring-0 field-sizing-content max-h-[6lh]",
154
+ "bg-transparent dark:bg-transparent focus-visible:ring-0",
155
+ "text-sm placeholder:text-muted-foreground",
156
+ "disabled:cursor-not-allowed disabled:opacity-50",
157
+ className,
158
+ ),
159
+ });
160
+ },
161
+ );
121
162
  ChatInputField.displayName = "ChatInput.Field";
122
- const ChatInputSubmit = React.forwardRef(({ asChild = false, className, disabled: disabledProp, children, ...props }, ref) => {
123
- const { value, disabled, isSubmitting } = useChatInputContext();
124
- const isDisabled = disabledProp || disabled || isSubmitting || !value.trim();
125
- const Comp = asChild ? Slot : Button;
126
- return (_jsx(Comp, { ref: ref, type: "submit", disabled: isDisabled, size: "icon", className: cn(!asChild &&
127
- "gap-1.5 rounded-lg bg-transparent text-foreground hover:bg-transparent", className), ...props, children: children }));
128
- });
163
+ const ChatInputSubmit = React.forwardRef(
164
+ (
165
+ { asChild = false, className, disabled: disabledProp, children, ...props },
166
+ ref,
167
+ ) => {
168
+ const { value, disabled, isSubmitting } = useChatInputContext();
169
+ const isDisabled =
170
+ disabledProp || disabled || isSubmitting || !value.trim();
171
+ const Comp = asChild ? Slot : Button;
172
+ return _jsx(Comp, {
173
+ ref: ref,
174
+ type: "submit",
175
+ disabled: isDisabled,
176
+ size: "icon",
177
+ className: cn(
178
+ !asChild &&
179
+ "gap-1.5 rounded-lg bg-transparent text-foreground hover:bg-transparent",
180
+ className,
181
+ ),
182
+ ...props,
183
+ children: children,
184
+ });
185
+ },
186
+ );
129
187
  ChatInputSubmit.displayName = "ChatInput.Submit";
130
- const ChatInputToolbar = React.forwardRef(({ className, children, ...props }, ref) => {
131
- return (_jsx("div", { ref: ref, className: cn("flex items-center justify-between p-1", className), ...props, children: children }));
132
- });
188
+ const ChatInputToolbar = React.forwardRef(
189
+ ({ className, children, ...props }, ref) => {
190
+ return _jsx("div", {
191
+ ref: ref,
192
+ className: cn("flex items-center justify-between p-1", className),
193
+ ...props,
194
+ children: children,
195
+ });
196
+ },
197
+ );
133
198
  ChatInputToolbar.displayName = "ChatInput.Toolbar";
134
199
  /* -------------------------------------------------------------------------------------------------
135
200
  * Exports
136
201
  * -----------------------------------------------------------------------------------------------*/
137
- export { ChatInputRoot as Root, ChatInputField as Field, ChatInputSubmit as Submit, ChatInputToolbar as Toolbar, };
202
+ export {
203
+ ChatInputRoot as Root,
204
+ ChatInputField as Field,
205
+ ChatInputSubmit as Submit,
206
+ ChatInputToolbar as Toolbar,
207
+ };
@@ -1,9 +1,12 @@
1
1
  import { type DisplayMessage } from "./MessageList.js";
2
2
  interface ChatInterfaceProps {
3
- initialMessages?: DisplayMessage[];
4
- thinkingDisplayStyle?: "collapsible" | "inline";
5
- status?: string;
3
+ initialMessages?: DisplayMessage[];
4
+ thinkingDisplayStyle?: "collapsible" | "inline";
5
+ status?: string;
6
6
  }
7
- export declare function ChatInterface({ initialMessages, thinkingDisplayStyle, status, }: ChatInterfaceProps): import("react/jsx-runtime").JSX.Element;
8
- export {};
9
- //# sourceMappingURL=ChatInterface.d.ts.map
7
+ export declare function ChatInterface({
8
+ initialMessages,
9
+ thinkingDisplayStyle,
10
+ status,
11
+ }: ChatInterfaceProps): import("react/jsx-runtime").JSX.Element;
12
+ //# sourceMappingURL=ChatInterface.d.ts.map
@@ -1,50 +1,51 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState, useEffect } from "react";
3
1
  import { ChevronDown } from "lucide-react";
4
- import { MessageList } from "./MessageList.js";
5
- import { ChatStatus } from "./ChatStatus.js";
2
+ import { useEffect, useState } from "react";
3
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
+ import { ChatInput } from "./ChatInput.js";
6
5
  import { ChatSecondaryPanel } from "./ChatSecondaryPanel.js";
6
+ import { ChatStatus } from "./ChatStatus.js";
7
7
  import { HeightTransition } from "./HeightTransition.js";
8
- import { ChatInput } from "./ChatInput.js";
8
+ import { MessageList } from "./MessageList.js";
9
+
9
10
  const SAMPLE_TODOS = [
10
- {
11
- id: "1",
12
- text: "Identify the last 25 Winter Olympics host countries",
13
- status: "completed",
14
- },
15
- {
16
- id: "2",
17
- text: "For each host country, find the tallest mountain",
18
- status: "in_progress",
19
- },
20
- {
21
- id: "3",
22
- text: "Gather key details for each mountain (name, elevation, location)",
23
- status: "pending",
24
- },
25
- {
26
- id: "4",
27
- text: "Verify information using reliable sources (geographical databases, official records)",
28
- status: "pending",
29
- },
30
- {
31
- id: "5",
32
- text: "Compile findings into a summary table or document",
33
- status: "pending",
34
- },
11
+ {
12
+ id: "1",
13
+ text: "Identify the last 25 Winter Olympics host countries",
14
+ status: "completed",
15
+ },
16
+ {
17
+ id: "2",
18
+ text: "For each host country, find the tallest mountain",
19
+ status: "in_progress",
20
+ },
21
+ {
22
+ id: "3",
23
+ text: "Gather key details for each mountain (name, elevation, location)",
24
+ status: "pending",
25
+ },
26
+ {
27
+ id: "4",
28
+ text: "Verify information using reliable sources (geographical databases, official records)",
29
+ status: "pending",
30
+ },
31
+ {
32
+ id: "5",
33
+ text: "Compile findings into a summary table or document",
34
+ status: "pending",
35
+ },
35
36
  ];
36
37
  const SAMPLE_MESSAGES = [
37
- {
38
- id: "msg-1",
39
- role: "user",
40
- content: "Hello! Can you help me understand how to use markdown?",
41
- timestamp: new Date().toISOString(),
42
- isStreaming: false,
43
- },
44
- {
45
- id: "msg-2",
46
- role: "assistant",
47
- content: `Sure! Markdown is a lightweight markup language. Here are some basics:
38
+ {
39
+ id: "msg-1",
40
+ role: "user",
41
+ content: "Hello! Can you help me understand how to use markdown?",
42
+ timestamp: new Date().toISOString(),
43
+ isStreaming: false,
44
+ },
45
+ {
46
+ id: "msg-2",
47
+ role: "assistant",
48
+ content: `Sure! Markdown is a lightweight markup language. Here are some basics:
48
49
 
49
50
  ## Headings
50
51
  Use \`#\` for headings. More \`#\` symbols make smaller headings.
@@ -79,54 +80,125 @@ You can make text **bold** or *italic*.
79
80
  |----------|----------|
80
81
  | Cell 1 | Cell 2 |
81
82
  | Cell 3 | Cell 4 |`,
82
- timestamp: new Date().toISOString(),
83
- isStreaming: false,
84
- metadata: {
85
- thinking: "Let me provide a comprehensive overview of markdown syntax...",
86
- },
87
- },
88
- {
89
- id: "msg-3",
90
- role: "user",
91
- content: "That's really helpful, thank you!",
92
- timestamp: new Date().toISOString(),
93
- isStreaming: false,
94
- },
83
+ timestamp: new Date().toISOString(),
84
+ isStreaming: false,
85
+ metadata: {
86
+ thinking: "Let me provide a comprehensive overview of markdown syntax...",
87
+ },
88
+ },
89
+ {
90
+ id: "msg-3",
91
+ role: "user",
92
+ content: "That's really helpful, thank you!",
93
+ timestamp: new Date().toISOString(),
94
+ isStreaming: false,
95
+ },
95
96
  ];
96
- export function ChatInterface({ initialMessages = SAMPLE_MESSAGES, thinkingDisplayStyle = "collapsible", status = "Connected", }) {
97
- const [messages, setMessages] = useState(initialMessages);
98
- const [currentStatus, setCurrentStatus] = useState(status);
99
- const [config, setConfig] = useState(null);
100
- const [isHeaderExpanded, setIsHeaderExpanded] = useState(false);
101
- const [todos] = useState(SAMPLE_TODOS);
102
- // Listen for config and status updates from parent window
103
- useEffect(() => {
104
- const handleMessage = (event) => {
105
- if (event.data.type === "CONFIG_UPDATE") {
106
- const newConfig = event.data.config;
107
- setConfig(newConfig);
108
- applyConfigToDocument(newConfig);
109
- }
110
- else if (event.data.type === "STATUS_UPDATE") {
111
- setCurrentStatus(event.data.status);
112
- }
113
- };
114
- window.addEventListener("message", handleMessage);
115
- // Request config from parent on mount
116
- if (window.parent !== window) {
117
- window.parent.postMessage({ type: "REQUEST_CONFIG" }, "*");
118
- }
119
- return () => {
120
- window.removeEventListener("message", handleMessage);
121
- };
122
- }, []);
123
- const applyConfigToDocument = (cfg) => {
124
- const root = document.documentElement;
125
- root.setAttribute("data-theme", cfg.colorScheme);
126
- root.style.setProperty("--color-accent", cfg.accentColor);
127
- root.style.setProperty("--font-family", cfg.typography);
128
- root.style.setProperty("--font-size", `${cfg.fontSize}px`);
129
- };
130
- return (_jsxs("div", { className: "flex flex-col h-screen bg-[var(--color-bg)] text-[var(--color-text)]", children: [_jsxs("div", { className: "relative border-b border-[var(--color-border)] bg-[var(--color-surface)] z-10", children: [_jsxs("div", { className: "flex items-center justify-between px-6 py-4", children: [_jsx("h1", { className: "text-xl font-semibold m-0", children: "Chat Interface" }), _jsxs("div", { className: "flex items-center gap-3", children: [_jsx(ChatStatus, { children: currentStatus }), _jsx("button", { onClick: () => setIsHeaderExpanded(!isHeaderExpanded), className: "p-1 rounded hover:bg-[var(--color-bg)] transition-colors", "aria-label": isHeaderExpanded ? "Collapse header" : "Expand header", children: _jsx(ChevronDown, { className: `w-5 h-5 text-[var(--color-text)] transition-transform duration-200 ${isHeaderExpanded ? "rotate-180" : ""}` }) })] })] }), _jsx("div", { className: "absolute top-full left-0 right-0 z-20", children: _jsx(HeightTransition, { children: isHeaderExpanded && (_jsx("div", { className: "bg-[var(--color-surface)] border-b border-[var(--color-border)] px-6 py-4 shadow-lg", children: _jsx(ChatSecondaryPanel, { todos: todos }) })) }) })] }), _jsx("div", { className: "flex-1 overflow-y-auto py-4", children: _jsx(MessageList, { messages: messages, thinkingDisplayStyle: config?.thinkingDisplayStyle || thinkingDisplayStyle }) }), _jsx("div", { className: "border-t border-[var(--color-border)] px-6 py-4 bg-[var(--color-surface)]", children: _jsx(ChatInput, { value: "", onChange: () => { }, onSubmit: () => { }, disabled: true, placeholder: "Type a message..." }) })] }));
97
+ export function ChatInterface({
98
+ initialMessages = SAMPLE_MESSAGES,
99
+ thinkingDisplayStyle = "collapsible",
100
+ status = "Connected",
101
+ }) {
102
+ const [messages, setMessages] = useState(initialMessages);
103
+ const [currentStatus, setCurrentStatus] = useState(status);
104
+ const [config, setConfig] = useState(null);
105
+ const [isHeaderExpanded, setIsHeaderExpanded] = useState(false);
106
+ const [todos] = useState(SAMPLE_TODOS);
107
+ // Listen for config and status updates from parent window
108
+ useEffect(() => {
109
+ const handleMessage = (event) => {
110
+ if (event.data.type === "CONFIG_UPDATE") {
111
+ const newConfig = event.data.config;
112
+ setConfig(newConfig);
113
+ applyConfigToDocument(newConfig);
114
+ } else if (event.data.type === "STATUS_UPDATE") {
115
+ setCurrentStatus(event.data.status);
116
+ }
117
+ };
118
+ window.addEventListener("message", handleMessage);
119
+ // Request config from parent on mount
120
+ if (window.parent !== window) {
121
+ window.parent.postMessage({ type: "REQUEST_CONFIG" }, "*");
122
+ }
123
+ return () => {
124
+ window.removeEventListener("message", handleMessage);
125
+ };
126
+ }, []);
127
+ const applyConfigToDocument = (cfg) => {
128
+ const root = document.documentElement;
129
+ root.setAttribute("data-theme", cfg.colorScheme);
130
+ root.style.setProperty("--color-accent", cfg.accentColor);
131
+ root.style.setProperty("--font-family", cfg.typography);
132
+ root.style.setProperty("--font-size", `${cfg.fontSize}px`);
133
+ };
134
+ return _jsxs("div", {
135
+ className:
136
+ "flex flex-col h-screen bg-[var(--color-bg)] text-[var(--color-text)]",
137
+ children: [
138
+ _jsxs("div", {
139
+ className:
140
+ "relative border-b border-[var(--color-border)] bg-[var(--color-surface)] z-10",
141
+ children: [
142
+ _jsxs("div", {
143
+ className: "flex items-center justify-between px-6 py-4",
144
+ children: [
145
+ _jsx("h1", {
146
+ className: "text-xl font-semibold m-0",
147
+ children: "Chat Interface",
148
+ }),
149
+ _jsxs("div", {
150
+ className: "flex items-center gap-3",
151
+ children: [
152
+ _jsx(ChatStatus, { children: currentStatus }),
153
+ _jsx("button", {
154
+ onClick: () => setIsHeaderExpanded(!isHeaderExpanded),
155
+ className:
156
+ "p-1 rounded hover:bg-[var(--color-bg)] transition-colors",
157
+ "aria-label": isHeaderExpanded
158
+ ? "Collapse header"
159
+ : "Expand header",
160
+ children: _jsx(ChevronDown, {
161
+ className: `w-5 h-5 text-[var(--color-text)] transition-transform duration-200 ${isHeaderExpanded ? "rotate-180" : ""}`,
162
+ }),
163
+ }),
164
+ ],
165
+ }),
166
+ ],
167
+ }),
168
+ _jsx("div", {
169
+ className: "absolute top-full left-0 right-0 z-20",
170
+ children: _jsx(HeightTransition, {
171
+ children:
172
+ isHeaderExpanded &&
173
+ _jsx("div", {
174
+ className:
175
+ "bg-[var(--color-surface)] border-b border-[var(--color-border)] px-6 py-4 shadow-lg",
176
+ children: _jsx(ChatSecondaryPanel, { todos: todos }),
177
+ }),
178
+ }),
179
+ }),
180
+ ],
181
+ }),
182
+ _jsx("div", {
183
+ className: "flex-1 overflow-y-auto py-4",
184
+ children: _jsx(MessageList, {
185
+ messages: messages,
186
+ thinkingDisplayStyle:
187
+ config?.thinkingDisplayStyle || thinkingDisplayStyle,
188
+ }),
189
+ }),
190
+ _jsx("div", {
191
+ className:
192
+ "border-t border-[var(--color-border)] px-6 py-4 bg-[var(--color-surface)]",
193
+ children: _jsx(ChatInput, {
194
+ value: "",
195
+ onChange: () => {},
196
+ onSubmit: () => {},
197
+ disabled: true,
198
+ placeholder: "Type a message...",
199
+ }),
200
+ }),
201
+ ],
202
+ });
131
203
  }
132
- //# sourceMappingURL=ChatInterface.js.map
204
+ //# sourceMappingURL=ChatInterface.js.map