@promptbook/cli 0.103.0-54 → 0.103.0-56
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/apps/agents-server/config.ts +0 -2
- package/apps/agents-server/package-lock.json +1163 -0
- package/apps/agents-server/package.json +6 -0
- package/apps/agents-server/src/app/admin/chat-feedback/ChatFeedbackClient.tsx +79 -6
- package/apps/agents-server/src/app/admin/chat-history/ChatHistoryClient.tsx +171 -69
- package/apps/agents-server/src/app/agents/[agentName]/AgentChatWrapper.tsx +3 -1
- package/apps/agents-server/src/app/agents/[agentName]/AgentOptionsMenu.tsx +216 -0
- package/apps/agents-server/src/app/agents/[agentName]/AgentProfileChat.tsx +78 -0
- package/apps/agents-server/src/app/agents/[agentName]/AgentProfileView.tsx +233 -0
- package/apps/agents-server/src/app/agents/[agentName]/CloneAgentButton.tsx +4 -4
- package/apps/agents-server/src/app/agents/[agentName]/InstallPwaButton.tsx +2 -2
- package/apps/agents-server/src/app/agents/[agentName]/QrCodeModal.tsx +90 -0
- package/apps/agents-server/src/app/agents/[agentName]/agentLinks.tsx +80 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/book/route.ts +3 -1
- package/apps/agents-server/src/app/agents/[agentName]/api/chat/route.ts +11 -1
- package/apps/agents-server/src/app/agents/[agentName]/api/mcp/route.ts +203 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/modelRequirements/route.ts +3 -1
- package/apps/agents-server/src/app/agents/[agentName]/api/modelRequirements/systemMessage/route.ts +3 -1
- package/apps/agents-server/src/app/agents/[agentName]/api/openai/chat/completions/route.ts +3 -169
- package/apps/agents-server/src/app/agents/[agentName]/api/openai/models/route.ts +93 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/openai/v1/chat/completions/route.ts +10 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/openai/v1/models/route.ts +93 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/openrouter/chat/completions/route.ts +10 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/voice/route.ts +4 -0
- package/apps/agents-server/src/app/agents/[agentName]/chat/page.tsx +9 -2
- package/apps/agents-server/src/app/agents/[agentName]/integration/SdkCodeTabs.tsx +31 -0
- package/apps/agents-server/src/app/agents/[agentName]/integration/page.tsx +271 -30
- package/apps/agents-server/src/app/agents/[agentName]/links/page.tsx +182 -0
- package/apps/agents-server/src/app/agents/[agentName]/page.tsx +108 -165
- package/apps/agents-server/src/app/agents/[agentName]/website-integration/page.tsx +61 -0
- package/apps/agents-server/src/app/api/auth/change-password/route.ts +75 -0
- package/apps/agents-server/src/app/api/chat-feedback/export/route.ts +55 -0
- package/apps/agents-server/src/app/api/chat-history/export/route.ts +55 -0
- package/apps/agents-server/src/app/api/openai/v1/chat/completions/route.ts +6 -0
- package/apps/agents-server/src/app/api/openai/v1/models/route.ts +65 -0
- package/apps/agents-server/src/app/docs/[docId]/page.tsx +12 -32
- package/apps/agents-server/src/app/docs/page.tsx +42 -17
- package/apps/agents-server/src/app/globals.css +129 -0
- package/apps/agents-server/src/app/layout.tsx +8 -2
- package/apps/agents-server/src/app/manifest.ts +1 -1
- package/apps/agents-server/src/components/ChangePasswordDialog/ChangePasswordDialog.tsx +41 -0
- package/apps/agents-server/src/components/ChangePasswordForm/ChangePasswordForm.tsx +159 -0
- package/apps/agents-server/src/components/DocumentationContent/DocumentationContent.tsx +87 -0
- package/apps/agents-server/src/components/Header/Header.tsx +94 -38
- package/apps/agents-server/src/components/OpenMojiIcon/OpenMojiIcon.tsx +20 -0
- package/apps/agents-server/src/components/PrintButton/PrintButton.tsx +18 -0
- package/apps/agents-server/src/components/PrintHeader/PrintHeader.tsx +18 -0
- package/apps/agents-server/src/database/migrations/2025-12-0070-chat-history-source.sql +2 -0
- package/apps/agents-server/src/database/schema.ts +6 -0
- package/apps/agents-server/src/middleware.ts +1 -1
- package/apps/agents-server/src/utils/convertToCsv.ts +31 -0
- package/apps/agents-server/src/utils/handleChatCompletion.ts +355 -0
- package/apps/agents-server/src/utils/resolveInheritedAgentSource.ts +100 -0
- package/apps/agents-server/src/utils/validateApiKey.ts +128 -0
- package/apps/agents-server/tailwind.config.ts +1 -1
- package/esm/index.es.js +1188 -175
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +4 -0
- package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +5 -0
- package/esm/typings/src/commitments/CLOSED/CLOSED.d.ts +35 -0
- package/esm/typings/src/commitments/COMPONENT/COMPONENT.d.ts +28 -0
- package/esm/typings/src/commitments/FROM/FROM.d.ts +34 -0
- package/esm/typings/src/commitments/LANGUAGE/LANGUAGE.d.ts +35 -0
- package/esm/typings/src/commitments/META_COLOR/META_COLOR.d.ts +6 -0
- package/esm/typings/src/commitments/META_FONT/META_FONT.d.ts +42 -0
- package/esm/typings/src/commitments/OPEN/OPEN.d.ts +35 -0
- package/esm/typings/src/commitments/USE/USE.d.ts +53 -0
- package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.d.ts +38 -0
- package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.test.d.ts +1 -0
- package/esm/typings/src/commitments/USE_MCP/USE_MCP.d.ts +37 -0
- package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +38 -0
- package/esm/typings/src/commitments/index.d.ts +12 -1
- package/esm/typings/src/playground/playground.d.ts +3 -0
- package/esm/typings/src/utils/color/Color.d.ts +8 -0
- package/esm/typings/src/utils/color/css-colors.d.ts +1 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +1180 -167
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/playground/playground1.d.ts +0 -2
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
import { Chat } from '@promptbook-local/components';
|
|
4
|
+
import type { ChatMessage } from '@promptbook-local/types';
|
|
3
5
|
import { useEffect, useMemo, useState } from 'react';
|
|
4
6
|
import { Card } from '../../../components/Homepage/Card';
|
|
5
7
|
import {
|
|
@@ -62,6 +64,7 @@ export function ChatFeedbackClient({ initialAgentName }: ChatFeedbackClientProps
|
|
|
62
64
|
const [search, setSearch] = useState('');
|
|
63
65
|
const [sortBy, setSortBy] = useState<ChatFeedbackSortField>('createdAt');
|
|
64
66
|
const [sortOrder, setSortOrder] = useState<ChatFeedbackSortOrder>('desc');
|
|
67
|
+
const [selectedThread, setSelectedThread] = useState<ChatMessage[] | null>(null);
|
|
65
68
|
const [loading, setLoading] = useState(true);
|
|
66
69
|
const [error, setError] = useState<string | null>(null);
|
|
67
70
|
|
|
@@ -192,6 +195,25 @@ export function ChatFeedbackClient({ initialAgentName }: ChatFeedbackClientProps
|
|
|
192
195
|
}
|
|
193
196
|
};
|
|
194
197
|
|
|
198
|
+
const handleViewChat = (row: ChatFeedbackRow) => {
|
|
199
|
+
if (!row.chatThread) {
|
|
200
|
+
alert('No chat thread available for this feedback.');
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
try {
|
|
204
|
+
// Ensure dates are Date objects
|
|
205
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
206
|
+
const thread = (row.chatThread as unknown as any[]).map((msg) => ({
|
|
207
|
+
...msg,
|
|
208
|
+
date: msg.date ? new Date(msg.date) : (msg.createdAt ? new Date(msg.createdAt) : undefined),
|
|
209
|
+
})) as ChatMessage[];
|
|
210
|
+
setSelectedThread(thread);
|
|
211
|
+
} catch (e) {
|
|
212
|
+
console.error('Failed to parse chat thread', e);
|
|
213
|
+
alert('Failed to parse chat thread.');
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
|
|
195
217
|
const handleDeleteRow = async (row: ChatFeedbackRow) => {
|
|
196
218
|
if (!row.id) return;
|
|
197
219
|
|
|
@@ -250,6 +272,14 @@ export function ChatFeedbackClient({ initialAgentName }: ChatFeedbackClientProps
|
|
|
250
272
|
|
|
251
273
|
const isSortedBy = (field: ChatFeedbackSortField) => sortBy === field;
|
|
252
274
|
|
|
275
|
+
const getExportUrl = () => {
|
|
276
|
+
const params = new URLSearchParams();
|
|
277
|
+
if (agentName) {
|
|
278
|
+
params.set('agentName', agentName);
|
|
279
|
+
}
|
|
280
|
+
return `/api/chat-feedback/export?${params.toString()}`;
|
|
281
|
+
};
|
|
282
|
+
|
|
253
283
|
return (
|
|
254
284
|
<div className="container mx-auto px-4 py-8 space-y-6">
|
|
255
285
|
<div className="mt-20 mb-4 flex flex-col gap-2 md:flex-row md:items-end md:justify-between">
|
|
@@ -259,12 +289,24 @@ export function ChatFeedbackClient({ initialAgentName }: ChatFeedbackClientProps
|
|
|
259
289
|
Review and triage user feedback collected from your agents.
|
|
260
290
|
</p>
|
|
261
291
|
</div>
|
|
262
|
-
<div className="text-sm text-gray-500 md:text-right">
|
|
263
|
-
<div
|
|
264
|
-
|
|
292
|
+
<div className="flex items-end gap-4 text-sm text-gray-500 md:text-right">
|
|
293
|
+
<div>
|
|
294
|
+
<a
|
|
295
|
+
href={getExportUrl()}
|
|
296
|
+
target="_blank"
|
|
297
|
+
rel="noopener noreferrer"
|
|
298
|
+
className="inline-flex items-center justify-center rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 shadow-sm hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2"
|
|
299
|
+
>
|
|
300
|
+
Download CSV
|
|
301
|
+
</a>
|
|
265
302
|
</div>
|
|
266
|
-
<div
|
|
267
|
-
|
|
303
|
+
<div>
|
|
304
|
+
<div className="text-xl font-semibold text-gray-900">
|
|
305
|
+
{total.toLocaleString()}
|
|
306
|
+
</div>
|
|
307
|
+
<div className="text-xs uppercase tracking-wide text-gray-400">
|
|
308
|
+
Total feedback entries
|
|
309
|
+
</div>
|
|
268
310
|
</div>
|
|
269
311
|
</div>
|
|
270
312
|
</div>
|
|
@@ -468,7 +510,16 @@ export function ChatFeedbackClient({ initialAgentName }: ChatFeedbackClientProps
|
|
|
468
510
|
{row.platform || '-'}
|
|
469
511
|
</div>
|
|
470
512
|
</td>
|
|
471
|
-
<td className="whitespace-nowrap px-4 py-3 text-right text-xs font-medium">
|
|
513
|
+
<td className="whitespace-nowrap px-4 py-3 text-right text-xs font-medium space-x-2">
|
|
514
|
+
{row.chatThread && (
|
|
515
|
+
<button
|
|
516
|
+
type="button"
|
|
517
|
+
onClick={() => handleViewChat(row)}
|
|
518
|
+
className="text-blue-600 hover:text-blue-800"
|
|
519
|
+
>
|
|
520
|
+
View Chat
|
|
521
|
+
</button>
|
|
522
|
+
)}
|
|
472
523
|
<button
|
|
473
524
|
type="button"
|
|
474
525
|
onClick={() => handleDeleteRow(row)}
|
|
@@ -536,6 +587,28 @@ export function ChatFeedbackClient({ initialAgentName }: ChatFeedbackClientProps
|
|
|
536
587
|
</div>
|
|
537
588
|
</div>
|
|
538
589
|
</Card>
|
|
590
|
+
|
|
591
|
+
{selectedThread && (
|
|
592
|
+
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50 p-4">
|
|
593
|
+
<div className="bg-white rounded-lg shadow-xl w-full max-w-4xl h-[80vh] flex flex-col overflow-hidden">
|
|
594
|
+
<div className="flex justify-between items-center p-4 border-b border-gray-200">
|
|
595
|
+
<h3 className="text-lg font-medium text-gray-900">Chat Thread</h3>
|
|
596
|
+
<button
|
|
597
|
+
onClick={() => setSelectedThread(null)}
|
|
598
|
+
className="text-gray-400 hover:text-gray-500"
|
|
599
|
+
>
|
|
600
|
+
<span className="sr-only">Close</span>
|
|
601
|
+
<svg className="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
602
|
+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
|
|
603
|
+
</svg>
|
|
604
|
+
</button>
|
|
605
|
+
</div>
|
|
606
|
+
<div className="flex-1 overflow-hidden relative">
|
|
607
|
+
<Chat messages={selectedThread} />
|
|
608
|
+
</div>
|
|
609
|
+
</div>
|
|
610
|
+
</div>
|
|
611
|
+
)}
|
|
539
612
|
</div>
|
|
540
613
|
);
|
|
541
614
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
import { MockedChat } from '@promptbook-local/components';
|
|
4
|
+
import type { ChatMessage } from '@promptbook-local/types';
|
|
3
5
|
import { useEffect, useMemo, useState } from 'react';
|
|
4
6
|
import { Card } from '../../../components/Homepage/Card';
|
|
5
7
|
import {
|
|
@@ -83,6 +85,7 @@ export function ChatHistoryClient({ initialAgentName }: ChatHistoryClientProps)
|
|
|
83
85
|
const [search, setSearch] = useState('');
|
|
84
86
|
const [sortBy, setSortBy] = useState<ChatHistorySortField>('createdAt');
|
|
85
87
|
const [sortOrder, setSortOrder] = useState<ChatHistorySortOrder>('desc');
|
|
88
|
+
const [viewMode, setViewMode] = useState<'table' | 'chat'>('table');
|
|
86
89
|
const [loading, setLoading] = useState(true);
|
|
87
90
|
const [error, setError] = useState<string | null>(null);
|
|
88
91
|
|
|
@@ -213,6 +216,21 @@ export function ChatHistoryClient({ initialAgentName }: ChatHistoryClientProps)
|
|
|
213
216
|
}
|
|
214
217
|
};
|
|
215
218
|
|
|
219
|
+
const handleViewModeChange = (mode: 'table' | 'chat') => {
|
|
220
|
+
setViewMode(mode);
|
|
221
|
+
if (mode === 'chat') {
|
|
222
|
+
// When switching to chat view, sort by creation date ascending to make sense of conversation flow
|
|
223
|
+
setSortBy('createdAt');
|
|
224
|
+
setSortOrder('asc');
|
|
225
|
+
setPageSize(100); // Show more messages in chat view
|
|
226
|
+
} else {
|
|
227
|
+
// Default back to desc when switching to table
|
|
228
|
+
setSortBy('createdAt');
|
|
229
|
+
setSortOrder('desc');
|
|
230
|
+
setPageSize(20);
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
|
|
216
234
|
const handleDeleteRow = async (row: ChatHistoryRow) => {
|
|
217
235
|
if (!row.id) return;
|
|
218
236
|
|
|
@@ -271,6 +289,75 @@ export function ChatHistoryClient({ initialAgentName }: ChatHistoryClientProps)
|
|
|
271
289
|
|
|
272
290
|
const isSortedBy = (field: ChatHistorySortField) => sortBy === field;
|
|
273
291
|
|
|
292
|
+
const getExportUrl = () => {
|
|
293
|
+
const params = new URLSearchParams();
|
|
294
|
+
if (agentName) {
|
|
295
|
+
params.set('agentName', agentName);
|
|
296
|
+
}
|
|
297
|
+
return `/api/chat-history/export?${params.toString()}`;
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
const chatMessages = useMemo(() => {
|
|
301
|
+
if (viewMode !== 'chat') return [];
|
|
302
|
+
return items.map((row) => {
|
|
303
|
+
const message = row.message as { role?: string; content?: string };
|
|
304
|
+
const role = (message.role || 'USER').toUpperCase();
|
|
305
|
+
return {
|
|
306
|
+
id: String(row.id),
|
|
307
|
+
from: role === 'USER' ? 'USER' : 'ASSISTANT',
|
|
308
|
+
content: message.content || JSON.stringify(message),
|
|
309
|
+
isComplete: true,
|
|
310
|
+
date: new Date(row.createdAt),
|
|
311
|
+
} satisfies ChatMessage;
|
|
312
|
+
});
|
|
313
|
+
}, [items, viewMode]);
|
|
314
|
+
|
|
315
|
+
const pagination = (
|
|
316
|
+
<div className="mt-4 flex flex-col items-center justify-between gap-3 border-t border-gray-100 pt-4 text-xs text-gray-600 md:flex-row">
|
|
317
|
+
<div>
|
|
318
|
+
{total > 0 ? (
|
|
319
|
+
<>
|
|
320
|
+
Showing{' '}
|
|
321
|
+
<span className="font-semibold">
|
|
322
|
+
{Math.min((page - 1) * pageSize + 1, total)}
|
|
323
|
+
</span>{' '}
|
|
324
|
+
–{' '}
|
|
325
|
+
<span className="font-semibold">
|
|
326
|
+
{Math.min(page * pageSize, total)}
|
|
327
|
+
</span>{' '}
|
|
328
|
+
of{' '}
|
|
329
|
+
<span className="font-semibold">{total}</span>{' '}
|
|
330
|
+
messages
|
|
331
|
+
</>
|
|
332
|
+
) : (
|
|
333
|
+
'No messages'
|
|
334
|
+
)}
|
|
335
|
+
</div>
|
|
336
|
+
<div className="flex items-center gap-2">
|
|
337
|
+
<button
|
|
338
|
+
type="button"
|
|
339
|
+
onClick={() => setPage((prev) => Math.max(1, prev - 1))}
|
|
340
|
+
disabled={page <= 1}
|
|
341
|
+
className="inline-flex items-center justify-center rounded-md border border-gray-300 px-2 py-1 text-xs font-medium text-gray-700 disabled:cursor-not-allowed disabled:opacity-50"
|
|
342
|
+
>
|
|
343
|
+
Previous
|
|
344
|
+
</button>
|
|
345
|
+
<span>
|
|
346
|
+
Page <span className="font-semibold">{page}</span> of{' '}
|
|
347
|
+
<span className="font-semibold">{totalPages}</span>
|
|
348
|
+
</span>
|
|
349
|
+
<button
|
|
350
|
+
type="button"
|
|
351
|
+
onClick={() => setPage((prev) => Math.min(totalPages, prev + 1))}
|
|
352
|
+
disabled={page >= totalPages}
|
|
353
|
+
className="inline-flex items-center justify-center rounded-md border border-gray-300 px-2 py-1 text-xs font-medium text-gray-700 disabled:cursor-not-allowed disabled:opacity-50"
|
|
354
|
+
>
|
|
355
|
+
Next
|
|
356
|
+
</button>
|
|
357
|
+
</div>
|
|
358
|
+
</div>
|
|
359
|
+
);
|
|
360
|
+
|
|
274
361
|
return (
|
|
275
362
|
<div className="container mx-auto px-4 py-8 space-y-6">
|
|
276
363
|
<div className="mt-20 mb-4 flex flex-col gap-2 md:flex-row md:items-end md:justify-between">
|
|
@@ -280,12 +367,48 @@ export function ChatHistoryClient({ initialAgentName }: ChatHistoryClientProps)
|
|
|
280
367
|
Inspect and manage all recorded chat messages across your agents.
|
|
281
368
|
</p>
|
|
282
369
|
</div>
|
|
283
|
-
<div className="text-sm text-gray-500 md:text-right">
|
|
284
|
-
<div className="
|
|
285
|
-
|
|
370
|
+
<div className="flex items-end gap-4 text-sm text-gray-500 md:text-right">
|
|
371
|
+
<div className="flex rounded-md shadow-sm" role="group">
|
|
372
|
+
<button
|
|
373
|
+
type="button"
|
|
374
|
+
onClick={() => handleViewModeChange('table')}
|
|
375
|
+
className={`px-4 py-2 text-sm font-medium border border-gray-300 rounded-l-lg ${
|
|
376
|
+
viewMode === 'table'
|
|
377
|
+
? 'bg-blue-600 text-white border-blue-600'
|
|
378
|
+
: 'bg-white text-gray-700 hover:bg-gray-50'
|
|
379
|
+
}`}
|
|
380
|
+
>
|
|
381
|
+
Table
|
|
382
|
+
</button>
|
|
383
|
+
<button
|
|
384
|
+
type="button"
|
|
385
|
+
onClick={() => handleViewModeChange('chat')}
|
|
386
|
+
className={`px-4 py-2 text-sm font-medium border border-gray-300 rounded-r-lg border-l-0 ${
|
|
387
|
+
viewMode === 'chat'
|
|
388
|
+
? 'bg-blue-600 text-white border-blue-600'
|
|
389
|
+
: 'bg-white text-gray-700 hover:bg-gray-50'
|
|
390
|
+
}`}
|
|
391
|
+
>
|
|
392
|
+
Chat
|
|
393
|
+
</button>
|
|
394
|
+
</div>
|
|
395
|
+
<div>
|
|
396
|
+
<a
|
|
397
|
+
href={getExportUrl()}
|
|
398
|
+
target="_blank"
|
|
399
|
+
rel="noopener noreferrer"
|
|
400
|
+
className="inline-flex items-center justify-center rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 shadow-sm hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2"
|
|
401
|
+
>
|
|
402
|
+
Download CSV
|
|
403
|
+
</a>
|
|
286
404
|
</div>
|
|
287
|
-
<div
|
|
288
|
-
|
|
405
|
+
<div>
|
|
406
|
+
<div className="text-xl font-semibold text-gray-900">
|
|
407
|
+
{total.toLocaleString()}
|
|
408
|
+
</div>
|
|
409
|
+
<div className="text-xs uppercase tracking-wide text-gray-400">
|
|
410
|
+
Total messages
|
|
411
|
+
</div>
|
|
289
412
|
</div>
|
|
290
413
|
</div>
|
|
291
414
|
</div>
|
|
@@ -372,12 +495,27 @@ export function ChatHistoryClient({ initialAgentName }: ChatHistoryClientProps)
|
|
|
372
495
|
)}
|
|
373
496
|
</Card>
|
|
374
497
|
|
|
375
|
-
|
|
376
|
-
<div className="
|
|
377
|
-
<
|
|
378
|
-
|
|
379
|
-
|
|
498
|
+
{viewMode === 'chat' ? (
|
|
499
|
+
<div className="bg-white rounded-lg shadow border border-gray-200 overflow-hidden flex flex-col">
|
|
500
|
+
<div className="h-[800px] relative">
|
|
501
|
+
<MockedChat
|
|
502
|
+
messages={chatMessages}
|
|
503
|
+
isPausable={true}
|
|
504
|
+
isResettable={false}
|
|
505
|
+
isSaveButtonEnabled={true}
|
|
506
|
+
/>
|
|
507
|
+
</div>
|
|
508
|
+
<div className="p-4 bg-gray-50 border-t border-gray-200">
|
|
509
|
+
{pagination}
|
|
510
|
+
</div>
|
|
380
511
|
</div>
|
|
512
|
+
) : (
|
|
513
|
+
<Card>
|
|
514
|
+
<div className="flex items-center justify-between mb-4">
|
|
515
|
+
<h2 className="text-lg font-medium text-gray-900">
|
|
516
|
+
Messages ({total})
|
|
517
|
+
</h2>
|
|
518
|
+
</div>
|
|
381
519
|
{error && (
|
|
382
520
|
<div className="mb-4 rounded-md bg-red-50 px-4 py-3 text-sm text-red-800">
|
|
383
521
|
{error}
|
|
@@ -417,13 +555,27 @@ export function ChatHistoryClient({ initialAgentName }: ChatHistoryClientProps)
|
|
|
417
555
|
)}
|
|
418
556
|
</button>
|
|
419
557
|
</th>
|
|
420
|
-
<th className="px-4 py-3 text-left font-medium text-gray-500">
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
<th className="px-4 py-3 text-left font-medium text-gray-500">
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
<th className="px-4 py-3 text-
|
|
558
|
+
<th className="px-4 py-3 text-left font-medium text-gray-500">
|
|
559
|
+
Role
|
|
560
|
+
</th>
|
|
561
|
+
<th className="px-4 py-3 text-left font-medium text-gray-500">
|
|
562
|
+
Message
|
|
563
|
+
</th>
|
|
564
|
+
<th className="px-4 py-3 text-left font-medium text-gray-500">
|
|
565
|
+
URL
|
|
566
|
+
</th>
|
|
567
|
+
<th className="px-4 py-3 text-left font-medium text-gray-500">
|
|
568
|
+
IP
|
|
569
|
+
</th>
|
|
570
|
+
<th className="px-4 py-3 text-left font-medium text-gray-500">
|
|
571
|
+
Language
|
|
572
|
+
</th>
|
|
573
|
+
<th className="px-4 py-3 text-left font-medium text-gray-500">
|
|
574
|
+
Platform
|
|
575
|
+
</th>
|
|
576
|
+
<th className="px-4 py-3 text-right font-medium text-gray-500">
|
|
577
|
+
Actions
|
|
578
|
+
</th>
|
|
427
579
|
</tr>
|
|
428
580
|
</thead>
|
|
429
581
|
<tbody className="divide-y divide-gray-200 bg-white">
|
|
@@ -474,59 +626,9 @@ export function ChatHistoryClient({ initialAgentName }: ChatHistoryClientProps)
|
|
|
474
626
|
</table>
|
|
475
627
|
</div>
|
|
476
628
|
)}
|
|
477
|
-
|
|
478
|
-
<div className="mt-4 flex flex-col items-center justify-between gap-3 border-t border-gray-100 pt-4 text-xs text-gray-600 md:flex-row">
|
|
479
|
-
<div>
|
|
480
|
-
{total > 0 ? (
|
|
481
|
-
<>
|
|
482
|
-
Showing{' '}
|
|
483
|
-
<span className="font-semibold">
|
|
484
|
-
{Math.min((page - 1) * pageSize + 1, total)}
|
|
485
|
-
</span>{' '}
|
|
486
|
-
–{' '}
|
|
487
|
-
<span className="font-semibold">
|
|
488
|
-
{Math.min(page * pageSize, total)}
|
|
489
|
-
</span>{' '}
|
|
490
|
-
of{' '}
|
|
491
|
-
<span className="font-semibold">
|
|
492
|
-
{total}
|
|
493
|
-
</span>{' '}
|
|
494
|
-
messages
|
|
495
|
-
</>
|
|
496
|
-
) : (
|
|
497
|
-
'No messages'
|
|
498
|
-
)}
|
|
499
|
-
</div>
|
|
500
|
-
<div className="flex items-center gap-2">
|
|
501
|
-
<button
|
|
502
|
-
type="button"
|
|
503
|
-
onClick={() => setPage((prev) => Math.max(1, prev - 1))}
|
|
504
|
-
disabled={page <= 1}
|
|
505
|
-
className="inline-flex items-center justify-center rounded-md border border-gray-300 px-2 py-1 text-xs font-medium text-gray-700 disabled:cursor-not-allowed disabled:opacity-50"
|
|
506
|
-
>
|
|
507
|
-
Previous
|
|
508
|
-
</button>
|
|
509
|
-
<span>
|
|
510
|
-
Page{' '}
|
|
511
|
-
<span className="font-semibold">
|
|
512
|
-
{page}
|
|
513
|
-
</span>{' '}
|
|
514
|
-
of{' '}
|
|
515
|
-
<span className="font-semibold">
|
|
516
|
-
{totalPages}
|
|
517
|
-
</span>
|
|
518
|
-
</span>
|
|
519
|
-
<button
|
|
520
|
-
type="button"
|
|
521
|
-
onClick={() => setPage((prev) => Math.min(totalPages, prev + 1))}
|
|
522
|
-
disabled={page >= totalPages}
|
|
523
|
-
className="inline-flex items-center justify-center rounded-md border border-gray-300 px-2 py-1 text-xs font-medium text-gray-700 disabled:cursor-not-allowed disabled:opacity-50"
|
|
524
|
-
>
|
|
525
|
-
Next
|
|
526
|
-
</button>
|
|
527
|
-
</div>
|
|
528
|
-
</div>
|
|
629
|
+
{pagination}
|
|
529
630
|
</Card>
|
|
631
|
+
)}
|
|
530
632
|
</div>
|
|
531
633
|
);
|
|
532
634
|
}
|
|
@@ -9,12 +9,13 @@ import { string_agent_url } from '../../../../../../src/types/typeAliases';
|
|
|
9
9
|
type AgentChatWrapperProps = {
|
|
10
10
|
agentUrl: string_agent_url;
|
|
11
11
|
defaultMessage?: string;
|
|
12
|
+
autoExecuteMessage?: string;
|
|
12
13
|
};
|
|
13
14
|
|
|
14
15
|
// TODO: [🐱🚀] Rename to AgentChatSomethingWrapper
|
|
15
16
|
|
|
16
17
|
export function AgentChatWrapper(props: AgentChatWrapperProps) {
|
|
17
|
-
const { agentUrl, defaultMessage } = props;
|
|
18
|
+
const { agentUrl, defaultMessage, autoExecuteMessage } = props;
|
|
18
19
|
|
|
19
20
|
const agentPromise = useMemo(
|
|
20
21
|
() =>
|
|
@@ -67,6 +68,7 @@ export function AgentChatWrapper(props: AgentChatWrapperProps) {
|
|
|
67
68
|
agent={agent}
|
|
68
69
|
onFeedback={handleFeedback}
|
|
69
70
|
defaultMessage={defaultMessage}
|
|
71
|
+
autoExecuteMessage={autoExecuteMessage}
|
|
70
72
|
/>
|
|
71
73
|
);
|
|
72
74
|
}
|