@promptbook/markitdown 0.100.0-9 → 0.100.0

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 (129) hide show
  1. package/README.md +7 -14
  2. package/esm/index.es.js +252 -23
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/color.index.d.ts +50 -0
  5. package/esm/typings/src/_packages/components.index.d.ts +36 -0
  6. package/esm/typings/src/_packages/core.index.d.ts +30 -0
  7. package/esm/typings/src/_packages/types.index.d.ts +38 -0
  8. package/esm/typings/src/book-2.0/agent-source/parseAgentSource.d.ts +30 -0
  9. package/esm/typings/src/book-2.0/agent-source/parseAgentSource.test.d.ts +1 -0
  10. package/esm/typings/src/book-2.0/agent-source/string_book.d.ts +26 -0
  11. package/esm/typings/src/book-2.0/commitments/ACTION/ACTION.d.ts +38 -0
  12. package/esm/typings/src/book-2.0/commitments/FORMAT/FORMAT.d.ts +39 -0
  13. package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/KNOWLEDGE.d.ts +45 -0
  14. package/esm/typings/src/book-2.0/commitments/META_IMAGE/META_IMAGE.d.ts +44 -0
  15. package/esm/typings/src/book-2.0/commitments/META_LINK/META_LINK.d.ts +56 -0
  16. package/esm/typings/src/book-2.0/commitments/MODEL/MODEL.d.ts +39 -0
  17. package/esm/typings/src/book-2.0/commitments/NOTE/NOTE.d.ts +49 -0
  18. package/esm/typings/src/book-2.0/commitments/PERSONA/PERSONA.d.ts +46 -0
  19. package/esm/typings/src/book-2.0/commitments/RULE/RULE.d.ts +44 -0
  20. package/esm/typings/src/book-2.0/commitments/SAMPLE/SAMPLE.d.ts +44 -0
  21. package/esm/typings/src/book-2.0/commitments/STYLE/STYLE.d.ts +38 -0
  22. package/esm/typings/src/book-2.0/commitments/_base/BaseCommitmentDefinition.d.ts +52 -0
  23. package/esm/typings/src/book-2.0/commitments/_base/BookCommitment.d.ts +5 -0
  24. package/esm/typings/src/book-2.0/commitments/_base/CommitmentDefinition.d.ts +48 -0
  25. package/esm/typings/src/book-2.0/commitments/_base/NotYetImplementedCommitmentDefinition.d.ts +22 -0
  26. package/esm/typings/src/book-2.0/commitments/_base/createEmptyAgentModelRequirements.d.ts +19 -0
  27. package/esm/typings/src/book-2.0/commitments/_misc/AgentModelRequirements.d.ts +37 -0
  28. package/esm/typings/src/book-2.0/commitments/_misc/AgentSourceParseResult.d.ts +18 -0
  29. package/esm/typings/src/book-2.0/commitments/_misc/ParsedCommitment.d.ts +22 -0
  30. package/esm/typings/src/book-2.0/commitments/_misc/createAgentModelRequirements.d.ts +62 -0
  31. package/esm/typings/src/book-2.0/commitments/_misc/createAgentModelRequirementsWithCommitments.d.ts +36 -0
  32. package/esm/typings/src/book-2.0/commitments/_misc/createCommitmentRegex.d.ts +20 -0
  33. package/esm/typings/src/book-2.0/commitments/_misc/parseAgentSourceWithCommitments.d.ts +24 -0
  34. package/esm/typings/src/book-2.0/commitments/_misc/removeCommentsFromSystemMessage.d.ts +11 -0
  35. package/esm/typings/src/book-2.0/commitments/index.d.ts +56 -0
  36. package/esm/typings/src/book-2.0/utils/profileImageUtils.d.ts +39 -0
  37. package/esm/typings/src/book-components/AvatarProfile/AvatarChip/AvatarChip.d.ts +35 -0
  38. package/esm/typings/src/book-components/AvatarProfile/AvatarChip/AvatarChipFromSource.d.ts +21 -0
  39. package/esm/typings/src/book-components/AvatarProfile/AvatarChip/index.d.ts +2 -0
  40. package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.d.ts +26 -0
  41. package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfileFromSource.d.ts +19 -0
  42. package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +35 -0
  43. package/esm/typings/src/book-components/BookEditor/BookEditorInner.d.ts +15 -0
  44. package/esm/typings/src/book-components/BookEditor/config.d.ts +10 -0
  45. package/esm/typings/src/book-components/BookEditor/injectCssModuleIntoShadowRoot.d.ts +11 -0
  46. package/esm/typings/src/book-components/Chat/Chat/Chat.d.ts +20 -0
  47. package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +110 -0
  48. package/esm/typings/src/book-components/Chat/LlmChat/LlmChat.d.ts +14 -0
  49. package/esm/typings/src/book-components/Chat/LlmChat/LlmChat.test.d.ts +1 -0
  50. package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +24 -0
  51. package/esm/typings/src/book-components/Chat/types/ChatMessage.d.ts +16 -0
  52. package/esm/typings/src/book-components/Chat/types/ChatParticipant.d.ts +32 -0
  53. package/esm/typings/src/book-components/Chat/utils/ChatPersistence.d.ts +25 -0
  54. package/esm/typings/src/book-components/Chat/utils/ExportFormat.d.ts +4 -0
  55. package/esm/typings/src/book-components/Chat/utils/addUtmParamsToUrl.d.ts +7 -0
  56. package/esm/typings/src/book-components/Chat/utils/createShortLinkForChat.d.ts +7 -0
  57. package/esm/typings/src/book-components/Chat/utils/downloadFile.d.ts +6 -0
  58. package/esm/typings/src/book-components/Chat/utils/exportChatHistory.d.ts +9 -0
  59. package/esm/typings/src/book-components/Chat/utils/generatePdfContent.d.ts +8 -0
  60. package/esm/typings/src/book-components/Chat/utils/generateQrDataUrl.d.ts +7 -0
  61. package/esm/typings/src/book-components/Chat/utils/getPromptbookBranding.d.ts +6 -0
  62. package/esm/typings/src/book-components/Chat/utils/messagesToHtml.d.ts +8 -0
  63. package/esm/typings/src/book-components/Chat/utils/messagesToJson.d.ts +7 -0
  64. package/esm/typings/src/book-components/Chat/utils/messagesToMarkdown.d.ts +8 -0
  65. package/esm/typings/src/book-components/Chat/utils/messagesToText.d.ts +8 -0
  66. package/esm/typings/src/book-components/_common/react-utils/classNames.d.ts +7 -0
  67. package/esm/typings/src/book-components/_common/react-utils/collectCssTextsForClass.d.ts +7 -0
  68. package/esm/typings/src/book-components/_common/react-utils/escapeHtml.d.ts +6 -0
  69. package/esm/typings/src/book-components/_common/react-utils/escapeRegex.d.ts +6 -0
  70. package/esm/typings/src/config.d.ts +19 -0
  71. package/esm/typings/src/execution/AvailableModel.d.ts +4 -0
  72. package/esm/typings/src/execution/ExecutionTask.d.ts +27 -1
  73. package/esm/typings/src/execution/LlmExecutionTools.d.ts +8 -0
  74. package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +6 -1
  75. package/esm/typings/src/llm-providers/_common/filterModels.d.ts +0 -3
  76. package/esm/typings/src/llm-providers/_common/profiles/llmProviderProfiles.d.ts +81 -0
  77. package/esm/typings/src/llm-providers/_common/profiles/test/llmProviderProfiles.test.d.ts +1 -0
  78. package/esm/typings/src/llm-providers/_multiple/MultipleLlmExecutionTools.d.ts +5 -0
  79. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +5 -5
  80. package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
  81. package/esm/typings/src/llm-providers/deepseek/deepseek-models.d.ts +1 -1
  82. package/esm/typings/src/llm-providers/google/google-models.d.ts +1 -1
  83. package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +5 -0
  84. package/esm/typings/src/llm-providers/ollama/ollama-models.d.ts +1 -1
  85. package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +8 -0
  86. package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +5 -0
  87. package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
  88. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +5 -0
  89. package/esm/typings/src/pipeline/book-notation.d.ts +2 -1
  90. package/esm/typings/src/playground/permanent/error-handling-playground.d.ts +5 -0
  91. package/esm/typings/src/types/ModelRequirements.d.ts +0 -2
  92. package/esm/typings/src/types/typeAliases.d.ts +6 -0
  93. package/esm/typings/src/utils/color/$randomColor.d.ts +11 -0
  94. package/esm/typings/src/utils/color/Color.d.ts +180 -0
  95. package/esm/typings/src/utils/color/css-colors.d.ts +159 -0
  96. package/esm/typings/src/utils/color/internal-utils/checkChannelValue.d.ts +14 -0
  97. package/esm/typings/src/utils/color/internal-utils/hslToRgb.d.ts +17 -0
  98. package/esm/typings/src/utils/color/internal-utils/rgbToHsl.d.ts +17 -0
  99. package/esm/typings/src/utils/color/operators/ColorTransformer.d.ts +5 -0
  100. package/esm/typings/src/utils/color/operators/darken.d.ts +9 -0
  101. package/esm/typings/src/utils/color/operators/furthest.d.ts +16 -0
  102. package/esm/typings/src/utils/color/operators/grayscale.d.ts +9 -0
  103. package/esm/typings/src/utils/color/operators/lighten.d.ts +12 -0
  104. package/esm/typings/src/utils/color/operators/mixWithColor.d.ts +11 -0
  105. package/esm/typings/src/utils/color/operators/nearest.d.ts +10 -0
  106. package/esm/typings/src/utils/color/operators/negative.d.ts +7 -0
  107. package/esm/typings/src/utils/color/operators/negativeLightness.d.ts +7 -0
  108. package/esm/typings/src/utils/color/operators/withAlpha.d.ts +9 -0
  109. package/esm/typings/src/utils/color/utils/areColorsEqual.d.ts +14 -0
  110. package/esm/typings/src/utils/color/utils/colorDistance.d.ts +21 -0
  111. package/esm/typings/src/utils/color/utils/colorHue.d.ts +11 -0
  112. package/esm/typings/src/utils/color/utils/colorHueDistance.d.ts +11 -0
  113. package/esm/typings/src/utils/color/utils/colorHueDistance.test.d.ts +1 -0
  114. package/esm/typings/src/utils/color/utils/colorLuminance.d.ts +9 -0
  115. package/esm/typings/src/utils/color/utils/colorSatulightion.d.ts +7 -0
  116. package/esm/typings/src/utils/color/utils/colorSaturation.d.ts +9 -0
  117. package/esm/typings/src/utils/color/utils/colorToDataUrl.d.ts +10 -0
  118. package/esm/typings/src/utils/color/utils/mixColors.d.ts +11 -0
  119. package/esm/typings/src/utils/organization/preserve.d.ts +21 -0
  120. package/esm/typings/src/utils/take/classes/TakeChain.d.ts +11 -0
  121. package/esm/typings/src/utils/take/interfaces/ITakeChain.d.ts +12 -0
  122. package/esm/typings/src/utils/take/interfaces/Takeable.d.ts +7 -0
  123. package/esm/typings/src/utils/take/take.d.ts +12 -0
  124. package/esm/typings/src/utils/take/take.test.d.ts +1 -0
  125. package/esm/typings/src/version.d.ts +1 -1
  126. package/package.json +2 -3
  127. package/umd/index.umd.js +256 -27
  128. package/umd/index.umd.js.map +1 -1
  129. package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +0 -14
package/README.md CHANGED
@@ -10,14 +10,18 @@ Write AI applications using plain human language across multiple models and plat
10
10
  [![NPM Version of ![Promptbook logo - cube with letters P and B](./design/logo-h1.png) Promptbook](https://badge.fury.io/js/promptbook.svg)](https://www.npmjs.com/package/promptbook)
11
11
  [![Quality of package ![Promptbook logo - cube with letters P and B](./design/logo-h1.png) Promptbook](https://packagequality.com/shield/promptbook.svg)](https://packagequality.com/#?package=promptbook)
12
12
  [![Known Vulnerabilities](https://snyk.io/test/github/webgptorg/promptbook/badge.svg)](https://snyk.io/test/github/webgptorg/promptbook)
13
- [![Build Status](https://github.com/webgptorg/promptbook/actions/workflows/ci.yml/badge.svg)](https://github.com/webgptorg/promptbook/actions)
14
- [![Coverage Status](https://coveralls.io/repos/github/webgptorg/promptbook/badge.svg?branch=main)](https://coveralls.io/github/webgptorg/promptbook?branch=main)
13
+ [![🧪 Test Books](https://github.com/webgptorg/promptbook/actions/workflows/test-books.yml/badge.svg)](https://github.com/webgptorg/promptbook/actions/workflows/test-books.yml)
14
+ [![🧪 Test build](https://github.com/webgptorg/promptbook/actions/workflows/test-build.yml/badge.svg)](https://github.com/webgptorg/promptbook/actions/workflows/test-build.yml)
15
+ [![🧪 Lint](https://github.com/webgptorg/promptbook/actions/workflows/test-lint.yml/badge.svg)](https://github.com/webgptorg/promptbook/actions/workflows/test-lint.yml)
16
+ [![🧪 Spell check](https://github.com/webgptorg/promptbook/actions/workflows/test-spell-check.yml/badge.svg)](https://github.com/webgptorg/promptbook/actions/workflows/test-spell-check.yml)
17
+ [![🧪 Test types](https://github.com/webgptorg/promptbook/actions/workflows/test-types.yml/badge.svg)](https://github.com/webgptorg/promptbook/actions/workflows/test-types.yml)
15
18
  [![Issues](https://img.shields.io/github/issues/webgptorg/promptbook.svg?style=flat)](https://github.com/webgptorg/promptbook/issues)
16
19
 
17
20
 
18
21
 
19
22
  ## 🌟 New Features
20
23
 
24
+ - 🚀 **GPT-5 Support** - Now includes OpenAI's most advanced language model with unprecedented reasoning capabilities and 200K context window
21
25
  - 💡 VS Code support for `.book` files with syntax highlighting and IntelliSense
22
26
  - 🐳 Official Docker image (`hejny/promptbook`) for seamless containerized usage
23
27
  - 🔥 Native support for OpenAI `o3-mini`, GPT-4 and other leading LLMs
@@ -25,10 +29,6 @@ Write AI applications using plain human language across multiple models and plat
25
29
 
26
30
 
27
31
 
28
- <blockquote style="color: #ff8811">
29
- <b>⚠ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>.
30
- </blockquote>
31
-
32
32
  ## 📦 Package `@promptbook/markitdown`
33
33
 
34
34
  - Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
@@ -60,8 +60,6 @@ Rest of the documentation is common for **entire promptbook ecosystem**:
60
60
 
61
61
  During the computer revolution, we have seen [multiple generations of computer languages](https://github.com/webgptorg/promptbook/discussions/180), from the physical rewiring of the vacuum tubes through low-level machine code to the high-level languages like Python or JavaScript. And now, we're on the edge of the **next revolution**!
62
62
 
63
-
64
-
65
63
  It's a revolution of writing software in **plain human language** that is understandable and executable by both humans and machines – and it's going to change everything!
66
64
 
67
65
  The incredible growth in power of microprocessors and the Moore's Law have been the driving force behind the ever-more powerful languages, and it's been an amazing journey! Similarly, the large language models (like GPT or Claude) are the next big thing in language technology, and they're set to transform the way we interact with computers.
@@ -187,8 +185,6 @@ Join our growing community of developers and users:
187
185
 
188
186
  _A concise, Markdown-based DSL for crafting AI workflows and automations._
189
187
 
190
-
191
-
192
188
  ### Introduction
193
189
 
194
190
  Book is a Markdown-based language that simplifies the creation of AI applications, workflows, and automations. With human-readable commands, you can define inputs, outputs, personas, knowledge sources, and actions—without needing model-specific details.
@@ -238,8 +234,6 @@ Personas can have access to different knowledge, tools and actions. They can als
238
234
 
239
235
  - [PERSONA](https://github.com/webgptorg/promptbook/blob/main/documents/commands/PERSONA.md)
240
236
 
241
-
242
-
243
237
  ### **3. How:** Knowledge, Instruments and Actions
244
238
 
245
239
  The resources used by the personas are used to do the work.
@@ -314,6 +308,7 @@ Or you can install them separately:
314
308
  - **[@promptbook/editable](https://www.npmjs.com/package/@promptbook/editable)** - Editable book as native javascript object with imperative object API
315
309
  - **[@promptbook/templates](https://www.npmjs.com/package/@promptbook/templates)** - Useful templates and examples of books which can be used as a starting point
316
310
  - **[@promptbook/types](https://www.npmjs.com/package/@promptbook/types)** - Just typescript types used in the library
311
+ - **[@promptbook/color](https://www.npmjs.com/package/@promptbook/color)** - Color manipulation library
317
312
  - ⭐ **[@promptbook/cli](https://www.npmjs.com/package/@promptbook/cli)** - Command line interface utilities for promptbooks
318
313
  - 🐋 **[Docker image](https://hub.docker.com/r/hejny/promptbook/)** - Promptbook server
319
314
 
@@ -339,8 +334,6 @@ The following glossary is used to clarify certain concepts:
339
334
 
340
335
  _Note: This section is not a complete dictionary, more list of general AI / LLM terms that has connection with Promptbook_
341
336
 
342
-
343
-
344
337
  ### 💯 Core concepts
345
338
 
346
339
  - [📚 Collection of pipelines](https://github.com/webgptorg/promptbook/discussions/65)
package/esm/index.es.js CHANGED
@@ -3,8 +3,9 @@ import spaceTrim, { spaceTrim as spaceTrim$1 } from 'spacetrim';
3
3
  import { SHA256 } from 'crypto-js';
4
4
  import hexEncoder from 'crypto-js/enc-hex';
5
5
  import { basename, join, dirname } from 'path';
6
- import { format } from 'prettier';
7
6
  import parserHtml from 'prettier/parser-html';
7
+ import parserMarkdown from 'prettier/parser-markdown';
8
+ import { format } from 'prettier/standalone';
8
9
  import { randomBytes } from 'crypto';
9
10
  import { Subject } from 'rxjs';
10
11
  import { forTime } from 'waitasecond';
@@ -26,7 +27,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
26
27
  * @generated
27
28
  * @see https://github.com/webgptorg/promptbook
28
29
  */
29
- const PROMPTBOOK_ENGINE_VERSION = '0.100.0-9';
30
+ const PROMPTBOOK_ENGINE_VERSION = '0.100.0';
30
31
  /**
31
32
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
32
33
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -218,6 +219,19 @@ let DEFAULT_IS_VERBOSE = false;
218
219
  * @public exported from `@promptbook/core`
219
220
  */
220
221
  const DEFAULT_IS_AUTO_INSTALLED = false;
222
+ /**
223
+ * Default simulated duration for a task in milliseconds (used for progress reporting)
224
+ *
225
+ * @public exported from `@promptbook/core`
226
+ */
227
+ const DEFAULT_TASK_SIMULATED_DURATION_MS = 5 * 60 * 1000; // 5 minutes
228
+ /**
229
+ * API request timeout in milliseconds
230
+ * Can be overridden via API_REQUEST_TIMEOUT environment variable
231
+ *
232
+ * @public exported from `@promptbook/core`
233
+ */
234
+ parseInt(process.env.API_REQUEST_TIMEOUT || '90000');
221
235
  /**
222
236
  * Indicates whether pipeline logic validation is enabled. When true, the pipeline logic is checked for consistency.
223
237
  *
@@ -1021,7 +1035,7 @@ function prettifyMarkdown(content) {
1021
1035
  try {
1022
1036
  return format(content, {
1023
1037
  parser: 'markdown',
1024
- plugins: [parserHtml],
1038
+ plugins: [parserMarkdown, parserHtml],
1025
1039
  // TODO: DRY - make some import or auto-copy of .prettierrc
1026
1040
  endOfLine: 'lf',
1027
1041
  tabWidth: 4,
@@ -2523,6 +2537,7 @@ function createTask(options) {
2523
2537
  const errors = [];
2524
2538
  const warnings = [];
2525
2539
  let currentValue = {};
2540
+ let customTldr = null;
2526
2541
  const partialResultSubject = new Subject();
2527
2542
  // <- Note: Not using `BehaviorSubject` because on error we can't access the last value
2528
2543
  const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
@@ -2533,6 +2548,9 @@ function createTask(options) {
2533
2548
  Object.assign(currentValue, newOngoingResult);
2534
2549
  // <- TODO: assign deep
2535
2550
  partialResultSubject.next(newOngoingResult);
2551
+ }, (tldrInfo) => {
2552
+ customTldr = tldrInfo;
2553
+ updatedAt = new Date();
2536
2554
  });
2537
2555
  finalResultPromise
2538
2556
  .catch((error) => {
@@ -2586,6 +2604,78 @@ function createTask(options) {
2586
2604
  return status;
2587
2605
  // <- Note: [1] --||--
2588
2606
  },
2607
+ get tldr() {
2608
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
2609
+ // Use custom tldr if available
2610
+ if (customTldr) {
2611
+ return customTldr;
2612
+ }
2613
+ // Fallback to default implementation
2614
+ const cv = currentValue;
2615
+ // If explicit percent is provided, use it
2616
+ let percentRaw = (_f = (_d = (_b = (_a = cv === null || cv === void 0 ? void 0 : cv.tldr) === null || _a === void 0 ? void 0 : _a.percent) !== null && _b !== void 0 ? _b : (_c = cv === null || cv === void 0 ? void 0 : cv.usage) === null || _c === void 0 ? void 0 : _c.percent) !== null && _d !== void 0 ? _d : (_e = cv === null || cv === void 0 ? void 0 : cv.progress) === null || _e === void 0 ? void 0 : _e.percent) !== null && _f !== void 0 ? _f : cv === null || cv === void 0 ? void 0 : cv.percent;
2617
+ // Simulate progress if not provided
2618
+ if (typeof percentRaw !== 'number') {
2619
+ // Simulate progress: evenly split across subtasks, based on elapsed time
2620
+ const now = new Date();
2621
+ const elapsedMs = now.getTime() - createdAt.getTime();
2622
+ const totalMs = DEFAULT_TASK_SIMULATED_DURATION_MS;
2623
+ // If subtasks are defined, split progress evenly
2624
+ const subtaskCount = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) ? cv.subtasks.length : 1;
2625
+ const completedSubtasks = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks)
2626
+ ? cv.subtasks.filter((s) => s.done || s.completed).length
2627
+ : 0;
2628
+ // Progress from completed subtasks
2629
+ const subtaskProgress = subtaskCount > 0 ? completedSubtasks / subtaskCount : 0;
2630
+ // Progress from elapsed time for current subtask
2631
+ const timeProgress = Math.min(elapsedMs / totalMs, 1);
2632
+ // Combine: completed subtasks + time progress for current subtask
2633
+ percentRaw = Math.min(subtaskProgress + (1 / subtaskCount) * timeProgress, 1);
2634
+ if (status === 'FINISHED')
2635
+ percentRaw = 1;
2636
+ if (status === 'ERROR')
2637
+ percentRaw = 0;
2638
+ }
2639
+ // Clamp to [0,1]
2640
+ let percent = Number(percentRaw) || 0;
2641
+ if (percent < 0)
2642
+ percent = 0;
2643
+ if (percent > 1)
2644
+ percent = 1;
2645
+ // Build a short message: prefer explicit tldr.message, then common summary/message fields, then errors/warnings, then status
2646
+ const messageFromResult = (_k = (_j = (_h = (_g = cv === null || cv === void 0 ? void 0 : cv.tldr) === null || _g === void 0 ? void 0 : _g.message) !== null && _h !== void 0 ? _h : cv === null || cv === void 0 ? void 0 : cv.message) !== null && _j !== void 0 ? _j : cv === null || cv === void 0 ? void 0 : cv.summary) !== null && _k !== void 0 ? _k : cv === null || cv === void 0 ? void 0 : cv.statusMessage;
2647
+ let message = messageFromResult;
2648
+ if (!message) {
2649
+ // If subtasks, show current subtask
2650
+ if (Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) && cv.subtasks.length > 0) {
2651
+ const current = cv.subtasks.find((s) => !s.done && !s.completed);
2652
+ if (current && current.title) {
2653
+ message = `Working on ${current.title}`;
2654
+ }
2655
+ }
2656
+ if (!message) {
2657
+ if (errors.length) {
2658
+ message = errors[errors.length - 1].message || 'Error';
2659
+ }
2660
+ else if (warnings.length) {
2661
+ message = warnings[warnings.length - 1].message || 'Warning';
2662
+ }
2663
+ else if (status === 'FINISHED') {
2664
+ message = 'Finished';
2665
+ }
2666
+ else if (status === 'ERROR') {
2667
+ message = 'Error';
2668
+ }
2669
+ else {
2670
+ message = 'Running';
2671
+ }
2672
+ }
2673
+ }
2674
+ return {
2675
+ percent: percent,
2676
+ message,
2677
+ };
2678
+ },
2589
2679
  get createdAt() {
2590
2680
  return createdAt;
2591
2681
  // <- Note: [1] --||--
@@ -2834,6 +2924,76 @@ function countUsage(llmTools) {
2834
2924
  * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
2835
2925
  */
2836
2926
 
2927
+ /**
2928
+ * Predefined profiles for LLM providers to maintain consistency across the application
2929
+ * These profiles represent each provider as a virtual persona in chat interfaces
2930
+ *
2931
+ * @private !!!!
2932
+ */
2933
+ const LLM_PROVIDER_PROFILES = {
2934
+ OPENAI: {
2935
+ name: 'OPENAI',
2936
+ fullname: 'OpenAI GPT',
2937
+ color: '#10a37f', // OpenAI's signature green
2938
+ // Note: avatarSrc could be added when we have provider logos available
2939
+ },
2940
+ ANTHROPIC: {
2941
+ name: 'ANTHROPIC',
2942
+ fullname: 'Anthropic Claude',
2943
+ color: '#d97706', // Anthropic's orange/amber color
2944
+ },
2945
+ AZURE_OPENAI: {
2946
+ name: 'AZURE_OPENAI',
2947
+ fullname: 'Azure OpenAI',
2948
+ color: '#0078d4', // Microsoft Azure blue
2949
+ },
2950
+ GOOGLE: {
2951
+ name: 'GOOGLE',
2952
+ fullname: 'Google Gemini',
2953
+ color: '#4285f4', // Google blue
2954
+ },
2955
+ DEEPSEEK: {
2956
+ name: 'DEEPSEEK',
2957
+ fullname: 'DeepSeek',
2958
+ color: '#7c3aed', // Purple color for DeepSeek
2959
+ },
2960
+ OLLAMA: {
2961
+ name: 'OLLAMA',
2962
+ fullname: 'Ollama',
2963
+ color: '#059669', // Emerald green for local models
2964
+ },
2965
+ REMOTE: {
2966
+ name: 'REMOTE',
2967
+ fullname: 'Remote Server',
2968
+ color: '#6b7280', // Gray for remote/proxy connections
2969
+ },
2970
+ MOCKED_ECHO: {
2971
+ name: 'MOCKED_ECHO',
2972
+ fullname: 'Echo (Test)',
2973
+ color: '#8b5cf6', // Purple for test/mock tools
2974
+ },
2975
+ MOCKED_FAKE: {
2976
+ name: 'MOCKED_FAKE',
2977
+ fullname: 'Fake LLM (Test)',
2978
+ color: '#ec4899', // Pink for fake/test tools
2979
+ },
2980
+ VERCEL: {
2981
+ name: 'VERCEL',
2982
+ fullname: 'Vercel AI',
2983
+ color: '#000000', // Vercel's black
2984
+ },
2985
+ MULTIPLE: {
2986
+ name: 'MULTIPLE',
2987
+ fullname: 'Multiple Providers',
2988
+ color: '#6366f1', // Indigo for combined/multiple providers
2989
+ },
2990
+ };
2991
+ /**
2992
+ * TODO: Refactor this - each profile must be alongside the provider definition
2993
+ * TODO: Unite `AvatarProfileProps` and `ChatParticipant`
2994
+ * Note: [💞] Ignore a discrepancy between file name and entity name
2995
+ */
2996
+
2837
2997
  /**
2838
2998
  * Multiple LLM Execution Tools is a proxy server that uses multiple execution tools internally and exposes the executor interface externally.
2839
2999
  *
@@ -2859,7 +3019,7 @@ class MultipleLlmExecutionTools {
2859
3019
  }
2860
3020
  return spaceTrim((block) => `
2861
3021
  ${headLine}
2862
-
3022
+
2863
3023
  ${ /* <- Note: Indenting the description: */block(description)}
2864
3024
  `);
2865
3025
  })
@@ -2870,6 +3030,9 @@ class MultipleLlmExecutionTools {
2870
3030
  ${block(innerModelsTitlesAndDescriptions)}
2871
3031
  `);
2872
3032
  }
3033
+ get profile() {
3034
+ return LLM_PROVIDER_PROFILES.MULTIPLE;
3035
+ }
2873
3036
  /**
2874
3037
  * Check the configuration of all execution tools
2875
3038
  */
@@ -2914,25 +3077,22 @@ class MultipleLlmExecutionTools {
2914
3077
  const errors = [];
2915
3078
  llm: for (const llmExecutionTools of this.llmExecutionTools) {
2916
3079
  try {
2917
- variant: switch (prompt.modelRequirements.modelVariant) {
3080
+ switch (prompt.modelRequirements.modelVariant) {
2918
3081
  case 'CHAT':
2919
3082
  if (llmExecutionTools.callChatModel === undefined) {
2920
3083
  continue llm;
2921
3084
  }
2922
3085
  return await llmExecutionTools.callChatModel(prompt);
2923
- break variant;
2924
3086
  case 'COMPLETION':
2925
3087
  if (llmExecutionTools.callCompletionModel === undefined) {
2926
3088
  continue llm;
2927
3089
  }
2928
3090
  return await llmExecutionTools.callCompletionModel(prompt);
2929
- break variant;
2930
3091
  case 'EMBEDDING':
2931
3092
  if (llmExecutionTools.callEmbeddingModel === undefined) {
2932
3093
  continue llm;
2933
3094
  }
2934
3095
  return await llmExecutionTools.callEmbeddingModel(prompt);
2935
- break variant;
2936
3096
  // <- case [🤖]:
2937
3097
  default:
2938
3098
  throw new UnexpectedError(`Unknown model variant "${prompt.modelRequirements.modelVariant}"`);
@@ -3085,7 +3245,7 @@ async function preparePersona(personaDescription, tools, options) {
3085
3245
  const result = await preparePersonaExecutor({
3086
3246
  availableModels /* <- Note: Passing as JSON */,
3087
3247
  personaDescription,
3088
- }).asPromise();
3248
+ }).asPromise({ isCrashedOnError: true });
3089
3249
  const { outputParameters } = result;
3090
3250
  const { modelsRequirements: modelsRequirementsJson } = outputParameters;
3091
3251
  let modelsRequirementsUnchecked = jsonParse(modelsRequirementsJson);
@@ -3849,7 +4009,7 @@ async function preparePipeline(pipeline, tools, options) {
3849
4009
  });
3850
4010
  const result = await prepareTitleExecutor({
3851
4011
  book: sources.map(({ content }) => content).join('\n\n'),
3852
- }).asPromise();
4012
+ }).asPromise({ isCrashedOnError: true });
3853
4013
  const { outputParameters } = result;
3854
4014
  const { title: titleRaw } = outputParameters;
3855
4015
  if (isVerbose) {
@@ -4943,7 +5103,7 @@ function validatePromptResult(options) {
4943
5103
  */
4944
5104
  async function executeAttempts(options) {
4945
5105
  const { jokerParameterNames, priority, maxAttempts, // <- Note: [💂]
4946
- preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, } = options;
5106
+ preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, } = options;
4947
5107
  const $ongoingTaskResult = {
4948
5108
  $result: null,
4949
5109
  $resultString: null,
@@ -5187,6 +5347,10 @@ async function executeAttempts(options) {
5187
5347
  result: $ongoingTaskResult.$resultString,
5188
5348
  error: error,
5189
5349
  });
5350
+ // Report failed attempt
5351
+ onProgress({
5352
+ errors: [error],
5353
+ });
5190
5354
  }
5191
5355
  finally {
5192
5356
  if (!isJokerAttempt &&
@@ -6060,15 +6224,74 @@ function createPipelineExecutor(options) {
6060
6224
  });
6061
6225
  });
6062
6226
  };
6063
- const pipelineExecutor = (inputParameters) => createTask({
6064
- taskType: 'EXECUTION',
6065
- title: pipeline.title,
6066
- taskProcessCallback(updateOngoingResult) {
6067
- return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
6068
- updateOngoingResult(newOngoingResult);
6069
- });
6070
- },
6071
- });
6227
+ const pipelineExecutor = (inputParameters) => {
6228
+ const startTime = new Date().getTime();
6229
+ return createTask({
6230
+ taskType: 'EXECUTION',
6231
+ title: pipeline.title,
6232
+ taskProcessCallback(updateOngoingResult, updateTldr) {
6233
+ return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
6234
+ var _a, _b;
6235
+ updateOngoingResult(newOngoingResult);
6236
+ // Calculate and update tldr based on pipeline progress
6237
+ const cv = newOngoingResult;
6238
+ // Calculate progress based on parameters resolved vs total parameters
6239
+ const totalParameters = pipeline.parameters.filter(p => !p.isInput).length;
6240
+ let resolvedParameters = 0;
6241
+ let currentTaskTitle = '';
6242
+ // Get the resolved parameters from output parameters
6243
+ if (cv === null || cv === void 0 ? void 0 : cv.outputParameters) {
6244
+ // Count how many output parameters have non-empty values
6245
+ resolvedParameters = Object.values(cv.outputParameters).filter(value => value !== undefined && value !== null && String(value).trim() !== '').length;
6246
+ }
6247
+ // Try to determine current task from execution report
6248
+ if (((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) && cv.executionReport.promptExecutions.length > 0) {
6249
+ const lastExecution = cv.executionReport.promptExecutions[cv.executionReport.promptExecutions.length - 1];
6250
+ if ((_b = lastExecution === null || lastExecution === void 0 ? void 0 : lastExecution.prompt) === null || _b === void 0 ? void 0 : _b.title) {
6251
+ currentTaskTitle = lastExecution.prompt.title;
6252
+ }
6253
+ }
6254
+ // Calculate base progress percentage
6255
+ let percent = totalParameters > 0 ? resolvedParameters / totalParameters : 0;
6256
+ // Add time-based progress for current task if we haven't completed all parameters
6257
+ if (resolvedParameters < totalParameters) {
6258
+ const elapsedMs = new Date().getTime() - startTime;
6259
+ const estimatedTotalMs = totalParameters * 30 * 1000; // Estimate 30 seconds per parameter
6260
+ const timeProgress = Math.min(elapsedMs / estimatedTotalMs, 0.9); // Cap at 90% for time-based progress
6261
+ // If we have time progress but no parameter progress, show time progress
6262
+ if (percent === 0 && timeProgress > 0) {
6263
+ percent = Math.min(timeProgress, 0.1); // Show some progress but not more than 10%
6264
+ }
6265
+ else if (percent < 1) {
6266
+ // Add partial progress for current task
6267
+ const taskProgress = totalParameters > 0 ? (1 / totalParameters) * 0.5 : 0; // 50% of task progress
6268
+ percent = Math.min(percent + taskProgress, 0.95); // Cap at 95% until fully complete
6269
+ }
6270
+ }
6271
+ // Clamp to [0,1]
6272
+ percent = Math.min(Math.max(percent, 0), 1);
6273
+ // Generate message
6274
+ let message = '';
6275
+ if (currentTaskTitle) {
6276
+ message = `Executing: ${currentTaskTitle}`;
6277
+ }
6278
+ else if (resolvedParameters === 0) {
6279
+ message = 'Starting pipeline execution';
6280
+ }
6281
+ else if (resolvedParameters < totalParameters) {
6282
+ message = `Processing pipeline (${resolvedParameters}/${totalParameters} parameters resolved)`;
6283
+ }
6284
+ else {
6285
+ message = 'Completing pipeline execution';
6286
+ }
6287
+ updateTldr({
6288
+ percent: percent,
6289
+ message,
6290
+ });
6291
+ });
6292
+ },
6293
+ });
6294
+ };
6072
6295
  // <- TODO: Make types such as there is no need to do `as` for `createTask`
6073
6296
  return pipelineExecutor;
6074
6297
  }
@@ -6153,7 +6376,9 @@ class MarkdownScraper {
6153
6376
  },
6154
6377
  });
6155
6378
  const knowledgeContent = await source.asText();
6156
- const result = await prepareKnowledgeFromMarkdownExecutor({ knowledgeContent }).asPromise();
6379
+ const result = await prepareKnowledgeFromMarkdownExecutor({ knowledgeContent }).asPromise({
6380
+ isCrashedOnError: true,
6381
+ });
6157
6382
  const { outputParameters } = result;
6158
6383
  const { knowledgePieces: knowledgePiecesRaw } = outputParameters;
6159
6384
  const knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
@@ -6177,12 +6402,16 @@ class MarkdownScraper {
6177
6402
  ];
6178
6403
  */
6179
6404
  try {
6180
- const titleResult = await prepareTitleExecutor({ knowledgePieceContent }).asPromise();
6405
+ const titleResult = await prepareTitleExecutor({ knowledgePieceContent }).asPromise({
6406
+ isCrashedOnError: true,
6407
+ });
6181
6408
  const { title: titleRaw = 'Untitled' } = titleResult.outputParameters;
6182
6409
  title = spaceTrim(titleRaw) /* <- TODO: Maybe do in pipeline */;
6183
6410
  name = titleToName(title);
6184
6411
  // --- Keywords
6185
- const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise();
6412
+ const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise({
6413
+ isCrashedOnError: true,
6414
+ });
6186
6415
  const { keywords: keywordsRaw = '' } = keywordsResult.outputParameters;
6187
6416
  keywords = (keywordsRaw || '')
6188
6417
  .split(',')