@promptbook/cli 0.104.0-2 → 0.104.0-3
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/package.json +3 -4
- package/apps/agents-server/public/swagger.json +115 -0
- package/apps/agents-server/scripts/generate-reserved-paths/generate-reserved-paths.ts +11 -7
- package/apps/agents-server/src/app/AddAgentButton.tsx +1 -2
- package/apps/agents-server/src/app/admin/chat-feedback/ChatFeedbackClient.tsx +221 -274
- package/apps/agents-server/src/app/admin/chat-history/ChatHistoryClient.tsx +94 -137
- package/apps/agents-server/src/app/admin/metadata/MetadataClient.tsx +8 -8
- package/apps/agents-server/src/app/agents/[agentName]/AgentChatWrapper.tsx +15 -1
- package/apps/agents-server/src/app/agents/[agentName]/AgentOptionsMenu.tsx +1 -3
- package/apps/agents-server/src/app/agents/[agentName]/AgentProfileChat.tsx +29 -16
- package/apps/agents-server/src/app/agents/[agentName]/api/chat/route.ts +3 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/mcp/route.ts +6 -11
- package/apps/agents-server/src/app/agents/[agentName]/api/voice/route.ts +4 -1
- package/apps/agents-server/src/app/agents/[agentName]/code/api/route.ts +8 -6
- package/apps/agents-server/src/app/agents/[agentName]/code/page.tsx +33 -30
- package/apps/agents-server/src/app/api/agents/[agentName]/clone/route.ts +10 -12
- package/apps/agents-server/src/app/api/agents/[agentName]/route.ts +1 -2
- package/apps/agents-server/src/app/api/agents/route.ts +1 -1
- package/apps/agents-server/src/app/api/api-tokens/route.ts +6 -7
- package/apps/agents-server/src/app/api/docs/book.md/route.ts +3 -0
- package/apps/agents-server/src/app/api/metadata/route.ts +5 -6
- package/apps/agents-server/src/app/api/upload/route.ts +9 -0
- package/apps/agents-server/src/app/page.tsx +1 -1
- package/apps/agents-server/src/app/swagger/page.tsx +14 -0
- package/apps/agents-server/src/components/AgentProfile/AgentProfile.tsx +4 -2
- package/apps/agents-server/src/components/AgentProfile/QrCodeModal.tsx +0 -1
- package/apps/agents-server/src/components/Auth/AuthControls.tsx +5 -4
- package/apps/agents-server/src/components/Header/Header.tsx +27 -5
- package/apps/agents-server/src/components/Homepage/AgentCard.tsx +22 -3
- package/apps/agents-server/src/components/_utils/headlessParam.tsx +7 -3
- package/apps/agents-server/src/generated/reservedPaths.ts +6 -1
- package/apps/agents-server/src/middleware.ts +12 -3
- package/apps/agents-server/src/utils/auth.ts +117 -17
- package/apps/agents-server/src/utils/getUserIdFromRequest.ts +3 -1
- package/apps/agents-server/src/utils/handleChatCompletion.ts +9 -5
- package/apps/agents-server/src/utils/validateApiKey.ts +5 -10
- package/esm/index.es.js +55 -8
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/book-components/Chat/types/ChatMessage.d.ts +7 -11
- package/esm/typings/src/types/Message.d.ts +49 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +55 -8
- package/umd/index.umd.js.map +1 -1
|
@@ -4,14 +4,13 @@
|
|
|
4
4
|
"migrate-database": "npx tsx ./src/database/migrate.ts",
|
|
5
5
|
"generate-reserved-paths": "ts-node ./scripts/generate-reserved-paths/generate-reserved-paths.ts",
|
|
6
6
|
"prebuild": "npm run generate-reserved-paths",
|
|
7
|
-
"--postbuild": "echo {} > .next/export-detail.json && mkdir -p .next/export && echo \"Not found !!!!\" > .next/export/404.html && echo \"Server error !!!!\" > .next/export/500.html",
|
|
8
|
-
"--0": " <- !!!!",
|
|
9
7
|
"predev": "npm run generate-reserved-paths",
|
|
10
8
|
"dev": "(npx kill-port 4440 || true) && next dev -p 4440",
|
|
11
|
-
"test
|
|
9
|
+
"test": "npm run lint && npm run test-build",
|
|
10
|
+
"test-build": "(npx kill-port 4440 || true) && next build",
|
|
12
11
|
"build": "(npx kill-port 4440 || true) && next build",
|
|
13
12
|
"start": "next start -p 4440",
|
|
14
|
-
"lint": "next lint",
|
|
13
|
+
"lint": "next lint --max-warnings=0",
|
|
15
14
|
"postinstall": "cd ../../ && npm ci"
|
|
16
15
|
}
|
|
17
16
|
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
{
|
|
2
|
+
"openapi": "3.0.0",
|
|
3
|
+
"info": {
|
|
4
|
+
"title": "Agents Server API",
|
|
5
|
+
"version": "1.0.0",
|
|
6
|
+
"description": "API documentation for the Agents Server"
|
|
7
|
+
},
|
|
8
|
+
"servers": [
|
|
9
|
+
{
|
|
10
|
+
"url": "/",
|
|
11
|
+
"description": "Current Server"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"paths": {
|
|
15
|
+
"/api/agents": {
|
|
16
|
+
"get": {
|
|
17
|
+
"summary": "List all agents",
|
|
18
|
+
"tags": ["Agents"],
|
|
19
|
+
"responses": {
|
|
20
|
+
"200": {
|
|
21
|
+
"description": "A list of agents",
|
|
22
|
+
"content": {
|
|
23
|
+
"application/json": {
|
|
24
|
+
"schema": {
|
|
25
|
+
"type": "array",
|
|
26
|
+
"items": {
|
|
27
|
+
"type": "object",
|
|
28
|
+
"properties": {
|
|
29
|
+
"name": { "type": "string" },
|
|
30
|
+
"title": { "type": "string" },
|
|
31
|
+
"description": { "type": "string" }
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"/api/chat": {
|
|
42
|
+
"post": {
|
|
43
|
+
"summary": "Chat with an agent",
|
|
44
|
+
"tags": ["Chat"],
|
|
45
|
+
"requestBody": {
|
|
46
|
+
"required": true,
|
|
47
|
+
"content": {
|
|
48
|
+
"application/json": {
|
|
49
|
+
"schema": {
|
|
50
|
+
"type": "object",
|
|
51
|
+
"properties": {
|
|
52
|
+
"agentName": { "type": "string" },
|
|
53
|
+
"message": { "type": "string" }
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"responses": {
|
|
60
|
+
"200": {
|
|
61
|
+
"description": "Chat response"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"/api/agents/{agentName}": {
|
|
67
|
+
"get": {
|
|
68
|
+
"summary": "Get agent details",
|
|
69
|
+
"tags": ["Agents"],
|
|
70
|
+
"parameters": [
|
|
71
|
+
{
|
|
72
|
+
"name": "agentName",
|
|
73
|
+
"in": "path",
|
|
74
|
+
"required": true,
|
|
75
|
+
"schema": {
|
|
76
|
+
"type": "string"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
"responses": {
|
|
81
|
+
"200": {
|
|
82
|
+
"description": "Agent details"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"/api/upload": {
|
|
88
|
+
"post": {
|
|
89
|
+
"summary": "Upload a file",
|
|
90
|
+
"tags": ["Upload"],
|
|
91
|
+
"requestBody": {
|
|
92
|
+
"content": {
|
|
93
|
+
"multipart/form-data": {
|
|
94
|
+
"schema": {
|
|
95
|
+
"type": "object",
|
|
96
|
+
"properties": {
|
|
97
|
+
"file": {
|
|
98
|
+
"type": "string",
|
|
99
|
+
"format": "binary"
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
"responses": {
|
|
107
|
+
"200": {
|
|
108
|
+
"description": "File uploaded"
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"--0": "<- TODO: !!!! Generate this file dynamically from the codebase of the Agents server app"
|
|
115
|
+
}
|
|
@@ -3,26 +3,29 @@ import path from 'path';
|
|
|
3
3
|
import { GENERATOR_WARNING } from '../../../../src/config';
|
|
4
4
|
|
|
5
5
|
const appDir = path.join(__dirname, '..', '..', 'src', 'app');
|
|
6
|
+
const publicDir = path.join(__dirname, '..', '..', 'public');
|
|
6
7
|
const outputFile = path.join(__dirname, '..', '..', 'src', 'generated', 'reservedPaths.ts');
|
|
7
8
|
|
|
8
9
|
// Read the app directory
|
|
9
|
-
const
|
|
10
|
+
const appEntries = fs.readdirSync(appDir, { withFileTypes: true });
|
|
10
11
|
|
|
11
12
|
// Filter to get only directories (excluding dynamic routes like [agentName])
|
|
12
|
-
const reservedPaths =
|
|
13
|
+
const reservedPaths = appEntries
|
|
13
14
|
.filter((entry) => entry.isDirectory())
|
|
14
15
|
.map((entry) => entry.name)
|
|
15
16
|
.filter((name) => !name.startsWith('[') && !name.endsWith(']'));
|
|
16
17
|
|
|
17
|
-
//
|
|
18
|
+
// Read the public directory (files and folders)
|
|
19
|
+
const publicEntries = fs.readdirSync(publicDir, { withFileTypes: true });
|
|
20
|
+
const publicPaths = publicEntries.map((entry) => entry.name).filter((name) => !name.startsWith('.'));
|
|
21
|
+
|
|
22
|
+
// Add additional paths that are not in app or public but should be reserved
|
|
18
23
|
const additionalPaths = [
|
|
19
24
|
'_next', // Next.js internal paths
|
|
20
25
|
'manifest.webmanifest', // PWA manifest
|
|
21
|
-
'sw.js', // Service Worker
|
|
22
|
-
'favicon.ico', // Favicon
|
|
23
26
|
];
|
|
24
27
|
|
|
25
|
-
const allReservedPaths = [...new Set([...reservedPaths, ...additionalPaths])].sort();
|
|
28
|
+
const allReservedPaths = [...new Set([...reservedPaths, ...publicPaths, ...additionalPaths])].sort();
|
|
26
29
|
|
|
27
30
|
// Generate the TypeScript file
|
|
28
31
|
const content = `/**
|
|
@@ -31,7 +34,8 @@ const content = `/**
|
|
|
31
34
|
*
|
|
32
35
|
* ${GENERATOR_WARNING}
|
|
33
36
|
*
|
|
34
|
-
* @see /apps/agents-server/src/app - source directory
|
|
37
|
+
* @see /apps/agents-server/src/app - source directory for routes
|
|
38
|
+
* @see /apps/agents-server/public - source directory for static files
|
|
35
39
|
* @see /apps/agents-server/src/middleware.ts - where this is used
|
|
36
40
|
*/
|
|
37
41
|
export const RESERVED_PATHS: readonly string[] = ${JSON.stringify(allReservedPaths, null, 4)} as const;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
'use client';
|
|
3
2
|
|
|
4
3
|
import { useRouter } from 'next/navigation';
|
|
@@ -12,7 +11,7 @@ export function AddAgentButton() {
|
|
|
12
11
|
|
|
13
12
|
const handleAddAgent = async () => {
|
|
14
13
|
setIsLoading(true);
|
|
15
|
-
const { agentName
|
|
14
|
+
const { /*agentName,*/ permanentId } = await $createAgentAction();
|
|
16
15
|
// TODO: Add proper error handling and UI feedback
|
|
17
16
|
if (permanentId) {
|
|
18
17
|
router.push(`/agents/${permanentId}`);
|