@cntyclub/agent-react 0.1.1 → 0.3.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/README.md +26 -0
- package/dist/api/schema.d.ts +347 -0
- package/dist/api/schema.d.ts.map +1 -0
- package/dist/api-client.d.ts +30 -0
- package/dist/api-client.d.ts.map +1 -0
- package/dist/components/agent-panel.d.ts +20 -0
- package/dist/components/agent-panel.d.ts.map +1 -0
- package/dist/components/agent-widget.d.ts +23 -0
- package/dist/components/agent-widget.d.ts.map +1 -0
- package/dist/components/message-item.d.ts +7 -0
- package/dist/components/message-item.d.ts.map +1 -0
- package/dist/components/tool-approval-card.d.ts +14 -0
- package/dist/components/tool-approval-card.d.ts.map +1 -0
- package/dist/config.d.ts +7 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/index.d.ts +10 -213
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +80 -88
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +85 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/use-agent-chat.d.ts +26 -0
- package/dist/use-agent-chat.d.ts.map +1 -0
- package/package.json +7 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,213 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
pagination?: Record<string, unknown>;
|
|
12
|
-
}
|
|
13
|
-
type MessageBlock = TableBlock;
|
|
14
|
-
interface ToolCallInfo {
|
|
15
|
-
id?: string;
|
|
16
|
-
name?: string;
|
|
17
|
-
arguments?: Record<string, unknown>;
|
|
18
|
-
}
|
|
19
|
-
interface AgentMessage {
|
|
20
|
-
id: string;
|
|
21
|
-
role: "user" | "assistant" | "tool";
|
|
22
|
-
content: string;
|
|
23
|
-
created_at: string;
|
|
24
|
-
blocks?: MessageBlock[];
|
|
25
|
-
tool_calls?: ToolCallInfo[];
|
|
26
|
-
tool_name?: string;
|
|
27
|
-
tool_call_id?: string;
|
|
28
|
-
}
|
|
29
|
-
interface PendingApproval {
|
|
30
|
-
id: string;
|
|
31
|
-
tool_name: string;
|
|
32
|
-
arguments: Record<string, unknown>;
|
|
33
|
-
created_at: string;
|
|
34
|
-
}
|
|
35
|
-
interface ConversationSummary {
|
|
36
|
-
id: string;
|
|
37
|
-
title: string;
|
|
38
|
-
created_at: string;
|
|
39
|
-
updated_at: string;
|
|
40
|
-
}
|
|
41
|
-
interface AgentPublicConfig {
|
|
42
|
-
name: string;
|
|
43
|
-
description: string;
|
|
44
|
-
has_mcp: boolean;
|
|
45
|
-
is_public: boolean;
|
|
46
|
-
}
|
|
47
|
-
interface ChatResponse {
|
|
48
|
-
status: "success" | "error";
|
|
49
|
-
message?: string;
|
|
50
|
-
conversation_id?: string;
|
|
51
|
-
messages?: AgentMessage[];
|
|
52
|
-
pending_approvals?: PendingApproval[];
|
|
53
|
-
}
|
|
54
|
-
/** Maps MCP tools to a page in the host app so the agent can navigate alongside chat. */
|
|
55
|
-
interface AgentPageMapping {
|
|
56
|
-
/** MCP tool names whose execution relates to this page. */
|
|
57
|
-
tools: string[];
|
|
58
|
-
/** Host-app route (path) to navigate to, e.g. "/dashboard/target-companies". */
|
|
59
|
-
route: string;
|
|
60
|
-
/** Human title shown in navigation hints. */
|
|
61
|
-
title: string;
|
|
62
|
-
/**
|
|
63
|
-
* Optional builder for dynamic routes: receives the tool arguments and
|
|
64
|
-
* returns the concrete path (e.g. `/dashboard/company/${args.id}`).
|
|
65
|
-
* Return null to skip navigation for that call.
|
|
66
|
-
*/
|
|
67
|
-
buildRoute?: (args: Record<string, unknown>) => string | null;
|
|
68
|
-
}
|
|
69
|
-
interface AgentConfig {
|
|
70
|
-
/** The Agent Mode client ID from the office panel (identifies the agent only). */
|
|
71
|
-
clientId: string;
|
|
72
|
-
/** Country Club backend base URL, e.g. https://api.country.club */
|
|
73
|
-
apiBaseUrl: string;
|
|
74
|
-
/** Returns the logged-in user's Country Club JWT (or null when logged out). */
|
|
75
|
-
getAccessToken: () => string | null | Promise<string | null>;
|
|
76
|
-
/** Display name override; falls back to the backend-configured agent name. */
|
|
77
|
-
agentName?: string;
|
|
78
|
-
/** Short line under the title in the panel header. */
|
|
79
|
-
tagline?: string;
|
|
80
|
-
/** Suggested prompts shown on the empty state. */
|
|
81
|
-
suggestions?: string[];
|
|
82
|
-
/** Navigate the host app (e.g. Next router push). Enables page-follow in popup mode. */
|
|
83
|
-
navigate?: (path: string) => void;
|
|
84
|
-
/** Tool → page mappings used for page-follow navigation and hints. */
|
|
85
|
-
pages?: AgentPageMapping[];
|
|
86
|
-
/** Widget appearance tweaks. All styling comes from the host's UI-kit theme tokens. */
|
|
87
|
-
appearance?: {
|
|
88
|
-
/** Floating button position. Default: "bottom-right". */
|
|
89
|
-
position?: "bottom-right" | "bottom-left";
|
|
90
|
-
/** Desktop popup panel size. Defaults: 400 x 640. */
|
|
91
|
-
panelWidth?: number;
|
|
92
|
-
panelHeight?: number;
|
|
93
|
-
/** Hide the floating button (render the panel through your own trigger). */
|
|
94
|
-
hideLauncher?: boolean;
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
declare class AgentApiError extends Error {
|
|
99
|
-
status: number;
|
|
100
|
-
constructor(message: string, status: number);
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Thin fetch client for the Country Club Agent Mode API.
|
|
104
|
-
*
|
|
105
|
-
* Every request carries the agent client_id (query param — also used by the
|
|
106
|
-
* backend's per-agent CORS middleware, including on preflights) and the
|
|
107
|
-
* logged-in user's bearer token.
|
|
108
|
-
*/
|
|
109
|
-
declare class AgentApiClient {
|
|
110
|
-
private config;
|
|
111
|
-
constructor(config: AgentConfig);
|
|
112
|
-
private request;
|
|
113
|
-
getConfig(): Promise<AgentPublicConfig>;
|
|
114
|
-
sendMessage(message: string, conversationId?: string | null): Promise<ChatResponse>;
|
|
115
|
-
resolveApproval(callId: string, approve: boolean): Promise<ChatResponse>;
|
|
116
|
-
listConversations(): Promise<{
|
|
117
|
-
conversations: ConversationSummary[];
|
|
118
|
-
}>;
|
|
119
|
-
getConversation(conversationId: string): Promise<{
|
|
120
|
-
conversation: ConversationSummary;
|
|
121
|
-
messages: ChatResponse["messages"];
|
|
122
|
-
pending_approvals: ChatResponse["pending_approvals"];
|
|
123
|
-
}>;
|
|
124
|
-
deleteConversation(conversationId: string): Promise<void>;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
interface AgentChatState {
|
|
128
|
-
agentInfo: AgentPublicConfig | null;
|
|
129
|
-
conversationId: string | null;
|
|
130
|
-
conversations: ConversationSummary[];
|
|
131
|
-
messages: AgentMessage[];
|
|
132
|
-
pendingApprovals: PendingApproval[];
|
|
133
|
-
sending: boolean;
|
|
134
|
-
resolvingApprovalId: string | null;
|
|
135
|
-
error: string | null;
|
|
136
|
-
}
|
|
137
|
-
interface AgentChatActions {
|
|
138
|
-
send: (text: string) => Promise<void>;
|
|
139
|
-
resolveApproval: (callId: string, approve: boolean) => Promise<void>;
|
|
140
|
-
newChat: () => void;
|
|
141
|
-
openConversation: (conversationId: string) => Promise<void>;
|
|
142
|
-
refreshConversations: () => Promise<void>;
|
|
143
|
-
deleteConversation: (conversationId: string) => Promise<void>;
|
|
144
|
-
clearError: () => void;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Headless chat state for an Agent Mode agent: message history, sending,
|
|
148
|
-
* pending write-tool approvals, and conversation management. UI-agnostic.
|
|
149
|
-
*/
|
|
150
|
-
declare function useAgentChat(config: AgentConfig): AgentChatState & AgentChatActions;
|
|
151
|
-
|
|
152
|
-
interface AgentPanelProps {
|
|
153
|
-
config: AgentConfig;
|
|
154
|
-
chat: AgentChatState & AgentChatActions;
|
|
155
|
-
/** Fullscreen "Agent Mode" is active. */
|
|
156
|
-
agentMode: boolean;
|
|
157
|
-
/** Hide the expand button (mobile is always fullscreen). */
|
|
158
|
-
canToggleAgentMode: boolean;
|
|
159
|
-
onToggleAgentMode: () => void;
|
|
160
|
-
onClose: () => void;
|
|
161
|
-
className?: string;
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* The chat surface shared by the popup panel and fullscreen Agent Mode.
|
|
165
|
-
* Header (title, history, new chat, expand/collapse, close) + messages + input.
|
|
166
|
-
*/
|
|
167
|
-
declare function AgentPanel({ agentMode, canToggleAgentMode, chat, className, config, onClose, onToggleAgentMode, }: AgentPanelProps): React.JSX.Element;
|
|
168
|
-
|
|
169
|
-
interface AgentWidgetProps {
|
|
170
|
-
config: AgentConfig;
|
|
171
|
-
/** Controlled open state (optional). */
|
|
172
|
-
open?: boolean;
|
|
173
|
-
onOpenChange?: (open: boolean) => void;
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* The embeddable Agent Mode widget.
|
|
177
|
-
*
|
|
178
|
-
* - Closed: a floating round button (bottom-right by default).
|
|
179
|
-
* - Open on desktop: a popup panel anchored to the button, with an
|
|
180
|
-
* "Agent Mode" button that expands to a fullscreen chat. While in the popup,
|
|
181
|
-
* the widget can navigate the host app to pages related to the tools the
|
|
182
|
-
* agent uses (via `config.pages` + `config.navigate`).
|
|
183
|
-
* - Open on mobile: fullscreen from the start.
|
|
184
|
-
*
|
|
185
|
-
* All colors come from the host app's UI-kit theme tokens, so light/dark mode
|
|
186
|
-
* follows the dashboard automatically.
|
|
187
|
-
*/
|
|
188
|
-
declare function AgentWidget({ config, onOpenChange, open: controlledOpen }: AgentWidgetProps): React.JSX.Element;
|
|
189
|
-
|
|
190
|
-
/** Renders one conversation message: user/assistant bubbles or tool results. */
|
|
191
|
-
declare function MessageItem({ message }: {
|
|
192
|
-
message: AgentMessage;
|
|
193
|
-
}): React.JSX.Element | null;
|
|
194
|
-
|
|
195
|
-
interface ToolApprovalCardProps {
|
|
196
|
-
approval: PendingApproval;
|
|
197
|
-
resolving: boolean;
|
|
198
|
-
onResolve: (callId: string, approve: boolean) => void;
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* Approval prompt for a write action the agent wants to perform. The stored
|
|
202
|
-
* arguments are shown so the user knows exactly what will change; nothing runs
|
|
203
|
-
* until they approve.
|
|
204
|
-
*/
|
|
205
|
-
declare function ToolApprovalCard({ approval, onResolve, resolving }: ToolApprovalCardProps): React.JSX.Element;
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Identity helper that gives host apps full type inference/checking when
|
|
209
|
-
* declaring their agent config file.
|
|
210
|
-
*/
|
|
211
|
-
declare function defineAgentConfig(config: AgentConfig): AgentConfig;
|
|
212
|
-
|
|
213
|
-
export { AgentApiClient, AgentApiError, type AgentChatActions, type AgentChatState, type AgentConfig, type AgentMessage, type AgentPageMapping, AgentPanel, type AgentPanelProps, type AgentPublicConfig, AgentWidget, type AgentWidgetProps, type ChatResponse, type ConversationSummary, type MessageBlock, MessageItem, type PendingApproval, type TableBlock, ToolApprovalCard, type ToolApprovalCardProps, type ToolCallInfo, defineAgentConfig, useAgentChat };
|
|
1
|
+
export { AgentApiClient, AgentApiError } from "./api-client";
|
|
2
|
+
export { AgentPanel, type AgentPanelProps } from "./components/agent-panel";
|
|
3
|
+
export { AgentWidget, type AgentWidgetProps } from "./components/agent-widget";
|
|
4
|
+
export { MessageItem } from "./components/message-item";
|
|
5
|
+
export { ToolApprovalCard, type ToolApprovalCardProps } from "./components/tool-approval-card";
|
|
6
|
+
export { defineAgentConfig } from "./config";
|
|
7
|
+
export type { AgentConfig, AgentMessage, AgentModeSchemas, AgentPageMapping, AgentPublicConfig, ApprovalRequest, ChatRequest, ChatResponse, ConversationSummary, MessageBlock, PendingApproval, TableBlock, ToolCallInfo, } from "./types";
|
|
8
|
+
export type { components as AgentModeComponents, operations as AgentModeOperations, paths as AgentModePaths, } from "./api/schema";
|
|
9
|
+
export { useAgentChat, type AgentChatActions, type AgentChatState, } from "./use-agent-chat";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,KAAK,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAC/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,YAAY,EACV,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,YAAY,EACZ,eAAe,EACf,UAAU,EACV,YAAY,GACb,MAAM,SAAS,CAAC;AAEjB,YAAY,EACV,UAAU,IAAI,mBAAmB,EACjC,UAAU,IAAI,mBAAmB,EACjC,KAAK,IAAI,cAAc,GACxB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,YAAY,EACZ,KAAK,gBAAgB,EACrB,KAAK,cAAc,GACpB,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ChatMessage, ChatMessageBubble, Markdown, DataTablePaged, ChatToolCard, ChatToolCardHeader, ChatToolCardActions, Button, Spinner, Tooltip, TooltipTrigger, TooltipContent, Chat, ChatMessages, ChatTypingIndicator, cn, ChatInput, useMediaQuery, TooltipProvider, Fab } from '@cntyclub/ui-react';
|
|
2
|
-
import { WrenchIcon,
|
|
1
|
+
import { ChatMessage, ChatMessageBubble, Markdown, ChatToolChip, DataTablePaged, ChatToolCard, ChatToolCardHeader, ChatToolCardActions, Button, Spinner, ChatHeader, ChatHeaderAvatar, ChatHeaderTitle, ChatHeaderActions, Tooltip, TooltipTrigger, TooltipContent, Chat, ChatMessages, ChatEmptyState, ChatEmptyStateIcon, ChatEmptyStateTitle, ChatEmptyStateDescription, ChatSuggestions, ChatSuggestion, ChatTypingIndicator, cn, ChatInput, useMediaQuery, TooltipProvider, Fab } from '@cntyclub/ui-react';
|
|
2
|
+
import { WrenchIcon, CheckIcon, ShieldAlertIcon, HistoryIcon, SquarePenIcon, Minimize2Icon, Maximize2Icon, XIcon, Trash2Icon, SparklesIcon } from 'lucide-react';
|
|
3
3
|
import * as React2 from 'react';
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
|
|
@@ -89,19 +89,11 @@ function MessageItem({ message }) {
|
|
|
89
89
|
if (!message.content && requestedTools.length === 0) return null;
|
|
90
90
|
return /* @__PURE__ */ jsxs(ChatMessage, { from: "assistant", children: [
|
|
91
91
|
message.content ? /* @__PURE__ */ jsx(ChatMessageBubble, { from: "assistant", children: /* @__PURE__ */ jsx(Markdown, { children: message.content }) }) : null,
|
|
92
|
-
requestedTools.map((toolCall) => /* @__PURE__ */ jsxs(
|
|
93
|
-
"
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
/* @__PURE__ */ jsx(WrenchIcon, { className: "size-3" }),
|
|
98
|
-
"Using ",
|
|
99
|
-
humanizeToolName(toolCall.name ?? "tool"),
|
|
100
|
-
"\u2026"
|
|
101
|
-
]
|
|
102
|
-
},
|
|
103
|
-
toolCall.id ?? toolCall.name
|
|
104
|
-
))
|
|
92
|
+
requestedTools.map((toolCall) => /* @__PURE__ */ jsxs(ChatToolChip, { icon: /* @__PURE__ */ jsx(WrenchIcon, {}), children: [
|
|
93
|
+
"Using ",
|
|
94
|
+
humanizeToolName(toolCall.name ?? "tool"),
|
|
95
|
+
"\u2026"
|
|
96
|
+
] }, toolCall.id ?? toolCall.name))
|
|
105
97
|
] });
|
|
106
98
|
}
|
|
107
99
|
const tableBlocks = (message.blocks ?? []).filter((block) => block.type === "table");
|
|
@@ -113,8 +105,7 @@ function MessageItem({ message }) {
|
|
|
113
105
|
rows: block.rows,
|
|
114
106
|
totalCount: typeof block.pagination?.count === "number" ? block.pagination.count : block.row_count
|
|
115
107
|
}
|
|
116
|
-
) }, `${message.id}-${index}`)) : /* @__PURE__ */ jsxs(
|
|
117
|
-
/* @__PURE__ */ jsx(CheckCircle2Icon, { className: "size-3" }),
|
|
108
|
+
) }, `${message.id}-${index}`)) : /* @__PURE__ */ jsxs(ChatToolChip, { icon: /* @__PURE__ */ jsx(CheckIcon, {}), children: [
|
|
118
109
|
humanizeToolName(message.tool_name ?? "tool"),
|
|
119
110
|
" finished"
|
|
120
111
|
] }) });
|
|
@@ -205,72 +196,74 @@ function AgentPanel({
|
|
|
205
196
|
),
|
|
206
197
|
"data-slot": "agent-panel",
|
|
207
198
|
children: [
|
|
208
|
-
/* @__PURE__ */ jsxs(
|
|
209
|
-
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: [
|
|
210
|
-
/* @__PURE__ */ jsx(
|
|
211
|
-
/* @__PURE__ */ jsxs(
|
|
199
|
+
/* @__PURE__ */ jsxs(ChatHeader, { children: [
|
|
200
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 items-center gap-2.5", children: [
|
|
201
|
+
/* @__PURE__ */ jsx(ChatHeaderAvatar, {}),
|
|
202
|
+
/* @__PURE__ */ jsxs(ChatHeaderTitle, { children: [
|
|
212
203
|
/* @__PURE__ */ jsx("div", { className: "truncate font-medium text-sm", children: agentName }),
|
|
213
204
|
config.tagline ? /* @__PURE__ */ jsx("div", { className: "truncate text-muted-foreground text-xs", children: config.tagline }) : null
|
|
214
205
|
] })
|
|
215
206
|
] }),
|
|
216
|
-
/* @__PURE__ */ jsxs(
|
|
217
|
-
/* @__PURE__ */
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
/* @__PURE__ */
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
/* @__PURE__ */
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
207
|
+
/* @__PURE__ */ jsxs(ChatHeaderActions, { children: [
|
|
208
|
+
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
209
|
+
/* @__PURE__ */ jsx(
|
|
210
|
+
TooltipTrigger,
|
|
211
|
+
{
|
|
212
|
+
render: /* @__PURE__ */ jsx(
|
|
213
|
+
Button,
|
|
214
|
+
{
|
|
215
|
+
"aria-label": "Conversation history",
|
|
216
|
+
onClick: view === "history" ? () => setView("chat") : openHistory,
|
|
217
|
+
size: "icon-sm",
|
|
218
|
+
variant: "ghost",
|
|
219
|
+
children: /* @__PURE__ */ jsx(HistoryIcon, {})
|
|
220
|
+
}
|
|
221
|
+
)
|
|
222
|
+
}
|
|
223
|
+
),
|
|
224
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: "History" })
|
|
225
|
+
] }),
|
|
226
|
+
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
227
|
+
/* @__PURE__ */ jsx(
|
|
228
|
+
TooltipTrigger,
|
|
229
|
+
{
|
|
230
|
+
render: /* @__PURE__ */ jsx(
|
|
231
|
+
Button,
|
|
232
|
+
{
|
|
233
|
+
"aria-label": "New chat",
|
|
234
|
+
onClick: () => {
|
|
235
|
+
chat.newChat();
|
|
236
|
+
setView("chat");
|
|
237
|
+
},
|
|
238
|
+
size: "icon-sm",
|
|
239
|
+
variant: "ghost",
|
|
240
|
+
children: /* @__PURE__ */ jsx(SquarePenIcon, {})
|
|
241
|
+
}
|
|
242
|
+
)
|
|
243
|
+
}
|
|
244
|
+
),
|
|
245
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: "New chat" })
|
|
246
|
+
] }),
|
|
247
|
+
canToggleAgentMode ? /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
248
|
+
/* @__PURE__ */ jsx(
|
|
249
|
+
TooltipTrigger,
|
|
250
|
+
{
|
|
251
|
+
render: /* @__PURE__ */ jsx(
|
|
252
|
+
Button,
|
|
253
|
+
{
|
|
254
|
+
"aria-label": agentMode ? "Exit Agent Mode" : "Enter Agent Mode",
|
|
255
|
+
onClick: onToggleAgentMode,
|
|
256
|
+
size: "icon-sm",
|
|
257
|
+
variant: "ghost",
|
|
258
|
+
children: agentMode ? /* @__PURE__ */ jsx(Minimize2Icon, {}) : /* @__PURE__ */ jsx(Maximize2Icon, {})
|
|
259
|
+
}
|
|
260
|
+
)
|
|
261
|
+
}
|
|
262
|
+
),
|
|
263
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: agentMode ? "Exit Agent Mode" : "Agent Mode" })
|
|
264
|
+
] }) : null,
|
|
265
|
+
/* @__PURE__ */ jsx(Button, { "aria-label": "Close", onClick: onClose, size: "icon-sm", variant: "ghost", children: /* @__PURE__ */ jsx(XIcon, {}) })
|
|
266
|
+
] })
|
|
274
267
|
] }),
|
|
275
268
|
view === "history" ? /* @__PURE__ */ jsx("div", { className: "flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto p-2", children: chat.conversations.length === 0 ? /* @__PURE__ */ jsx("p", { className: "p-4 text-center text-muted-foreground text-sm", children: "No conversations yet." }) : chat.conversations.map((conversation) => /* @__PURE__ */ jsxs(
|
|
276
269
|
"div",
|
|
@@ -307,22 +300,21 @@ function AgentPanel({
|
|
|
307
300
|
},
|
|
308
301
|
conversation.id
|
|
309
302
|
)) }) : /* @__PURE__ */ jsxs(Chat, { children: [
|
|
310
|
-
/* @__PURE__ */ jsx(ChatMessages, { className: cn(agentMode && "mx-auto w-full max-w-3xl"), children: chat.messages.length === 0 && !chat.sending ? /* @__PURE__ */ jsxs(
|
|
311
|
-
/* @__PURE__ */ jsx(
|
|
303
|
+
/* @__PURE__ */ jsx(ChatMessages, { className: cn(agentMode && "mx-auto w-full max-w-3xl"), children: chat.messages.length === 0 && !chat.sending ? /* @__PURE__ */ jsxs(ChatEmptyState, { children: [
|
|
304
|
+
/* @__PURE__ */ jsx(ChatEmptyStateIcon, {}),
|
|
312
305
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
313
|
-
/* @__PURE__ */ jsxs(
|
|
306
|
+
/* @__PURE__ */ jsxs(ChatEmptyStateTitle, { children: [
|
|
314
307
|
"Hi! I'm ",
|
|
315
308
|
agentName,
|
|
316
309
|
"."
|
|
317
310
|
] }),
|
|
318
|
-
/* @__PURE__ */ jsx(
|
|
311
|
+
/* @__PURE__ */ jsx(ChatEmptyStateDescription, { className: "mt-1", children: "Ask me anything about your data \u2014 I can look things up and take actions (with your approval)." })
|
|
319
312
|
] }),
|
|
320
|
-
/* @__PURE__ */ jsx(
|
|
321
|
-
|
|
313
|
+
/* @__PURE__ */ jsx(ChatSuggestions, { children: suggestions.slice(0, 4).map((suggestion, index) => /* @__PURE__ */ jsx(
|
|
314
|
+
ChatSuggestion,
|
|
322
315
|
{
|
|
316
|
+
index,
|
|
323
317
|
onClick: () => handleSubmit(suggestion),
|
|
324
|
-
size: "sm",
|
|
325
|
-
variant: "outline",
|
|
326
318
|
children: suggestion
|
|
327
319
|
},
|
|
328
320
|
suggestion
|
|
@@ -347,7 +339,7 @@ function AgentPanel({
|
|
|
347
339
|
/* @__PURE__ */ jsx(
|
|
348
340
|
ChatInput,
|
|
349
341
|
{
|
|
350
|
-
className: cn(agentMode && "mx-auto w-full max-w-3xl
|
|
342
|
+
className: cn(agentMode && "mx-auto w-full max-w-3xl"),
|
|
351
343
|
disabled: busy || chat.pendingApprovals.length > 0,
|
|
352
344
|
onSubmit: handleSubmit,
|
|
353
345
|
onValueChange: setDraft,
|