@promptbook/cli 0.104.0-6 → 0.104.0-8

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 (48) hide show
  1. package/apps/agents-server/config.ts +1 -3
  2. package/apps/agents-server/src/app/admin/browser-test/BrowserTestClient.tsx +85 -0
  3. package/apps/agents-server/src/app/admin/browser-test/page.tsx +13 -0
  4. package/apps/agents-server/src/app/agents/[agentName]/AgentProfileWrapper.tsx +49 -10
  5. package/apps/agents-server/src/app/agents/[agentName]/_utils.ts +0 -3
  6. package/apps/agents-server/src/app/agents/[agentName]/code/page.tsx +5 -2
  7. package/apps/agents-server/src/app/agents/[agentName]/images/default-avatar.png/getAgentDefaultAvatarPrompt.ts +31 -0
  8. package/apps/agents-server/src/app/agents/[agentName]/images/default-avatar.png/route.ts +56 -38
  9. package/apps/agents-server/src/app/agents/[agentName]/images/icon-256.png/route.tsx +10 -1
  10. package/apps/agents-server/src/app/agents/[agentName]/images/page.tsx +200 -0
  11. package/apps/agents-server/src/app/agents/[agentName]/images/screenshot-fullhd.png/route.tsx +5 -4
  12. package/apps/agents-server/src/app/agents/[agentName]/images/screenshot-phone.png/route.tsx +5 -4
  13. package/apps/agents-server/src/app/agents/[agentName]/integration/page.tsx +8 -1
  14. package/apps/agents-server/src/app/agents/[agentName]/links/page.tsx +8 -1
  15. package/apps/agents-server/src/app/agents/[agentName]/opengraph-image.tsx +7 -2
  16. package/apps/agents-server/src/app/agents/[agentName]/page.tsx +3 -4
  17. package/apps/agents-server/src/app/agents/[agentName]/system-message/page.tsx +15 -3
  18. package/apps/agents-server/src/app/api/browser-test/screenshot/route.ts +30 -0
  19. package/apps/agents-server/src/app/humans.txt/route.ts +1 -1
  20. package/apps/agents-server/src/app/page.tsx +4 -2
  21. package/apps/agents-server/src/app/recycle-bin/page.tsx +3 -1
  22. package/apps/agents-server/src/app/robots.txt/route.ts +1 -1
  23. package/apps/agents-server/src/app/security.txt/route.ts +1 -1
  24. package/apps/agents-server/src/app/sitemap.xml/route.ts +4 -5
  25. package/apps/agents-server/src/components/AgentProfile/AgentProfile.tsx +22 -13
  26. package/apps/agents-server/src/components/Header/Header.tsx +4 -0
  27. package/apps/agents-server/src/components/Homepage/AgentCard.tsx +46 -9
  28. package/apps/agents-server/src/components/Homepage/AgentsList.tsx +32 -14
  29. package/apps/agents-server/src/components/Homepage/DeletedAgentsList.tsx +22 -6
  30. package/apps/agents-server/src/components/Homepage/ExternalAgentsSection.tsx +12 -3
  31. package/apps/agents-server/src/components/Homepage/ExternalAgentsSectionClient.tsx +19 -10
  32. package/apps/agents-server/src/components/VercelDeploymentCard/VercelDeploymentCard.tsx +2 -0
  33. package/apps/agents-server/src/components/_utils/generateMetaTxt.ts +12 -10
  34. package/apps/agents-server/src/tools/$provideBrowserForServer.ts +29 -0
  35. package/apps/agents-server/src/tools/$provideCdnForServer.ts +1 -1
  36. package/esm/index.es.js +8 -9
  37. package/esm/index.es.js.map +1 -1
  38. package/esm/typings/servers.d.ts +8 -0
  39. package/esm/typings/src/_packages/core.index.d.ts +2 -0
  40. package/esm/typings/src/_packages/types.index.d.ts +2 -0
  41. package/esm/typings/src/book-2.0/utils/generatePlaceholderAgentProfileImageUrl.d.ts +2 -2
  42. package/esm/typings/src/types/ModelRequirements.d.ts +38 -14
  43. package/esm/typings/src/types/typeAliases.d.ts +7 -1
  44. package/esm/typings/src/utils/color/utils/colorToDataUrl.d.ts +2 -1
  45. package/esm/typings/src/version.d.ts +1 -1
  46. package/package.json +1 -1
  47. package/umd/index.umd.js +8 -9
  48. package/umd/index.umd.js.map +1 -1
@@ -29,9 +29,7 @@ const config = ConfigChecker.from({
29
29
  *
30
30
  * Note: When `SERVERS` are used, this URL will be overridden by the server URL.
31
31
  */
32
- export const NEXT_PUBLIC_SITE_URL = config
33
- .get('NEXT_PUBLIC_SITE_URL')
34
- .url()./* <- TODO: !!!! Is it ok not to be required().*/ value;
32
+ export const NEXT_PUBLIC_SITE_URL = config.get('NEXT_PUBLIC_SITE_URL').url().value;
35
33
 
36
34
  /**
37
35
  * [♐️] Vercel environment: "development" | "preview" | "production"
@@ -0,0 +1,85 @@
1
+ 'use client';
2
+
3
+ import { useState, useEffect } from 'react';
4
+ import { Card } from '../../../components/Homepage/Card';
5
+
6
+ export function BrowserTestClient() {
7
+ const [imageUrl, setImageUrl] = useState<string | null>(null);
8
+
9
+ useEffect(() => {
10
+ return () => {
11
+ if (imageUrl) {
12
+ URL.revokeObjectURL(imageUrl);
13
+ }
14
+ };
15
+ }, [imageUrl]);
16
+ const [isLoading, setIsLoading] = useState(false);
17
+ const [error, setError] = useState<string | null>(null);
18
+
19
+ const handleTakeScreenshot = async () => {
20
+ setIsLoading(true);
21
+ setError(null);
22
+ try {
23
+ const response = await fetch('/api/browser-test/screenshot');
24
+ if (!response.ok) {
25
+ const text = await response.text();
26
+ let errorMessage;
27
+ try {
28
+ const json = JSON.parse(text);
29
+ errorMessage = json.error || response.statusText;
30
+ } catch {
31
+ errorMessage = text || response.statusText;
32
+ }
33
+ throw new Error(`Error: ${response.status} ${errorMessage}`);
34
+ }
35
+ const blob = await response.blob();
36
+ const url = URL.createObjectURL(blob);
37
+ setImageUrl(url);
38
+ } catch (err) {
39
+ setError(String(err));
40
+ } finally {
41
+ setIsLoading(false);
42
+ }
43
+ };
44
+
45
+ return (
46
+ <div className="container mx-auto px-4 py-8 space-y-6">
47
+ <div className="mt-20 mb-4 flex flex-col gap-2 md:flex-row md:items-end md:justify-between">
48
+ <div>
49
+ <h1 className="text-3xl text-gray-900 font-light">Browser Test</h1>
50
+ <p className="mt-1 text-sm text-gray-500">
51
+ Launch a browser instance and take a screenshot to verify functionality.
52
+ </p>
53
+ </div>
54
+ </div>
55
+
56
+ <Card>
57
+ <div className="mb-4">
58
+ <p className="mb-2">Click the button below to launch a browser instance (if not running), navigate to ptbk.io, and take a screenshot.</p>
59
+ <button
60
+ onClick={handleTakeScreenshot}
61
+ disabled={isLoading}
62
+ className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded disabled:opacity-50"
63
+ >
64
+ {isLoading ? 'Taking Screenshot...' : 'Take Screenshot'}
65
+ </button>
66
+ </div>
67
+
68
+ {error && (
69
+ <div className="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mb-4" role="alert">
70
+ <strong className="font-bold">Error: </strong>
71
+ <span className="block sm:inline">{error}</span>
72
+ </div>
73
+ )}
74
+
75
+ {imageUrl && (
76
+ <div className="border rounded shadow-lg overflow-hidden">
77
+ <h2 className="text-xl font-semibold p-2 bg-gray-100">Screenshot</h2>
78
+ {/* eslint-disable-next-line @next/next/no-img-element */}
79
+ <img src={imageUrl} alt="Screenshot of ptbk.io" className="w-full h-auto" />
80
+ </div>
81
+ )}
82
+ </Card>
83
+ </div>
84
+ );
85
+ }
@@ -0,0 +1,13 @@
1
+ import { ForbiddenPage } from '../../../components/ForbiddenPage/ForbiddenPage';
2
+ import { isUserAdmin } from '../../../utils/isUserAdmin';
3
+ import { BrowserTestClient } from './BrowserTestClient';
4
+
5
+ export default async function BrowserTestPage() {
6
+ const isAdmin = await isUserAdmin();
7
+
8
+ if (!isAdmin) {
9
+ return <ForbiddenPage />;
10
+ }
11
+
12
+ return <BrowserTestClient />;
13
+ }
@@ -5,19 +5,57 @@ import { AgentProfile } from '../../../components/AgentProfile/AgentProfile';
5
5
  import { AgentOptionsMenu } from './AgentOptionsMenu';
6
6
 
7
7
  type AgentProfileWrapperProps = {
8
- agent: AgentBasicInformation;
9
- agentUrl: string;
10
- agentEmail: string;
11
- agentName: string_agent_name;
12
- brandColorHex: string;
13
- isAdmin: boolean;
14
- isHeadless: boolean;
15
- actions: React.ReactNode;
16
- children: React.ReactNode;
8
+ /***
9
+ * @@@
10
+ */
11
+ readonly agent: AgentBasicInformation;
12
+
13
+ /***
14
+ * @@@
15
+ */
16
+ readonly agentUrl: string;
17
+
18
+ /**
19
+ * Base URL of the agents server
20
+ */
21
+ readonly publicUrl: URL;
22
+
23
+ /***
24
+ * @@@
25
+ */
26
+ readonly agentEmail: string;
27
+
28
+ /***
29
+ * @@@
30
+ */
31
+ readonly agentName: string_agent_name;
32
+
33
+ /***
34
+ * @@@
35
+ */
36
+ readonly brandColorHex: string;
37
+
38
+ /***
39
+ * @@@
40
+ */
41
+ readonly isAdmin: boolean;
42
+
43
+ /***
44
+ * @@@
45
+ */
46
+ readonly isHeadless: boolean;
47
+
48
+ readonly actions: React.ReactNode;
49
+
50
+ /***
51
+ * @@@
52
+ */
53
+ readonly children: React.ReactNode;
17
54
  };
18
55
 
19
56
  export function AgentProfileWrapper(props: AgentProfileWrapperProps) {
20
- const { agent, agentUrl, agentEmail, agentName, brandColorHex, isAdmin, isHeadless, actions, children } = props;
57
+ const { agent, agentUrl, publicUrl, agentEmail, agentName, brandColorHex, isAdmin, isHeadless, actions, children } =
58
+ props;
21
59
 
22
60
  // Derived agentName from agent data
23
61
  const derivedAgentName = agent.agentName;
@@ -27,6 +65,7 @@ export function AgentProfileWrapper(props: AgentProfileWrapperProps) {
27
65
  <AgentProfile
28
66
  agent={agent}
29
67
  agentUrl={agentUrl}
68
+ publicUrl={publicUrl}
30
69
  permanentId={permanentId || agentName}
31
70
  agentEmail={agentEmail}
32
71
  isHeadless={isHeadless}
@@ -14,9 +14,6 @@ export async function getAgentProfile(agentName: string) {
14
14
  const collection = await $provideAgentCollectionForServer();
15
15
  const agentSource = await collection.getAgentSource(agentName);
16
16
  const agentProfile = parseAgentSource(agentSource);
17
-
18
- console.log('!!!!', { agentSource, agentProfile });
19
-
20
17
  return agentProfile;
21
18
  }
22
19
 
@@ -1,5 +1,6 @@
1
1
  'use client';
2
2
 
3
+ import { NEXT_PUBLIC_SITE_URL } from '@/config';
3
4
  import Editor from '@monaco-editor/react';
4
5
  import { generatePlaceholderAgentProfileImageUrl } from '@promptbook-local/core';
5
6
  import { AgentBasicInformation } from '@promptbook-local/types';
@@ -120,8 +121,10 @@ export default function AgentCodePage({ params }: { params: Promise<{ agentName:
120
121
  <img
121
122
  src={
122
123
  agentProfile.meta.image ||
123
- agentProfile.permanentId ||
124
- generatePlaceholderAgentProfileImageUrl(agentName)
124
+ generatePlaceholderAgentProfileImageUrl(
125
+ agentProfile.permanentId || agentName,
126
+ NEXT_PUBLIC_SITE_URL, // <- TODO: !!!! Use here `const { publicUrl } = await $provideServer();`
127
+ )
125
128
  }
126
129
  alt={agentProfile.meta.fullname || agentName}
127
130
  className="w-16 h-16 rounded-full object-cover border-2 border-gray-200"
@@ -0,0 +1,31 @@
1
+ import { AgentBasicInformation } from '@promptbook-local/types';
2
+ import spaceTrim from 'spacetrim';
3
+ import { string_prompt_image } from '../../../../../../../../src/types/typeAliases';
4
+
5
+ export function getAgentDefaultAvatarPrompt(agent: AgentBasicInformation): string_prompt_image {
6
+ const {
7
+ agentName,
8
+ personaDescription,
9
+ meta: { fullname, color },
10
+ } = agent;
11
+
12
+ return spaceTrim(
13
+ (block) => `
14
+ Professional corporate headshot of ${fullname || agentName}
15
+
16
+ ${block(personaDescription || '')}
17
+
18
+ - Professional business portrait photograph
19
+ - Photorealistic, studio quality lighting
20
+ - Shot with 85mm lens, shallow depth of field
21
+ - Neutral gray or soft gradient background
22
+ - Subject wearing professional attire with accent colors: ${color}
23
+ - Confident, approachable expression with slight smile
24
+ - Eye-level camera angle, centered composition
25
+ - Soft diffused lighting, subtle rim light
26
+ - Sharp focus on eyes, cinematic color grading
27
+ - 8K resolution, ultra detailed
28
+
29
+ `,
30
+ );
31
+ }
@@ -4,12 +4,13 @@ import { $provideAgentCollectionForServer } from '@/src/tools/$provideAgentColle
4
4
  import { $provideCdnForServer } from '@/src/tools/$provideCdnForServer';
5
5
  import { $provideExecutionToolsForServer } from '@/src/tools/$provideExecutionToolsForServer';
6
6
  import { parseAgentSource } from '@promptbook-local/core';
7
- import { serializeError } from '@promptbook-local/utils';
7
+ import { computeHash, serializeError } from '@promptbook-local/utils';
8
8
  import { NextRequest, NextResponse } from 'next/server';
9
9
  import { assertsError } from '../../../../../../../../src/errors/assertsError';
10
- import { getSingleLlmExecutionTools } from '../../../../../../../../src/llm-providers/_multiple/getSingleLlmExecutionTools';
11
10
  import type { LlmExecutionTools } from '../../../../../../../../src/execution/LlmExecutionTools';
11
+ import { getSingleLlmExecutionTools } from '../../../../../../../../src/llm-providers/_multiple/getSingleLlmExecutionTools';
12
12
  import type { string_url } from '../../../../../../../../src/types/typeAliases';
13
+ import { getAgentDefaultAvatarPrompt } from './getAgentDefaultAvatarPrompt';
13
14
 
14
15
  export async function GET(request: NextRequest, { params }: { params: Promise<{ agentName: string }> }) {
15
16
  try {
@@ -20,13 +21,28 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
20
21
  return NextResponse.json({ error: 'Agent name is required' }, { status: 400 });
21
22
  }
22
23
 
23
- // Define a unique filename/key for this agent's default avatar
24
- // This is used for DB lookup and CDN storage, distinct from generic images
25
- const internalFilename = `agent-${agentName}-default-avatar.png`;
24
+ // 1. Fetch agent data first to construct the prompt
25
+ const collection = await $provideAgentCollectionForServer();
26
+ let agentSource;
27
+ try {
28
+ agentSource = await collection.getAgentSource(agentName);
29
+ } catch (error) {
30
+ // If agent not found, redirect to pravatar with the agent name as unique identifier
31
+ const pravaratUrl = `https://i.pravatar.cc/1024?u=${encodeURIComponent(agentName)}`;
32
+ return NextResponse.redirect(pravaratUrl);
33
+ }
34
+
35
+ const agentProfile = parseAgentSource(agentSource);
36
+
37
+ const prompt = getAgentDefaultAvatarPrompt(agentProfile);
38
+
39
+ // Use hash of the prompt as cache key - this ensures regeneration when prompt changes
40
+ const promptHash = computeHash(prompt);
41
+ const internalFilename = `agent-avatar-${promptHash}.png`;
26
42
 
27
43
  const supabase = $provideSupabaseForServer();
28
44
 
29
- // Check if image already exists in database
45
+ // Check if image with this prompt hash already exists in database
30
46
  const { data: existingImage, error: selectError } = await supabase
31
47
  .from(await $getTableName(`Image`))
32
48
  .select('cdnUrl')
@@ -39,35 +55,24 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
39
55
  }
40
56
 
41
57
  if (existingImage) {
42
- // Image exists, redirect to CDN
43
- return NextResponse.redirect(existingImage.cdnUrl as string_url);
58
+ // Image exists, fetch from CDN and return directly
59
+ const imageResponse = await fetch(existingImage.cdnUrl as string_url);
60
+ if (!imageResponse.ok) {
61
+ console.warn(`Failed to fetch image from CDN: ${imageResponse.status}`);
62
+ return NextResponse.redirect(existingImage.cdnUrl);
63
+ }
64
+ const imageBuffer = await imageResponse.arrayBuffer();
65
+ return new NextResponse(imageBuffer, {
66
+ status: 200,
67
+ headers: {
68
+ 'Content-Type': 'image/png',
69
+ 'Cache-Control': 'public, max-age=31536000, immutable',
70
+ },
71
+ });
44
72
  }
45
73
 
46
74
  // Image doesn't exist, generate it
47
75
 
48
- // 1. Fetch agent data
49
- const collection = await $provideAgentCollectionForServer();
50
- let agentSource;
51
- try {
52
- agentSource = await collection.getAgentSource(agentName);
53
- } catch (error) {
54
- // If agent not found, return 404 or default generic image?
55
- // User said: "Use the ... instead of Gravatar for agents that do not have custom uploaded avatar"
56
- // If agent doesn't exist, we probably can't generate a specific avatar.
57
- return NextResponse.json({ error: 'Agent not found' }, { status: 404 });
58
- }
59
-
60
- const agentProfile = parseAgentSource(agentSource);
61
-
62
- // Extract required fields
63
- const name = agentProfile.meta?.title || agentProfile.agentName || agentName;
64
- const persona = agentProfile.personaDescription || 'an AI agent';
65
- const color = agentProfile.meta?.color || 'blue';
66
-
67
- // Construct prompt
68
- // "Image of {agent.name}, {agent.persona}, portrait, use color ${agent.meta.color}, detailed, high quality"
69
- const prompt = `Image of ${name}, ${persona}, portrait, use color ${color}, detailed, high quality`;
70
-
71
76
  // 2. Generate image
72
77
  const executionTools = await $provideExecutionToolsForServer();
73
78
  const llmTools = getSingleLlmExecutionTools(executionTools.llm) as LlmExecutionTools;
@@ -79,12 +84,14 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
79
84
  const imageResult = await llmTools.callImageGenerationModel({
80
85
  title: `Generate default avatar for ${agentName}`,
81
86
  content: prompt,
82
- parameters: {
83
- size: '1024x1792', // Vertical orientation
84
- },
87
+ parameters: {},
85
88
  modelRequirements: {
86
89
  modelVariant: 'IMAGE_GENERATION',
87
- modelName: 'dall-e-3',
90
+ modelName: 'dall-e-3',
91
+ size: '1024x1792', // <- Vertical orientation
92
+ // <- TODO: [🤐] DRY
93
+ quality: 'hd',
94
+ style: 'natural',
88
95
  },
89
96
  });
90
97
 
@@ -125,9 +132,20 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
125
132
  throw insertError;
126
133
  }
127
134
 
128
- // Redirect to the newly created image
129
- return NextResponse.redirect(cdnUrl.href as string_url);
130
-
135
+ // Return the newly created image directly
136
+ const finalImageResponse = await fetch(cdnUrl.href);
137
+ if (!finalImageResponse.ok) {
138
+ console.warn(`Failed to fetch newly created image from CDN: ${finalImageResponse.status}`);
139
+ return NextResponse.redirect(cdnUrl.href);
140
+ }
141
+ const finalImageBuffer = await finalImageResponse.arrayBuffer();
142
+ return new NextResponse(finalImageBuffer, {
143
+ status: 200,
144
+ headers: {
145
+ 'Content-Type': 'image/png',
146
+ 'Cache-Control': 'public, max-age=31536000, immutable',
147
+ },
148
+ });
131
149
  } catch (error) {
132
150
  assertsError(error);
133
151
  console.error('Error serving default avatar:', error);
@@ -1,3 +1,4 @@
1
+ import { $provideServer } from '@/src/tools/$provideServer';
1
2
  import { generatePlaceholderAgentProfileImageUrl, PROMPTBOOK_COLOR } from '@promptbook-local/core';
2
3
  import { serializeError } from '@promptbook-local/utils';
3
4
  import { ImageResponse } from 'next/og';
@@ -18,6 +19,7 @@ export async function GET(request: Request, { params }: { params: Promise<{ agen
18
19
  const agentName = await getAgentName(params);
19
20
  const agentProfile = await getAgentProfile(agentName);
20
21
  const agentColor = Color.from(agentProfile.meta.color || PROMPTBOOK_COLOR);
22
+ const { publicUrl } = await $provideServer();
21
23
 
22
24
  return new ImageResponse(
23
25
  (
@@ -30,6 +32,7 @@ export async function GET(request: Request, { params }: { params: Promise<{ agen
30
32
  alignItems: 'center',
31
33
  justifyContent: 'center',
32
34
  borderRadius: '50%',
35
+ aspectRatio: '1 / 1',
33
36
  overflow: 'hidden',
34
37
  }}
35
38
  >
@@ -46,7 +49,13 @@ export async function GET(request: Request, { params }: { params: Promise<{ agen
46
49
  {/* Note: `next/image` is not working propperly with `next/og` */}
47
50
  {/* eslint-disable-next-line @next/next/no-img-element */}
48
51
  <img
49
- src={agentProfile.meta.image || agentProfile.permanentId ||generatePlaceholderAgentProfileImageUrl(agentName)}
52
+ src={
53
+ agentProfile.meta.image ||
54
+ generatePlaceholderAgentProfileImageUrl(
55
+ agentProfile.permanentId || agentName,
56
+ publicUrl,
57
+ )
58
+ }
50
59
  alt="Agent Icon"
51
60
  />
52
61
  </div>
@@ -0,0 +1,200 @@
1
+ 'use server';
2
+
3
+ import { saturate } from '@promptbook-local/color';
4
+ import { PROMPTBOOK_COLOR } from '@promptbook-local/core';
5
+ import Link from 'next/link';
6
+ import { Color } from '../../../../../../../src/utils/color/Color';
7
+ import { getAgentName, getAgentProfile } from '../_utils';
8
+
9
+ /**
10
+ * Available image types for agents with their descriptions and sizes
11
+ */
12
+ const AGENT_IMAGES = [
13
+ {
14
+ name: 'default-avatar.png',
15
+ title: 'Default Avatar',
16
+ description: 'AI-generated avatar image based on the agent profile. Vertical orientation (1024x1792).',
17
+ size: '1024×1792',
18
+ },
19
+ {
20
+ name: 'icon-256.png',
21
+ title: 'Icon (256×256)',
22
+ description: 'Small circular icon suitable for profile pictures and thumbnails.',
23
+ size: '256×256',
24
+ },
25
+ {
26
+ name: 'screenshot-fullhd.png',
27
+ title: 'Screenshot Full HD',
28
+ description: 'Landscape screenshot showing the agent with name. Suitable for desktop previews.',
29
+ size: '1920×1080',
30
+ },
31
+ {
32
+ name: 'screenshot-phone.png',
33
+ title: 'Screenshot Phone',
34
+ description: 'Portrait screenshot optimized for mobile devices.',
35
+ size: '1080×1920',
36
+ },
37
+ ] as const;
38
+
39
+ export default async function AgentImagesPage({ params }: { params: Promise<{ agentName: string }> }) {
40
+ const agentName = await getAgentName(params);
41
+ const agentProfile = await getAgentProfile(agentName);
42
+
43
+ const brandColor = Color.fromSafe(agentProfile.meta.color || PROMPTBOOK_COLOR);
44
+ const brandColorHex = brandColor.then(saturate(-0.5)).toHex();
45
+
46
+ const fullname = (agentProfile.meta.fullname || agentProfile.agentName || 'Agent') as string;
47
+
48
+ return (
49
+ <div
50
+ style={{
51
+ minHeight: '100vh',
52
+ backgroundColor: '#f5f5f5',
53
+ padding: '2rem',
54
+ }}
55
+ >
56
+ <div
57
+ style={{
58
+ maxWidth: '1200px',
59
+ margin: '0 auto',
60
+ }}
61
+ >
62
+ <header
63
+ style={{
64
+ marginBottom: '2rem',
65
+ padding: '1.5rem',
66
+ backgroundColor: brandColorHex,
67
+ borderRadius: '12px',
68
+ color: 'white',
69
+ }}
70
+ >
71
+ <h1 style={{ margin: 0, fontSize: '2rem' }}>
72
+ Images for <strong>{fullname}</strong>
73
+ </h1>
74
+ <p style={{ margin: '0.5rem 0 0', opacity: 0.9 }}>
75
+ All available image assets for agent{' '}
76
+ <code
77
+ style={{
78
+ backgroundColor: 'rgba(255,255,255,0.2)',
79
+ padding: '2px 6px',
80
+ borderRadius: '4px',
81
+ }}
82
+ >
83
+ {agentName}
84
+ </code>
85
+ </p>
86
+ </header>
87
+
88
+ <div
89
+ style={{
90
+ display: 'grid',
91
+ gridTemplateColumns: 'repeat(auto-fill, minmax(300px, 1fr))',
92
+ gap: '1.5rem',
93
+ }}
94
+ >
95
+ {AGENT_IMAGES.map((image) => {
96
+ const imageUrl = `/agents/${encodeURIComponent(agentName)}/images/${image.name}`;
97
+ return (
98
+ <div
99
+ key={image.name}
100
+ style={{
101
+ backgroundColor: 'white',
102
+ borderRadius: '12px',
103
+ overflow: 'hidden',
104
+ boxShadow: '0 2px 8px rgba(0,0,0,0.1)',
105
+ }}
106
+ >
107
+ <div
108
+ style={{
109
+ aspectRatio: '16/9',
110
+ backgroundColor: '#e0e0e0',
111
+ display: 'flex',
112
+ alignItems: 'center',
113
+ justifyContent: 'center',
114
+ overflow: 'hidden',
115
+ }}
116
+ >
117
+ {/* eslint-disable-next-line @next/next/no-img-element */}
118
+ <img
119
+ src={imageUrl}
120
+ alt={image.title}
121
+ style={{
122
+ maxWidth: '100%',
123
+ maxHeight: '100%',
124
+ objectFit: 'contain',
125
+ }}
126
+ />
127
+ </div>
128
+ <div style={{ padding: '1rem' }}>
129
+ <h2 style={{ margin: '0 0 0.5rem', fontSize: '1.25rem' }}>{image.title}</h2>
130
+ <p style={{ margin: '0 0 0.5rem', color: '#666', fontSize: '0.9rem' }}>
131
+ {image.description}
132
+ </p>
133
+ <div
134
+ style={{
135
+ display: 'flex',
136
+ justifyContent: 'space-between',
137
+ alignItems: 'center',
138
+ marginTop: '1rem',
139
+ }}
140
+ >
141
+ <span
142
+ style={{
143
+ backgroundColor: '#f0f0f0',
144
+ padding: '4px 8px',
145
+ borderRadius: '4px',
146
+ fontSize: '0.85rem',
147
+ color: '#555',
148
+ }}
149
+ >
150
+ {image.size}
151
+ </span>
152
+ <Link
153
+ href={imageUrl}
154
+ target="_blank"
155
+ style={{
156
+ backgroundColor: brandColorHex,
157
+ color: 'white',
158
+ padding: '8px 16px',
159
+ borderRadius: '6px',
160
+ textDecoration: 'none',
161
+ fontSize: '0.9rem',
162
+ }}
163
+ >
164
+ Open Image
165
+ </Link>
166
+ </div>
167
+ </div>
168
+ </div>
169
+ );
170
+ })}
171
+ </div>
172
+
173
+ <footer
174
+ style={{
175
+ marginTop: '2rem',
176
+ padding: '1rem',
177
+ backgroundColor: 'white',
178
+ borderRadius: '12px',
179
+ textAlign: 'center',
180
+ color: '#666',
181
+ }}
182
+ >
183
+ <p style={{ margin: 0 }}>
184
+ <Link
185
+ href={`/agents/${encodeURIComponent(agentName)}`}
186
+ style={{ color: brandColorHex, textDecoration: 'none' }}
187
+ >
188
+ ← Back to {fullname}
189
+ </Link>
190
+ </p>
191
+ </footer>
192
+ </div>
193
+ </div>
194
+ );
195
+ }
196
+
197
+ /**
198
+ * TODO: [🦚] Add download button functionality
199
+ * TODO: [🦚] Add image regeneration option for default-avatar
200
+ */
@@ -1,4 +1,5 @@
1
- import { generatePlaceholderAgentProfileImageUrl, PROMPTBOOK_COLOR } from '@promptbook-local/core';
1
+ import { $provideServer } from '@/src/tools/$provideServer';
2
+ import { PROMPTBOOK_COLOR } from '@promptbook-local/core';
2
3
  import { serializeError } from '@promptbook-local/utils';
3
4
  import { ImageResponse } from 'next/og';
4
5
  import { assertsError } from '../../../../../../../../src/errors/assertsError';
@@ -21,6 +22,7 @@ export async function GET(request: Request, { params }: { params: Promise<{ agen
21
22
  const agentProfile = await getAgentProfile(agentName);
22
23
  const agentColor = Color.from(agentProfile.meta.color || PROMPTBOOK_COLOR);
23
24
  const backgroundColor = agentColor.then(grayscale(0.5));
25
+ const { publicUrl } = await $provideServer();
24
26
 
25
27
  return new ImageResponse(
26
28
  (
@@ -48,10 +50,9 @@ export async function GET(request: Request, { params }: { params: Promise<{ agen
48
50
  <img
49
51
  style={{
50
52
  width: '80%',
51
- backgroundColor: agentColor.toHex(),
52
- borderRadius: '50%',
53
+ // backgroundColor: agentColor.toHex(),
53
54
  }}
54
- src={agentProfile.meta.image || agentProfile.permanentId ||generatePlaceholderAgentProfileImageUrl(agentName)}
55
+ src={`${publicUrl.href}agents/${agentProfile.permanentId || agentName}/images/icon-256.png`}
55
56
  alt="Agent Icon"
56
57
  />
57
58
  </div>