@promptbook/cli 0.112.0-96 → 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 (79) hide show
  1. package/apps/agents-server/playwright.config.ts +2 -1
  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 +124 -34
  5. package/apps/agents-server/src/app/admin/servers/CreateServerDialog.tsx +46 -505
  6. package/apps/agents-server/src/app/admin/servers/ServersClient.tsx +23 -11
  7. package/apps/agents-server/src/app/admin/servers/ServersRegistryApi.ts +5 -0
  8. package/apps/agents-server/src/app/admin/servers/ServersRegistryDnsTypes.ts +87 -0
  9. package/apps/agents-server/src/app/admin/servers/ServersRegistryTable.tsx +258 -128
  10. package/apps/agents-server/src/app/admin/servers/useCreateServerWizard.ts +46 -334
  11. package/apps/agents-server/src/app/admin/servers/useServersRegistryState.ts +26 -2
  12. package/apps/agents-server/src/app/admin/update/UpdateClient.tsx +435 -0
  13. package/apps/agents-server/src/app/admin/update/page.tsx +14 -0
  14. package/apps/agents-server/src/app/agents/[agentName]/chat/CanonicalAgentChatSurface.tsx +24 -0
  15. package/apps/agents-server/src/app/api/admin/cli-access/route.ts +137 -0
  16. package/apps/agents-server/src/app/api/admin/code-runners/authentication/route.ts +140 -0
  17. package/apps/agents-server/src/app/api/admin/code-runners/route.ts +4 -35
  18. package/apps/agents-server/src/app/api/admin/servers/[serverId]/route.ts +7 -2
  19. package/apps/agents-server/src/app/api/admin/servers/route.ts +95 -4
  20. package/apps/agents-server/src/app/api/admin/update/route.ts +52 -0
  21. package/apps/agents-server/src/app/api/auth/login/route.ts +8 -0
  22. package/apps/agents-server/src/app/api/auth/logout/route.ts +10 -2
  23. package/apps/agents-server/src/app/api/chat/export/pdf/route.ts +63 -0
  24. package/apps/agents-server/src/app/page.tsx +10 -0
  25. package/apps/agents-server/src/components/AdminTerminal/AdminTerminalCard.tsx +279 -0
  26. package/apps/agents-server/src/components/AdminTerminal/useAdminTerminalSession.ts +336 -0
  27. package/apps/agents-server/src/components/Header/buildHeaderSystemMenuItems.ts +10 -0
  28. package/apps/agents-server/src/languages/ServerTranslationKeys.ts +2 -0
  29. package/apps/agents-server/src/languages/translations/czech.yaml +2 -0
  30. package/apps/agents-server/src/languages/translations/english.yaml +2 -0
  31. package/apps/agents-server/src/middleware.ts +32 -0
  32. package/apps/agents-server/src/tools/BrowserConnectionProvider.ts +1 -1
  33. package/apps/agents-server/src/utils/chatExport/downloadChatPdfFromServer.ts +59 -0
  34. package/apps/agents-server/src/utils/chatExport/renderHtmlToPdfOnServer.ts +37 -0
  35. package/apps/agents-server/src/utils/codeRunnerAuthentication.ts +234 -0
  36. package/apps/agents-server/src/utils/codeRunnerConfiguration.ts +67 -0
  37. package/apps/agents-server/src/utils/createInteractiveTerminalEventStream.ts +84 -0
  38. package/apps/agents-server/src/utils/interactiveTerminalSession.ts +442 -0
  39. package/apps/agents-server/src/utils/serverCliAccess.ts +221 -0
  40. package/apps/agents-server/src/utils/serverManagement/standaloneVpsServerMetadata.ts +145 -0
  41. package/apps/agents-server/src/utils/serverRegistry.ts +3 -2
  42. package/apps/agents-server/src/utils/session.ts +37 -9
  43. package/apps/agents-server/src/utils/shibboleth/createShibbolethAuthenticationLogPayload.ts +173 -0
  44. package/apps/agents-server/src/utils/shibboleth/writeShibbolethAuthenticationLog.ts +27 -0
  45. package/apps/agents-server/src/utils/standaloneVpsDnsDiagnostics.ts +258 -0
  46. package/apps/agents-server/src/utils/standaloneVpsRawIpBootstrap.ts +87 -0
  47. package/apps/agents-server/src/utils/vpsConfiguration.ts +87 -13
  48. package/apps/agents-server/src/utils/vpsSelfUpdate.ts +664 -0
  49. package/esm/apps/agents-server/src/utils/serverRegistry.d.ts +1 -1
  50. package/esm/index.es.js +7 -5
  51. package/esm/index.es.js.map +1 -1
  52. package/esm/src/book-components/Chat/Chat/ChatActionsBar.d.ts +2 -0
  53. package/esm/src/book-components/Chat/Chat/ChatProps.d.ts +6 -0
  54. package/esm/src/book-components/Chat/save/_common/ChatSaveFormatHandler.d.ts +35 -0
  55. package/esm/src/book-components/Chat/save/_common/createChatExportFilename.d.ts +11 -0
  56. package/esm/src/version.d.ts +1 -1
  57. package/package.json +1 -1
  58. package/src/book-components/Chat/Chat/Chat.tsx +2 -0
  59. package/src/book-components/Chat/Chat/ChatActionsBar.tsx +17 -9
  60. package/src/book-components/Chat/Chat/ChatProps.tsx +7 -0
  61. package/src/book-components/Chat/save/_common/ChatSaveFormatHandler.ts +40 -0
  62. package/src/book-components/Chat/save/_common/createChatExportFilename.ts +20 -0
  63. package/src/book-components/Chat/utils/renderMarkdown.ts +1 -3
  64. package/src/other/templates/getTemplatesPipelineCollection.ts +718 -790
  65. package/src/scrapers/document/DocumentScraper.ts +1 -1
  66. package/src/scrapers/document-legacy/LegacyDocumentScraper.ts +1 -1
  67. package/src/version.ts +2 -2
  68. package/src/versions.txt +2 -0
  69. package/umd/apps/agents-server/src/utils/serverRegistry.d.ts +1 -1
  70. package/umd/index.umd.js +7 -5
  71. package/umd/index.umd.js.map +1 -1
  72. package/umd/src/book-components/Chat/Chat/ChatActionsBar.d.ts +2 -0
  73. package/umd/src/book-components/Chat/Chat/ChatProps.d.ts +6 -0
  74. package/umd/src/book-components/Chat/save/_common/ChatSaveFormatHandler.d.ts +35 -0
  75. package/umd/src/book-components/Chat/save/_common/createChatExportFilename.d.ts +11 -0
  76. package/umd/src/version.d.ts +1 -1
  77. package/src/conversion/validation/_importPipeline.ts +0 -88
  78. /package/esm/src/conversion/validation/{_importPipeline.d.ts → _importPipeline.test.d.ts} +0 -0
  79. /package/umd/src/conversion/validation/{_importPipeline.d.ts → _importPipeline.test.d.ts} +0 -0
@@ -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-94`).
18
+ * It follows semantic versioning (e.g., `0.112.0-97`).
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-96",
3
+ "version": "0.112.0-98",
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
+ }
@@ -311,9 +311,7 @@ function normalizeSanitizedUrlValue(value: string): string {
311
311
  .filter((character) => {
312
312
  const characterCode = character.charCodeAt(0);
313
313
 
314
- return (
315
- characterCode > MAX_ASCII_CONTROL_CHARACTER_CODE && characterCode !== ASCII_DELETE_CHARACTER_CODE
316
- );
314
+ return characterCode > MAX_ASCII_CONTROL_CHARACTER_CODE && characterCode !== ASCII_DELETE_CHARACTER_CODE;
317
315
  })
318
316
  .join('');
319
317
  }