@promptbook/cli 0.104.0-1 → 0.104.0-10
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 +1 -3
- package/apps/agents-server/next.config.ts +2 -2
- package/apps/agents-server/package.json +7 -3
- package/apps/agents-server/public/fonts/OpenMoji-color-cbdt.woff2 +0 -0
- package/apps/agents-server/public/swagger.json +115 -0
- package/apps/agents-server/scripts/generate-reserved-paths/generate-reserved-paths.ts +54 -0
- package/apps/agents-server/scripts/generate-reserved-paths/tsconfig.json +19 -0
- package/apps/agents-server/src/app/AddAgentButton.tsx +47 -21
- package/apps/agents-server/src/app/actions.ts +22 -5
- package/apps/agents-server/src/app/admin/browser-test/BrowserTestClient.tsx +211 -0
- package/apps/agents-server/src/app/admin/browser-test/page.tsx +13 -0
- 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/messages/MessagesClient.tsx +294 -0
- package/apps/agents-server/src/app/admin/messages/page.tsx +13 -0
- package/apps/agents-server/src/app/admin/messages/send-email/SendEmailClient.tsx +104 -0
- package/apps/agents-server/src/app/admin/messages/send-email/actions.ts +35 -0
- package/apps/agents-server/src/app/admin/messages/send-email/page.tsx +13 -0
- package/apps/agents-server/src/app/admin/metadata/MetadataClient.tsx +23 -19
- package/apps/agents-server/src/app/agents/[agentName]/AgentChatWrapper.tsx +15 -1
- package/apps/agents-server/src/app/agents/[agentName]/AgentOptionsMenu.tsx +51 -9
- package/apps/agents-server/src/app/agents/[agentName]/AgentProfileChat.tsx +47 -4
- package/apps/agents-server/src/app/agents/[agentName]/AgentProfileWrapper.tsx +53 -11
- package/apps/agents-server/src/app/agents/[agentName]/_utils.ts +23 -3
- package/apps/agents-server/src/app/agents/[agentName]/agentLinks.tsx +8 -8
- package/apps/agents-server/src/app/agents/[agentName]/api/agents/route.ts +17 -26
- package/apps/agents-server/src/app/agents/[agentName]/api/book/route.ts +4 -2
- package/apps/agents-server/src/app/agents/[agentName]/api/chat/route.ts +20 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/mcp/route.ts +6 -11
- package/apps/agents-server/src/app/agents/[agentName]/api/profile/route.ts +5 -1
- package/apps/agents-server/src/app/agents/[agentName]/api/voice/route.ts +5 -2
- package/apps/agents-server/src/app/agents/[agentName]/book/BookEditorWrapper.tsx +20 -16
- package/apps/agents-server/src/app/agents/[agentName]/book/page.tsx +15 -2
- package/apps/agents-server/src/app/agents/[agentName]/book+chat/page.tsx +15 -2
- package/apps/agents-server/src/app/agents/[agentName]/chat/page.tsx +12 -0
- package/apps/agents-server/src/app/agents/[agentName]/code/api/route.ts +68 -0
- package/apps/agents-server/src/app/agents/[agentName]/code/page.tsx +223 -0
- package/apps/agents-server/src/app/agents/[agentName]/generateAgentMetadata.ts +5 -0
- package/apps/agents-server/src/app/agents/[agentName]/history/actions.ts +2 -2
- package/apps/agents-server/src/app/agents/[agentName]/history/page.tsx +10 -3
- package/apps/agents-server/src/app/agents/[agentName]/images/default-avatar.png/getAgentDefaultAvatarPrompt.ts +31 -0
- package/apps/agents-server/src/app/agents/[agentName]/images/default-avatar.png/route.ts +194 -0
- package/apps/agents-server/src/app/agents/[agentName]/images/icon-256.png/route.tsx +14 -2
- package/apps/agents-server/src/app/agents/[agentName]/images/page.tsx +200 -0
- package/apps/agents-server/src/app/agents/[agentName]/images/screenshot-fullhd.png/route.tsx +4 -3
- package/apps/agents-server/src/app/agents/[agentName]/images/screenshot-phone.png/route.tsx +4 -3
- package/apps/agents-server/src/app/agents/[agentName]/integration/page.tsx +10 -3
- package/apps/agents-server/src/app/agents/[agentName]/links/page.tsx +11 -4
- package/apps/agents-server/src/app/agents/[agentName]/opengraph-image.tsx +11 -2
- package/apps/agents-server/src/app/agents/[agentName]/page.tsx +18 -10
- package/apps/agents-server/src/app/agents/[agentName]/system-message/page.tsx +100 -0
- package/apps/agents-server/src/app/api/admin-email/route.ts +12 -0
- package/apps/agents-server/src/app/api/agents/[agentName]/clone/route.ts +13 -14
- package/apps/agents-server/src/app/api/agents/[agentName]/restore/route.ts +20 -0
- package/apps/agents-server/src/app/api/agents/[agentName]/route.ts +43 -1
- package/apps/agents-server/src/app/api/agents/route.ts +28 -3
- package/apps/agents-server/src/app/api/api-tokens/route.ts +6 -7
- package/apps/agents-server/src/app/api/browser-test/act/route.ts +141 -0
- package/apps/agents-server/src/app/api/browser-test/screenshot/route.ts +30 -0
- package/apps/agents-server/src/app/api/browser-test/scroll-facebook/route.ts +62 -0
- package/apps/agents-server/src/app/api/docs/book.md/route.ts +61 -0
- package/apps/agents-server/src/app/api/emails/incoming/sendgrid/route.ts +48 -0
- package/apps/agents-server/src/app/api/federated-agents/route.ts +12 -0
- package/apps/agents-server/src/app/api/images/[filename]/route.ts +107 -0
- package/apps/agents-server/src/app/api/messages/route.ts +102 -0
- package/apps/agents-server/src/app/api/metadata/route.ts +5 -6
- package/apps/agents-server/src/app/api/upload/route.ts +128 -45
- package/apps/agents-server/src/app/docs/[docId]/page.tsx +2 -3
- package/apps/agents-server/src/app/docs/page.tsx +12 -12
- package/apps/agents-server/src/app/globals.css +140 -33
- package/apps/agents-server/src/app/humans.txt/route.ts +1 -1
- package/apps/agents-server/src/app/layout.tsx +27 -22
- package/apps/agents-server/src/app/page.tsx +54 -6
- package/apps/agents-server/src/app/recycle-bin/actions.ts +20 -14
- package/apps/agents-server/src/app/recycle-bin/page.tsx +27 -41
- package/apps/agents-server/src/app/robots.txt/route.ts +1 -1
- package/apps/agents-server/src/app/security.txt/route.ts +1 -1
- package/apps/agents-server/src/app/sitemap.xml/route.ts +9 -7
- package/apps/agents-server/src/app/swagger/page.tsx +14 -0
- package/apps/agents-server/src/components/AgentProfile/AgentProfile.tsx +41 -116
- package/apps/agents-server/src/components/AgentProfile/AgentProfileImage.tsx +92 -0
- package/apps/agents-server/src/components/AgentProfile/QrCodeModal.tsx +0 -1
- package/apps/agents-server/src/components/AgentProfile/useAgentBackground.ts +97 -0
- package/apps/agents-server/src/components/Auth/AuthControls.tsx +5 -4
- package/apps/agents-server/src/components/DeletedAgentBanner.tsx +26 -0
- package/apps/agents-server/src/components/DocsToolbar/DocsToolbar.tsx +38 -0
- package/apps/agents-server/src/components/DocumentationContent/DocumentationContent.tsx +11 -9
- package/apps/agents-server/src/components/Footer/Footer.tsx +5 -5
- package/apps/agents-server/src/components/ForgottenPasswordDialog/ForgottenPasswordDialog.tsx +61 -0
- package/apps/agents-server/src/components/Header/Header.tsx +114 -40
- package/apps/agents-server/src/components/Homepage/AgentCard.tsx +145 -23
- package/apps/agents-server/src/components/Homepage/AgentsList.tsx +93 -15
- package/apps/agents-server/src/components/Homepage/DeletedAgentsList.tsx +66 -0
- package/apps/agents-server/src/components/Homepage/ExternalAgentsSection.tsx +12 -3
- package/apps/agents-server/src/components/Homepage/ExternalAgentsSectionClient.tsx +19 -10
- package/apps/agents-server/src/components/LayoutWrapper/LayoutWrapper.tsx +3 -2
- package/apps/agents-server/src/components/LoginForm/LoginForm.tsx +50 -1
- package/apps/agents-server/src/components/NewAgentDialog/NewAgentDialog.tsx +88 -0
- package/apps/agents-server/src/components/NotFoundPage/NotFoundPage.tsx +7 -2
- package/apps/agents-server/src/components/OpenMojiIcon/OpenMojiIcon.tsx +16 -7
- package/apps/agents-server/src/components/PrintHeader/PrintHeader.tsx +4 -4
- package/apps/agents-server/src/components/RegisterUserDialog/RegisterUserDialog.tsx +61 -0
- package/apps/agents-server/src/components/VercelDeploymentCard/VercelDeploymentCard.tsx +2 -0
- package/apps/agents-server/src/components/_utils/generateMetaTxt.ts +12 -10
- package/apps/agents-server/src/components/_utils/headlessParam.tsx +7 -3
- package/apps/agents-server/src/database/$provideSupabaseForBrowser.ts +3 -3
- package/apps/agents-server/src/database/$provideSupabaseForServer.ts +1 -1
- package/apps/agents-server/src/database/$provideSupabaseForWorker.ts +3 -3
- package/apps/agents-server/src/database/metadataDefaults.ts +19 -1
- package/apps/agents-server/src/database/migrate.ts +34 -1
- package/apps/agents-server/src/database/migrations/2025-11-0001-initial-schema.sql +1 -3
- package/apps/agents-server/src/database/migrations/2025-11-0002-metadata-table.sql +1 -3
- package/apps/agents-server/src/database/migrations/2025-12-0240-agent-public-id.sql +3 -0
- package/apps/agents-server/src/database/migrations/2025-12-0360-agent-deleted-at.sql +1 -0
- package/apps/agents-server/src/database/migrations/2025-12-0370-image-table.sql +19 -0
- package/apps/agents-server/src/database/migrations/2025-12-0380-agent-visibility.sql +1 -0
- package/apps/agents-server/src/database/migrations/2025-12-0390-upload-tracking.sql +20 -0
- package/apps/agents-server/src/database/migrations/2025-12-0401-file-upload-status.sql +13 -0
- package/apps/agents-server/src/database/migrations/2025-12-0402-message-table.sql +42 -0
- package/apps/agents-server/src/database/migrations/2025-12-0403-generation-lock-table.sql +15 -0
- package/apps/agents-server/src/database/migrations/2025-12-0640-openai-assistant-cache.sql +12 -0
- package/apps/agents-server/src/database/migrations/2025-12-0820-agent-history-permanent-id.sql +29 -0
- package/apps/agents-server/src/database/schema.ts +231 -4
- package/apps/agents-server/src/generated/reservedPaths.ts +32 -0
- package/apps/agents-server/src/message-providers/email/_common/Email.ts +73 -0
- package/apps/agents-server/src/message-providers/email/_common/utils/TODO.txt +1 -0
- package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddress.test.ts.todo +108 -0
- package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddress.ts +62 -0
- package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddresses.test.ts.todo +117 -0
- package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddresses.ts +19 -0
- package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddress.test.ts.todo +119 -0
- package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddress.ts +19 -0
- package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddresses.test.ts.todo +74 -0
- package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddresses.ts +14 -0
- package/apps/agents-server/src/message-providers/email/sendgrid/SendgridMessageProvider.ts +44 -0
- package/apps/agents-server/src/message-providers/email/sendgrid/parseInboundSendgridEmail.ts +49 -0
- package/apps/agents-server/src/message-providers/email/zeptomail/ZeptomailMessageProvider.ts +51 -0
- package/apps/agents-server/src/message-providers/index.ts +13 -0
- package/apps/agents-server/src/message-providers/interfaces/MessageProvider.ts +11 -0
- package/apps/agents-server/src/middleware.ts +19 -23
- package/apps/agents-server/src/tools/$provideBrowserForServer.ts +32 -0
- package/apps/agents-server/src/tools/$provideCdnForServer.ts +7 -2
- package/apps/agents-server/src/utils/auth.ts +117 -17
- package/apps/agents-server/src/utils/cdn/classes/TrackedFilesStorage.ts +57 -0
- package/apps/agents-server/src/utils/cdn/classes/VercelBlobStorage.ts +4 -0
- package/apps/agents-server/src/utils/cdn/interfaces/IFilesStorage.ts +18 -0
- package/apps/agents-server/src/utils/content/extractBodyContentFromHtml.ts +19 -0
- package/apps/agents-server/src/utils/getUserIdFromRequest.ts +35 -0
- package/apps/agents-server/src/utils/handleChatCompletion.ts +65 -5
- package/apps/agents-server/src/utils/messages/sendMessage.ts +91 -0
- package/apps/agents-server/src/utils/messagesAdmin.ts +72 -0
- package/apps/agents-server/src/utils/normalization/filenameToPrompt.test.ts +36 -0
- package/apps/agents-server/src/utils/normalization/filenameToPrompt.ts +25 -0
- package/apps/agents-server/src/utils/validateApiKey.ts +7 -11
- package/esm/index.es.js +2890 -2737
- package/esm/index.es.js.map +1 -1
- package/esm/typings/servers.d.ts +8 -0
- package/esm/typings/src/_packages/core.index.d.ts +2 -0
- package/esm/typings/src/_packages/types.index.d.ts +10 -2
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +6 -1
- package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirements.d.ts +6 -6
- package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.closed.test.d.ts +1 -0
- package/esm/typings/src/book-2.0/utils/generatePlaceholderAgentProfileImageUrl.d.ts +3 -3
- package/esm/typings/src/book-components/Chat/Chat/ChatMessageItem.d.ts +5 -1
- package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +5 -0
- package/esm/typings/src/book-components/Chat/CodeBlock/CodeBlock.d.ts +13 -0
- package/esm/typings/src/book-components/Chat/MarkdownContent/MarkdownContent.d.ts +1 -0
- package/esm/typings/src/book-components/Chat/types/ChatMessage.d.ts +7 -11
- package/esm/typings/src/book-components/_common/Dropdown/Dropdown.d.ts +2 -2
- package/esm/typings/src/book-components/_common/MenuHoisting/MenuHoistingContext.d.ts +56 -0
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +21 -11
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentsDatabaseSchema.d.ts +80 -14
- package/esm/typings/src/commitments/DICTIONARY/DICTIONARY.d.ts +46 -0
- package/esm/typings/src/commitments/index.d.ts +2 -1
- package/esm/typings/src/llm-providers/_multiple/MultipleLlmExecutionTools.d.ts +6 -2
- package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/ollama/OllamaExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/createOpenAiCompatibleExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -0
- package/esm/typings/src/types/Message.d.ts +49 -0
- package/esm/typings/src/types/ModelRequirements.d.ts +38 -14
- package/esm/typings/src/types/typeAliases.d.ts +23 -1
- package/esm/typings/src/utils/color/utils/colorToDataUrl.d.ts +2 -1
- package/esm/typings/src/utils/environment/$detectRuntimeEnvironment.d.ts +4 -4
- package/esm/typings/src/utils/environment/$isRunningInBrowser.d.ts +1 -1
- package/esm/typings/src/utils/environment/$isRunningInJest.d.ts +1 -1
- package/esm/typings/src/utils/environment/$isRunningInNode.d.ts +1 -1
- package/esm/typings/src/utils/environment/$isRunningInWebWorker.d.ts +1 -1
- package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +2 -2
- package/esm/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +2 -2
- package/esm/typings/src/utils/random/$randomBase58.d.ts +12 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +4018 -3865
- package/umd/index.umd.js.map +1 -1
- package/apps/agents-server/package-lock.json +0 -27
- package/apps/agents-server/public/fonts/download-font.js +0 -22
- package/apps/agents-server/src/components/PrintButton/PrintButton.tsx +0 -18
- package/esm/typings/src/book-2.0/utils/generateGravatarUrl.d.ts +0 -10
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { assertsError } from '../../../../../../../src/errors/assertsError';
|
|
5
|
+
import { sendEmailAction } from './actions';
|
|
6
|
+
|
|
7
|
+
export function SendEmailClient() {
|
|
8
|
+
const [status, setStatus] = useState<'IDLE' | 'LOADING' | 'SUCCESS' | 'ERROR'>('IDLE');
|
|
9
|
+
const [errorMessage, setErrorMessage] = useState<string | null>(null);
|
|
10
|
+
|
|
11
|
+
const handleSubmit = async (event: React.FormEvent<HTMLFormElement>) => {
|
|
12
|
+
event.preventDefault();
|
|
13
|
+
setStatus('LOADING');
|
|
14
|
+
setErrorMessage(null);
|
|
15
|
+
|
|
16
|
+
const formData = new FormData(event.currentTarget);
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
await sendEmailAction(formData);
|
|
20
|
+
setStatus('SUCCESS');
|
|
21
|
+
} catch (error) {
|
|
22
|
+
assertsError(error);
|
|
23
|
+
console.error(error);
|
|
24
|
+
setStatus('ERROR');
|
|
25
|
+
setErrorMessage(error.message);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div className="container mx-auto p-4">
|
|
31
|
+
<h1 className="text-2xl font-bold mb-4">Send Email (Test)</h1>
|
|
32
|
+
|
|
33
|
+
{status === 'SUCCESS' && (
|
|
34
|
+
<div className="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded mb-4">
|
|
35
|
+
Email sent successfully!
|
|
36
|
+
</div>
|
|
37
|
+
)}
|
|
38
|
+
|
|
39
|
+
{status === 'ERROR' && (
|
|
40
|
+
<div className="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mb-4">
|
|
41
|
+
Error: {errorMessage}
|
|
42
|
+
</div>
|
|
43
|
+
)}
|
|
44
|
+
|
|
45
|
+
<form onSubmit={handleSubmit} className="space-y-4 max-w-lg">
|
|
46
|
+
<div>
|
|
47
|
+
<label className="block text-sm font-medium text-gray-700">From</label>
|
|
48
|
+
<input
|
|
49
|
+
name="from"
|
|
50
|
+
type="text"
|
|
51
|
+
defaultValue="Test Promptbook <test@ptbk.io>"
|
|
52
|
+
required
|
|
53
|
+
className="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 border p-2"
|
|
54
|
+
/>
|
|
55
|
+
</div>
|
|
56
|
+
|
|
57
|
+
<div>
|
|
58
|
+
<label className="block text-sm font-medium text-gray-700">To</label>
|
|
59
|
+
<input
|
|
60
|
+
name="to"
|
|
61
|
+
type="text"
|
|
62
|
+
placeholder="recipient@example.com"
|
|
63
|
+
defaultValue="Pavol Hejný <pavol@ptbk.io>"
|
|
64
|
+
required
|
|
65
|
+
className="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 border p-2"
|
|
66
|
+
/>
|
|
67
|
+
<p className="text-xs text-gray-500 mt-1">Separate multiple addresses with commas</p>
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
<div>
|
|
71
|
+
<label className="block text-sm font-medium text-gray-700">Subject</label>
|
|
72
|
+
<input
|
|
73
|
+
name="subject"
|
|
74
|
+
type="text"
|
|
75
|
+
placeholder="Test Email"
|
|
76
|
+
defaultValue="Test Email"
|
|
77
|
+
required
|
|
78
|
+
className="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 border p-2"
|
|
79
|
+
/>
|
|
80
|
+
</div>
|
|
81
|
+
|
|
82
|
+
<div>
|
|
83
|
+
<label className="block text-sm font-medium text-gray-700">Body</label>
|
|
84
|
+
<textarea
|
|
85
|
+
name="body"
|
|
86
|
+
rows={6}
|
|
87
|
+
placeholder="Hello, this is a test email."
|
|
88
|
+
defaultValue="Hello, this is a test email."
|
|
89
|
+
required
|
|
90
|
+
className="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 border p-2"
|
|
91
|
+
/>
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
<button
|
|
95
|
+
type="submit"
|
|
96
|
+
disabled={status === 'LOADING'}
|
|
97
|
+
className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded disabled:opacity-50"
|
|
98
|
+
>
|
|
99
|
+
{status === 'LOADING' ? 'Sending...' : 'Send Email'}
|
|
100
|
+
</button>
|
|
101
|
+
</form>
|
|
102
|
+
</div>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use server';
|
|
2
|
+
|
|
3
|
+
import type { string_email, string_emails, string_html } from '@promptbook-local/types';
|
|
4
|
+
import { parseEmailAddress } from '../../../../message-providers/email/_common/utils/parseEmailAddress';
|
|
5
|
+
import { parseEmailAddresses } from '../../../../message-providers/email/_common/utils/parseEmailAddresses';
|
|
6
|
+
import { stringifyEmailAddress } from '../../../../message-providers/email/_common/utils/stringifyEmailAddress';
|
|
7
|
+
import { sendMessage } from '../../../../utils/messages/sendMessage';
|
|
8
|
+
|
|
9
|
+
export async function sendEmailAction(formData: FormData) {
|
|
10
|
+
const from = formData.get('from') as string;
|
|
11
|
+
const to = formData.get('to') as string;
|
|
12
|
+
const subject = formData.get('subject') as string;
|
|
13
|
+
const body = formData.get('body') as string;
|
|
14
|
+
|
|
15
|
+
if (!from || !to || !subject || !body) {
|
|
16
|
+
throw new Error('All fields are required');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const sender = stringifyEmailAddress(parseEmailAddress(from as string_email));
|
|
20
|
+
const recipients = parseEmailAddresses(to as string_emails).map(stringifyEmailAddress);
|
|
21
|
+
|
|
22
|
+
await sendMessage({
|
|
23
|
+
channel: 'EMAIL',
|
|
24
|
+
direction: 'OUTBOUND',
|
|
25
|
+
sender,
|
|
26
|
+
recipients,
|
|
27
|
+
subject,
|
|
28
|
+
content: body as string_html,
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
|
+
threadId: crypto.randomUUID() as any,
|
|
31
|
+
cc: [],
|
|
32
|
+
attachments: [],
|
|
33
|
+
metadata: {},
|
|
34
|
+
});
|
|
35
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ForbiddenPage } from '../../../../components/ForbiddenPage/ForbiddenPage';
|
|
2
|
+
import { isUserAdmin } from '../../../../utils/isUserAdmin';
|
|
3
|
+
import { SendEmailClient } from './SendEmailClient';
|
|
4
|
+
|
|
5
|
+
export default async function AdminSendEmailPage() {
|
|
6
|
+
const isAdmin = await isUserAdmin();
|
|
7
|
+
|
|
8
|
+
if (!isAdmin) {
|
|
9
|
+
return <ForbiddenPage />;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return <SendEmailClient />;
|
|
13
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { upload } from '@vercel/blob/client';
|
|
4
|
+
import { FileTextIcon, HashIcon, ImageIcon, ShieldIcon, ToggleLeftIcon, TypeIcon, Upload } from 'lucide-react';
|
|
4
5
|
import { useEffect, useRef, useState } from 'react';
|
|
5
6
|
import { metadataDefaults, MetadataType } from '../../../database/metadataDefaults';
|
|
6
7
|
|
|
@@ -148,19 +149,19 @@ export function MetadataClient() {
|
|
|
148
149
|
const getTypeIcon = (type?: MetadataType) => {
|
|
149
150
|
switch (type) {
|
|
150
151
|
case 'TEXT_SINGLE_LINE':
|
|
151
|
-
return <
|
|
152
|
+
return <TypeIcon className="w-4 h-4" />;
|
|
152
153
|
case 'TEXT':
|
|
153
|
-
return <
|
|
154
|
+
return <FileTextIcon className="w-4 h-4" />;
|
|
154
155
|
case 'NUMBER':
|
|
155
|
-
return <
|
|
156
|
+
return <HashIcon className="w-4 h-4" />;
|
|
156
157
|
case 'BOOLEAN':
|
|
157
|
-
return <
|
|
158
|
+
return <ToggleLeftIcon className="w-4 h-4" />;
|
|
158
159
|
case 'IMAGE_URL':
|
|
159
|
-
return <
|
|
160
|
+
return <ImageIcon className="w-4 h-4" />;
|
|
160
161
|
case 'IP_RANGE':
|
|
161
|
-
return <
|
|
162
|
+
return <ShieldIcon className="w-4 h-4" />;
|
|
162
163
|
default:
|
|
163
|
-
return <
|
|
164
|
+
return <TypeIcon className="w-4 h-4" />;
|
|
164
165
|
}
|
|
165
166
|
};
|
|
166
167
|
|
|
@@ -185,26 +186,29 @@ export function MetadataClient() {
|
|
|
185
186
|
|
|
186
187
|
try {
|
|
187
188
|
setIsUploading(true);
|
|
188
|
-
const formData = new FormData();
|
|
189
|
-
formData.append('file', file);
|
|
190
189
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
190
|
+
// Build the full path including prefix and user/files directory
|
|
191
|
+
const pathPrefix = process.env.NEXT_PUBLIC_CDN_PATH_PREFIX || '';
|
|
192
|
+
const uploadPath = pathPrefix ? `${pathPrefix}/user/files/${file.name}` : `user/files/${file.name}`;
|
|
193
|
+
|
|
194
|
+
// Upload directly to Vercel Blob using client upload
|
|
195
|
+
const blob = await upload(uploadPath, file, {
|
|
196
|
+
access: 'public',
|
|
197
|
+
handleUploadUrl: '/api/upload',
|
|
198
|
+
clientPayload: JSON.stringify({
|
|
199
|
+
purpose: formState.key || 'METADATA_IMAGE',
|
|
200
|
+
contentType: file.type,
|
|
201
|
+
}),
|
|
194
202
|
});
|
|
195
203
|
|
|
196
|
-
|
|
197
|
-
throw new Error(`Failed to upload file: ${response.statusText}`);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
const { fileUrl: longFileUrl } = await response.json();
|
|
204
|
+
const fileUrl = blob.url;
|
|
201
205
|
|
|
202
206
|
const LONG_URL = `${process.env.NEXT_PUBLIC_CDN_PUBLIC_URL!}/${process.env
|
|
203
207
|
.NEXT_PUBLIC_CDN_PATH_PREFIX!}/user/files/`;
|
|
204
208
|
const SHORT_URL = `https://ptbk.io/k/`;
|
|
205
209
|
// <- TODO: [🌍] Unite this logic in one place
|
|
206
210
|
|
|
207
|
-
const shortFileUrl =
|
|
211
|
+
const shortFileUrl = fileUrl.split(LONG_URL).join(SHORT_URL);
|
|
208
212
|
setFormState((prev) => ({ ...prev, value: shortFileUrl }));
|
|
209
213
|
} catch (err) {
|
|
210
214
|
setError(err instanceof Error ? err.message : 'Failed to upload image');
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { usePromise } from '@common/hooks/usePromise';
|
|
4
4
|
import { AgentChat } from '@promptbook-local/components';
|
|
5
5
|
import { RemoteAgent } from '@promptbook-local/core';
|
|
6
|
-
import { useCallback, useMemo } from 'react';
|
|
6
|
+
import { useCallback, useEffect, useMemo } from 'react';
|
|
7
7
|
import { string_agent_url } from '../../../../../../src/types/typeAliases';
|
|
8
8
|
|
|
9
9
|
type AgentChatWrapperProps = {
|
|
@@ -58,6 +58,20 @@ export function AgentChatWrapper(props: AgentChatWrapperProps) {
|
|
|
58
58
|
[agent, agentUrl],
|
|
59
59
|
);
|
|
60
60
|
|
|
61
|
+
// Remove the 'message' query parameter from URL after auto-executing a message
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
if (autoExecuteMessage && typeof window !== 'undefined') {
|
|
64
|
+
// Wait for the message to be processed, then remove the query parameter
|
|
65
|
+
const timer = setTimeout(() => {
|
|
66
|
+
const url = new URL(window.location.href);
|
|
67
|
+
url.searchParams.delete('message');
|
|
68
|
+
window.history.replaceState({}, '', url.toString());
|
|
69
|
+
}, 1000); // 1 second delay to ensure message processing is complete
|
|
70
|
+
|
|
71
|
+
return () => clearTimeout(timer);
|
|
72
|
+
}
|
|
73
|
+
}, [autoExecuteMessage]);
|
|
74
|
+
|
|
61
75
|
if (!agent) {
|
|
62
76
|
return <>{/* <- TODO: [🐱🚀] <PromptbookLoading /> */}</>;
|
|
63
77
|
}
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
import { TODO_any } from '@promptbook-local/types';
|
|
4
4
|
import {
|
|
5
|
+
CodeIcon,
|
|
5
6
|
CopyIcon,
|
|
6
7
|
CopyPlusIcon,
|
|
7
8
|
DownloadIcon,
|
|
9
|
+
FileTextIcon,
|
|
8
10
|
MailIcon,
|
|
9
11
|
MessageCircleQuestionIcon,
|
|
10
12
|
MessageSquareIcon,
|
|
@@ -13,10 +15,12 @@ import {
|
|
|
13
15
|
QrCodeIcon,
|
|
14
16
|
SmartphoneIcon,
|
|
15
17
|
SquareSplitHorizontalIcon,
|
|
18
|
+
TrashIcon,
|
|
16
19
|
} from 'lucide-react';
|
|
17
20
|
import { Barlow_Condensed } from 'next/font/google';
|
|
18
21
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
19
|
-
import { string_data_url, string_url_image } from '../../../../../../src/types/typeAliases';
|
|
22
|
+
import { string_agent_permanent_id, string_data_url, string_url_image } from '../../../../../../src/types/typeAliases';
|
|
23
|
+
import { deleteAgent } from '../../recycle-bin/actions';
|
|
20
24
|
import { getAgentLinks } from './agentLinks';
|
|
21
25
|
|
|
22
26
|
type BeforeInstallPromptEvent = Event & {
|
|
@@ -33,6 +37,7 @@ const barlowCondensed = Barlow_Condensed({
|
|
|
33
37
|
type AgentOptionsMenuProps = {
|
|
34
38
|
agentName: string;
|
|
35
39
|
derivedAgentName: string;
|
|
40
|
+
permanentId?: string_agent_permanent_id;
|
|
36
41
|
agentUrl: string;
|
|
37
42
|
agentEmail: string;
|
|
38
43
|
brandColorHex: string;
|
|
@@ -44,11 +49,10 @@ type AgentOptionsMenuProps = {
|
|
|
44
49
|
export function AgentOptionsMenu({
|
|
45
50
|
agentName,
|
|
46
51
|
derivedAgentName,
|
|
52
|
+
permanentId,
|
|
47
53
|
agentUrl,
|
|
48
54
|
agentEmail,
|
|
49
|
-
brandColorHex,
|
|
50
55
|
isAdmin = false,
|
|
51
|
-
backgroundImage,
|
|
52
56
|
onShowQrCode,
|
|
53
57
|
}: AgentOptionsMenuProps) {
|
|
54
58
|
const [isOpen, setIsOpen] = useState(false);
|
|
@@ -115,7 +119,7 @@ export function AgentOptionsMenu({
|
|
|
115
119
|
}
|
|
116
120
|
};
|
|
117
121
|
|
|
118
|
-
const links = getAgentLinks(agentName);
|
|
122
|
+
const links = getAgentLinks(permanentId || agentName);
|
|
119
123
|
const editBookLink = links.find((l) => l.title === 'Edit Book')!;
|
|
120
124
|
const integrationLink = links.find((l) => l.title === 'Integration')!;
|
|
121
125
|
const historyLink = links.find((l) => l.title === 'History & Feedback')!;
|
|
@@ -128,13 +132,29 @@ export function AgentOptionsMenu({
|
|
|
128
132
|
const handleUpdateUrl = () => {
|
|
129
133
|
if (
|
|
130
134
|
window.confirm(
|
|
131
|
-
`Are you sure you want to change the agent URL from "/agents/${agentName}" to "/agents/${derivedAgentName}"
|
|
135
|
+
`Are you sure you want to change the agent URL from "/agents/${agentName}" to "/agents/${derivedAgentName}"?`,
|
|
132
136
|
)
|
|
133
137
|
) {
|
|
134
138
|
window.location.href = updateUrlHref;
|
|
135
139
|
}
|
|
136
140
|
};
|
|
137
141
|
|
|
142
|
+
const handleDeleteAgent = async () => {
|
|
143
|
+
if (
|
|
144
|
+
window.confirm(
|
|
145
|
+
`Are you sure you want to delete the agent "${agentName}"? This action can be undone by restoring it from the recycle bin.`,
|
|
146
|
+
)
|
|
147
|
+
) {
|
|
148
|
+
try {
|
|
149
|
+
await deleteAgent(agentName);
|
|
150
|
+
window.location.href = '/';
|
|
151
|
+
} catch (error) {
|
|
152
|
+
console.error('Failed to delete agent:', error);
|
|
153
|
+
alert('Failed to delete agent. Please try again.');
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
|
|
138
158
|
const menuItems = [
|
|
139
159
|
...(showUpdateUrl
|
|
140
160
|
? [
|
|
@@ -166,6 +186,18 @@ export function AgentOptionsMenu({
|
|
|
166
186
|
icon: editBookLink.icon,
|
|
167
187
|
label: editBookLink.title,
|
|
168
188
|
},
|
|
189
|
+
{
|
|
190
|
+
type: 'link' as const,
|
|
191
|
+
href: `/agents/${encodeURIComponent(agentName)}/system-message`,
|
|
192
|
+
icon: FileTextIcon,
|
|
193
|
+
label: 'System Message',
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
type: 'link' as const,
|
|
197
|
+
href: `/agents/${encodeURIComponent(agentName)}/code`,
|
|
198
|
+
icon: CodeIcon,
|
|
199
|
+
label: 'View Code',
|
|
200
|
+
},
|
|
169
201
|
{ type: 'divider' as const },
|
|
170
202
|
{
|
|
171
203
|
type: 'link' as const,
|
|
@@ -243,6 +275,12 @@ export function AgentOptionsMenu({
|
|
|
243
275
|
icon: DownloadIcon,
|
|
244
276
|
label: 'Export Agent',
|
|
245
277
|
},
|
|
278
|
+
{
|
|
279
|
+
type: 'action' as const,
|
|
280
|
+
icon: TrashIcon,
|
|
281
|
+
label: 'Delete Agent',
|
|
282
|
+
onClick: handleDeleteAgent,
|
|
283
|
+
},
|
|
246
284
|
// {
|
|
247
285
|
// type: 'link' as const,
|
|
248
286
|
// href: backgroundImage,
|
|
@@ -297,12 +335,16 @@ export function AgentOptionsMenu({
|
|
|
297
335
|
}
|
|
298
336
|
}}
|
|
299
337
|
className={`flex items-center gap-3 px-4 py-2.5 w-full text-left transition-colors
|
|
300
|
-
${
|
|
301
|
-
|
|
302
|
-
|
|
338
|
+
${
|
|
339
|
+
item.highlight
|
|
340
|
+
? 'bg-yellow-100 text-yellow-900 font-bold hover:bg-yellow-200'
|
|
341
|
+
: 'text-gray-700 hover:bg-gray-50'
|
|
342
|
+
}
|
|
303
343
|
`}
|
|
304
344
|
>
|
|
305
|
-
<item.icon
|
|
345
|
+
<item.icon
|
|
346
|
+
className={`w-4 h-4 ${item.highlight ? 'text-yellow-700' : 'text-gray-500'}`}
|
|
347
|
+
/>
|
|
306
348
|
<span className="text-sm font-medium">{item.label}</span>
|
|
307
349
|
</button>
|
|
308
350
|
);
|
|
@@ -3,10 +3,14 @@
|
|
|
3
3
|
import { usePromise } from '@common/hooks/usePromise';
|
|
4
4
|
import { Chat } from '@promptbook-local/components';
|
|
5
5
|
import { RemoteAgent } from '@promptbook-local/core';
|
|
6
|
+
import { string_book } from '@promptbook-local/types';
|
|
6
7
|
import { useRouter } from 'next/navigation';
|
|
7
|
-
import { useCallback, useMemo } from 'react';
|
|
8
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
8
9
|
import spaceTrim from 'spacetrim';
|
|
9
10
|
import { string_agent_url, string_color } from '../../../../../../src/types/typeAliases';
|
|
11
|
+
import { keepUnused } from '../../../../../../src/utils/organization/keepUnused';
|
|
12
|
+
import { $createAgentFromBookAction } from '../../../app/actions';
|
|
13
|
+
import { DeletedAgentBanner } from '../../../components/DeletedAgentBanner';
|
|
10
14
|
|
|
11
15
|
type AgentProfileChatProps = {
|
|
12
16
|
agentUrl: string_agent_url;
|
|
@@ -14,10 +18,21 @@ type AgentProfileChatProps = {
|
|
|
14
18
|
fullname: string;
|
|
15
19
|
brandColorHex: string_color;
|
|
16
20
|
avatarSrc: string;
|
|
21
|
+
isDeleted?: boolean;
|
|
17
22
|
};
|
|
18
23
|
|
|
19
|
-
export function AgentProfileChat({
|
|
24
|
+
export function AgentProfileChat({
|
|
25
|
+
agentUrl,
|
|
26
|
+
agentName,
|
|
27
|
+
fullname,
|
|
28
|
+
brandColorHex,
|
|
29
|
+
avatarSrc,
|
|
30
|
+
isDeleted = false,
|
|
31
|
+
}: AgentProfileChatProps) {
|
|
20
32
|
const router = useRouter();
|
|
33
|
+
const [isCreatingAgent, setIsCreatingAgent] = useState(false);
|
|
34
|
+
|
|
35
|
+
keepUnused(isCreatingAgent);
|
|
21
36
|
|
|
22
37
|
const agentPromise = useMemo(
|
|
23
38
|
() =>
|
|
@@ -38,6 +53,24 @@ export function AgentProfileChat({ agentUrl, agentName, fullname, brandColorHex,
|
|
|
38
53
|
[agentName, router],
|
|
39
54
|
);
|
|
40
55
|
|
|
56
|
+
const handleCreateAgent = useCallback(
|
|
57
|
+
async (bookContent: string) => {
|
|
58
|
+
setIsCreatingAgent(true);
|
|
59
|
+
try {
|
|
60
|
+
const { permanentId } = await $createAgentFromBookAction(bookContent as string_book);
|
|
61
|
+
if (permanentId) {
|
|
62
|
+
router.push(`/agents/${permanentId}`);
|
|
63
|
+
}
|
|
64
|
+
} catch (error) {
|
|
65
|
+
console.error('Failed to create agent:', error);
|
|
66
|
+
alert('Failed to create agent. Please try again.');
|
|
67
|
+
} finally {
|
|
68
|
+
setIsCreatingAgent(false);
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
[router],
|
|
72
|
+
);
|
|
73
|
+
|
|
41
74
|
const initialMessage = useMemo(() => {
|
|
42
75
|
if (!agent) {
|
|
43
76
|
return 'Loading...';
|
|
@@ -52,6 +85,15 @@ export function AgentProfileChat({ agentUrl, agentName, fullname, brandColorHex,
|
|
|
52
85
|
);
|
|
53
86
|
}, [agent, fullname, agentName]);
|
|
54
87
|
|
|
88
|
+
// If agent is deleted, show banner instead of chat
|
|
89
|
+
if (isDeleted) {
|
|
90
|
+
return (
|
|
91
|
+
<div className="w-full min-h-[350px] md:min-h-[500px] flex items-center justify-center">
|
|
92
|
+
<DeletedAgentBanner message="This agent has been deleted. You can restore it from the Recycle Bin." />
|
|
93
|
+
</div>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
55
97
|
// If agent is not loaded yet, we can show a skeleton or just the default Chat structure
|
|
56
98
|
// But to match "same initial message", we need the agent loaded or at least the default fallback.
|
|
57
99
|
// The fallback above matches AgentChat.tsx default.
|
|
@@ -72,14 +114,15 @@ export function AgentProfileChat({ agentUrl, agentName, fullname, brandColorHex,
|
|
|
72
114
|
]}
|
|
73
115
|
messages={[
|
|
74
116
|
{
|
|
75
|
-
|
|
117
|
+
sender: 'AGENT',
|
|
76
118
|
content: initialMessage,
|
|
77
|
-
|
|
119
|
+
createdAt: new Date(),
|
|
78
120
|
id: 'initial-message',
|
|
79
121
|
isComplete: true,
|
|
80
122
|
},
|
|
81
123
|
]}
|
|
82
124
|
onMessage={handleMessage}
|
|
125
|
+
onCreateAgent={handleCreateAgent}
|
|
83
126
|
isSaveButtonEnabled={false}
|
|
84
127
|
isCopyButtonEnabled={false}
|
|
85
128
|
className="bg-transparent"
|
|
@@ -1,37 +1,79 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { AgentBasicInformation } from '@promptbook-local/types';
|
|
3
|
+
import { AgentBasicInformation, string_agent_name } from '@promptbook-local/types';
|
|
4
4
|
import { AgentProfile } from '../../../components/AgentProfile/AgentProfile';
|
|
5
5
|
import { AgentOptionsMenu } from './AgentOptionsMenu';
|
|
6
6
|
|
|
7
7
|
type AgentProfileWrapperProps = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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 } =
|
|
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;
|
|
62
|
+
const permanentId = agent.permanentId;
|
|
24
63
|
|
|
25
64
|
return (
|
|
26
65
|
<AgentProfile
|
|
27
66
|
agent={agent}
|
|
28
67
|
agentUrl={agentUrl}
|
|
68
|
+
publicUrl={publicUrl}
|
|
69
|
+
permanentId={permanentId || agentName}
|
|
29
70
|
agentEmail={agentEmail}
|
|
30
71
|
isHeadless={isHeadless}
|
|
31
72
|
renderMenu={({ onShowQrCode }) => (
|
|
32
73
|
<AgentOptionsMenu
|
|
33
74
|
agentName={agentName}
|
|
34
75
|
derivedAgentName={derivedAgentName}
|
|
76
|
+
permanentId={permanentId}
|
|
35
77
|
agentUrl={agentUrl}
|
|
36
78
|
agentEmail={agentEmail}
|
|
37
79
|
brandColorHex={brandColorHex}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { $getTableName } from '@/src/database/$getTableName';
|
|
1
2
|
import { $provideAgentCollectionForServer } from '@/src/tools/$provideAgentCollectionForServer';
|
|
2
3
|
import { parseAgentSource } from '@promptbook-local/core';
|
|
4
|
+
import { $provideSupabaseForServer } from '../../../database/$provideSupabaseForServer';
|
|
3
5
|
|
|
4
6
|
export const AGENT_ACTIONS = ['Emails', 'Web chat', 'Read documents', 'Browser', 'WhatsApp', '<Coding/>'];
|
|
5
7
|
|
|
@@ -10,10 +12,28 @@ export async function getAgentName(params: Promise<{ agentName: string }>) {
|
|
|
10
12
|
|
|
11
13
|
export async function getAgentProfile(agentName: string) {
|
|
12
14
|
const collection = await $provideAgentCollectionForServer();
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
+
const agentId = await collection.getAgentPermanentId(agentName);
|
|
16
|
+
const agentSource = await collection.getAgentSource(agentId);
|
|
17
|
+
const agentProfile = parseAgentSource(agentSource);
|
|
18
|
+
return agentProfile;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export async function isAgentDeleted(agentName: string): Promise<boolean> {
|
|
22
|
+
const supabase = $provideSupabaseForServer();
|
|
23
|
+
|
|
24
|
+
const result = await supabase
|
|
25
|
+
.from(await $getTableName(`Agent`))
|
|
26
|
+
.select('deletedAt')
|
|
27
|
+
.eq('agentName', agentName)
|
|
28
|
+
.single();
|
|
29
|
+
|
|
30
|
+
if (result.error || !result.data) {
|
|
31
|
+
return false; // If agent doesn't exist or error, consider not deleted
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return result.data.deletedAt !== null;
|
|
15
35
|
}
|
|
16
36
|
|
|
17
37
|
/**
|
|
18
|
-
* TODO: Split to multiple files
|
|
38
|
+
* TODO: Split to multiple files, refactor
|
|
19
39
|
*/
|