@promptbook/cli 0.112.0-97 → 0.112.0-99

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 (60) hide show
  1. package/apps/agents-server/README.md +3 -3
  2. package/apps/agents-server/src/app/admin/cli-access/CliAccessClient.tsx +99 -0
  3. package/apps/agents-server/src/app/admin/cli-access/page.tsx +14 -0
  4. package/apps/agents-server/src/app/admin/code-runners/CodeRunnersClient.tsx +76 -325
  5. package/apps/agents-server/src/app/admin/database/page.tsx +1 -2
  6. package/apps/agents-server/src/app/agents/[agentName]/chat/CanonicalAgentChatSurface.tsx +24 -0
  7. package/apps/agents-server/src/app/api/admin/cli-access/route.ts +137 -0
  8. package/apps/agents-server/src/app/api/admin/code-runners/authentication/route.ts +7 -64
  9. package/apps/agents-server/src/app/api/admin/servers/[serverId]/route.ts +3 -3
  10. package/apps/agents-server/src/app/api/admin/servers/route.ts +4 -4
  11. package/apps/agents-server/src/app/api/chat/export/pdf/route.ts +63 -0
  12. package/apps/agents-server/src/components/AdminTerminal/AdminTerminalCard.tsx +279 -0
  13. package/apps/agents-server/src/components/AdminTerminal/useAdminTerminalSession.ts +336 -0
  14. package/apps/agents-server/src/components/Header/buildHeaderSystemMenuItems.ts +4 -0
  15. package/apps/agents-server/src/database/$provideClientSql.ts +17 -4
  16. package/apps/agents-server/src/database/$provideDatabaseAdminExecutor.ts +24 -3
  17. package/apps/agents-server/src/database/$provideSupabaseForServer.ts +1 -11
  18. package/apps/agents-server/src/database/agentsServerDatabaseMode.ts +1 -20
  19. package/apps/agents-server/src/languages/ServerTranslationKeys.ts +1 -0
  20. package/apps/agents-server/src/languages/translations/czech.yaml +1 -0
  21. package/apps/agents-server/src/languages/translations/english.yaml +1 -0
  22. package/apps/agents-server/src/tools/$provideServer.ts +2 -2
  23. package/apps/agents-server/src/tools/BrowserConnectionProvider.ts +1 -1
  24. package/apps/agents-server/src/utils/chatExport/downloadChatPdfFromServer.ts +59 -0
  25. package/apps/agents-server/src/utils/chatExport/renderHtmlToPdfOnServer.ts +37 -0
  26. package/apps/agents-server/src/utils/codeRunnerAuthentication.ts +77 -237
  27. package/apps/agents-server/src/utils/createInteractiveTerminalEventStream.ts +84 -0
  28. package/apps/agents-server/src/utils/interactiveTerminalSession.ts +442 -0
  29. package/apps/agents-server/src/utils/serverCliAccess.ts +221 -0
  30. package/apps/agents-server/src/utils/serverRegistry.ts +4 -4
  31. package/apps/agents-server/src/utils/vpsConfiguration.ts +2 -0
  32. package/esm/apps/agents-server/src/database/agentsServerDatabaseMode.d.ts +1 -9
  33. package/esm/index.es.js +2 -2
  34. package/esm/src/book-components/Chat/Chat/ChatActionsBar.d.ts +2 -0
  35. package/esm/src/book-components/Chat/Chat/ChatProps.d.ts +6 -0
  36. package/esm/src/book-components/Chat/save/_common/ChatSaveFormatHandler.d.ts +35 -0
  37. package/esm/src/book-components/Chat/save/_common/createChatExportFilename.d.ts +11 -0
  38. package/esm/src/version.d.ts +1 -1
  39. package/package.json +1 -1
  40. package/src/book-components/Chat/Chat/Chat.tsx +2 -0
  41. package/src/book-components/Chat/Chat/ChatActionsBar.tsx +17 -9
  42. package/src/book-components/Chat/Chat/ChatProps.tsx +7 -0
  43. package/src/book-components/Chat/save/_common/ChatSaveFormatHandler.ts +40 -0
  44. package/src/book-components/Chat/save/_common/createChatExportFilename.ts +20 -0
  45. package/src/cli/cli-commands/agents-server/ensureAgentsServerEnvFile.ts +1 -1
  46. package/src/other/templates/getTemplatesPipelineCollection.ts +706 -736
  47. package/src/version.ts +2 -2
  48. package/src/versions.txt +2 -0
  49. package/umd/apps/agents-server/src/database/agentsServerDatabaseMode.d.ts +1 -9
  50. package/umd/index.umd.js +2 -2
  51. package/umd/src/book-components/Chat/Chat/ChatActionsBar.d.ts +2 -0
  52. package/umd/src/book-components/Chat/Chat/ChatProps.d.ts +6 -0
  53. package/umd/src/book-components/Chat/save/_common/ChatSaveFormatHandler.d.ts +35 -0
  54. package/umd/src/book-components/Chat/save/_common/createChatExportFilename.d.ts +11 -0
  55. package/umd/src/version.d.ts +1 -1
  56. package/apps/agents-server/src/database/$providePostgresPool.ts +0 -27
  57. package/apps/agents-server/src/database/postgres/$provideLocalPostgresSupabase.ts +0 -1261
  58. package/src/conversion/validation/_importPipeline.ts +0 -88
  59. /package/esm/src/conversion/validation/{_importPipeline.d.ts → _importPipeline.test.d.ts} +0 -0
  60. /package/umd/src/conversion/validation/{_importPipeline.d.ts → _importPipeline.test.d.ts} +0 -0
@@ -9,7 +9,7 @@ export declare const AGENTS_SERVER_SQLITE_PATH_ENV_NAME = "PTBK_AGENTS_SERVER_SQ
9
9
  /**
10
10
  * Supported Agents Server database backends.
11
11
  */
12
- export type AgentsServerDatabaseMode = 'supabase' | 'sqlite' | 'postgres';
12
+ export type AgentsServerDatabaseMode = 'supabase' | 'sqlite';
13
13
  /**
14
14
  * Resolves the configured Agents Server database backend.
15
15
  */
@@ -18,11 +18,3 @@ export declare function resolveAgentsServerDatabaseMode(): AgentsServerDatabaseM
18
18
  * Returns whether the Agents Server is using the local SQLite backend.
19
19
  */
20
20
  export declare function isAgentsServerSqliteMode(): boolean;
21
- /**
22
- * Returns whether the Agents Server is using the standalone PostgreSQL backend.
23
- */
24
- export declare function isAgentsServerPostgresMode(): boolean;
25
- /**
26
- * Returns whether the Agents Server is using a standalone local database backend.
27
- */
28
- export declare function isAgentsServerStandaloneMode(): boolean;
package/esm/index.es.js CHANGED
@@ -58,7 +58,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
58
58
  * @generated
59
59
  * @see https://github.com/webgptorg/promptbook
60
60
  */
61
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-97';
61
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-99';
62
62
  /**
63
63
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
64
64
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -2469,7 +2469,7 @@ const AGENTS_SERVER_ENV_DOCUMENTATION_BASE_URL = 'https://github.com/webgptorg/p
2469
2469
  */
2470
2470
  const AGENTS_SERVER_ENV_CREATED_COMMENT = '# Created by `ptbk agents-server init` command';
2471
2471
  /**
2472
- * Variables required for a local Agents Server backed by Supabase, standalone PostgreSQL, or standalone SQLite.
2472
+ * Variables required for a local Agents Server backed by Supabase or standalone SQLite.
2473
2473
  */
2474
2474
  const REQUIRED_AGENTS_SERVER_ENV_VARIABLES = [
2475
2475
  createAgentsServerEnvVariable('PTBK_AGENTS_SERVER_DATABASE', 'supabase'),
@@ -1,5 +1,6 @@
1
1
  import { type MouseEvent, type MutableRefObject, type ReactNode } from 'react';
2
2
  import type { Promisable } from 'type-fest';
3
+ import type { ChatSaveFormatHandlerMap } from '../save/_common/ChatSaveFormatHandler';
3
4
  import type { string_chat_format_name } from '../save/_common/string_chat_format_name';
4
5
  import type { ChatMessage } from '../types/ChatMessage';
5
6
  import type { ChatParticipant } from '../types/ChatParticipant';
@@ -27,6 +28,7 @@ export type ChatActionsBarProps = {
27
28
  onUseTemplate?: () => void;
28
29
  extraActions?: ReactNode;
29
30
  saveFormats?: Array<string_chat_format_name>;
31
+ saveFormatHandlers?: ChatSaveFormatHandlerMap;
30
32
  isSaveButtonEnabled: boolean;
31
33
  shouldFadeActions: boolean;
32
34
  /**
@@ -8,6 +8,7 @@ import type { AgentChipData } from '../AgentChip/AgentChip';
8
8
  import type { string_chat_format_name } from '../save/_common/string_chat_format_name';
9
9
  import type { ChatMessage } from '../types/ChatMessage';
10
10
  import type { ChatParticipant } from '../types/ChatParticipant';
11
+ import type { ChatSaveFormatHandlerMap } from '../save/_common/ChatSaveFormatHandler';
11
12
  /**
12
13
  * Response data returned by the optional `onFeedback` handler.
13
14
  *
@@ -629,6 +630,11 @@ export type ChatProps = {
629
630
  * @default * All supported formats (see `string_chat_format_name` type)
630
631
  */
631
632
  readonly saveFormats?: Array<string_chat_format_name>;
633
+ /**
634
+ * Optional host-provided handlers that replace the default browser download flow
635
+ * for selected save formats.
636
+ */
637
+ readonly saveFormatHandlers?: ChatSaveFormatHandlerMap;
632
638
  /**
633
639
  * Is the writing textarea automatically focused?
634
640
  *
@@ -0,0 +1,35 @@
1
+ import type { Promisable } from 'type-fest';
2
+ import type { ChatMessage } from '../../types/ChatMessage';
3
+ import type { ChatParticipant } from '../../types/ChatParticipant';
4
+ import type { string_chat_format_name } from './string_chat_format_name';
5
+ /**
6
+ * Serializable chat payload exposed to custom save-format handlers.
7
+ *
8
+ * @private Internal helper for chat save integrations.
9
+ */
10
+ export type ChatSaveFormatHandlerOptions = {
11
+ /**
12
+ * Exported chat title used by downstream filename or document generation.
13
+ */
14
+ readonly title: string;
15
+ /**
16
+ * Messages included in the export.
17
+ */
18
+ readonly messages: ReadonlyArray<ChatMessage>;
19
+ /**
20
+ * Participant metadata included in the export.
21
+ */
22
+ readonly participants: ReadonlyArray<ChatParticipant>;
23
+ };
24
+ /**
25
+ * Custom handler used to override one chat save format.
26
+ *
27
+ * @private Internal helper for chat save integrations.
28
+ */
29
+ export type ChatSaveFormatHandler = (options: ChatSaveFormatHandlerOptions) => Promisable<void>;
30
+ /**
31
+ * Optional map of chat save formats handled by the host application.
32
+ *
33
+ * @private Internal helper for chat save integrations.
34
+ */
35
+ export type ChatSaveFormatHandlerMap = Partial<Record<string_chat_format_name, ChatSaveFormatHandler>>;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Builds one normalized filename for a chat export download.
3
+ *
4
+ * @param title - Human-readable chat title.
5
+ * @param fileExtension - Output file extension without a leading dot.
6
+ * @param date - Export date used in the filename.
7
+ * @returns Stable filename suitable for browser downloads and HTTP headers.
8
+ *
9
+ * @private Internal helper shared by chat export flows.
10
+ */
11
+ export declare function createChatExportFilename(title: string, fileExtension: string, date?: Date): string;
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
15
15
  export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
16
16
  /**
17
17
  * Represents the version string of the Promptbook engine.
18
- * It follows semantic versioning (e.g., `0.112.0-96`).
18
+ * It follows semantic versioning (e.g., `0.112.0-98`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/cli",
3
- "version": "0.112.0-97",
3
+ "version": "0.112.0-99",
4
4
  "description": "Promptbook: Create persistent AI agents that turn your company's scattered knowledge into action",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -107,6 +107,7 @@ export function Chat(props: ChatProps) {
107
107
  extraActions,
108
108
  actionsContainer,
109
109
  saveFormats,
110
+ saveFormatHandlers,
110
111
  isSaveButtonEnabled = true,
111
112
  isCopyButtonEnabled = true,
112
113
  buttonColor: buttonColorRaw,
@@ -315,6 +316,7 @@ export function Chat(props: ChatProps) {
315
316
  onUseTemplate={onUseTemplate}
316
317
  extraActions={extraActions}
317
318
  saveFormats={saveFormats}
319
+ saveFormatHandlers={saveFormatHandlers}
318
320
  isSaveButtonEnabled={isSaveButtonEnabled}
319
321
  shouldFadeActions={shouldFadeActions}
320
322
  shouldDisableActions={shouldDisableActions}
@@ -3,11 +3,12 @@
3
3
  import { useCallback, useEffect, useState, type MouseEvent, type MutableRefObject, type ReactNode } from 'react';
4
4
  import { createPortal } from 'react-dom';
5
5
  import type { Promisable } from 'type-fest';
6
- import { normalizeToKebabCase } from '../../../utils/normalization/normalize-to-kebab-case';
7
6
  import { classNames } from '../../_common/react-utils/classNames';
8
7
  import { ResetIcon } from '../../icons/ResetIcon';
9
8
  import { SaveIcon } from '../../icons/SaveIcon';
10
9
  import { TemplateIcon } from '../../icons/TemplateIcon';
10
+ import type { ChatSaveFormatHandlerMap } from '../save/_common/ChatSaveFormatHandler';
11
+ import { createChatExportFilename } from '../save/_common/createChatExportFilename';
11
12
  import { getChatSaveFormatDefinitions } from '../save/_common/getChatSaveFormatDefinitions';
12
13
  import type { string_chat_format_name } from '../save/_common/string_chat_format_name';
13
14
  import type { ChatMessage } from '../types/ChatMessage';
@@ -38,6 +39,7 @@ export type ChatActionsBarProps = {
38
39
  onUseTemplate?: () => void;
39
40
  extraActions?: ReactNode;
40
41
  saveFormats?: Array<string_chat_format_name>;
42
+ saveFormatHandlers?: ChatSaveFormatHandlerMap;
41
43
  isSaveButtonEnabled: boolean;
42
44
  shouldFadeActions: boolean;
43
45
  /**
@@ -71,6 +73,7 @@ export function ChatActionsBar(props: ChatActionsBarProps) {
71
73
  onUseTemplate,
72
74
  extraActions,
73
75
  saveFormats,
76
+ saveFormatHandlers,
74
77
  isSaveButtonEnabled,
75
78
  shouldFadeActions,
76
79
  shouldDisableActions,
@@ -98,23 +101,28 @@ export function ChatActionsBar(props: ChatActionsBarProps) {
98
101
 
99
102
  const handleDownload = useCallback(
100
103
  async (format: string_chat_format_name) => {
104
+ const customSaveFormatHandler = saveFormatHandlers?.[format];
105
+ if (customSaveFormatHandler) {
106
+ await customSaveFormatHandler({
107
+ title,
108
+ messages,
109
+ participants,
110
+ });
111
+ setShowSaveMenu(false);
112
+ return;
113
+ }
114
+
101
115
  const formatDefinition = getChatSaveFormatDefinitions([format])[0];
102
116
  if (!formatDefinition) {
103
117
  return;
104
118
  }
105
119
 
106
- const date = new Date();
107
- const dateName = `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, '0')}-${date
108
- .getDate()
109
- .toString()
110
- .padStart(2, '0')}`;
111
-
112
120
  const content = await formatDefinition.getContent({ title, messages, participants });
113
121
  const blob = new Blob([content], { type: formatDefinition.mimeType });
114
122
  const url = URL.createObjectURL(blob);
115
123
  const link = document.createElement('a');
116
124
  link.href = url;
117
- link.download = `${normalizeToKebabCase(title)}-${dateName}.${formatDefinition.fileExtension}`;
125
+ link.download = createChatExportFilename(title, formatDefinition.fileExtension);
118
126
  document.body.appendChild(link);
119
127
  link.click();
120
128
  setTimeout(() => {
@@ -123,7 +131,7 @@ export function ChatActionsBar(props: ChatActionsBarProps) {
123
131
  }, 100);
124
132
  setShowSaveMenu(false);
125
133
  },
126
- [messages, participants, title],
134
+ [messages, participants, saveFormatHandlers, title],
127
135
  );
128
136
 
129
137
  const firstMessageFromUser = messages[0]?.sender === 'USER';
@@ -12,6 +12,7 @@ import type { AgentChipData } from '../AgentChip/AgentChip';
12
12
  import type { string_chat_format_name } from '../save/_common/string_chat_format_name';
13
13
  import type { ChatMessage } from '../types/ChatMessage';
14
14
  import type { ChatParticipant } from '../types/ChatParticipant';
15
+ import type { ChatSaveFormatHandlerMap } from '../save/_common/ChatSaveFormatHandler';
15
16
 
16
17
  /**
17
18
  * Response data returned by the optional `onFeedback` handler.
@@ -728,6 +729,12 @@ export type ChatProps = {
728
729
  */
729
730
  readonly saveFormats?: Array<string_chat_format_name>;
730
731
 
732
+ /**
733
+ * Optional host-provided handlers that replace the default browser download flow
734
+ * for selected save formats.
735
+ */
736
+ readonly saveFormatHandlers?: ChatSaveFormatHandlerMap;
737
+
731
738
  /**
732
739
  * Is the writing textarea automatically focused?
733
740
  *
@@ -0,0 +1,40 @@
1
+ import type { Promisable } from 'type-fest';
2
+ import type { ChatMessage } from '../../types/ChatMessage';
3
+ import type { ChatParticipant } from '../../types/ChatParticipant';
4
+ import type { string_chat_format_name } from './string_chat_format_name';
5
+
6
+ /**
7
+ * Serializable chat payload exposed to custom save-format handlers.
8
+ *
9
+ * @private Internal helper for chat save integrations.
10
+ */
11
+ export type ChatSaveFormatHandlerOptions = {
12
+ /**
13
+ * Exported chat title used by downstream filename or document generation.
14
+ */
15
+ readonly title: string;
16
+
17
+ /**
18
+ * Messages included in the export.
19
+ */
20
+ readonly messages: ReadonlyArray<ChatMessage>;
21
+
22
+ /**
23
+ * Participant metadata included in the export.
24
+ */
25
+ readonly participants: ReadonlyArray<ChatParticipant>;
26
+ };
27
+
28
+ /**
29
+ * Custom handler used to override one chat save format.
30
+ *
31
+ * @private Internal helper for chat save integrations.
32
+ */
33
+ export type ChatSaveFormatHandler = (options: ChatSaveFormatHandlerOptions) => Promisable<void>;
34
+
35
+ /**
36
+ * Optional map of chat save formats handled by the host application.
37
+ *
38
+ * @private Internal helper for chat save integrations.
39
+ */
40
+ export type ChatSaveFormatHandlerMap = Partial<Record<string_chat_format_name, ChatSaveFormatHandler>>;
@@ -0,0 +1,20 @@
1
+ import { normalizeToKebabCase } from '../../../../utils/normalization/normalize-to-kebab-case';
2
+
3
+ /**
4
+ * Builds one normalized filename for a chat export download.
5
+ *
6
+ * @param title - Human-readable chat title.
7
+ * @param fileExtension - Output file extension without a leading dot.
8
+ * @param date - Export date used in the filename.
9
+ * @returns Stable filename suitable for browser downloads and HTTP headers.
10
+ *
11
+ * @private Internal helper shared by chat export flows.
12
+ */
13
+ export function createChatExportFilename(title: string, fileExtension: string, date = new Date()): string {
14
+ const dateName = `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, '0')}-${date
15
+ .getDate()
16
+ .toString()
17
+ .padStart(2, '0')}`;
18
+
19
+ return `${normalizeToKebabCase(title)}-${dateName}.${fileExtension}`;
20
+ }
@@ -26,7 +26,7 @@ const AGENTS_SERVER_ENV_DOCUMENTATION_BASE_URL =
26
26
  const AGENTS_SERVER_ENV_CREATED_COMMENT = '# Created by `ptbk agents-server init` command';
27
27
 
28
28
  /**
29
- * Variables required for a local Agents Server backed by Supabase, standalone PostgreSQL, or standalone SQLite.
29
+ * Variables required for a local Agents Server backed by Supabase or standalone SQLite.
30
30
  */
31
31
  const REQUIRED_AGENTS_SERVER_ENV_VARIABLES: ReadonlyArray<RequiredAgentsServerEnvVariable> = [
32
32
  createAgentsServerEnvVariable('PTBK_AGENTS_SERVER_DATABASE', 'supabase'),