@promptbook/cli 0.103.0-55 → 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.
Files changed (61) hide show
  1. package/apps/agents-server/package-lock.json +1163 -0
  2. package/apps/agents-server/package.json +6 -0
  3. package/apps/agents-server/src/app/agents/[agentName]/AgentChatWrapper.tsx +3 -1
  4. package/apps/agents-server/src/app/agents/[agentName]/AgentOptionsMenu.tsx +216 -0
  5. package/apps/agents-server/src/app/agents/[agentName]/AgentProfileChat.tsx +78 -0
  6. package/apps/agents-server/src/app/agents/[agentName]/AgentProfileView.tsx +233 -0
  7. package/apps/agents-server/src/app/agents/[agentName]/CloneAgentButton.tsx +4 -4
  8. package/apps/agents-server/src/app/agents/[agentName]/InstallPwaButton.tsx +2 -2
  9. package/apps/agents-server/src/app/agents/[agentName]/QrCodeModal.tsx +90 -0
  10. package/apps/agents-server/src/app/agents/[agentName]/agentLinks.tsx +80 -0
  11. package/apps/agents-server/src/app/agents/[agentName]/api/book/route.ts +3 -1
  12. package/apps/agents-server/src/app/agents/[agentName]/api/chat/route.ts +11 -1
  13. package/apps/agents-server/src/app/agents/[agentName]/api/openai/models/route.ts +93 -0
  14. package/apps/agents-server/src/app/agents/[agentName]/api/openai/v1/chat/completions/route.ts +10 -0
  15. package/apps/agents-server/src/app/agents/[agentName]/api/openai/v1/models/route.ts +93 -0
  16. package/apps/agents-server/src/app/agents/[agentName]/api/voice/route.ts +4 -0
  17. package/apps/agents-server/src/app/agents/[agentName]/chat/page.tsx +9 -2
  18. package/apps/agents-server/src/app/agents/[agentName]/integration/SdkCodeTabs.tsx +31 -0
  19. package/apps/agents-server/src/app/agents/[agentName]/integration/page.tsx +271 -30
  20. package/apps/agents-server/src/app/agents/[agentName]/links/page.tsx +61 -97
  21. package/apps/agents-server/src/app/agents/[agentName]/page.tsx +108 -165
  22. package/apps/agents-server/src/app/agents/[agentName]/website-integration/page.tsx +61 -0
  23. package/apps/agents-server/src/app/api/openai/v1/chat/completions/route.ts +6 -0
  24. package/apps/agents-server/src/app/api/openai/v1/models/route.ts +65 -0
  25. package/apps/agents-server/src/app/docs/[docId]/page.tsx +12 -32
  26. package/apps/agents-server/src/app/docs/page.tsx +42 -17
  27. package/apps/agents-server/src/app/globals.css +129 -0
  28. package/apps/agents-server/src/app/layout.tsx +8 -2
  29. package/apps/agents-server/src/app/manifest.ts +1 -1
  30. package/apps/agents-server/src/components/DocumentationContent/DocumentationContent.tsx +87 -0
  31. package/apps/agents-server/src/components/OpenMojiIcon/OpenMojiIcon.tsx +20 -0
  32. package/apps/agents-server/src/components/PrintButton/PrintButton.tsx +18 -0
  33. package/apps/agents-server/src/components/PrintHeader/PrintHeader.tsx +18 -0
  34. package/apps/agents-server/src/database/migrations/2025-12-0070-chat-history-source.sql +2 -0
  35. package/apps/agents-server/src/database/schema.ts +6 -0
  36. package/apps/agents-server/src/utils/handleChatCompletion.ts +186 -14
  37. package/apps/agents-server/src/utils/resolveInheritedAgentSource.ts +13 -6
  38. package/apps/agents-server/src/utils/validateApiKey.ts +128 -0
  39. package/apps/agents-server/tailwind.config.ts +1 -1
  40. package/esm/index.es.js +865 -441
  41. package/esm/index.es.js.map +1 -1
  42. package/esm/typings/src/_packages/core.index.d.ts +6 -8
  43. package/esm/typings/src/_packages/types.index.d.ts +1 -1
  44. package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +5 -0
  45. package/esm/typings/src/commitments/META_COLOR/META_COLOR.d.ts +6 -0
  46. package/esm/typings/src/commitments/META_FONT/META_FONT.d.ts +42 -0
  47. package/esm/typings/src/commitments/USE/USE.d.ts +53 -0
  48. package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.d.ts +38 -0
  49. package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.test.d.ts +1 -0
  50. package/esm/typings/src/commitments/{IMPORTANT/IMPORTANT.d.ts → USE_MCP/USE_MCP.d.ts} +16 -5
  51. package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +38 -0
  52. package/esm/typings/src/commitments/index.d.ts +93 -1
  53. package/esm/typings/src/playground/playground.d.ts +3 -0
  54. package/esm/typings/src/utils/color/Color.d.ts +8 -0
  55. package/esm/typings/src/utils/color/css-colors.d.ts +1 -0
  56. package/esm/typings/src/version.d.ts +1 -1
  57. package/package.json +1 -1
  58. package/umd/index.umd.js +861 -437
  59. package/umd/index.umd.js.map +1 -1
  60. package/esm/typings/src/commitments/registry.d.ts +0 -68
  61. package/esm/typings/src/playground/playground1.d.ts +0 -2
@@ -1,61 +1,302 @@
1
1
  'use server';
2
2
 
3
- import { $provideAgentCollectionForServer } from '@/src/tools/$provideAgentCollectionForServer';
3
+ import { $getTableName } from '@/src/database/$getTableName';
4
+ import { $provideSupabase } from '@/src/database/$provideSupabase';
4
5
  import { $provideServer } from '@/src/tools/$provideServer';
5
- import { PromptbookAgent } from '@promptbook-local/components';
6
- import { parseAgentSource } from '@promptbook-local/core';
6
+ import { isUserAdmin } from '@/src/utils/isUserAdmin';
7
+ import { PROMPTBOOK_COLOR } from '@promptbook-local/core';
8
+ import { ArrowLeftIcon, BoxIcon, CodeIcon, GlobeIcon, ServerIcon, TerminalIcon } from 'lucide-react';
7
9
  import { headers } from 'next/headers';
10
+ import Link from 'next/link';
11
+ import { notFound } from 'next/navigation';
8
12
  import spaceTrim from 'spacetrim';
13
+ import { Color } from '../../../../../../../src/utils/color/Color';
14
+ import { withAlpha } from '../../../../../../../src/utils/color/operators/withAlpha';
9
15
  import { $sideEffect } from '../../../../../../../src/utils/organization/$sideEffect';
10
16
  import { CodePreview } from '../../../../../../_common/components/CodePreview/CodePreview';
17
+ import { getAgentLinks } from '../agentLinks';
18
+ import { CopyField } from '../CopyField';
19
+ import { getAgentName, getAgentProfile } from '../_utils';
11
20
  import { generateAgentMetadata } from '../generateAgentMetadata';
21
+ import { SdkCodeTabs } from './SdkCodeTabs';
12
22
 
13
23
  export const generateMetadata = generateAgentMetadata;
14
24
 
15
- export default async function AgentChatPage({ params }: { params: Promise<{ agentName: string }> }) {
25
+ export default async function AgentIntegrationPage({ params }: { params: Promise<{ agentName: string }> }) {
16
26
  $sideEffect(headers());
17
- let { agentName } = await params;
18
- agentName = decodeURIComponent(agentName);
27
+ const agentName = await getAgentName(params);
28
+ const isAdmin = await isUserAdmin();
29
+
30
+ let agentProfile;
31
+ try {
32
+ agentProfile = await getAgentProfile(agentName);
33
+ } catch (error) {
34
+ if (
35
+ error instanceof Error &&
36
+ (error.message.includes('Cannot coerce the result to a single JSON object') ||
37
+ error.message.includes('JSON object requested, multiple (or no) results returned'))
38
+ ) {
39
+ notFound();
40
+ }
41
+ throw error;
42
+ }
19
43
 
20
- const collection = await $provideAgentCollectionForServer();
21
- const agentSource = await collection.getAgentSource(agentName);
22
- const { meta } = parseAgentSource(agentSource);
23
- const { fullname, color, image, ...restMeta } = meta;
24
44
  const { publicUrl } = await $provideServer();
25
- const agentUrl = `${publicUrl.href}agents/${encodeURIComponent(agentName)}`;
45
+ const baseUrl = `${publicUrl.href}agents/${encodeURIComponent(agentName)}`;
46
+ const agentApiBase = `${publicUrl.href}agents/${encodeURIComponent(agentName)}`;
47
+ const rootUrl = publicUrl.href.replace(/\/$/, '');
26
48
 
27
- const code = spaceTrim(
28
- (block) => `
49
+ // Get API Key if admin
50
+ let apiKey = 'ptbk_...';
51
+ if (isAdmin) {
52
+ const supabase = $provideSupabase();
53
+ const table = await $getTableName('ApiTokens');
54
+ const { data } = await supabase
55
+ .from(table)
56
+ .select('token')
57
+ .eq('isRevoked', false)
58
+ .order('createdAt', { ascending: false })
59
+ .limit(1);
60
+
61
+ if (data && data.length > 0) {
62
+ apiKey = data[0].token;
63
+ }
64
+ }
29
65
 
66
+ // Extract brand color from meta
67
+ const brandColor = Color.from(agentProfile.meta.color || PROMPTBOOK_COLOR);
68
+ const backgroundColor = (await brandColor.then(withAlpha(0.05))).toHex();
69
+ const borderColor = (await brandColor.then(withAlpha(0.1))).toHex();
70
+ const primaryColor = (await brandColor).toHex();
71
+
72
+ // Website Integration Code
73
+ const { fullname, color, image, ...restMeta } = agentProfile.meta;
74
+ const websiteIntegrationCode = spaceTrim(
75
+ (block) => `
30
76
  import { PromptbookAgent } from '@promptbook/components';
31
77
 
32
78
  export function YourComponent() {
33
79
  return(
34
80
  <PromptbookAgent
35
- agentUrl="${agentUrl}"
81
+ agentUrl="${baseUrl}"
36
82
  meta={${block(JSON.stringify({ fullname, color, image, ...restMeta }, null, 4))}}
37
83
  />
38
84
  );
39
85
  }
40
-
41
86
  `,
42
87
  );
43
88
 
89
+ // OpenAI Compatible Curl
90
+ const curlCode = spaceTrim(`
91
+ curl ${agentApiBase}/api/openai/v1/chat/completions \\
92
+ -H "Content-Type: application/json" \\
93
+ -H "Authorization: Bearer ${apiKey}" \\
94
+ -d '{
95
+ "model": "agent:${agentName}",
96
+ "messages": [
97
+ {"role": "user", "content": "Hello!"}
98
+ ]
99
+ }'
100
+ `);
101
+
102
+ // OpenAI Compatible Python
103
+ const pythonCode = spaceTrim(`
104
+ from openai import OpenAI
105
+
106
+ client = OpenAI(
107
+ base_url="${agentApiBase}/api/openai/v1",
108
+ api_key="${apiKey}",
109
+ )
110
+
111
+ response = client.chat.completions.create(
112
+ model="agent:${agentName}",
113
+ messages=[
114
+ {"role": "user", "content": "Hello!"}
115
+ ]
116
+ )
117
+
118
+ print(response.choices[0].message.content)
119
+ `);
120
+
121
+ // OpenAI Compatible JS
122
+ const jsCode = spaceTrim(`
123
+ import OpenAI from 'openai';
124
+
125
+ const client = new OpenAI({
126
+ baseURL: '${agentApiBase}/api/openai/v1',
127
+ apiKey: '${apiKey}',
128
+ });
129
+
130
+ async function main() {
131
+ const response = await client.chat.completions.create({
132
+ model: 'agent:${agentName}',
133
+ messages: [{ role: 'user', content: 'Hello!' }],
134
+ });
135
+
136
+ console.log(response.choices[0].message.content);
137
+ }
138
+
139
+ main();
140
+ `);
141
+
142
+ // MCP Config
143
+ const mcpConfigCode = spaceTrim(`
144
+ {
145
+ "mcpServers": {
146
+ "${agentName}": {
147
+ "command": "npx",
148
+ "args": [
149
+ "-y",
150
+ "@promptbook/cli",
151
+ "mcp",
152
+ "${baseUrl}"
153
+ ]
154
+ }
155
+ }
156
+ }
157
+ `);
158
+
159
+ const agentLinks = getAgentLinks(agentName);
160
+ const chatLink = agentLinks.find((l) => l.title === 'Chat with Agent')!;
161
+ const websiteIntegrationLink = agentLinks.find((l) => l.title === 'Website Integration')!;
162
+
44
163
  return (
45
- <main className="w-screen h-screen p-4">
46
- <h1 className="text-2xl font-bold p-4 border-b">{meta.fullname || agentName} Integration Code</h1>
47
- <p className="mt-4 mb-8 text-gray-600">
48
- Use the following code to integrate the <strong>{meta.fullname || agentName}</strong> agent into your
49
- React application using the <code>{'<PromptbookAgent />'}</code> component.
50
- </p>
51
-
52
- <CodePreview code={code} />
53
- <PromptbookAgent agentUrl={agentUrl} meta={meta} />
54
- </main>
164
+ <div
165
+ className="min-h-screen p-6 md:p-12 flex flex-col items-center"
166
+ style={{
167
+ backgroundColor,
168
+ }}
169
+ >
170
+ <div className="w-full max-w-5xl bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden">
171
+ {/* Header */}
172
+ <div className="p-6 border-b flex items-center gap-4" style={{ borderColor }}>
173
+ {agentProfile.meta.image && (
174
+ // eslint-disable-next-line @next/next/no-img-element
175
+ <img
176
+ src={agentProfile.meta.image as string}
177
+ alt={agentProfile.meta.fullname || agentName}
178
+ className="w-16 h-16 rounded-full object-cover border-2"
179
+ style={{ borderColor: primaryColor }}
180
+ />
181
+ )}
182
+ <div className="flex-1">
183
+ <h1 className="text-2xl font-bold text-gray-900">{agentProfile.meta.fullname || agentName}</h1>
184
+ <p className="text-gray-500 flex items-center gap-2">
185
+ <CodeIcon className="w-4 h-4" />
186
+ Integration Options
187
+ </p>
188
+ </div>
189
+ <Link
190
+ href={chatLink.href}
191
+ className="p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-full transition-colors"
192
+ title="Back to Agent"
193
+ >
194
+ <ArrowLeftIcon className="w-6 h-6" />
195
+ </Link>
196
+ </div>
197
+
198
+ <div className="p-6 space-y-6">
199
+ {/* Website Integration */}
200
+ <div className="p-6 rounded-xl border-2 border-green-200 bg-green-50/30 shadow-sm">
201
+ <div className="flex items-start gap-4 mb-4">
202
+ <div className="p-3 rounded-xl bg-green-100 text-green-600 shadow-sm">
203
+ <GlobeIcon className="w-6 h-6" />
204
+ </div>
205
+ <div>
206
+ <h2 className="text-xl font-bold text-gray-900">Website Integration</h2>
207
+ <p className="text-gray-600">
208
+ Embed the agent chat widget directly into your React application.
209
+ </p>
210
+ <p className="text-sm text-gray-500 mt-1">
211
+ <Link href={websiteIntegrationLink.href} className="text-blue-600 hover:underline">
212
+ View detailed guide &rarr;
213
+ </Link>
214
+ </p>
215
+ </div>
216
+ </div>
217
+ <CodePreview code={websiteIntegrationCode} language="typescript" />
218
+ </div>
219
+
220
+ {/* OpenAI API Compatible Endpoint */}
221
+ <div className="p-6 rounded-xl border-2 border-blue-200 bg-blue-50/30 shadow-sm">
222
+ <div className="flex items-start gap-4 mb-4">
223
+ <div className="p-3 rounded-xl bg-blue-100 text-blue-600 shadow-sm">
224
+ <TerminalIcon className="w-6 h-6" />
225
+ </div>
226
+ <div className="flex-1">
227
+ <h2 className="text-xl font-bold text-gray-900">OpenAI Compatible API</h2>
228
+ <p className="text-gray-600">
229
+ Use the agent as a drop-in replacement for OpenAI API in your existing applications.
230
+ </p>
231
+ <div className="grid md:grid-cols-3 gap-4 mt-4 mb-2">
232
+ <CopyField label="Endpoint URL" value={`${agentApiBase}/api/openai/v1`} />
233
+ <CopyField label="Model Name" value={`agent:${agentName}`} />
234
+ {isAdmin ? (
235
+ <CopyField label="API Key" value={apiKey} />
236
+ ) : (
237
+ <div className="flex flex-col gap-1">
238
+ <span className="text-xs font-medium text-gray-500 uppercase tracking-wider">
239
+ API Key
240
+ </span>
241
+ <div className="text-sm text-gray-500 italic bg-gray-50 p-2 rounded border border-gray-200">
242
+ Contact admin for API Key
243
+ </div>
244
+ </div>
245
+ )}
246
+ </div>
247
+ {isAdmin && apiKey === 'ptbk_...' && (
248
+ <p className="text-sm text-amber-600 mt-2">
249
+ No API token found.{' '}
250
+ <Link href="/admin/api-tokens" className="underline font-medium">
251
+ Create one in settings
252
+ </Link>
253
+ .
254
+ </p>
255
+ )}
256
+ </div>
257
+ </div>
258
+
259
+ <SdkCodeTabs curlCode={curlCode} pythonCode={pythonCode} jsCode={jsCode} />
260
+ </div>
261
+
262
+ {/* OpenRouter Integration */}
263
+ <div className="p-6 rounded-xl border-2 border-purple-200 bg-purple-50/30 shadow-sm">
264
+ <div className="flex items-start gap-4 mb-4">
265
+ <div className="p-3 rounded-xl bg-purple-100 text-purple-600 shadow-sm">
266
+ <ServerIcon className="w-6 h-6" />
267
+ </div>
268
+ <div>
269
+ <h2 className="text-xl font-bold text-gray-900">OpenRouter Integration</h2>
270
+ <p className="text-gray-600">Connect via OpenRouter compatible endpoint.</p>
271
+ <div className="grid md:grid-cols-2 gap-4 mt-4">
272
+ <CopyField label="Endpoint URL" value={`${agentApiBase}/api/openrouter`} />
273
+ <CopyField label="Model Name" value={`agent:${agentName}`} />
274
+ </div>
275
+ </div>
276
+ </div>
277
+ </div>
278
+
279
+ {/* MCP Integration */}
280
+ <div className="p-6 rounded-xl border-2 border-orange-200 bg-orange-50/30 shadow-sm">
281
+ <div className="flex items-start gap-4 mb-4">
282
+ <div className="p-3 rounded-xl bg-orange-100 text-orange-600 shadow-sm">
283
+ <BoxIcon className="w-6 h-6" />
284
+ </div>
285
+ <div>
286
+ <h2 className="text-xl font-bold text-gray-900">MCP Integration</h2>
287
+ <p className="text-gray-600">
288
+ Use Model Context Protocol to connect this agent with compatible tools and IDEs
289
+ (like Claude Desktop, Cursor, etc.).
290
+ </p>
291
+ </div>
292
+ </div>
293
+ <CodePreview
294
+ code={mcpConfigCode.replace(rootUrl + '/api', agentApiBase + '/api')}
295
+ language="json"
296
+ />
297
+ </div>
298
+ </div>
299
+ </div>
300
+ </div>
55
301
  );
56
302
  }
57
-
58
- /**
59
- * TODO: Make this page better, bring from Promptbook.Studio
60
- * TODO: [🚗] Components and pages here should be just tiny UI wraper around proper agent logic and conponents
61
- */
@@ -1,25 +1,22 @@
1
1
  'use server';
2
2
 
3
3
  import { $provideServer } from '@/src/tools/$provideServer';
4
- import { Color } from '../../../../../../../src/utils/color/Color';
5
- import { withAlpha } from '../../../../../../../src/utils/color/operators/withAlpha';
6
4
  import { PROMPTBOOK_COLOR } from '@promptbook-local/core';
7
- import { ArrowLeftIcon, BookOpenIcon, CodeIcon, HistoryIcon, HomeIcon, LinkIcon, MessageSquareIcon, ShareIcon } from 'lucide-react';
5
+ import { ArrowLeftIcon, CodeIcon, HomeIcon, LinkIcon, ShareIcon } from 'lucide-react';
8
6
  import { headers } from 'next/headers';
9
7
  import Link from 'next/link';
10
8
  import { notFound } from 'next/navigation';
9
+ import { Color } from '../../../../../../../src/utils/color/Color';
10
+ import { withAlpha } from '../../../../../../../src/utils/color/operators/withAlpha';
11
11
  import { $sideEffect } from '../../../../../../../src/utils/organization/$sideEffect';
12
+ import { getAgentExternalLinks, getAgentLinks } from '../agentLinks';
12
13
  import { CopyField } from '../CopyField';
13
14
  import { getAgentName, getAgentProfile } from '../_utils';
14
15
  import { generateAgentMetadata } from '../generateAgentMetadata';
15
16
 
16
17
  export const generateMetadata = generateAgentMetadata;
17
18
 
18
- export default async function AgentLinksPage({
19
- params,
20
- }: {
21
- params: Promise<{ agentName: string }>;
22
- }) {
19
+ export default async function AgentLinksPage({ params }: { params: Promise<{ agentName: string }> }) {
23
20
  $sideEffect(headers());
24
21
  const agentName = await getAgentName(params);
25
22
 
@@ -39,7 +36,7 @@ export default async function AgentLinksPage({
39
36
 
40
37
  const { publicUrl } = await $provideServer();
41
38
  const baseUrl = `${publicUrl.href}agents/${encodeURIComponent(agentName)}`;
42
-
39
+
43
40
  // Extract brand color from meta
44
41
  const brandColor = Color.from(agentProfile.meta.color || PROMPTBOOK_COLOR);
45
42
  const backgroundColor = (await brandColor.then(withAlpha(0.05))).toHex();
@@ -47,19 +44,15 @@ export default async function AgentLinksPage({
47
44
  const primaryColor = (await brandColor).toHex();
48
45
 
49
46
  return (
50
- <div
47
+ <div
51
48
  className="min-h-screen p-6 md:p-12 flex flex-col items-center"
52
49
  style={{
53
50
  backgroundColor,
54
51
  }}
55
52
  >
56
53
  <div className="w-full max-w-3xl bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden">
57
-
58
54
  {/* Header */}
59
- <div
60
- className="p-6 border-b flex items-center gap-4"
61
- style={{ borderColor }}
62
- >
55
+ <div className="p-6 border-b flex items-center gap-4" style={{ borderColor }}>
63
56
  {agentProfile.meta.image && (
64
57
  // eslint-disable-next-line @next/next/no-img-element
65
58
  <img
@@ -70,15 +63,13 @@ export default async function AgentLinksPage({
70
63
  />
71
64
  )}
72
65
  <div className="flex-1">
73
- <h1 className="text-2xl font-bold text-gray-900">
74
- {agentProfile.meta.fullname || agentName}
75
- </h1>
66
+ <h1 className="text-2xl font-bold text-gray-900">{agentProfile.meta.fullname || agentName}</h1>
76
67
  <p className="text-gray-500 flex items-center gap-2">
77
68
  <LinkIcon className="w-4 h-4" />
78
69
  Signpost & Links
79
70
  </p>
80
71
  </div>
81
- <Link
72
+ <Link
82
73
  href={`/agents/${encodeURIComponent(agentName)}`}
83
74
  className="p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-full transition-colors"
84
75
  title="Back to Agent"
@@ -88,7 +79,6 @@ export default async function AgentLinksPage({
88
79
  </div>
89
80
 
90
81
  <div className="divide-y divide-gray-100">
91
-
92
82
  {/* API Endpoints */}
93
83
  <div className="p-6">
94
84
  <h2 className="text-lg font-semibold text-gray-800 mb-4 flex items-center gap-2">
@@ -97,26 +87,36 @@ export default async function AgentLinksPage({
97
87
  </h2>
98
88
  <div className="grid gap-4">
99
89
  <div>
100
- <h3 className="text-sm font-medium text-gray-700 mb-1">OpenAI Compatible Chat Completion</h3>
101
- <p className="text-xs text-gray-500 mb-2">Standard OpenAI API endpoint for chat completions.</p>
102
- <CopyField label="Endpoint URL" value={`${baseUrl}/api/openai/chat/completions`} />
90
+ <h3 className="text-sm font-medium text-gray-700 mb-1">
91
+ OpenAI Compatible Chat Completion
92
+ </h3>
93
+ <p className="text-xs text-gray-500 mb-2">
94
+ Standard OpenAI API endpoint for chat completions.
95
+ </p>
96
+ <CopyField label="Endpoint URL" value={`${baseUrl}/api/openai/v1/chat/completions`} />
103
97
  </div>
104
-
98
+
105
99
  <div>
106
100
  <h3 className="text-sm font-medium text-gray-700 mb-1">OpenRouter Compatible</h3>
107
- <p className="text-xs text-gray-500 mb-2">Endpoint compatible with OpenRouter API format.</p>
101
+ <p className="text-xs text-gray-500 mb-2">
102
+ Endpoint compatible with OpenRouter API format.
103
+ </p>
108
104
  <CopyField label="Endpoint URL" value={`${baseUrl}/api/openrouter/chat/completions`} />
109
105
  </div>
110
106
 
111
107
  <div>
112
108
  <h3 className="text-sm font-medium text-gray-700 mb-1">Model Context Protocol (MCP)</h3>
113
- <p className="text-xs text-gray-500 mb-2">Endpoint for Model Context Protocol integration.</p>
109
+ <p className="text-xs text-gray-500 mb-2">
110
+ Endpoint for Model Context Protocol integration.
111
+ </p>
114
112
  <CopyField label="Endpoint URL" value={`${baseUrl}/api/mcp`} />
115
113
  </div>
116
114
 
117
115
  <div>
118
116
  <h3 className="text-sm font-medium text-gray-700 mb-1">Model Requirements</h3>
119
- <p className="text-xs text-gray-500 mb-2">Get requirements and capabilities of the model.</p>
117
+ <p className="text-xs text-gray-500 mb-2">
118
+ Get requirements and capabilities of the model.
119
+ </p>
120
120
  <CopyField label="Endpoint URL" value={`${baseUrl}/api/modelRequirements`} />
121
121
  </div>
122
122
  </div>
@@ -129,50 +129,25 @@ export default async function AgentLinksPage({
129
129
  Agent Resources
130
130
  </h2>
131
131
  <div className="grid md:grid-cols-2 gap-4">
132
- <Link
133
- href={`/agents/${encodeURIComponent(agentName)}`}
134
- className="block p-4 rounded-lg border border-gray-200 hover:border-gray-300 hover:shadow-md transition-all group bg-white"
135
- >
136
- <div className="flex items-center gap-3 mb-2">
137
- <div className="p-2 rounded-lg bg-blue-50 text-blue-600 group-hover:bg-blue-100 transition-colors">
138
- <MessageSquareIcon className="w-5 h-5" />
139
- </div>
140
- <span className="font-medium text-gray-900">Chat with Agent</span>
141
- </div>
142
- <p className="text-sm text-gray-500">
143
- Direct interface to converse with {agentProfile.meta.fullname || agentName}.
144
- </p>
145
- </Link>
146
-
147
- <Link
148
- href={`/agents/${encodeURIComponent(agentName)}/history`}
149
- className="block p-4 rounded-lg border border-gray-200 hover:border-gray-300 hover:shadow-md transition-all group bg-white"
150
- >
151
- <div className="flex items-center gap-3 mb-2">
152
- <div className="p-2 rounded-lg bg-purple-50 text-purple-600 group-hover:bg-purple-100 transition-colors">
153
- <HistoryIcon className="w-5 h-5" />
154
- </div>
155
- <span className="font-medium text-gray-900">History & Feedback</span>
156
- </div>
157
- <p className="text-sm text-gray-500">
158
- View past conversations and provide feedback.
159
- </p>
160
- </Link>
161
-
162
- <Link
163
- href={`/agents/${encodeURIComponent(agentName)}/integration`}
164
- className="block p-4 rounded-lg border border-gray-200 hover:border-gray-300 hover:shadow-md transition-all group bg-white"
165
- >
166
- <div className="flex items-center gap-3 mb-2">
167
- <div className="p-2 rounded-lg bg-green-50 text-green-600 group-hover:bg-green-100 transition-colors">
168
- <CodeIcon className="w-5 h-5" />
169
- </div>
170
- <span className="font-medium text-gray-900">Integration Guide</span>
171
- </div>
172
- <p className="text-sm text-gray-500">
173
- Learn how to integrate this agent into your applications.
174
- </p>
175
- </Link>
132
+ {getAgentLinks(agentName)
133
+ .filter((link) =>
134
+ ['Chat with Agent', 'History & Feedback', 'Integration'].includes(link.title),
135
+ )
136
+ .map((link) => (
137
+ <Link
138
+ key={link.href}
139
+ href={link.href}
140
+ className="block p-4 rounded-lg border border-gray-200 hover:border-gray-300 hover:shadow-md transition-all group bg-white"
141
+ >
142
+ <div className="flex items-center gap-3 mb-2">
143
+ <div className="p-2 rounded-lg bg-gray-50 text-gray-600 group-hover:bg-gray-100 transition-colors">
144
+ <link.icon className="w-5 h-5" />
145
+ </div>
146
+ <span className="font-medium text-gray-900">{link.title}</span>
147
+ </div>
148
+ <p className="text-sm text-gray-500">{link.description}</p>
149
+ </Link>
150
+ ))}
176
151
  </div>
177
152
  </div>
178
153
 
@@ -183,34 +158,23 @@ export default async function AgentLinksPage({
183
158
  Promptbook Ecosystem
184
159
  </h2>
185
160
  <div className="grid md:grid-cols-2 gap-4">
186
- <a
187
- href="https://promptbook.studio"
188
- target="_blank"
189
- rel="noopener noreferrer"
190
- className="flex items-center gap-3 p-3 rounded-lg bg-white border border-gray-200 hover:border-gray-300 transition-colors"
191
- >
192
- <BookOpenIcon className="w-5 h-5 text-gray-400" />
193
- <div>
194
- <div className="font-medium text-gray-900">Promptbook Studio</div>
195
- <div className="text-xs text-gray-500">Create and manage your own agents</div>
196
- </div>
197
- </a>
198
-
199
- <a
200
- href="https://github.com/webgptorg/promptbook"
201
- target="_blank"
202
- rel="noopener noreferrer"
203
- className="flex items-center gap-3 p-3 rounded-lg bg-white border border-gray-200 hover:border-gray-300 transition-colors"
204
- >
205
- <CodeIcon className="w-5 h-5 text-gray-400" />
206
- <div>
207
- <div className="font-medium text-gray-900">GitHub Repository</div>
208
- <div className="text-xs text-gray-500">Star us and contribute to the project</div>
209
- </div>
210
- </a>
161
+ {getAgentExternalLinks().map((link) => (
162
+ <a
163
+ key={link.href}
164
+ href={link.href}
165
+ target={link.target}
166
+ rel={link.rel}
167
+ className="flex items-center gap-3 p-3 rounded-lg bg-white border border-gray-200 hover:border-gray-300 transition-colors"
168
+ >
169
+ <link.icon className="w-5 h-5 text-gray-400" />
170
+ <div>
171
+ <div className="font-medium text-gray-900">{link.title}</div>
172
+ <div className="text-xs text-gray-500">{link.description}</div>
173
+ </div>
174
+ </a>
175
+ ))}
211
176
  </div>
212
177
  </div>
213
-
214
178
  </div>
215
179
  </div>
216
180
  </div>