@promptbook/node 0.100.0-9 → 0.100.1

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 (130) hide show
  1. package/README.md +7 -14
  2. package/esm/index.es.js +273 -58
  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 +29 -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 +40 -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 +11 -6
  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/_common/register/LlmToolsMetadata.d.ts +3 -4
  79. package/esm/typings/src/llm-providers/_multiple/MultipleLlmExecutionTools.d.ts +5 -0
  80. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +5 -5
  81. package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
  82. package/esm/typings/src/llm-providers/deepseek/deepseek-models.d.ts +1 -1
  83. package/esm/typings/src/llm-providers/google/google-models.d.ts +1 -1
  84. package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +5 -0
  85. package/esm/typings/src/llm-providers/ollama/ollama-models.d.ts +1 -1
  86. package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +8 -0
  87. package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +5 -0
  88. package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
  89. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +5 -0
  90. package/esm/typings/src/pipeline/book-notation.d.ts +2 -1
  91. package/esm/typings/src/playground/permanent/error-handling-playground.d.ts +5 -0
  92. package/esm/typings/src/types/ModelRequirements.d.ts +0 -2
  93. package/esm/typings/src/types/typeAliases.d.ts +6 -0
  94. package/esm/typings/src/utils/color/$randomColor.d.ts +11 -0
  95. package/esm/typings/src/utils/color/Color.d.ts +179 -0
  96. package/esm/typings/src/utils/color/css-colors.d.ts +159 -0
  97. package/esm/typings/src/utils/color/internal-utils/checkChannelValue.d.ts +14 -0
  98. package/esm/typings/src/utils/color/internal-utils/hslToRgb.d.ts +17 -0
  99. package/esm/typings/src/utils/color/internal-utils/rgbToHsl.d.ts +17 -0
  100. package/esm/typings/src/utils/color/operators/ColorTransformer.d.ts +5 -0
  101. package/esm/typings/src/utils/color/operators/darken.d.ts +9 -0
  102. package/esm/typings/src/utils/color/operators/furthest.d.ts +16 -0
  103. package/esm/typings/src/utils/color/operators/grayscale.d.ts +9 -0
  104. package/esm/typings/src/utils/color/operators/lighten.d.ts +12 -0
  105. package/esm/typings/src/utils/color/operators/mixWithColor.d.ts +11 -0
  106. package/esm/typings/src/utils/color/operators/nearest.d.ts +10 -0
  107. package/esm/typings/src/utils/color/operators/negative.d.ts +7 -0
  108. package/esm/typings/src/utils/color/operators/negativeLightness.d.ts +7 -0
  109. package/esm/typings/src/utils/color/operators/withAlpha.d.ts +9 -0
  110. package/esm/typings/src/utils/color/utils/areColorsEqual.d.ts +14 -0
  111. package/esm/typings/src/utils/color/utils/colorDistance.d.ts +21 -0
  112. package/esm/typings/src/utils/color/utils/colorHue.d.ts +11 -0
  113. package/esm/typings/src/utils/color/utils/colorHueDistance.d.ts +11 -0
  114. package/esm/typings/src/utils/color/utils/colorHueDistance.test.d.ts +1 -0
  115. package/esm/typings/src/utils/color/utils/colorLuminance.d.ts +9 -0
  116. package/esm/typings/src/utils/color/utils/colorSatulightion.d.ts +7 -0
  117. package/esm/typings/src/utils/color/utils/colorSaturation.d.ts +9 -0
  118. package/esm/typings/src/utils/color/utils/colorToDataUrl.d.ts +10 -0
  119. package/esm/typings/src/utils/color/utils/mixColors.d.ts +11 -0
  120. package/esm/typings/src/utils/organization/preserve.d.ts +21 -0
  121. package/esm/typings/src/utils/take/classes/TakeChain.d.ts +11 -0
  122. package/esm/typings/src/utils/take/interfaces/ITakeChain.d.ts +12 -0
  123. package/esm/typings/src/utils/take/interfaces/Takeable.d.ts +7 -0
  124. package/esm/typings/src/utils/take/take.d.ts +12 -0
  125. package/esm/typings/src/utils/take/take.test.d.ts +1 -0
  126. package/esm/typings/src/version.d.ts +1 -1
  127. package/package.json +2 -3
  128. package/umd/index.umd.js +277 -62
  129. package/umd/index.umd.js.map +1 -1
  130. 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/node`
33
33
 
34
34
  - Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
@@ -64,8 +64,6 @@ Rest of the documentation is common for **entire promptbook ecosystem**:
64
64
 
65
65
  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**!
66
66
 
67
-
68
-
69
67
  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!
70
68
 
71
69
  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.
@@ -191,8 +189,6 @@ Join our growing community of developers and users:
191
189
 
192
190
  _A concise, Markdown-based DSL for crafting AI workflows and automations._
193
191
 
194
-
195
-
196
192
  ### Introduction
197
193
 
198
194
  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.
@@ -242,8 +238,6 @@ Personas can have access to different knowledge, tools and actions. They can als
242
238
 
243
239
  - [PERSONA](https://github.com/webgptorg/promptbook/blob/main/documents/commands/PERSONA.md)
244
240
 
245
-
246
-
247
241
  ### **3. How:** Knowledge, Instruments and Actions
248
242
 
249
243
  The resources used by the personas are used to do the work.
@@ -318,6 +312,7 @@ Or you can install them separately:
318
312
  - **[@promptbook/editable](https://www.npmjs.com/package/@promptbook/editable)** - Editable book as native javascript object with imperative object API
319
313
  - **[@promptbook/templates](https://www.npmjs.com/package/@promptbook/templates)** - Useful templates and examples of books which can be used as a starting point
320
314
  - **[@promptbook/types](https://www.npmjs.com/package/@promptbook/types)** - Just typescript types used in the library
315
+ - **[@promptbook/color](https://www.npmjs.com/package/@promptbook/color)** - Color manipulation library
321
316
  - ⭐ **[@promptbook/cli](https://www.npmjs.com/package/@promptbook/cli)** - Command line interface utilities for promptbooks
322
317
  - 🐋 **[Docker image](https://hub.docker.com/r/hejny/promptbook/)** - Promptbook server
323
318
 
@@ -343,8 +338,6 @@ The following glossary is used to clarify certain concepts:
343
338
 
344
339
  _Note: This section is not a complete dictionary, more list of general AI / LLM terms that has connection with Promptbook_
345
340
 
346
-
347
-
348
341
  ### 💯 Core concepts
349
342
 
350
343
  - [📚 Collection of pipelines](https://github.com/webgptorg/promptbook/discussions/65)
package/esm/index.es.js CHANGED
@@ -3,8 +3,9 @@ import { stat, access, constants, readFile, writeFile, readdir, mkdir, unlink }
3
3
  import { basename, join, dirname, relative } from 'path';
4
4
  import spaceTrim, { spaceTrim as spaceTrim$1 } from 'spacetrim';
5
5
  import JSZip from 'jszip';
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';
@@ -30,7 +31,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
30
31
  * @generated
31
32
  * @see https://github.com/webgptorg/promptbook
32
33
  */
33
- const PROMPTBOOK_ENGINE_VERSION = '0.100.0-9';
34
+ const PROMPTBOOK_ENGINE_VERSION = '0.100.1';
34
35
  /**
35
36
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
36
37
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -232,6 +233,19 @@ let DEFAULT_IS_VERBOSE = false;
232
233
  * @public exported from `@promptbook/core`
233
234
  */
234
235
  const DEFAULT_IS_AUTO_INSTALLED = false;
236
+ /**
237
+ * Default simulated duration for a task in milliseconds (used for progress reporting)
238
+ *
239
+ * @public exported from `@promptbook/core`
240
+ */
241
+ const DEFAULT_TASK_SIMULATED_DURATION_MS = 5 * 60 * 1000; // 5 minutes
242
+ /**
243
+ * API request timeout in milliseconds
244
+ * Can be overridden via API_REQUEST_TIMEOUT environment variable
245
+ *
246
+ * @public exported from `@promptbook/core`
247
+ */
248
+ parseInt(process.env.API_REQUEST_TIMEOUT || '90000');
235
249
  /**
236
250
  * Indicates whether pipeline logic validation is enabled. When true, the pipeline logic is checked for consistency.
237
251
  *
@@ -1281,7 +1295,7 @@ function prettifyMarkdown(content) {
1281
1295
  try {
1282
1296
  return format(content, {
1283
1297
  parser: 'markdown',
1284
- plugins: [parserHtml],
1298
+ plugins: [parserMarkdown, parserHtml],
1285
1299
  // TODO: DRY - make some import or auto-copy of .prettierrc
1286
1300
  endOfLine: 'lf',
1287
1301
  tabWidth: 4,
@@ -2092,6 +2106,7 @@ function createTask(options) {
2092
2106
  const errors = [];
2093
2107
  const warnings = [];
2094
2108
  let currentValue = {};
2109
+ let customTldr = null;
2095
2110
  const partialResultSubject = new Subject();
2096
2111
  // <- Note: Not using `BehaviorSubject` because on error we can't access the last value
2097
2112
  const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
@@ -2102,6 +2117,9 @@ function createTask(options) {
2102
2117
  Object.assign(currentValue, newOngoingResult);
2103
2118
  // <- TODO: assign deep
2104
2119
  partialResultSubject.next(newOngoingResult);
2120
+ }, (tldrInfo) => {
2121
+ customTldr = tldrInfo;
2122
+ updatedAt = new Date();
2105
2123
  });
2106
2124
  finalResultPromise
2107
2125
  .catch((error) => {
@@ -2155,6 +2173,78 @@ function createTask(options) {
2155
2173
  return status;
2156
2174
  // <- Note: [1] --||--
2157
2175
  },
2176
+ get tldr() {
2177
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
2178
+ // Use custom tldr if available
2179
+ if (customTldr) {
2180
+ return customTldr;
2181
+ }
2182
+ // Fallback to default implementation
2183
+ const cv = currentValue;
2184
+ // If explicit percent is provided, use it
2185
+ 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;
2186
+ // Simulate progress if not provided
2187
+ if (typeof percentRaw !== 'number') {
2188
+ // Simulate progress: evenly split across subtasks, based on elapsed time
2189
+ const now = new Date();
2190
+ const elapsedMs = now.getTime() - createdAt.getTime();
2191
+ const totalMs = DEFAULT_TASK_SIMULATED_DURATION_MS;
2192
+ // If subtasks are defined, split progress evenly
2193
+ const subtaskCount = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) ? cv.subtasks.length : 1;
2194
+ const completedSubtasks = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks)
2195
+ ? cv.subtasks.filter((s) => s.done || s.completed).length
2196
+ : 0;
2197
+ // Progress from completed subtasks
2198
+ const subtaskProgress = subtaskCount > 0 ? completedSubtasks / subtaskCount : 0;
2199
+ // Progress from elapsed time for current subtask
2200
+ const timeProgress = Math.min(elapsedMs / totalMs, 1);
2201
+ // Combine: completed subtasks + time progress for current subtask
2202
+ percentRaw = Math.min(subtaskProgress + (1 / subtaskCount) * timeProgress, 1);
2203
+ if (status === 'FINISHED')
2204
+ percentRaw = 1;
2205
+ if (status === 'ERROR')
2206
+ percentRaw = 0;
2207
+ }
2208
+ // Clamp to [0,1]
2209
+ let percent = Number(percentRaw) || 0;
2210
+ if (percent < 0)
2211
+ percent = 0;
2212
+ if (percent > 1)
2213
+ percent = 1;
2214
+ // Build a short message: prefer explicit tldr.message, then common summary/message fields, then errors/warnings, then status
2215
+ 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;
2216
+ let message = messageFromResult;
2217
+ if (!message) {
2218
+ // If subtasks, show current subtask
2219
+ if (Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) && cv.subtasks.length > 0) {
2220
+ const current = cv.subtasks.find((s) => !s.done && !s.completed);
2221
+ if (current && current.title) {
2222
+ message = `Working on ${current.title}`;
2223
+ }
2224
+ }
2225
+ if (!message) {
2226
+ if (errors.length) {
2227
+ message = errors[errors.length - 1].message || 'Error';
2228
+ }
2229
+ else if (warnings.length) {
2230
+ message = warnings[warnings.length - 1].message || 'Warning';
2231
+ }
2232
+ else if (status === 'FINISHED') {
2233
+ message = 'Finished';
2234
+ }
2235
+ else if (status === 'ERROR') {
2236
+ message = 'Error';
2237
+ }
2238
+ else {
2239
+ message = 'Running';
2240
+ }
2241
+ }
2242
+ }
2243
+ return {
2244
+ percent: percent,
2245
+ message,
2246
+ };
2247
+ },
2158
2248
  get createdAt() {
2159
2249
  return createdAt;
2160
2250
  // <- Note: [1] --||--
@@ -2902,6 +2992,76 @@ function mapAvailableToExpectedParameters(options) {
2902
2992
  return mappedParameters;
2903
2993
  }
2904
2994
 
2995
+ /**
2996
+ * Predefined profiles for LLM providers to maintain consistency across the application
2997
+ * These profiles represent each provider as a virtual persona in chat interfaces
2998
+ *
2999
+ * @private !!!!
3000
+ */
3001
+ const LLM_PROVIDER_PROFILES = {
3002
+ OPENAI: {
3003
+ name: 'OPENAI',
3004
+ fullname: 'OpenAI GPT',
3005
+ color: '#10a37f', // OpenAI's signature green
3006
+ // Note: avatarSrc could be added when we have provider logos available
3007
+ },
3008
+ ANTHROPIC: {
3009
+ name: 'ANTHROPIC',
3010
+ fullname: 'Anthropic Claude',
3011
+ color: '#d97706', // Anthropic's orange/amber color
3012
+ },
3013
+ AZURE_OPENAI: {
3014
+ name: 'AZURE_OPENAI',
3015
+ fullname: 'Azure OpenAI',
3016
+ color: '#0078d4', // Microsoft Azure blue
3017
+ },
3018
+ GOOGLE: {
3019
+ name: 'GOOGLE',
3020
+ fullname: 'Google Gemini',
3021
+ color: '#4285f4', // Google blue
3022
+ },
3023
+ DEEPSEEK: {
3024
+ name: 'DEEPSEEK',
3025
+ fullname: 'DeepSeek',
3026
+ color: '#7c3aed', // Purple color for DeepSeek
3027
+ },
3028
+ OLLAMA: {
3029
+ name: 'OLLAMA',
3030
+ fullname: 'Ollama',
3031
+ color: '#059669', // Emerald green for local models
3032
+ },
3033
+ REMOTE: {
3034
+ name: 'REMOTE',
3035
+ fullname: 'Remote Server',
3036
+ color: '#6b7280', // Gray for remote/proxy connections
3037
+ },
3038
+ MOCKED_ECHO: {
3039
+ name: 'MOCKED_ECHO',
3040
+ fullname: 'Echo (Test)',
3041
+ color: '#8b5cf6', // Purple for test/mock tools
3042
+ },
3043
+ MOCKED_FAKE: {
3044
+ name: 'MOCKED_FAKE',
3045
+ fullname: 'Fake LLM (Test)',
3046
+ color: '#ec4899', // Pink for fake/test tools
3047
+ },
3048
+ VERCEL: {
3049
+ name: 'VERCEL',
3050
+ fullname: 'Vercel AI',
3051
+ color: '#000000', // Vercel's black
3052
+ },
3053
+ MULTIPLE: {
3054
+ name: 'MULTIPLE',
3055
+ fullname: 'Multiple Providers',
3056
+ color: '#6366f1', // Indigo for combined/multiple providers
3057
+ },
3058
+ };
3059
+ /**
3060
+ * TODO: Refactor this - each profile must be alongside the provider definition
3061
+ * TODO: [🕛] Unite `AvatarProfileProps`, `ChatParticipant`, `LlmExecutionTools` + `LlmToolsMetadata`
3062
+ * Note: [💞] Ignore a discrepancy between file name and entity name
3063
+ */
3064
+
2905
3065
  /**
2906
3066
  * Multiple LLM Execution Tools is a proxy server that uses multiple execution tools internally and exposes the executor interface externally.
2907
3067
  *
@@ -2927,7 +3087,7 @@ class MultipleLlmExecutionTools {
2927
3087
  }
2928
3088
  return spaceTrim((block) => `
2929
3089
  ${headLine}
2930
-
3090
+
2931
3091
  ${ /* <- Note: Indenting the description: */block(description)}
2932
3092
  `);
2933
3093
  })
@@ -2938,6 +3098,9 @@ class MultipleLlmExecutionTools {
2938
3098
  ${block(innerModelsTitlesAndDescriptions)}
2939
3099
  `);
2940
3100
  }
3101
+ get profile() {
3102
+ return LLM_PROVIDER_PROFILES.MULTIPLE;
3103
+ }
2941
3104
  /**
2942
3105
  * Check the configuration of all execution tools
2943
3106
  */
@@ -2982,25 +3145,22 @@ class MultipleLlmExecutionTools {
2982
3145
  const errors = [];
2983
3146
  llm: for (const llmExecutionTools of this.llmExecutionTools) {
2984
3147
  try {
2985
- variant: switch (prompt.modelRequirements.modelVariant) {
3148
+ switch (prompt.modelRequirements.modelVariant) {
2986
3149
  case 'CHAT':
2987
3150
  if (llmExecutionTools.callChatModel === undefined) {
2988
3151
  continue llm;
2989
3152
  }
2990
3153
  return await llmExecutionTools.callChatModel(prompt);
2991
- break variant;
2992
3154
  case 'COMPLETION':
2993
3155
  if (llmExecutionTools.callCompletionModel === undefined) {
2994
3156
  continue llm;
2995
3157
  }
2996
3158
  return await llmExecutionTools.callCompletionModel(prompt);
2997
- break variant;
2998
3159
  case 'EMBEDDING':
2999
3160
  if (llmExecutionTools.callEmbeddingModel === undefined) {
3000
3161
  continue llm;
3001
3162
  }
3002
3163
  return await llmExecutionTools.callEmbeddingModel(prompt);
3003
- break variant;
3004
3164
  // <- case [🤖]:
3005
3165
  default:
3006
3166
  throw new UnexpectedError(`Unknown model variant "${prompt.modelRequirements.modelVariant}"`);
@@ -3808,7 +3968,7 @@ function validatePromptResult(options) {
3808
3968
  */
3809
3969
  async function executeAttempts(options) {
3810
3970
  const { jokerParameterNames, priority, maxAttempts, // <- Note: [💂]
3811
- preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, } = options;
3971
+ preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, } = options;
3812
3972
  const $ongoingTaskResult = {
3813
3973
  $result: null,
3814
3974
  $resultString: null,
@@ -4052,6 +4212,10 @@ async function executeAttempts(options) {
4052
4212
  result: $ongoingTaskResult.$resultString,
4053
4213
  error: error,
4054
4214
  });
4215
+ // Report failed attempt
4216
+ onProgress({
4217
+ errors: [error],
4218
+ });
4055
4219
  }
4056
4220
  finally {
4057
4221
  if (!isJokerAttempt &&
@@ -4925,15 +5089,74 @@ function createPipelineExecutor(options) {
4925
5089
  });
4926
5090
  });
4927
5091
  };
4928
- const pipelineExecutor = (inputParameters) => createTask({
4929
- taskType: 'EXECUTION',
4930
- title: pipeline.title,
4931
- taskProcessCallback(updateOngoingResult) {
4932
- return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
4933
- updateOngoingResult(newOngoingResult);
4934
- });
4935
- },
4936
- });
5092
+ const pipelineExecutor = (inputParameters) => {
5093
+ const startTime = new Date().getTime();
5094
+ return createTask({
5095
+ taskType: 'EXECUTION',
5096
+ title: pipeline.title,
5097
+ taskProcessCallback(updateOngoingResult, updateTldr) {
5098
+ return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
5099
+ var _a, _b;
5100
+ updateOngoingResult(newOngoingResult);
5101
+ // Calculate and update tldr based on pipeline progress
5102
+ const cv = newOngoingResult;
5103
+ // Calculate progress based on parameters resolved vs total parameters
5104
+ const totalParameters = pipeline.parameters.filter(p => !p.isInput).length;
5105
+ let resolvedParameters = 0;
5106
+ let currentTaskTitle = '';
5107
+ // Get the resolved parameters from output parameters
5108
+ if (cv === null || cv === void 0 ? void 0 : cv.outputParameters) {
5109
+ // Count how many output parameters have non-empty values
5110
+ resolvedParameters = Object.values(cv.outputParameters).filter(value => value !== undefined && value !== null && String(value).trim() !== '').length;
5111
+ }
5112
+ // Try to determine current task from execution report
5113
+ if (((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) && cv.executionReport.promptExecutions.length > 0) {
5114
+ const lastExecution = cv.executionReport.promptExecutions[cv.executionReport.promptExecutions.length - 1];
5115
+ if ((_b = lastExecution === null || lastExecution === void 0 ? void 0 : lastExecution.prompt) === null || _b === void 0 ? void 0 : _b.title) {
5116
+ currentTaskTitle = lastExecution.prompt.title;
5117
+ }
5118
+ }
5119
+ // Calculate base progress percentage
5120
+ let percent = totalParameters > 0 ? resolvedParameters / totalParameters : 0;
5121
+ // Add time-based progress for current task if we haven't completed all parameters
5122
+ if (resolvedParameters < totalParameters) {
5123
+ const elapsedMs = new Date().getTime() - startTime;
5124
+ const estimatedTotalMs = totalParameters * 30 * 1000; // Estimate 30 seconds per parameter
5125
+ const timeProgress = Math.min(elapsedMs / estimatedTotalMs, 0.9); // Cap at 90% for time-based progress
5126
+ // If we have time progress but no parameter progress, show time progress
5127
+ if (percent === 0 && timeProgress > 0) {
5128
+ percent = Math.min(timeProgress, 0.1); // Show some progress but not more than 10%
5129
+ }
5130
+ else if (percent < 1) {
5131
+ // Add partial progress for current task
5132
+ const taskProgress = totalParameters > 0 ? (1 / totalParameters) * 0.5 : 0; // 50% of task progress
5133
+ percent = Math.min(percent + taskProgress, 0.95); // Cap at 95% until fully complete
5134
+ }
5135
+ }
5136
+ // Clamp to [0,1]
5137
+ percent = Math.min(Math.max(percent, 0), 1);
5138
+ // Generate message
5139
+ let message = '';
5140
+ if (currentTaskTitle) {
5141
+ message = `Executing: ${currentTaskTitle}`;
5142
+ }
5143
+ else if (resolvedParameters === 0) {
5144
+ message = 'Starting pipeline execution';
5145
+ }
5146
+ else if (resolvedParameters < totalParameters) {
5147
+ message = `Processing pipeline (${resolvedParameters}/${totalParameters} parameters resolved)`;
5148
+ }
5149
+ else {
5150
+ message = 'Completing pipeline execution';
5151
+ }
5152
+ updateTldr({
5153
+ percent: percent,
5154
+ message,
5155
+ });
5156
+ });
5157
+ },
5158
+ });
5159
+ };
4937
5160
  // <- TODO: Make types such as there is no need to do `as` for `createTask`
4938
5161
  return pipelineExecutor;
4939
5162
  }
@@ -5069,7 +5292,7 @@ async function preparePersona(personaDescription, tools, options) {
5069
5292
  const result = await preparePersonaExecutor({
5070
5293
  availableModels /* <- Note: Passing as JSON */,
5071
5294
  personaDescription,
5072
- }).asPromise();
5295
+ }).asPromise({ isCrashedOnError: true });
5073
5296
  const { outputParameters } = result;
5074
5297
  const { modelsRequirements: modelsRequirementsJson } = outputParameters;
5075
5298
  let modelsRequirementsUnchecked = jsonParse(modelsRequirementsJson);
@@ -5959,7 +6182,7 @@ async function preparePipeline(pipeline, tools, options) {
5959
6182
  });
5960
6183
  const result = await prepareTitleExecutor({
5961
6184
  book: sources.map(({ content }) => content).join('\n\n'),
5962
- }).asPromise();
6185
+ }).asPromise({ isCrashedOnError: true });
5963
6186
  const { outputParameters } = result;
5964
6187
  const { title: titleRaw } = outputParameters;
5965
6188
  if (isVerbose) {
@@ -10667,31 +10890,23 @@ function extractBlock(markdown) {
10667
10890
  return content;
10668
10891
  }
10669
10892
 
10893
+ /**
10894
+ * @private internal for `preserve`
10895
+ */
10896
+ const _preserved = [];
10670
10897
  /**
10671
10898
  * Does nothing, but preserves the function in the bundle
10672
10899
  * Compiler is tricked into thinking the function is used
10673
10900
  *
10674
10901
  * @param value any function to preserve
10675
10902
  * @returns nothing
10676
- * @private internal function of `JavascriptExecutionTools` and `JavascriptEvalExecutionTools`
10677
- */
10678
- function preserve(func) {
10679
- // Note: NOT calling the function
10680
- (async () => {
10681
- // TODO: [💩] Change to `await forEver` or `forTime(Infinity)`
10682
- await forTime(100000000);
10683
- // [1]
10684
- try {
10685
- await func();
10686
- }
10687
- finally {
10688
- // do nothing
10689
- }
10690
- })();
10903
+ * @private within the repository
10904
+ */
10905
+ function $preserve(...value) {
10906
+ _preserved.push(...value);
10691
10907
  }
10692
10908
  /**
10693
- * TODO: Probably remove in favour of `keepImported`
10694
- * TODO: [1] This maybe does memory leak
10909
+ * Note: [💞] Ignore a discrepancy between file name and entity name
10695
10910
  */
10696
10911
 
10697
10912
  // Note: [💎]
@@ -10719,25 +10934,25 @@ class JavascriptEvalExecutionTools {
10719
10934
  // Note: [💎]
10720
10935
  // Note: Using direct eval, following variables are in same scope as eval call so they are accessible from inside the evaluated script:
10721
10936
  const spaceTrim$1 = (_) => spaceTrim(_);
10722
- preserve(spaceTrim$1);
10937
+ $preserve(spaceTrim$1);
10723
10938
  const removeQuotes$1 = removeQuotes;
10724
- preserve(removeQuotes$1);
10939
+ $preserve(removeQuotes$1);
10725
10940
  const unwrapResult$1 = unwrapResult;
10726
- preserve(unwrapResult$1);
10941
+ $preserve(unwrapResult$1);
10727
10942
  const trimEndOfCodeBlock$1 = trimEndOfCodeBlock;
10728
- preserve(trimEndOfCodeBlock$1);
10943
+ $preserve(trimEndOfCodeBlock$1);
10729
10944
  const trimCodeBlock$1 = trimCodeBlock;
10730
- preserve(trimCodeBlock$1);
10945
+ $preserve(trimCodeBlock$1);
10731
10946
  // TODO: DRY [🍯]
10732
10947
  const trim = (str) => str.trim();
10733
- preserve(trim);
10948
+ $preserve(trim);
10734
10949
  // TODO: DRY [🍯]
10735
10950
  const reverse = (str) => str.split('').reverse().join('');
10736
- preserve(reverse);
10951
+ $preserve(reverse);
10737
10952
  const removeEmojis$1 = removeEmojis;
10738
- preserve(removeEmojis$1);
10953
+ $preserve(removeEmojis$1);
10739
10954
  const prettifyMarkdown$1 = prettifyMarkdown;
10740
- preserve(prettifyMarkdown$1);
10955
+ $preserve(prettifyMarkdown$1);
10741
10956
  //-------[n12:]---
10742
10957
  const capitalize$1 = capitalize;
10743
10958
  const decapitalize$1 = decapitalize;
@@ -10753,18 +10968,18 @@ class JavascriptEvalExecutionTools {
10753
10968
  // TODO: DRY [🍯]
10754
10969
  Array.from(parseKeywordsFromString(input)).join(', '); /* <- TODO: [🧠] What is the best format comma list, bullet list,...? */
10755
10970
  const normalizeTo_SCREAMING_CASE$1 = normalizeTo_SCREAMING_CASE;
10756
- preserve(capitalize$1);
10757
- preserve(decapitalize$1);
10758
- preserve(nameToUriPart$1);
10759
- preserve(nameToUriParts$1);
10760
- preserve(removeDiacritics$1);
10761
- preserve(normalizeWhitespaces$1);
10762
- preserve(normalizeToKebabCase$1);
10763
- preserve(normalizeTo_camelCase$1);
10764
- preserve(normalizeTo_snake_case$1);
10765
- preserve(normalizeTo_PascalCase$1);
10766
- preserve(parseKeywords);
10767
- preserve(normalizeTo_SCREAMING_CASE$1);
10971
+ $preserve(capitalize$1);
10972
+ $preserve(decapitalize$1);
10973
+ $preserve(nameToUriPart$1);
10974
+ $preserve(nameToUriParts$1);
10975
+ $preserve(removeDiacritics$1);
10976
+ $preserve(normalizeWhitespaces$1);
10977
+ $preserve(normalizeToKebabCase$1);
10978
+ $preserve(normalizeTo_camelCase$1);
10979
+ $preserve(normalizeTo_snake_case$1);
10980
+ $preserve(normalizeTo_PascalCase$1);
10981
+ $preserve(parseKeywords);
10982
+ $preserve(normalizeTo_SCREAMING_CASE$1);
10768
10983
  //-------[/n12]---
10769
10984
  if (!script.includes('return')) {
10770
10985
  script = `return ${script}`;