@promptbook/cli 0.104.0-13 → 0.104.0-15
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/src/app/admin/files/FilesGalleryClient.tsx +96 -57
- package/apps/agents-server/src/app/admin/image-generator-test/ImageGeneratorTestClient.tsx +297 -111
- package/apps/agents-server/src/app/admin/images/ImagesGalleryClient.tsx +95 -56
- package/apps/agents-server/src/app/agents/[agentName]/AgentOptionsMenu.tsx +58 -69
- package/apps/agents-server/src/app/agents/[agentName]/AgentProfileWrapper.tsx +2 -2
- package/apps/agents-server/src/app/agents/[agentName]/agentLinks.tsx +1 -21
- package/apps/agents-server/src/app/agents/[agentName]/{code → export-as-transpiled-code}/api/route.ts +6 -1
- package/apps/agents-server/src/app/agents/[agentName]/{code → export-as-transpiled-code}/page.tsx +3 -3
- package/apps/agents-server/src/app/agents/[agentName]/links/README.md +1 -0
- package/apps/agents-server/src/app/agents/[agentName]/links/{page.tsx → page.tsx.tmp} +1 -1
- package/apps/agents-server/src/app/agents/[agentName]/page.tsx +1 -1
- package/apps/agents-server/src/app/agents/[agentName]/system-message/page.tsx +26 -34
- package/apps/agents-server/src/app/api/browser-test/act/route.ts +1 -1
- package/apps/agents-server/src/app/api/browser-test/scroll-facebook/route.ts +1 -1
- package/apps/agents-server/src/app/api/docs/book.md/route.ts +1 -1
- package/apps/agents-server/src/app/api/messages/route.ts +2 -2
- package/apps/agents-server/src/app/layout.tsx +5 -4
- package/apps/agents-server/src/components/AgentProfile/AgentProfile.tsx +2 -2
- package/apps/agents-server/src/components/Header/Header.tsx +5 -4
- package/apps/agents-server/src/database/getMetadata.ts +1 -1
- package/apps/agents-server/src/database/migrate.ts +8 -8
- package/apps/agents-server/src/message-providers/email/sendgrid/SendgridMessageProvider.ts +3 -3
- package/apps/agents-server/src/message-providers/email/zeptomail/ZeptomailMessageProvider.ts +3 -3
- package/apps/agents-server/src/utils/getEffectiveFederatedServers.ts +2 -2
- package/apps/agents-server/src/utils/resolveInheritedAgentSource.ts +33 -30
- package/esm/index.es.js +34 -26
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/components.index.d.ts +0 -6
- package/esm/typings/src/book-components/Chat/types/ChatMessage.d.ts +4 -1
- package/esm/typings/src/book-components/_common/Dropdown/Dropdown.d.ts +5 -1
- package/esm/typings/src/book-components/_common/HamburgerMenu/HamburgerMenu.d.ts +4 -0
- package/esm/typings/src/book-components/icons/AboutIcon.d.ts +5 -1
- package/esm/typings/src/book-components/icons/AttachmentIcon.d.ts +6 -2
- package/esm/typings/src/book-components/icons/CameraIcon.d.ts +6 -2
- package/esm/typings/src/book-components/icons/DownloadIcon.d.ts +5 -1
- package/esm/typings/src/book-components/icons/MenuIcon.d.ts +5 -1
- package/esm/typings/src/book-components/icons/SaveIcon.d.ts +6 -2
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +7 -5
- package/esm/typings/src/llm-providers/_common/utils/count-total-usage/countUsage.d.ts +7 -3
- package/esm/typings/src/llm-providers/_multiple/joinLlmExecutionTools.d.ts +11 -7
- package/esm/typings/src/remote-server/ui/ServerApp.d.ts +5 -1
- package/esm/typings/src/types/typeAliasEmoji.d.ts +2 -2
- package/esm/typings/src/utils/random/$randomAgentPersona.d.ts +4 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +34 -26
- package/umd/index.umd.js.map +1 -1
- /package/apps/agents-server/src/app/agents/[agentName]/api/{modelRequirements → model-requirements}/TODO.txt +0 -0
- /package/apps/agents-server/src/app/agents/[agentName]/api/{modelRequirements → model-requirements}/route.ts +0 -0
- /package/apps/agents-server/src/app/agents/[agentName]/api/{modelRequirements/systemMessage → model-requirements/system-message}/route.ts +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { ChevronLeft, ChevronRight, File, Grid, LayoutList, Loader2 } from 'lucide-react';
|
|
4
4
|
import Link from 'next/link';
|
|
5
|
-
import { useEffect, useRef, useState } from 'react';
|
|
5
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
6
6
|
import { FileWithAgent, listFiles } from './actions';
|
|
7
7
|
|
|
8
8
|
type ViewMode = 'TABLE' | 'GRID';
|
|
@@ -16,37 +16,40 @@ export function FilesGalleryClient() {
|
|
|
16
16
|
const [limit] = useState(20);
|
|
17
17
|
const [hasMore, setHasMore] = useState(true);
|
|
18
18
|
|
|
19
|
-
const loadFiles =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
const loadFiles = useCallback(
|
|
20
|
+
async (pageNum: number, isNewView: boolean) => {
|
|
21
|
+
setIsLoading(true);
|
|
22
|
+
try {
|
|
23
|
+
const result = await listFiles({ page: pageNum, limit });
|
|
24
|
+
if (isNewView) {
|
|
25
|
+
setFiles(result.files);
|
|
26
|
+
} else {
|
|
27
|
+
setFiles((prev) => [...prev, ...result.files]);
|
|
28
|
+
}
|
|
29
|
+
setTotal(result.total);
|
|
30
|
+
setHasMore(result.files.length === limit);
|
|
31
|
+
} catch (error) {
|
|
32
|
+
console.error(error);
|
|
33
|
+
} finally {
|
|
34
|
+
setIsLoading(false);
|
|
27
35
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
console.error(error);
|
|
32
|
-
} finally {
|
|
33
|
-
setIsLoading(false);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
+
},
|
|
37
|
+
[limit],
|
|
38
|
+
);
|
|
36
39
|
|
|
37
40
|
useEffect(() => {
|
|
38
41
|
loadFiles(1, true);
|
|
39
42
|
setPage(1);
|
|
40
43
|
setHasMore(true);
|
|
41
|
-
}, [viewMode]);
|
|
44
|
+
}, [loadFiles, viewMode]);
|
|
42
45
|
|
|
43
|
-
const handleLoadMore = () => {
|
|
46
|
+
const handleLoadMore = useCallback(() => {
|
|
44
47
|
if (!isLoading && hasMore) {
|
|
45
48
|
const nextPage = page + 1;
|
|
46
49
|
setPage(nextPage);
|
|
47
50
|
loadFiles(nextPage, false);
|
|
48
51
|
}
|
|
49
|
-
};
|
|
52
|
+
}, [isLoading, hasMore, page, loadFiles]);
|
|
50
53
|
|
|
51
54
|
// Table view pagination
|
|
52
55
|
const handlePageChange = (newPage: number) => {
|
|
@@ -57,26 +60,26 @@ export function FilesGalleryClient() {
|
|
|
57
60
|
const observerTarget = useRef<HTMLDivElement>(null);
|
|
58
61
|
|
|
59
62
|
useEffect(() => {
|
|
63
|
+
const target = observerTarget.current; // Capture the current value
|
|
60
64
|
const observer = new IntersectionObserver(
|
|
61
65
|
(entries) => {
|
|
62
66
|
if (entries[0].isIntersecting && hasMore && !isLoading && viewMode === 'GRID') {
|
|
63
67
|
handleLoadMore();
|
|
64
68
|
}
|
|
65
69
|
},
|
|
66
|
-
{ threshold: 0.1 }
|
|
70
|
+
{ threshold: 0.1 },
|
|
67
71
|
);
|
|
68
72
|
|
|
69
|
-
if (
|
|
70
|
-
observer.observe(
|
|
73
|
+
if (target) {
|
|
74
|
+
observer.observe(target);
|
|
71
75
|
}
|
|
72
76
|
|
|
73
77
|
return () => {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
observer.unobserve(observerTarget.current);
|
|
78
|
+
if (target) {
|
|
79
|
+
observer.unobserve(target);
|
|
77
80
|
}
|
|
78
81
|
};
|
|
79
|
-
}, [hasMore, isLoading, viewMode, page]);
|
|
82
|
+
}, [hasMore, isLoading, viewMode, page, handleLoadMore]);
|
|
80
83
|
|
|
81
84
|
return (
|
|
82
85
|
<div className="container mx-auto px-4 py-8 space-y-6">
|
|
@@ -86,7 +89,9 @@ export function FilesGalleryClient() {
|
|
|
86
89
|
<button
|
|
87
90
|
onClick={() => setViewMode('TABLE')}
|
|
88
91
|
className={`p-2 rounded-md transition-colors ${
|
|
89
|
-
viewMode === 'TABLE'
|
|
92
|
+
viewMode === 'TABLE'
|
|
93
|
+
? 'bg-white shadow-sm text-blue-600'
|
|
94
|
+
: 'text-gray-500 hover:text-gray-900'
|
|
90
95
|
}`}
|
|
91
96
|
title="Table View"
|
|
92
97
|
>
|
|
@@ -95,7 +100,9 @@ export function FilesGalleryClient() {
|
|
|
95
100
|
<button
|
|
96
101
|
onClick={() => setViewMode('GRID')}
|
|
97
102
|
className={`p-2 rounded-md transition-colors ${
|
|
98
|
-
viewMode === 'GRID'
|
|
103
|
+
viewMode === 'GRID'
|
|
104
|
+
? 'bg-white shadow-sm text-blue-600'
|
|
105
|
+
: 'text-gray-500 hover:text-gray-900'
|
|
99
106
|
}`}
|
|
100
107
|
title="Grid View"
|
|
101
108
|
>
|
|
@@ -124,7 +131,12 @@ export function FilesGalleryClient() {
|
|
|
124
131
|
<tr key={file.id} className="bg-white border-b hover:bg-gray-50">
|
|
125
132
|
<td className="px-6 py-4">
|
|
126
133
|
{file.storageUrl ? (
|
|
127
|
-
<a
|
|
134
|
+
<a
|
|
135
|
+
href={file.storageUrl}
|
|
136
|
+
target="_blank"
|
|
137
|
+
rel="noopener noreferrer"
|
|
138
|
+
className="text-blue-600 hover:underline"
|
|
139
|
+
>
|
|
128
140
|
{file.fileName}
|
|
129
141
|
</a>
|
|
130
142
|
) : (
|
|
@@ -135,7 +147,10 @@ export function FilesGalleryClient() {
|
|
|
135
147
|
<td className="px-6 py-4">{(file.fileSize / 1024).toFixed(2)} KB</td>
|
|
136
148
|
<td className="px-6 py-4">
|
|
137
149
|
{file.agent ? (
|
|
138
|
-
<Link
|
|
150
|
+
<Link
|
|
151
|
+
href={`/${file.agent.agentName}`}
|
|
152
|
+
className="text-blue-600 hover:underline"
|
|
153
|
+
>
|
|
139
154
|
{file.agent.agentName}
|
|
140
155
|
</Link>
|
|
141
156
|
) : (
|
|
@@ -148,10 +163,15 @@ export function FilesGalleryClient() {
|
|
|
148
163
|
</span>
|
|
149
164
|
</td>
|
|
150
165
|
<td className="px-6 py-4">
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
166
|
+
<span
|
|
167
|
+
className={`px-2 py-1 rounded-full text-xs font-medium ${
|
|
168
|
+
file.status === 'COMPLETED'
|
|
169
|
+
? 'bg-green-100 text-green-800'
|
|
170
|
+
: file.status === 'FAILED'
|
|
171
|
+
? 'bg-red-100 text-red-800'
|
|
172
|
+
: 'bg-blue-100 text-blue-800'
|
|
173
|
+
}`}
|
|
174
|
+
>
|
|
155
175
|
{file.status}
|
|
156
176
|
</span>
|
|
157
177
|
</td>
|
|
@@ -173,7 +193,9 @@ export function FilesGalleryClient() {
|
|
|
173
193
|
{/* Pagination for Table */}
|
|
174
194
|
<div className="flex items-center justify-between px-6 py-4 border-t bg-gray-50">
|
|
175
195
|
<span className="text-sm text-gray-700">
|
|
176
|
-
Showing <span className="font-medium">{(page - 1) * limit + 1}</span> to
|
|
196
|
+
Showing <span className="font-medium">{(page - 1) * limit + 1}</span> to{' '}
|
|
197
|
+
<span className="font-medium">{Math.min(page * limit, total)}</span> of{' '}
|
|
198
|
+
<span className="font-medium">{total}</span> results
|
|
177
199
|
</span>
|
|
178
200
|
<div className="flex gap-2">
|
|
179
201
|
<button
|
|
@@ -197,14 +219,22 @@ export function FilesGalleryClient() {
|
|
|
197
219
|
<>
|
|
198
220
|
<div className="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4">
|
|
199
221
|
{files.map((file) => (
|
|
200
|
-
<div
|
|
201
|
-
|
|
222
|
+
<div
|
|
223
|
+
key={file.id}
|
|
224
|
+
className="group relative border rounded-lg overflow-hidden bg-white shadow-sm hover:shadow-md transition-shadow"
|
|
225
|
+
>
|
|
226
|
+
<a
|
|
227
|
+
href={file.storageUrl || '#'}
|
|
228
|
+
target="_blank"
|
|
229
|
+
rel="noopener noreferrer"
|
|
230
|
+
className="block aspect-square relative bg-gray-100 flex items-center justify-center"
|
|
231
|
+
>
|
|
202
232
|
{file.fileType.startsWith('image/') && file.storageUrl ? (
|
|
203
233
|
/* eslint-disable-next-line @next/next/no-img-element */
|
|
204
|
-
<img
|
|
205
|
-
src={file.storageUrl}
|
|
206
|
-
alt={file.fileName}
|
|
207
|
-
className="object-cover w-full h-full transition-transform duration-300 group-hover:scale-105"
|
|
234
|
+
<img
|
|
235
|
+
src={file.storageUrl}
|
|
236
|
+
alt={file.fileName}
|
|
237
|
+
className="object-cover w-full h-full transition-transform duration-300 group-hover:scale-105"
|
|
208
238
|
loading="lazy"
|
|
209
239
|
/>
|
|
210
240
|
) : (
|
|
@@ -214,25 +244,38 @@ export function FilesGalleryClient() {
|
|
|
214
244
|
<div className="p-3">
|
|
215
245
|
<div className="flex items-center justify-between gap-2 mb-1">
|
|
216
246
|
{file.agent ? (
|
|
217
|
-
<Link
|
|
247
|
+
<Link
|
|
248
|
+
href={`/${file.agent.agentName}`}
|
|
249
|
+
className="text-xs font-medium text-blue-600 hover:underline truncate"
|
|
250
|
+
>
|
|
218
251
|
{file.agent.agentName}
|
|
219
252
|
</Link>
|
|
220
253
|
) : (
|
|
221
|
-
|
|
254
|
+
<span className="text-xs text-gray-400">No agent</span>
|
|
222
255
|
)}
|
|
223
256
|
<span className="text-[10px] text-gray-400 whitespace-nowrap">
|
|
224
|
-
{new Date(file.createdAt).toLocaleDateString(undefined, {
|
|
257
|
+
{new Date(file.createdAt).toLocaleDateString(undefined, {
|
|
258
|
+
month: 'short',
|
|
259
|
+
day: 'numeric',
|
|
260
|
+
})}
|
|
225
261
|
</span>
|
|
226
262
|
</div>
|
|
227
263
|
<p className="text-xs text-gray-600 truncate" title={file.fileName}>
|
|
228
264
|
{file.fileName}
|
|
229
265
|
</p>
|
|
230
266
|
<div className="mt-1 flex justify-between items-center">
|
|
231
|
-
<span className="text-[10px] text-gray-500">
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
267
|
+
<span className="text-[10px] text-gray-500">
|
|
268
|
+
{(file.fileSize / 1024).toFixed(1)} KB
|
|
269
|
+
</span>
|
|
270
|
+
<span
|
|
271
|
+
className={`px-1.5 py-0.5 rounded-full text-[10px] font-medium ${
|
|
272
|
+
file.status === 'COMPLETED'
|
|
273
|
+
? 'bg-green-100 text-green-800'
|
|
274
|
+
: file.status === 'FAILED'
|
|
275
|
+
? 'bg-red-100 text-red-800'
|
|
276
|
+
: 'bg-blue-100 text-blue-800'
|
|
277
|
+
}`}
|
|
278
|
+
>
|
|
236
279
|
{file.status}
|
|
237
280
|
</span>
|
|
238
281
|
</div>
|
|
@@ -240,18 +283,14 @@ export function FilesGalleryClient() {
|
|
|
240
283
|
</div>
|
|
241
284
|
))}
|
|
242
285
|
</div>
|
|
243
|
-
|
|
286
|
+
|
|
244
287
|
{files.length === 0 && !isLoading && (
|
|
245
|
-
<div className="text-center text-gray-500 py-12">
|
|
246
|
-
No files found.
|
|
247
|
-
</div>
|
|
288
|
+
<div className="text-center text-gray-500 py-12">No files found.</div>
|
|
248
289
|
)}
|
|
249
290
|
|
|
250
291
|
{/* Infinite Scroll Loader */}
|
|
251
292
|
<div className="py-8 flex justify-center" ref={observerTarget}>
|
|
252
|
-
{isLoading &&
|
|
253
|
-
<Loader2 className="w-8 h-8 animate-spin text-blue-500" />
|
|
254
|
-
)}
|
|
293
|
+
{isLoading && <Loader2 className="w-8 h-8 animate-spin text-blue-500" />}
|
|
255
294
|
{!isLoading && !hasMore && files.length > 0 && (
|
|
256
295
|
<p className="text-gray-400 text-sm">No more files</p>
|
|
257
296
|
)}
|