@promptbook/cli 0.112.0-103 → 0.112.0-105

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 (190) hide show
  1. package/apps/agents-server/src/app/AddAgentButton.tsx +0 -5
  2. package/apps/agents-server/src/app/actions.ts +50 -0
  3. package/apps/agents-server/src/app/admin/image-generator-test/ImageAttachmentsEditor.tsx +19 -3
  4. package/apps/agents-server/src/app/admin/limits/LimitsClient.tsx +11 -12
  5. package/apps/agents-server/src/app/admin/metadata/MetadataClient.tsx +34 -2
  6. package/apps/agents-server/src/app/admin/servers/CreateServerDialog.tsx +6 -1
  7. package/apps/agents-server/src/app/admin/servers/useCreateServerWizard.ts +13 -1
  8. package/apps/agents-server/src/app/agents/[agentName]/AgentChatWrapper.tsx +11 -2
  9. package/apps/agents-server/src/app/agents/[agentName]/AgentProfileChat.tsx +14 -5
  10. package/apps/agents-server/src/app/agents/[agentName]/book/BookEditorWrapper.tsx +7 -1
  11. package/apps/agents-server/src/app/agents/[agentName]/chat/CanonicalAgentChatSurface.tsx +11 -1
  12. package/apps/agents-server/src/app/agents/[agentName]/images/default-avatar.png/route.ts +6 -2
  13. package/apps/agents-server/src/app/api/health/route.ts +18 -0
  14. package/apps/agents-server/src/app/api/images/[filename]/route.ts +6 -2
  15. package/apps/agents-server/src/app/api/internal/agent-runner-limits/route.ts +51 -0
  16. package/apps/agents-server/src/app/api/upload/route.ts +48 -12
  17. package/apps/agents-server/src/app/layout.tsx +13 -0
  18. package/apps/agents-server/src/components/AgentProfile/AgentProfile.tsx +1 -4
  19. package/apps/agents-server/src/components/FileUploadAvailability/FileUploadAvailabilityContext.tsx +50 -0
  20. package/apps/agents-server/src/components/FileUploadAvailability/FileUploadUnavailableNotice.tsx +45 -0
  21. package/apps/agents-server/src/components/Header/Header.tsx +0 -11
  22. package/apps/agents-server/src/components/Header/useHeaderAgentMenus.tsx +0 -5
  23. package/apps/agents-server/src/components/LayoutWrapper/LayoutWrapper.tsx +85 -76
  24. package/apps/agents-server/src/components/NewAgentDialog/NewAgentDialog.tsx +7 -3
  25. package/apps/agents-server/src/components/NewAgentDialog/NewAgentWizardKnowledgeStep.tsx +6 -0
  26. package/apps/agents-server/src/components/NewAgentDialog/useNewAgentDialog.tsx +39 -16
  27. package/apps/agents-server/src/components/NewAgentDialog/useNewAgentWizardKnowledgeState.ts +8 -1
  28. package/apps/agents-server/src/constants/defaultAgentAvatarVisual.ts +1 -1
  29. package/apps/agents-server/src/constants/serverLimits.ts +22 -2
  30. package/apps/agents-server/src/database/migrations/2026-06-0200-default-agent-avatar-visual-octopus3d3.sql +16 -0
  31. package/apps/agents-server/src/database/seedDefaultAgents.ts +218 -0
  32. package/apps/agents-server/src/middleware.ts +2 -1
  33. package/apps/agents-server/src/tools/$provideCdnForServer.ts +114 -9
  34. package/apps/agents-server/src/utils/agentRouting/resolveAgentRouteTarget.ts +27 -4
  35. package/apps/agents-server/src/utils/defaultAgents/loadDefaultAgentBooks.ts +103 -0
  36. package/apps/agents-server/src/utils/knowledge/createInlineKnowledgeSourceUploader.ts +24 -5
  37. package/apps/agents-server/src/utils/serverLimits.ts +26 -1
  38. package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerDefaultAgents.ts +1 -85
  39. package/apps/agents-server/src/utils/shareTargetPayloads.ts +20 -2
  40. package/apps/agents-server/src/utils/upload/fileUploadAvailability.ts +91 -0
  41. package/apps/agents-server/src/utils/upload/uploadFileToServer.ts +46 -2
  42. package/esm/apps/agents-server/src/constants/federatedAgentImport.d.ts +42 -0
  43. package/esm/apps/agents-server/src/constants/serverLimits.d.ts +207 -0
  44. package/esm/apps/agents-server/src/constants/toolUsageLimits.d.ts +55 -0
  45. package/esm/index.es.js +1109 -35
  46. package/esm/index.es.js.map +1 -1
  47. package/esm/scripts/run-agent-messages/main/AgentMessageFailureTracker.d.ts +27 -0
  48. package/esm/scripts/run-agent-messages/main/handleAgentWatchError.d.ts +4 -0
  49. package/esm/scripts/run-agent-messages/main/runAgentMessages.d.ts +1 -0
  50. package/esm/scripts/run-agent-messages/messages/moveAgentMessageToFailed.d.ts +17 -0
  51. package/esm/src/avatars/types/AvatarVisualDefinition.d.ts +1 -1
  52. package/esm/src/avatars/visuals/octopus3d3AvatarVisual.d.ts +7 -0
  53. package/esm/src/book-components/BookEditor/BookEditor.d.ts +5 -4
  54. package/esm/src/book-components/BookEditor/BookEditorTheme.d.ts +24 -0
  55. package/esm/src/book-components/BookEditor/useBookEditorMonacoLanguage.d.ts +1 -6
  56. package/esm/src/book-components/BookEditor/useBookEditorMonacoLifecycle.d.ts +1 -4
  57. package/esm/src/book-components/BookEditor/useBookEditorMonacoStyles.d.ts +2 -1
  58. package/esm/src/cli/cli-commands/agent-folder/agentProjectPaths.d.ts +6 -0
  59. package/esm/src/version.d.ts +1 -1
  60. package/package.json +1 -1
  61. package/src/avatars/types/AvatarVisualDefinition.ts +1 -0
  62. package/src/avatars/visuals/avatarVisualRegistry.ts +2 -0
  63. package/src/avatars/visuals/octopus3d3AvatarVisual.ts +902 -0
  64. package/src/book-components/BookEditor/BookEditor.tsx +10 -7
  65. package/src/book-components/BookEditor/BookEditorMonaco.tsx +3 -1
  66. package/src/book-components/BookEditor/BookEditorTheme.ts +32 -0
  67. package/src/book-components/BookEditor/useBookEditorMonacoLanguage.ts +12 -15
  68. package/src/book-components/BookEditor/useBookEditorMonacoLifecycle.ts +1 -5
  69. package/src/book-components/BookEditor/useBookEditorMonacoStyles.ts +2 -1
  70. package/src/cli/cli-commands/agent-folder/agentProjectPaths.ts +7 -0
  71. package/src/cli/cli-commands/agents-server/buildAgentsServer.ts +109 -9
  72. package/src/cli/cli-commands/agents-server/startAgentsServer.ts +132 -4
  73. package/src/other/templates/getTemplatesPipelineCollection.ts +690 -747
  74. package/src/utils/agents/resolveAgentAvatarImageUrl.ts +1 -1
  75. package/src/version.ts +2 -2
  76. package/src/versions.txt +2 -1
  77. package/umd/apps/agents-server/src/constants/federatedAgentImport.d.ts +42 -0
  78. package/umd/apps/agents-server/src/constants/serverLimits.d.ts +207 -0
  79. package/umd/apps/agents-server/src/constants/toolUsageLimits.d.ts +55 -0
  80. package/umd/index.umd.js +1109 -35
  81. package/umd/index.umd.js.map +1 -1
  82. package/umd/scripts/run-agent-messages/main/AgentMessageFailureTracker.d.ts +27 -0
  83. package/umd/scripts/run-agent-messages/main/handleAgentWatchError.d.ts +4 -0
  84. package/umd/scripts/run-agent-messages/main/runAgentMessages.d.ts +1 -0
  85. package/umd/scripts/run-agent-messages/messages/moveAgentMessageToFailed.d.ts +17 -0
  86. package/umd/src/avatars/types/AvatarVisualDefinition.d.ts +1 -1
  87. package/umd/src/avatars/visuals/octopus3d3AvatarVisual.d.ts +7 -0
  88. package/umd/src/book-components/BookEditor/BookEditor.d.ts +5 -4
  89. package/umd/src/book-components/BookEditor/BookEditorTheme.d.ts +24 -0
  90. package/umd/src/book-components/BookEditor/useBookEditorMonacoLanguage.d.ts +1 -6
  91. package/umd/src/book-components/BookEditor/useBookEditorMonacoLifecycle.d.ts +1 -4
  92. package/umd/src/book-components/BookEditor/useBookEditorMonacoStyles.d.ts +2 -1
  93. package/umd/src/cli/cli-commands/agent-folder/agentProjectPaths.d.ts +6 -0
  94. package/umd/src/version.d.ts +1 -1
  95. package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddress.test.ts.todo +0 -108
  96. package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddresses.test.ts.todo +0 -117
  97. package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddress.test.ts.todo +0 -119
  98. package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddresses.test.ts.todo +0 -74
  99. package/apps/agents-server/tests/e2e/authentication-and-navigation.spec.ts.todo +0 -178
  100. package/src/_packages/browser.index.ts +0 -31
  101. package/src/_packages/browser.readme.md +0 -43
  102. package/src/book-2.0/agent-source/parseAgentSourceWithCommitments.test.ts.todo +0 -265
  103. package/src/book-components/BookEditor/BookEditorMonaco.test.tsx.todo +0 -115
  104. package/src/book-components/Chat/utils/renderMarkdown.test.ts.tmp +0 -199
  105. package/src/collection/agent-collection/constructors/agent-collection-in-directory/AgentCollectionInDirectory.test.ts.todo +0 -131
  106. package/src/commands/_common/parseCommand.test.ts.todo +0 -48
  107. package/src/commitments/META_LINK/META_LINK.test.ts.todo +0 -75
  108. package/src/conversion/validation/pipelineStringToJson-errors.test.ts.todo +0 -33
  109. package/src/dialogs/simple-prompt/SimplePromptInterfaceTools.ts +0 -51
  110. package/src/executables/browsers/locateSafari.test.ts.tmp +0 -15
  111. package/src/execution/PromptbookFetch.test-type.ts +0 -14
  112. package/src/execution/createPipelineExecutor/00-createPipelineExecutor.test.ts.todo +0 -0
  113. package/src/execution/execution-report/executionReportJsonToString.test.ts.todo +0 -83
  114. package/src/execution/utils/usageToHuman.test.ts.todo +0 -80
  115. package/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.ts +0 -76
  116. package/src/llm-providers/_common/utils/assertUniqueModels.ts +0 -27
  117. package/src/llm-providers/_multiple/playground/playground.ts +0 -141
  118. package/src/llm-providers/_multiple/playground/tsconfig.json +0 -19
  119. package/src/llm-providers/agent/playground/playground.ts +0 -190
  120. package/src/llm-providers/agent/playground/tsconfig.json +0 -19
  121. package/src/llm-providers/anthropic-claude/playground/playground.ts +0 -99
  122. package/src/llm-providers/anthropic-claude/playground/tsconfig.json +0 -19
  123. package/src/llm-providers/azure-openai/playground/playground.ts +0 -101
  124. package/src/llm-providers/azure-openai/playground/tsconfig.json +0 -19
  125. package/src/llm-providers/ollama/playground/playground.ts +0 -120
  126. package/src/llm-providers/ollama/playground/tsconfig.json +0 -19
  127. package/src/llm-providers/openai/playground/playground.ts +0 -406
  128. package/src/llm-providers/openai/playground/tsconfig.json +0 -19
  129. package/src/llm-providers/remote/playground/playground.ts +0 -144
  130. package/src/llm-providers/remote/playground/tsconfig.json +0 -19
  131. package/src/llm-providers/vercel/playground/playground.ts +0 -133
  132. package/src/llm-providers/vercel/playground/tsconfig.json +0 -19
  133. package/src/personas/preparePersona.test.ts.todo +0 -126
  134. package/src/playground/backup/_playground-boilerplate.ts.txt +0 -37
  135. package/src/playground/backup/playground-agent-os.txt +0 -62
  136. package/src/playground/backup/playground-brj-app.ts.txt +0 -302
  137. package/src/playground/backup/playground-browser-playwright.txt +0 -110
  138. package/src/playground/backup/playground-claude-mcp.txt +0 -43
  139. package/src/playground/backup/playground-document-conversion.txt +0 -84
  140. package/src/playground/backup/playground-glob.ts.txt +0 -42
  141. package/src/playground/backup/playground-mcp-server.txt +0 -1
  142. package/src/playground/backup/playground-openai-agent-kit.txt +0 -73
  143. package/src/playground/backup/playground-openai-function-calling.txt +0 -131
  144. package/src/playground/backup/playground-openai-streaming.ts.txt +0 -68
  145. package/src/playground/backup/playground-scrape-knowledge.txt +0 -65
  146. package/src/playground/backup/playground-scraperFetch.ts.txt +0 -44
  147. package/src/playground/backup/playground-using-openai-compatible-route-on-agents-server.ts.txt +0 -49
  148. package/src/playground/backup/playground-write-pavolhejny-bio.txt +0 -120
  149. package/src/playground/permanent/_boilerplate.ts +0 -54
  150. package/src/playground/permanent/agent-with-browser-playground.ts +0 -92
  151. package/src/playground/permanent/error-handling-playground.ts +0 -103
  152. package/src/playground/playground.ts +0 -36
  153. package/src/playground/tsconfig.json +0 -19
  154. package/src/scrapers/_boilerplate/BoilerplateScraper.test.ts.todo +0 -73
  155. package/src/scrapers/_boilerplate/playground/boilerplate-scraper-playground.ts +0 -79
  156. package/src/scrapers/_boilerplate/playground/tsconfig.json +0 -19
  157. package/src/scrapers/_common/utils/files/blobToDataurl.test.ts.todo +0 -17
  158. package/src/scrapers/_common/utils/files/dataurlToBlob.test.ts.todo +0 -52
  159. package/src/scrapers/_common/utils/files/isValidDataurl.test.ts.todo +0 -42
  160. package/src/scrapers/_common/utils/files/shorten.test.ts.todo +0 -13
  161. package/src/scrapers/document/playground/document-scraper-playground.ts +0 -80
  162. package/src/scrapers/document/playground/tsconfig.json +0 -19
  163. package/src/scrapers/document-legacy/playground/legacy-document-scraper-playground.ts +0 -80
  164. package/src/scrapers/document-legacy/playground/tsconfig.json +0 -19
  165. package/src/scrapers/markdown/playground/markdown-scraper-playground.ts +0 -74
  166. package/src/scrapers/markdown/playground/tsconfig.json +0 -19
  167. package/src/scrapers/markitdown/MarkitdownScraper.test.ts.todo +0 -132
  168. package/src/scrapers/markitdown/playground/markitdown-scraper-playground.ts +0 -91
  169. package/src/scrapers/markitdown/playground/tsconfig.json +0 -19
  170. package/src/scrapers/pdf/PdfScraper.test.ts.todo +0 -52
  171. package/src/scrapers/pdf/playground/pdf-scraper-playground.ts +0 -75
  172. package/src/scrapers/pdf/playground/tsconfig.json +0 -19
  173. package/src/scrapers/website/playground/tsconfig.json +0 -19
  174. package/src/scrapers/website/playground/website-scraper-playground.ts +0 -82
  175. package/src/storage/_common/PromptbookStorage.test-type.ts +0 -14
  176. package/src/storage/local-storage/getIndexedDbStorage.ts +0 -36
  177. package/src/storage/local-storage/getLocalStorage.ts +0 -33
  178. package/src/storage/local-storage/getSessionStorage.ts +0 -33
  179. package/src/storage/local-storage/utils/IndexedDbStorageOptions.ts +0 -16
  180. package/src/storage/local-storage/utils/makePromptbookStorageFromIndexedDb.ts +0 -58
  181. package/src/storage/local-storage/utils/makePromptbookStorageFromWebStorage.ts +0 -45
  182. package/src/transpilers/formatted-book-in-markdown/FormattedBookInMarkdownTranspiler.test.ts.todo +0 -35
  183. package/src/transpilers/openai-sdk/playground/playground.ts +0 -85
  184. package/src/transpilers/openai-sdk/playground/tmp/chatbot-openaisdk-1.js +0 -194
  185. package/src/transpilers/openai-sdk/playground/tmp/package.json +0 -3
  186. package/src/transpilers/openai-sdk/playground/tsconfig.json +0 -18
  187. package/src/utils/editable/utils/findUsableParameters.test.ts.todo +0 -43
  188. package/src/utils/editable/utils/stringifyPipelineJson.test.ts.todo +0 -38
  189. package/src/utils/markdown/prettifyMarkdown.test.ts.tmp +0 -42
  190. package/src/utils/serialization/serializeToPromptbookJavascript.test.ts.todo +0 -116
@@ -17,6 +17,8 @@ import type { HoistedMenuItem } from '../_common/MenuHoisting/MenuHoistingContex
17
17
  import { classNames } from '../_common/react-utils/classNames';
18
18
  import styles from './BookEditor.module.css';
19
19
  import { BookEditorMonaco } from './BookEditorMonaco';
20
+ import type { BookEditorTheme } from './BookEditorTheme';
21
+ import { BOOK_EDITOR_RENDER_THEME, resolveBookEditorRenderTheme } from './BookEditorTheme';
20
22
 
21
23
  /**
22
24
  * Monaco diagnostic shown inside `BookEditor`.
@@ -123,14 +125,14 @@ export type BookEditorProps = {
123
125
  readonly style?: CSSProperties;
124
126
 
125
127
  /**
126
- * Resolved visual theme used for the editor wrapper and Monaco instance.
128
+ * Resolved host application theme.
127
129
  *
128
- * Host applications should pass the final light/dark theme instead of relying on
129
- * browser media-query inference inside `<BookEditor/>`.
130
+ * `<BookEditor/>` accepts this for integration compatibility, but the notebook
131
+ * editor itself is intentionally rendered as light paper in every app theme.
130
132
  *
131
133
  * @default 'LIGHT'
132
134
  */
133
- readonly theme?: 'LIGHT' | 'DARK';
135
+ readonly theme?: BookEditorTheme;
134
136
 
135
137
  /**
136
138
  * Height of the `BookEditor` component
@@ -288,7 +290,7 @@ export function BookEditor(props: BookEditorProps) {
288
290
  agentSource,
289
291
  className,
290
292
  style,
291
- theme = 'LIGHT',
293
+ theme: hostTheme = BOOK_EDITOR_RENDER_THEME,
292
294
  zoom = 1,
293
295
  value,
294
296
  onChange,
@@ -309,6 +311,7 @@ export function BookEditor(props: BookEditorProps) {
309
311
  } = props;
310
312
 
311
313
  const [isFullscreen, setIsFullscreen] = useState(false);
314
+ const renderedTheme = resolveBookEditorRenderTheme(hostTheme);
312
315
 
313
316
  /**
314
317
  * Toggles fullscreen mode for the editor.
@@ -320,7 +323,7 @@ export function BookEditor(props: BookEditorProps) {
320
323
  const editorContent = (
321
324
  <div
322
325
  data-book-component="BookEditor"
323
- data-book-editor-theme={theme.toLowerCase()}
326
+ data-book-editor-theme={renderedTheme.toLowerCase()}
324
327
  className={classNames(
325
328
  styles.BookEditor,
326
329
  isVerbose && styles.isVerbose,
@@ -365,7 +368,7 @@ export function BookEditor(props: BookEditorProps) {
365
368
  zoom={zoom}
366
369
  monacoModelPath={monacoModelPath}
367
370
  hoistedMenuItems={hoistedMenuItems}
368
- theme={theme}
371
+ theme={renderedTheme}
369
372
  />
370
373
  </div>
371
374
  );
@@ -12,6 +12,7 @@ import type { BookEditorProps } from './BookEditor';
12
12
  import styles from './BookEditor.module.css';
13
13
  import { BookEditorActionbar } from './BookEditorActionbar';
14
14
  import { BookEditorMonacoConstants } from './BookEditorMonacoConstants';
15
+ import { BOOK_EDITOR_RENDER_THEME, resolveBookEditorRenderTheme } from './BookEditorTheme';
15
16
  import { createDeprecatedCommitmentDiagnostics } from './createDeprecatedCommitmentDiagnostics';
16
17
  import { useBookEditorMonacoDecorations } from './useBookEditorMonacoDecorations';
17
18
  import { useBookEditorMonacoDiagnostics } from './useBookEditorMonacoDiagnostics';
@@ -204,7 +205,7 @@ export function BookEditorMonaco(props: BookEditorProps) {
204
205
  onChange,
205
206
  diagnostics,
206
207
  isReadonly,
207
- theme = 'LIGHT',
208
+ theme: hostTheme = BOOK_EDITOR_RENDER_THEME,
208
209
  translations,
209
210
  onFileUpload,
210
211
  isUploadButtonShown,
@@ -219,6 +220,7 @@ export function BookEditorMonaco(props: BookEditorProps) {
219
220
  hoistedMenuItems,
220
221
  } = props;
221
222
 
223
+ const theme = resolveBookEditorRenderTheme(hostTheme);
222
224
  const zoomLevel = zoom;
223
225
  const { scaledLineHeight, scaledContentPaddingLeft, scaledVerticalLineLeft, scaledFontSize, scaledScrollbarSize } =
224
226
  createBookEditorMonacoScale(zoomLevel);
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Visual theme accepted by `<BookEditor/>` integrations.
3
+ *
4
+ * @private internal type of `BookEditor`
5
+ */
6
+ export type BookEditorTheme = 'LIGHT' | 'DARK';
7
+
8
+ /**
9
+ * Theme used for the actual notebook editor surface.
10
+ *
11
+ * The host application can still pass its resolved app theme, but book sources
12
+ * are intentionally rendered as light paper in both light and dark app modes.
13
+ *
14
+ * @private internal constant of `BookEditor`
15
+ */
16
+ export const BOOK_EDITOR_RENDER_THEME = 'LIGHT' satisfies BookEditorTheme;
17
+
18
+ /**
19
+ * Resolves an app-level theme into the visual theme used by `<BookEditor/>`.
20
+ *
21
+ * @param hostTheme - Resolved theme from the embedding application.
22
+ * @returns Light theme used by the Book editor surface.
23
+ *
24
+ * @private internal utility of `BookEditor`
25
+ */
26
+ export function resolveBookEditorRenderTheme(hostTheme: BookEditorTheme = BOOK_EDITOR_RENDER_THEME): BookEditorTheme {
27
+ if (hostTheme === 'DARK') {
28
+ return BOOK_EDITOR_RENDER_THEME;
29
+ }
30
+
31
+ return hostTheme;
32
+ }
@@ -8,19 +8,14 @@ import {
8
8
  import { PROMPTBOOK_SYNTAX_COLORS } from '../../config';
9
9
  import { BookEditorMonacoConstants } from './BookEditorMonacoConstants';
10
10
  import { BookEditorMonacoTokenization } from './BookEditorMonacoTokenization';
11
+ import type { BookEditorTheme } from './BookEditorTheme';
12
+ import { BOOK_EDITOR_RENDER_THEME, resolveBookEditorRenderTheme } from './BookEditorTheme';
11
13
 
12
14
  /**
13
15
  * Type describing monaco editor.
14
16
  */
15
17
  type MonacoEditor = typeof import('monaco-editor');
16
18
 
17
- /**
18
- * Resolved visual theme supported by the Book editor.
19
- *
20
- * @private function of BookEditorMonaco
21
- */
22
- type BookEditorTheme = 'LIGHT' | 'DARK';
23
-
24
19
  /**
25
20
  * Props for use book editor monaco language.
26
21
  */
@@ -286,12 +281,13 @@ function createNoteLikeBodyRules(
286
281
  *
287
282
  * @private function of BookEditorMonaco
288
283
  */
289
- export function ensureBookEditorMonacoLanguage(monaco: MonacoEditor, theme: BookEditorTheme = 'LIGHT'): void {
284
+ export function ensureBookEditorMonacoLanguage(monaco: MonacoEditor, theme: BookEditorTheme = BOOK_EDITOR_RENDER_THEME): void {
285
+ const renderedTheme = resolveBookEditorRenderTheme(theme);
290
286
  const monacoWithLanguageState = monaco as MonacoEditorWithBookEditorLanguageState;
291
287
  if (monacoWithLanguageState[BOOK_EDITOR_LANGUAGE_INITIALIZED_FLAG]) {
292
- if (monacoWithLanguageState[BOOK_EDITOR_THEME_MODE_FLAG] !== theme) {
293
- applyBookEditorMonacoTheme(monaco, theme);
294
- monacoWithLanguageState[BOOK_EDITOR_THEME_MODE_FLAG] = theme;
288
+ if (monacoWithLanguageState[BOOK_EDITOR_THEME_MODE_FLAG] !== renderedTheme) {
289
+ applyBookEditorMonacoTheme(monaco, renderedTheme);
290
+ monacoWithLanguageState[BOOK_EDITOR_THEME_MODE_FLAG] = renderedTheme;
295
291
  return;
296
292
  }
297
293
 
@@ -300,7 +296,7 @@ export function ensureBookEditorMonacoLanguage(monaco: MonacoEditor, theme: Book
300
296
  }
301
297
 
302
298
  monacoWithLanguageState[BOOK_EDITOR_LANGUAGE_INITIALIZED_FLAG] = true;
303
- monacoWithLanguageState[BOOK_EDITOR_THEME_MODE_FLAG] = theme;
299
+ monacoWithLanguageState[BOOK_EDITOR_THEME_MODE_FLAG] = renderedTheme;
304
300
 
305
301
  monaco.languages.register({ id: BookEditorMonacoConstants.BOOK_LANGUAGE_ID });
306
302
 
@@ -437,7 +433,7 @@ export function ensureBookEditorMonacoLanguage(monaco: MonacoEditor, theme: Book
437
433
  },
438
434
  });
439
435
 
440
- applyBookEditorMonacoTheme(monaco, theme);
436
+ applyBookEditorMonacoTheme(monaco, renderedTheme);
441
437
  }
442
438
 
443
439
  /**
@@ -462,8 +458,9 @@ type EnsureBookEditorMonacoLanguageForEditorProps = {
462
458
  * @private function of BookEditorMonaco
463
459
  */
464
460
  export function ensureBookEditorMonacoLanguageForEditor(props: EnsureBookEditorMonacoLanguageForEditorProps): void {
465
- const { monaco, monacoEditor, theme = 'LIGHT' } = props;
466
- ensureBookEditorMonacoLanguage(monaco, theme);
461
+ const { monaco, monacoEditor, theme = BOOK_EDITOR_RENDER_THEME } = props;
462
+ const renderedTheme = resolveBookEditorRenderTheme(theme);
463
+ ensureBookEditorMonacoLanguage(monaco, renderedTheme);
467
464
 
468
465
  const model = monacoEditor.getModel();
469
466
  if (!model) {
@@ -1,5 +1,6 @@
1
1
  import type { editor } from 'monaco-editor';
2
2
  import { useCallback, useEffect, useState } from 'react';
3
+ import type { BookEditorTheme } from './BookEditorTheme';
3
4
  import { ensureBookEditorMonacoLanguage, ensureBookEditorMonacoLanguageForEditor } from './useBookEditorMonacoLanguage';
4
5
 
5
6
  /**
@@ -7,11 +8,6 @@ import { ensureBookEditorMonacoLanguage, ensureBookEditorMonacoLanguageForEditor
7
8
  */
8
9
  type MonacoEditor = typeof import('monaco-editor');
9
10
 
10
- /**
11
- * Resolved visual theme supported by the Book editor.
12
- */
13
- type BookEditorTheme = 'LIGHT' | 'DARK';
14
-
15
11
  /**
16
12
  * Props for use book editor monaco lifecycle.
17
13
  */
@@ -1,5 +1,6 @@
1
1
  import { useEffect } from 'react';
2
2
  import { PROMPTBOOK_SYNTAX_COLORS } from '../../config';
3
+ import type { BookEditorTheme } from './BookEditorTheme';
3
4
 
4
5
  /**
5
6
  * Relative Y offset multiplier for aligning line background with Monaco rendering.
@@ -17,7 +18,7 @@ type UseBookEditorMonacoStylesProps = {
17
18
  readonly scaledContentPaddingLeft: number;
18
19
  readonly scaledVerticalLineLeft: number;
19
20
  readonly zoomLevel: number;
20
- readonly theme: 'LIGHT' | 'DARK';
21
+ readonly theme: BookEditorTheme;
21
22
  };
22
23
 
23
24
  /**
@@ -36,6 +36,13 @@ export const AGENT_QUEUED_MESSAGES_DIRECTORY_PATH = join(AGENT_MESSAGES_DIRECTOR
36
36
  */
37
37
  export const AGENT_FINISHED_MESSAGES_DIRECTORY_PATH = join(AGENT_MESSAGES_DIRECTORY_PATH, 'finished');
38
38
 
39
+ /**
40
+ * Relative path to messages that the agent runner stopped retrying.
41
+ *
42
+ * @private internal utility of `ptbk agent-folder`
43
+ */
44
+ export const AGENT_FAILED_MESSAGES_DIRECTORY_PATH = join(AGENT_MESSAGES_DIRECTORY_PATH, 'failed');
45
+
39
46
  /**
40
47
  * Relative path to generated local agent documentation initialized by `ptbk agent-folder init`.
41
48
  *
@@ -96,12 +96,41 @@ const AGENTS_SERVER_BUILD_INPUT_EXCLUDED_DIRECTORY_NAMES = new Set([
96
96
  'test-results',
97
97
  ]);
98
98
 
99
+ /**
100
+ * Runtime source files excluded from the packaged Agents Server copy.
101
+ *
102
+ * @private internal constant of `ptbk agents-server`
103
+ */
104
+ const AGENTS_SERVER_BUILD_INPUT_EXCLUDED_SOURCE_PATHS = new Set([
105
+ 'src/_packages/browser.index.ts',
106
+ 'src/_packages/browser.readme.md',
107
+ 'src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.ts',
108
+ 'src/llm-providers/_common/utils/assertUniqueModels.ts',
109
+ ]);
110
+
111
+ /**
112
+ * Runtime source folders excluded from the packaged Agents Server copy.
113
+ *
114
+ * @private internal constant of `ptbk agents-server`
115
+ */
116
+ const AGENTS_SERVER_BUILD_INPUT_EXCLUDED_SOURCE_PATH_PREFIXES = [
117
+ 'src/dialogs/simple-prompt',
118
+ 'src/storage/local-storage',
119
+ ] as const;
120
+
99
121
  /**
100
122
  * Test files copied out of packaged runtime input paths because Next does not build them.
101
123
  *
102
124
  * @private internal constant of `ptbk agents-server`
103
125
  */
104
- const AGENTS_SERVER_BUILD_INPUT_TEST_FILE_PATTERN = /\.(?:spec|test)\.[jt]sx?$/iu;
126
+ const AGENTS_SERVER_BUILD_INPUT_TEST_FILE_PATTERN = /\.(?:spec|test)(?:\.|$)/iu;
127
+
128
+ /**
129
+ * Type-only compile check files copied out of packaged runtime input paths.
130
+ *
131
+ * @private internal constant of `ptbk agents-server`
132
+ */
133
+ const AGENTS_SERVER_BUILD_INPUT_TEST_TYPE_FILE_PATTERN = /\.test-type\.[jt]sx?$/iu;
105
134
 
106
135
  /**
107
136
  * Metadata persisted after one successful Agents Server production build.
@@ -410,6 +439,7 @@ async function copyAgentsServerRuntimePath(options: {
410
439
  */
411
440
  function shouldCopyAgentsServerRuntimePath(sourcePath: string, sourceRootPath: string): boolean {
412
441
  const sourceRelativePath = relative(sourceRootPath, sourcePath).replace(/\\/gu, '/');
442
+ const sourceRuntimeRelativePath = normalizeRuntimeSourceRelativePath(sourcePath, sourceRootPath);
413
443
  const sourcePathSegments = sourceRelativePath.split('/').filter(Boolean);
414
444
  const sourceBasename = basename(sourcePath);
415
445
 
@@ -421,11 +451,58 @@ function shouldCopyAgentsServerRuntimePath(sourcePath: string, sourceRootPath: s
421
451
  return false;
422
452
  }
423
453
 
454
+ if (sourcePathSegments.includes('playground')) {
455
+ return false;
456
+ }
457
+
458
+ if (isExcludedAgentsServerRuntimeSourcePath(sourceRuntimeRelativePath)) {
459
+ return false;
460
+ }
461
+
424
462
  if (sourceBasename.startsWith('.env')) {
425
463
  return false;
426
464
  }
427
465
 
428
- return !AGENTS_SERVER_BUILD_INPUT_TEST_FILE_PATTERN.test(sourceBasename);
466
+ return (
467
+ !AGENTS_SERVER_BUILD_INPUT_TEST_FILE_PATTERN.test(sourceBasename) &&
468
+ !AGENTS_SERVER_BUILD_INPUT_TEST_TYPE_FILE_PATTERN.test(sourceBasename)
469
+ );
470
+ }
471
+
472
+ /**
473
+ * Normalizes a copied runtime path to the shape used inside the packaged runtime root.
474
+ */
475
+ function normalizeRuntimeSourceRelativePath(sourcePath: string, sourceRootPath: string): string {
476
+ const sourceRelativePath = relative(sourceRootPath, sourcePath).replace(/\\/gu, '/');
477
+ const sourceRootBasename = basename(sourceRootPath);
478
+
479
+ if (!sourceRelativePath) {
480
+ return sourceRootBasename;
481
+ }
482
+
483
+ return `${sourceRootBasename}/${sourceRelativePath}`;
484
+ }
485
+
486
+ /**
487
+ * Checks whether one normalized runtime path is equal to or nested below another path.
488
+ */
489
+ function isRuntimePathWithin(sourceRuntimeRelativePath: string, excludedSourcePathPrefix: string): boolean {
490
+ return (
491
+ sourceRuntimeRelativePath === excludedSourcePathPrefix ||
492
+ sourceRuntimeRelativePath.startsWith(`${excludedSourcePathPrefix}/`)
493
+ );
494
+ }
495
+
496
+ /**
497
+ * Returns true for runtime source files and folders that are not needed by the Agents Server build.
498
+ */
499
+ function isExcludedAgentsServerRuntimeSourcePath(sourceRuntimeRelativePath: string): boolean {
500
+ return (
501
+ AGENTS_SERVER_BUILD_INPUT_EXCLUDED_SOURCE_PATHS.has(sourceRuntimeRelativePath) ||
502
+ AGENTS_SERVER_BUILD_INPUT_EXCLUDED_SOURCE_PATH_PREFIXES.some((excludedSourcePathPrefix) =>
503
+ isRuntimePathWithin(sourceRuntimeRelativePath, excludedSourcePathPrefix),
504
+ )
505
+ );
429
506
  }
430
507
 
431
508
  /**
@@ -595,6 +672,10 @@ async function addAgentsServerBuildInputToFingerprint(
595
672
  readonly runtimeRootPath: string;
596
673
  },
597
674
  ): Promise<void> {
675
+ if (isExcludedAgentsServerBuildInputPath(options.inputPath, options.runtimeRootPath)) {
676
+ return;
677
+ }
678
+
598
679
  let inputStats;
599
680
 
600
681
  try {
@@ -605,10 +686,6 @@ async function addAgentsServerBuildInputToFingerprint(
605
686
  }
606
687
 
607
688
  if (inputStats.isFile()) {
608
- if (isExcludedAgentsServerBuildInputFile(options.inputPath)) {
609
- return;
610
- }
611
-
612
689
  fingerprint.update(`file:${normalizeBuildInputPath(options.runtimeRootPath, options.inputPath)}\n`);
613
690
  fingerprint.update(await readFile(options.inputPath));
614
691
  fingerprint.update('\n');
@@ -636,10 +713,33 @@ async function addAgentsServerBuildInputToFingerprint(
636
713
  }
637
714
 
638
715
  /**
639
- * Returns true for non-build test files inside shared runtime source paths.
716
+ * Returns true for non-build files and folders inside shared runtime source paths.
640
717
  */
641
- function isExcludedAgentsServerBuildInputFile(inputPath: string): boolean {
642
- return AGENTS_SERVER_BUILD_INPUT_TEST_FILE_PATTERN.test(basename(inputPath));
718
+ function isExcludedAgentsServerBuildInputPath(inputPath: string, runtimeRootPath: string): boolean {
719
+ const inputRelativePath = normalizeBuildInputPath(runtimeRootPath, inputPath);
720
+ const inputPathSegments = inputRelativePath.split('/').filter(Boolean);
721
+ const inputBasename = basename(inputPath);
722
+
723
+ if (
724
+ inputPathSegments.some((inputPathSegment) =>
725
+ AGENTS_SERVER_BUILD_INPUT_EXCLUDED_DIRECTORY_NAMES.has(inputPathSegment),
726
+ )
727
+ ) {
728
+ return true;
729
+ }
730
+
731
+ if (inputPathSegments.includes('playground')) {
732
+ return true;
733
+ }
734
+
735
+ if (isExcludedAgentsServerRuntimeSourcePath(inputRelativePath)) {
736
+ return true;
737
+ }
738
+
739
+ return (
740
+ AGENTS_SERVER_BUILD_INPUT_TEST_FILE_PATTERN.test(inputBasename) ||
741
+ AGENTS_SERVER_BUILD_INPUT_TEST_TYPE_FILE_PATTERN.test(inputBasename)
742
+ );
643
743
  }
644
744
 
645
745
  /**
@@ -19,6 +19,7 @@ import {
19
19
  ensureAgentsServerBuild,
20
20
  resolveAgentsServerAppPath,
21
21
  } from './buildAgentsServer';
22
+ import { DEFAULT_LOCAL_AGENT_RUNNER_MAX_FAILED_ATTEMPTS } from '../../../../apps/agents-server/src/constants/serverLimits';
22
23
 
23
24
  /**
24
25
  * Local worker-pump delay while the Agents Server foreground process stays active.
@@ -41,6 +42,20 @@ const USER_CHAT_JOB_WORKER_REPEATED_ERROR_LOG_INTERVAL = 10;
41
42
  */
42
43
  const USER_CHAT_JOB_WORKER_ERROR_BODY_MAX_LENGTH = 2_000;
43
44
 
45
+ /**
46
+ * Delay between foreground CLI attempts to load internal Agents Server limits during startup.
47
+ *
48
+ * @private internal constant of `ptbk agents-server`
49
+ */
50
+ const INTERNAL_SERVER_LIMITS_RETRY_DELAY_MS = 1_000;
51
+
52
+ /**
53
+ * Maximum time spent waiting for the internal limits route before startup fails.
54
+ *
55
+ * @private internal constant of `ptbk agents-server`
56
+ */
57
+ const INTERNAL_SERVER_LIMITS_STARTUP_TIMEOUT_MS = 60_000;
58
+
44
59
  /**
45
60
  * HTTP status used by an idle internal worker tick with no job to process.
46
61
  *
@@ -163,6 +178,15 @@ type AgentsServerSupervisorState = {
163
178
  };
164
179
  };
165
180
 
181
+ /**
182
+ * Local runner limits loaded from the running Agents Server app.
183
+ *
184
+ * @private internal type of `ptbk agents-server`
185
+ */
186
+ type LocalAgentRunnerLimits = {
187
+ readonly maxFailedAttempts: number;
188
+ };
189
+
166
190
  /**
167
191
  * Starts the Agents Server web app and local coding-agent queue workers in the foreground.
168
192
  *
@@ -229,6 +253,12 @@ export async function startAgentsServer(options: StartAgentsServerOptions): Prom
229
253
  logStreams,
230
254
  state,
231
255
  });
256
+ const localAgentRunnerLimits = await waitForLocalAgentRunnerLimits({
257
+ port: options.port,
258
+ environment: runtimeChildEnvironment,
259
+ logStreams,
260
+ state,
261
+ });
232
262
  stopUserChatJobWorkerPump = startUserChatJobWorkerPump({
233
263
  port: options.port,
234
264
  environment: runtimeChildEnvironment,
@@ -237,7 +267,7 @@ export async function startAgentsServer(options: StartAgentsServerOptions): Prom
237
267
  });
238
268
 
239
269
  await withCurrentWorkingDirectory(runtimePaths.agentRootPath, async () => {
240
- await runMultipleAgentMessages(createLocalAgentRunOptions(options), {
270
+ await runMultipleAgentMessages(createLocalAgentRunOptions(options, localAgentRunnerLimits), {
241
271
  shouldContinue: () => state.isContinuing,
242
272
  watchErrorLogDirectoryPath: runtimePaths.logDirectoryPath,
243
273
  onUiInitialized: (uiHandle) => {
@@ -409,7 +439,10 @@ function createAgentsServerChildEnvironment(port: number_port, agentRootPath: st
409
439
  /**
410
440
  * Creates local no-git agent runner options for folders managed by the Agents Server database.
411
441
  */
412
- function createLocalAgentRunOptions(options: StartAgentsServerOptions): AgentRunOptions {
442
+ function createLocalAgentRunOptions(
443
+ options: StartAgentsServerOptions,
444
+ localAgentRunnerLimits: LocalAgentRunnerLimits,
445
+ ): AgentRunOptions {
413
446
  return {
414
447
  agentName: options.agentName,
415
448
  model: options.model,
@@ -422,9 +455,90 @@ function createLocalAgentRunOptions(options: StartAgentsServerOptions): AgentRun
422
455
  autoPush: false,
423
456
  autoPull: false,
424
457
  autoClone: false,
458
+ maxMessageProcessingFailures: localAgentRunnerLimits.maxFailedAttempts,
459
+ };
460
+ }
461
+
462
+ /**
463
+ * Waits until the internal Next route can return current local runner limits.
464
+ */
465
+ async function waitForLocalAgentRunnerLimits(options: {
466
+ readonly port: number_port;
467
+ readonly environment: AgentsServerChildEnvironment;
468
+ readonly logStreams: AgentsServerLogStreams;
469
+ readonly state: AgentsServerSupervisorState;
470
+ }): Promise<LocalAgentRunnerLimits> {
471
+ const startedAt = Date.now();
472
+ let lastError: unknown;
473
+
474
+ while (options.state.isContinuing && Date.now() - startedAt < INTERNAL_SERVER_LIMITS_STARTUP_TIMEOUT_MS) {
475
+ try {
476
+ const limits = await fetchLocalAgentRunnerLimits(options);
477
+ logRunnerEvent(
478
+ options.logStreams.runner,
479
+ `Local agent runner max failed attempts: ${limits.maxFailedAttempts}.`,
480
+ );
481
+ return limits;
482
+ } catch (error) {
483
+ lastError = error;
484
+ await wait(INTERNAL_SERVER_LIMITS_RETRY_DELAY_MS);
485
+ }
486
+ }
487
+
488
+ if (!options.state.isContinuing) {
489
+ return {
490
+ maxFailedAttempts: DEFAULT_LOCAL_AGENT_RUNNER_MAX_FAILED_ATTEMPTS,
491
+ };
492
+ }
493
+
494
+ throw new NotAllowed(
495
+ spaceTrim(`
496
+ Failed to load local agent runner limits from the Agents Server.
497
+
498
+ ${lastError instanceof Error ? lastError.message : String(lastError)}
499
+ `),
500
+ );
501
+ }
502
+
503
+ /**
504
+ * Loads local runner limits through the token-protected internal Agents Server route.
505
+ */
506
+ async function fetchLocalAgentRunnerLimits(options: {
507
+ readonly port: number_port;
508
+ readonly environment: AgentsServerChildEnvironment;
509
+ }): Promise<LocalAgentRunnerLimits> {
510
+ const response = await fetch(`http://localhost:${options.port}/api/internal/agent-runner-limits`, {
511
+ method: 'GET',
512
+ cache: 'no-store',
513
+ headers: {
514
+ 'x-user-chat-worker-token': options.environment.PTBK_AGENTS_SERVER_USER_CHAT_WORKER_TOKEN,
515
+ },
516
+ });
517
+
518
+ if (!response.ok) {
519
+ const details = await readUserChatJobWorkerErrorDetails(response);
520
+ throw new Error(createInternalRouteErrorMessage('agent runner limits', response, details));
521
+ }
522
+
523
+ const payload = (await response.json()) as Partial<LocalAgentRunnerLimits>;
524
+ return {
525
+ maxFailedAttempts: normalizeLocalAgentRunnerMaxFailedAttempts(payload.maxFailedAttempts),
425
526
  };
426
527
  }
427
528
 
529
+ /**
530
+ * Normalizes the local runner retry cap returned by the internal server route.
531
+ */
532
+ function normalizeLocalAgentRunnerMaxFailedAttempts(rawValue: unknown): number {
533
+ const parsedValue = Number(rawValue);
534
+
535
+ if (!Number.isFinite(parsedValue) || parsedValue <= 0) {
536
+ return DEFAULT_LOCAL_AGENT_RUNNER_MAX_FAILED_ATTEMPTS;
537
+ }
538
+
539
+ return Math.floor(parsedValue);
540
+ }
541
+
428
542
  /**
429
543
  * Starts periodic internal worker calls that queue and reconcile local message-folder jobs.
430
544
  */
@@ -563,14 +677,21 @@ function parseUserChatJobWorkerErrorMessage(body: string): string | null {
563
677
  * Builds the foreground worker failure message from HTTP status and route details.
564
678
  */
565
679
  function createUserChatJobWorkerErrorMessage(response: Response, details: string | null): string {
680
+ return createInternalRouteErrorMessage('user chat worker', response, details);
681
+ }
682
+
683
+ /**
684
+ * Builds a foreground failure message for one internal Agents Server route.
685
+ */
686
+ function createInternalRouteErrorMessage(routeLabel: string, response: Response, details: string | null): string {
566
687
  const statusText = response.statusText ? ` ${response.statusText}` : '';
567
688
  const statusMessage = `${response.status}${statusText}`;
568
689
 
569
690
  if (!details) {
570
- return `Internal user chat worker returned ${statusMessage}.`;
691
+ return `Internal ${routeLabel} route returned ${statusMessage}.`;
571
692
  }
572
693
 
573
- return `Internal user chat worker returned ${statusMessage}: ${details}`;
694
+ return `Internal ${routeLabel} route returned ${statusMessage}: ${details}`;
574
695
  }
575
696
 
576
697
  /**
@@ -652,4 +773,11 @@ function stopChildProcess(commandProcess: ChildProcess | undefined): void {
652
773
  commandProcess.kill();
653
774
  }
654
775
 
776
+ /**
777
+ * Waits for the given delay.
778
+ */
779
+ async function wait(delayMs: number): Promise<void> {
780
+ await new Promise((resolve) => setTimeout(resolve, delayMs));
781
+ }
782
+
655
783
  // Note: [🟡] Code for CLI runtime [startAgentsServer](src/cli/cli-commands/agents-server/startAgentsServer.ts) should never be published outside of `@promptbook/cli`