@promptbook/cli 0.112.0-97 → 0.112.0-98

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 +721 -736
  47. package/src/version.ts +2 -2
  48. package/src/versions.txt +1 -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
package/src/version.ts CHANGED
@@ -16,11 +16,11 @@ export const BOOK_LANGUAGE_VERSION: string_semantic_version = '2.0.0';
16
16
  * @generated
17
17
  * @see https://github.com/webgptorg/promptbook
18
18
  */
19
- export const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version = '0.112.0-97';
19
+ export const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version = '0.112.0-98';
20
20
 
21
21
  /**
22
22
  * Represents the version string of the Promptbook engine.
23
- * It follows semantic versioning (e.g., `0.112.0-96`).
23
+ * It follows semantic versioning (e.g., `0.112.0-97`).
24
24
  *
25
25
  * @generated
26
26
  */
package/src/versions.txt CHANGED
@@ -1132,3 +1132,4 @@
1132
1132
  0.112.0-94
1133
1133
  0.112.0-96
1134
1134
  0.112.0-97
1135
+ 0.112.0-98
@@ -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/umd/index.umd.js CHANGED
@@ -60,7 +60,7 @@
60
60
  * @generated
61
61
  * @see https://github.com/webgptorg/promptbook
62
62
  */
63
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-97';
63
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-98';
64
64
  /**
65
65
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
66
66
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -2471,7 +2471,7 @@
2471
2471
  */
2472
2472
  const AGENTS_SERVER_ENV_CREATED_COMMENT = '# Created by `ptbk agents-server init` command';
2473
2473
  /**
2474
- * Variables required for a local Agents Server backed by Supabase, standalone PostgreSQL, or standalone SQLite.
2474
+ * Variables required for a local Agents Server backed by Supabase or standalone SQLite.
2475
2475
  */
2476
2476
  const REQUIRED_AGENTS_SERVER_ENV_VARIABLES = [
2477
2477
  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-97`).
19
19
  *
20
20
  * @generated
21
21
  */
@@ -1,27 +0,0 @@
1
- import { Pool } from 'pg';
2
- import { resolvePostgresConnectionString } from './resolvePostgresConnectionString';
3
-
4
- /**
5
- * Shared PostgreSQL pool reused across the Agents Server process.
6
- *
7
- * @private internal singleton of Agents Server database layer
8
- */
9
- let postgresPool: Pool | null = null;
10
-
11
- /**
12
- * Provides the shared PostgreSQL pool used by raw SQL helpers and local PostgreSQL adapters.
13
- *
14
- * @returns Shared PostgreSQL pool.
15
- *
16
- * @private exported from Agents Server database utilities
17
- */
18
- export function $providePostgresPool(): Pool {
19
- if (!postgresPool) {
20
- postgresPool = new Pool({
21
- connectionString: resolvePostgresConnectionString(),
22
- ssl: { rejectUnauthorized: false },
23
- });
24
- }
25
-
26
- return postgresPool;
27
- }