@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/umd/index.umd.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('colors'), require('fs/promises'), require('path'), require('spacetrim'), require('jszip'), require('prettier'), require('prettier/parser-html'), require('crypto'), require('rxjs'), require('waitasecond'), require('papaparse'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('crypto-js'), require('mime-types'), require('child_process'), require('dotenv')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'colors', 'fs/promises', 'path', 'spacetrim', 'jszip', 'prettier', 'prettier/parser-html', 'crypto', 'rxjs', 'waitasecond', 'papaparse', 'crypto-js/enc-hex', 'crypto-js/sha256', 'crypto-js', 'mime-types', 'child_process', 'dotenv'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-node"] = {}, global.colors, global.promises, global.path, global.spaceTrim, global.JSZip, global.prettier, global.parserHtml, global.crypto, global.rxjs, global.waitasecond, global.papaparse, global.hexEncoder, global.sha256, global.cryptoJs, global.mimeTypes, global.child_process, global.dotenv));
5
- })(this, (function (exports, colors, promises, path, spaceTrim, JSZip, prettier, parserHtml, crypto, rxjs, waitasecond, papaparse, hexEncoder, sha256, cryptoJs, mimeTypes, child_process, dotenv) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('colors'), require('fs/promises'), require('path'), require('spacetrim'), require('jszip'), require('prettier/parser-html'), require('prettier/parser-markdown'), require('prettier/standalone'), require('crypto'), require('rxjs'), require('waitasecond'), require('papaparse'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('crypto-js'), require('mime-types'), require('child_process'), require('dotenv')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'colors', 'fs/promises', 'path', 'spacetrim', 'jszip', 'prettier/parser-html', 'prettier/parser-markdown', 'prettier/standalone', 'crypto', 'rxjs', 'waitasecond', 'papaparse', 'crypto-js/enc-hex', 'crypto-js/sha256', 'crypto-js', 'mime-types', 'child_process', 'dotenv'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-node"] = {}, global.colors, global.promises, global.path, global.spaceTrim, global.JSZip, global.parserHtml, global.parserMarkdown, global.standalone, global.crypto, global.rxjs, global.waitasecond, global.papaparse, global.hexEncoder, global.sha256, global.cryptoJs, global.mimeTypes, global.child_process, global.dotenv));
5
+ })(this, (function (exports, colors, promises, path, spaceTrim, JSZip, parserHtml, parserMarkdown, standalone, crypto, rxjs, waitasecond, papaparse, hexEncoder, sha256, cryptoJs, mimeTypes, child_process, dotenv) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -28,6 +28,7 @@
28
28
  var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim);
29
29
  var JSZip__default = /*#__PURE__*/_interopDefaultLegacy(JSZip);
30
30
  var parserHtml__default = /*#__PURE__*/_interopDefaultLegacy(parserHtml);
31
+ var parserMarkdown__default = /*#__PURE__*/_interopDefaultLegacy(parserMarkdown);
31
32
  var hexEncoder__default = /*#__PURE__*/_interopDefaultLegacy(hexEncoder);
32
33
  var sha256__default = /*#__PURE__*/_interopDefaultLegacy(sha256);
33
34
  var dotenv__namespace = /*#__PURE__*/_interopNamespace(dotenv);
@@ -46,7 +47,7 @@
46
47
  * @generated
47
48
  * @see https://github.com/webgptorg/promptbook
48
49
  */
49
- const PROMPTBOOK_ENGINE_VERSION = '0.100.0-9';
50
+ const PROMPTBOOK_ENGINE_VERSION = '0.100.1';
50
51
  /**
51
52
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
52
53
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -248,6 +249,19 @@
248
249
  * @public exported from `@promptbook/core`
249
250
  */
250
251
  const DEFAULT_IS_AUTO_INSTALLED = false;
252
+ /**
253
+ * Default simulated duration for a task in milliseconds (used for progress reporting)
254
+ *
255
+ * @public exported from `@promptbook/core`
256
+ */
257
+ const DEFAULT_TASK_SIMULATED_DURATION_MS = 5 * 60 * 1000; // 5 minutes
258
+ /**
259
+ * API request timeout in milliseconds
260
+ * Can be overridden via API_REQUEST_TIMEOUT environment variable
261
+ *
262
+ * @public exported from `@promptbook/core`
263
+ */
264
+ parseInt(process.env.API_REQUEST_TIMEOUT || '90000');
251
265
  /**
252
266
  * Indicates whether pipeline logic validation is enabled. When true, the pipeline logic is checked for consistency.
253
267
  *
@@ -1295,9 +1309,9 @@
1295
1309
  */
1296
1310
  function prettifyMarkdown(content) {
1297
1311
  try {
1298
- return prettier.format(content, {
1312
+ return standalone.format(content, {
1299
1313
  parser: 'markdown',
1300
- plugins: [parserHtml__default["default"]],
1314
+ plugins: [parserMarkdown__default["default"], parserHtml__default["default"]],
1301
1315
  // TODO: DRY - make some import or auto-copy of .prettierrc
1302
1316
  endOfLine: 'lf',
1303
1317
  tabWidth: 4,
@@ -2108,6 +2122,7 @@
2108
2122
  const errors = [];
2109
2123
  const warnings = [];
2110
2124
  let currentValue = {};
2125
+ let customTldr = null;
2111
2126
  const partialResultSubject = new rxjs.Subject();
2112
2127
  // <- Note: Not using `BehaviorSubject` because on error we can't access the last value
2113
2128
  const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
@@ -2118,6 +2133,9 @@
2118
2133
  Object.assign(currentValue, newOngoingResult);
2119
2134
  // <- TODO: assign deep
2120
2135
  partialResultSubject.next(newOngoingResult);
2136
+ }, (tldrInfo) => {
2137
+ customTldr = tldrInfo;
2138
+ updatedAt = new Date();
2121
2139
  });
2122
2140
  finalResultPromise
2123
2141
  .catch((error) => {
@@ -2171,6 +2189,78 @@
2171
2189
  return status;
2172
2190
  // <- Note: [1] --||--
2173
2191
  },
2192
+ get tldr() {
2193
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
2194
+ // Use custom tldr if available
2195
+ if (customTldr) {
2196
+ return customTldr;
2197
+ }
2198
+ // Fallback to default implementation
2199
+ const cv = currentValue;
2200
+ // If explicit percent is provided, use it
2201
+ 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;
2202
+ // Simulate progress if not provided
2203
+ if (typeof percentRaw !== 'number') {
2204
+ // Simulate progress: evenly split across subtasks, based on elapsed time
2205
+ const now = new Date();
2206
+ const elapsedMs = now.getTime() - createdAt.getTime();
2207
+ const totalMs = DEFAULT_TASK_SIMULATED_DURATION_MS;
2208
+ // If subtasks are defined, split progress evenly
2209
+ const subtaskCount = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) ? cv.subtasks.length : 1;
2210
+ const completedSubtasks = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks)
2211
+ ? cv.subtasks.filter((s) => s.done || s.completed).length
2212
+ : 0;
2213
+ // Progress from completed subtasks
2214
+ const subtaskProgress = subtaskCount > 0 ? completedSubtasks / subtaskCount : 0;
2215
+ // Progress from elapsed time for current subtask
2216
+ const timeProgress = Math.min(elapsedMs / totalMs, 1);
2217
+ // Combine: completed subtasks + time progress for current subtask
2218
+ percentRaw = Math.min(subtaskProgress + (1 / subtaskCount) * timeProgress, 1);
2219
+ if (status === 'FINISHED')
2220
+ percentRaw = 1;
2221
+ if (status === 'ERROR')
2222
+ percentRaw = 0;
2223
+ }
2224
+ // Clamp to [0,1]
2225
+ let percent = Number(percentRaw) || 0;
2226
+ if (percent < 0)
2227
+ percent = 0;
2228
+ if (percent > 1)
2229
+ percent = 1;
2230
+ // Build a short message: prefer explicit tldr.message, then common summary/message fields, then errors/warnings, then status
2231
+ 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;
2232
+ let message = messageFromResult;
2233
+ if (!message) {
2234
+ // If subtasks, show current subtask
2235
+ if (Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) && cv.subtasks.length > 0) {
2236
+ const current = cv.subtasks.find((s) => !s.done && !s.completed);
2237
+ if (current && current.title) {
2238
+ message = `Working on ${current.title}`;
2239
+ }
2240
+ }
2241
+ if (!message) {
2242
+ if (errors.length) {
2243
+ message = errors[errors.length - 1].message || 'Error';
2244
+ }
2245
+ else if (warnings.length) {
2246
+ message = warnings[warnings.length - 1].message || 'Warning';
2247
+ }
2248
+ else if (status === 'FINISHED') {
2249
+ message = 'Finished';
2250
+ }
2251
+ else if (status === 'ERROR') {
2252
+ message = 'Error';
2253
+ }
2254
+ else {
2255
+ message = 'Running';
2256
+ }
2257
+ }
2258
+ }
2259
+ return {
2260
+ percent: percent,
2261
+ message,
2262
+ };
2263
+ },
2174
2264
  get createdAt() {
2175
2265
  return createdAt;
2176
2266
  // <- Note: [1] --||--
@@ -2918,6 +3008,76 @@
2918
3008
  return mappedParameters;
2919
3009
  }
2920
3010
 
3011
+ /**
3012
+ * Predefined profiles for LLM providers to maintain consistency across the application
3013
+ * These profiles represent each provider as a virtual persona in chat interfaces
3014
+ *
3015
+ * @private !!!!
3016
+ */
3017
+ const LLM_PROVIDER_PROFILES = {
3018
+ OPENAI: {
3019
+ name: 'OPENAI',
3020
+ fullname: 'OpenAI GPT',
3021
+ color: '#10a37f', // OpenAI's signature green
3022
+ // Note: avatarSrc could be added when we have provider logos available
3023
+ },
3024
+ ANTHROPIC: {
3025
+ name: 'ANTHROPIC',
3026
+ fullname: 'Anthropic Claude',
3027
+ color: '#d97706', // Anthropic's orange/amber color
3028
+ },
3029
+ AZURE_OPENAI: {
3030
+ name: 'AZURE_OPENAI',
3031
+ fullname: 'Azure OpenAI',
3032
+ color: '#0078d4', // Microsoft Azure blue
3033
+ },
3034
+ GOOGLE: {
3035
+ name: 'GOOGLE',
3036
+ fullname: 'Google Gemini',
3037
+ color: '#4285f4', // Google blue
3038
+ },
3039
+ DEEPSEEK: {
3040
+ name: 'DEEPSEEK',
3041
+ fullname: 'DeepSeek',
3042
+ color: '#7c3aed', // Purple color for DeepSeek
3043
+ },
3044
+ OLLAMA: {
3045
+ name: 'OLLAMA',
3046
+ fullname: 'Ollama',
3047
+ color: '#059669', // Emerald green for local models
3048
+ },
3049
+ REMOTE: {
3050
+ name: 'REMOTE',
3051
+ fullname: 'Remote Server',
3052
+ color: '#6b7280', // Gray for remote/proxy connections
3053
+ },
3054
+ MOCKED_ECHO: {
3055
+ name: 'MOCKED_ECHO',
3056
+ fullname: 'Echo (Test)',
3057
+ color: '#8b5cf6', // Purple for test/mock tools
3058
+ },
3059
+ MOCKED_FAKE: {
3060
+ name: 'MOCKED_FAKE',
3061
+ fullname: 'Fake LLM (Test)',
3062
+ color: '#ec4899', // Pink for fake/test tools
3063
+ },
3064
+ VERCEL: {
3065
+ name: 'VERCEL',
3066
+ fullname: 'Vercel AI',
3067
+ color: '#000000', // Vercel's black
3068
+ },
3069
+ MULTIPLE: {
3070
+ name: 'MULTIPLE',
3071
+ fullname: 'Multiple Providers',
3072
+ color: '#6366f1', // Indigo for combined/multiple providers
3073
+ },
3074
+ };
3075
+ /**
3076
+ * TODO: Refactor this - each profile must be alongside the provider definition
3077
+ * TODO: [🕛] Unite `AvatarProfileProps`, `ChatParticipant`, `LlmExecutionTools` + `LlmToolsMetadata`
3078
+ * Note: [💞] Ignore a discrepancy between file name and entity name
3079
+ */
3080
+
2921
3081
  /**
2922
3082
  * Multiple LLM Execution Tools is a proxy server that uses multiple execution tools internally and exposes the executor interface externally.
2923
3083
  *
@@ -2943,7 +3103,7 @@
2943
3103
  }
2944
3104
  return spaceTrim__default["default"]((block) => `
2945
3105
  ${headLine}
2946
-
3106
+
2947
3107
  ${ /* <- Note: Indenting the description: */block(description)}
2948
3108
  `);
2949
3109
  })
@@ -2954,6 +3114,9 @@
2954
3114
  ${block(innerModelsTitlesAndDescriptions)}
2955
3115
  `);
2956
3116
  }
3117
+ get profile() {
3118
+ return LLM_PROVIDER_PROFILES.MULTIPLE;
3119
+ }
2957
3120
  /**
2958
3121
  * Check the configuration of all execution tools
2959
3122
  */
@@ -2998,25 +3161,22 @@
2998
3161
  const errors = [];
2999
3162
  llm: for (const llmExecutionTools of this.llmExecutionTools) {
3000
3163
  try {
3001
- variant: switch (prompt.modelRequirements.modelVariant) {
3164
+ switch (prompt.modelRequirements.modelVariant) {
3002
3165
  case 'CHAT':
3003
3166
  if (llmExecutionTools.callChatModel === undefined) {
3004
3167
  continue llm;
3005
3168
  }
3006
3169
  return await llmExecutionTools.callChatModel(prompt);
3007
- break variant;
3008
3170
  case 'COMPLETION':
3009
3171
  if (llmExecutionTools.callCompletionModel === undefined) {
3010
3172
  continue llm;
3011
3173
  }
3012
3174
  return await llmExecutionTools.callCompletionModel(prompt);
3013
- break variant;
3014
3175
  case 'EMBEDDING':
3015
3176
  if (llmExecutionTools.callEmbeddingModel === undefined) {
3016
3177
  continue llm;
3017
3178
  }
3018
3179
  return await llmExecutionTools.callEmbeddingModel(prompt);
3019
- break variant;
3020
3180
  // <- case [🤖]:
3021
3181
  default:
3022
3182
  throw new UnexpectedError(`Unknown model variant "${prompt.modelRequirements.modelVariant}"`);
@@ -3824,7 +3984,7 @@
3824
3984
  */
3825
3985
  async function executeAttempts(options) {
3826
3986
  const { jokerParameterNames, priority, maxAttempts, // <- Note: [💂]
3827
- preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, } = options;
3987
+ preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, } = options;
3828
3988
  const $ongoingTaskResult = {
3829
3989
  $result: null,
3830
3990
  $resultString: null,
@@ -4068,6 +4228,10 @@
4068
4228
  result: $ongoingTaskResult.$resultString,
4069
4229
  error: error,
4070
4230
  });
4231
+ // Report failed attempt
4232
+ onProgress({
4233
+ errors: [error],
4234
+ });
4071
4235
  }
4072
4236
  finally {
4073
4237
  if (!isJokerAttempt &&
@@ -4941,15 +5105,74 @@
4941
5105
  });
4942
5106
  });
4943
5107
  };
4944
- const pipelineExecutor = (inputParameters) => createTask({
4945
- taskType: 'EXECUTION',
4946
- title: pipeline.title,
4947
- taskProcessCallback(updateOngoingResult) {
4948
- return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
4949
- updateOngoingResult(newOngoingResult);
4950
- });
4951
- },
4952
- });
5108
+ const pipelineExecutor = (inputParameters) => {
5109
+ const startTime = new Date().getTime();
5110
+ return createTask({
5111
+ taskType: 'EXECUTION',
5112
+ title: pipeline.title,
5113
+ taskProcessCallback(updateOngoingResult, updateTldr) {
5114
+ return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
5115
+ var _a, _b;
5116
+ updateOngoingResult(newOngoingResult);
5117
+ // Calculate and update tldr based on pipeline progress
5118
+ const cv = newOngoingResult;
5119
+ // Calculate progress based on parameters resolved vs total parameters
5120
+ const totalParameters = pipeline.parameters.filter(p => !p.isInput).length;
5121
+ let resolvedParameters = 0;
5122
+ let currentTaskTitle = '';
5123
+ // Get the resolved parameters from output parameters
5124
+ if (cv === null || cv === void 0 ? void 0 : cv.outputParameters) {
5125
+ // Count how many output parameters have non-empty values
5126
+ resolvedParameters = Object.values(cv.outputParameters).filter(value => value !== undefined && value !== null && String(value).trim() !== '').length;
5127
+ }
5128
+ // Try to determine current task from execution report
5129
+ if (((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) && cv.executionReport.promptExecutions.length > 0) {
5130
+ const lastExecution = cv.executionReport.promptExecutions[cv.executionReport.promptExecutions.length - 1];
5131
+ if ((_b = lastExecution === null || lastExecution === void 0 ? void 0 : lastExecution.prompt) === null || _b === void 0 ? void 0 : _b.title) {
5132
+ currentTaskTitle = lastExecution.prompt.title;
5133
+ }
5134
+ }
5135
+ // Calculate base progress percentage
5136
+ let percent = totalParameters > 0 ? resolvedParameters / totalParameters : 0;
5137
+ // Add time-based progress for current task if we haven't completed all parameters
5138
+ if (resolvedParameters < totalParameters) {
5139
+ const elapsedMs = new Date().getTime() - startTime;
5140
+ const estimatedTotalMs = totalParameters * 30 * 1000; // Estimate 30 seconds per parameter
5141
+ const timeProgress = Math.min(elapsedMs / estimatedTotalMs, 0.9); // Cap at 90% for time-based progress
5142
+ // If we have time progress but no parameter progress, show time progress
5143
+ if (percent === 0 && timeProgress > 0) {
5144
+ percent = Math.min(timeProgress, 0.1); // Show some progress but not more than 10%
5145
+ }
5146
+ else if (percent < 1) {
5147
+ // Add partial progress for current task
5148
+ const taskProgress = totalParameters > 0 ? (1 / totalParameters) * 0.5 : 0; // 50% of task progress
5149
+ percent = Math.min(percent + taskProgress, 0.95); // Cap at 95% until fully complete
5150
+ }
5151
+ }
5152
+ // Clamp to [0,1]
5153
+ percent = Math.min(Math.max(percent, 0), 1);
5154
+ // Generate message
5155
+ let message = '';
5156
+ if (currentTaskTitle) {
5157
+ message = `Executing: ${currentTaskTitle}`;
5158
+ }
5159
+ else if (resolvedParameters === 0) {
5160
+ message = 'Starting pipeline execution';
5161
+ }
5162
+ else if (resolvedParameters < totalParameters) {
5163
+ message = `Processing pipeline (${resolvedParameters}/${totalParameters} parameters resolved)`;
5164
+ }
5165
+ else {
5166
+ message = 'Completing pipeline execution';
5167
+ }
5168
+ updateTldr({
5169
+ percent: percent,
5170
+ message,
5171
+ });
5172
+ });
5173
+ },
5174
+ });
5175
+ };
4953
5176
  // <- TODO: Make types such as there is no need to do `as` for `createTask`
4954
5177
  return pipelineExecutor;
4955
5178
  }
@@ -5085,7 +5308,7 @@
5085
5308
  const result = await preparePersonaExecutor({
5086
5309
  availableModels /* <- Note: Passing as JSON */,
5087
5310
  personaDescription,
5088
- }).asPromise();
5311
+ }).asPromise({ isCrashedOnError: true });
5089
5312
  const { outputParameters } = result;
5090
5313
  const { modelsRequirements: modelsRequirementsJson } = outputParameters;
5091
5314
  let modelsRequirementsUnchecked = jsonParse(modelsRequirementsJson);
@@ -5975,7 +6198,7 @@
5975
6198
  });
5976
6199
  const result = await prepareTitleExecutor({
5977
6200
  book: sources.map(({ content }) => content).join('\n\n'),
5978
- }).asPromise();
6201
+ }).asPromise({ isCrashedOnError: true });
5979
6202
  const { outputParameters } = result;
5980
6203
  const { title: titleRaw } = outputParameters;
5981
6204
  if (isVerbose) {
@@ -10683,31 +10906,23 @@
10683
10906
  return content;
10684
10907
  }
10685
10908
 
10909
+ /**
10910
+ * @private internal for `preserve`
10911
+ */
10912
+ const _preserved = [];
10686
10913
  /**
10687
10914
  * Does nothing, but preserves the function in the bundle
10688
10915
  * Compiler is tricked into thinking the function is used
10689
10916
  *
10690
10917
  * @param value any function to preserve
10691
10918
  * @returns nothing
10692
- * @private internal function of `JavascriptExecutionTools` and `JavascriptEvalExecutionTools`
10693
- */
10694
- function preserve(func) {
10695
- // Note: NOT calling the function
10696
- (async () => {
10697
- // TODO: [💩] Change to `await forEver` or `forTime(Infinity)`
10698
- await waitasecond.forTime(100000000);
10699
- // [1]
10700
- try {
10701
- await func();
10702
- }
10703
- finally {
10704
- // do nothing
10705
- }
10706
- })();
10919
+ * @private within the repository
10920
+ */
10921
+ function $preserve(...value) {
10922
+ _preserved.push(...value);
10707
10923
  }
10708
10924
  /**
10709
- * TODO: Probably remove in favour of `keepImported`
10710
- * TODO: [1] This maybe does memory leak
10925
+ * Note: [💞] Ignore a discrepancy between file name and entity name
10711
10926
  */
10712
10927
 
10713
10928
  // Note: [💎]
@@ -10735,25 +10950,25 @@
10735
10950
  // Note: [💎]
10736
10951
  // Note: Using direct eval, following variables are in same scope as eval call so they are accessible from inside the evaluated script:
10737
10952
  const spaceTrim = (_) => spaceTrim__default["default"](_);
10738
- preserve(spaceTrim);
10953
+ $preserve(spaceTrim);
10739
10954
  const removeQuotes$1 = removeQuotes;
10740
- preserve(removeQuotes$1);
10955
+ $preserve(removeQuotes$1);
10741
10956
  const unwrapResult$1 = unwrapResult;
10742
- preserve(unwrapResult$1);
10957
+ $preserve(unwrapResult$1);
10743
10958
  const trimEndOfCodeBlock$1 = trimEndOfCodeBlock;
10744
- preserve(trimEndOfCodeBlock$1);
10959
+ $preserve(trimEndOfCodeBlock$1);
10745
10960
  const trimCodeBlock$1 = trimCodeBlock;
10746
- preserve(trimCodeBlock$1);
10961
+ $preserve(trimCodeBlock$1);
10747
10962
  // TODO: DRY [🍯]
10748
10963
  const trim = (str) => str.trim();
10749
- preserve(trim);
10964
+ $preserve(trim);
10750
10965
  // TODO: DRY [🍯]
10751
10966
  const reverse = (str) => str.split('').reverse().join('');
10752
- preserve(reverse);
10967
+ $preserve(reverse);
10753
10968
  const removeEmojis$1 = removeEmojis;
10754
- preserve(removeEmojis$1);
10969
+ $preserve(removeEmojis$1);
10755
10970
  const prettifyMarkdown$1 = prettifyMarkdown;
10756
- preserve(prettifyMarkdown$1);
10971
+ $preserve(prettifyMarkdown$1);
10757
10972
  //-------[n12:]---
10758
10973
  const capitalize$1 = capitalize;
10759
10974
  const decapitalize$1 = decapitalize;
@@ -10769,18 +10984,18 @@
10769
10984
  // TODO: DRY [🍯]
10770
10985
  Array.from(parseKeywordsFromString(input)).join(', '); /* <- TODO: [🧠] What is the best format comma list, bullet list,...? */
10771
10986
  const normalizeTo_SCREAMING_CASE$1 = normalizeTo_SCREAMING_CASE;
10772
- preserve(capitalize$1);
10773
- preserve(decapitalize$1);
10774
- preserve(nameToUriPart$1);
10775
- preserve(nameToUriParts$1);
10776
- preserve(removeDiacritics$1);
10777
- preserve(normalizeWhitespaces$1);
10778
- preserve(normalizeToKebabCase$1);
10779
- preserve(normalizeTo_camelCase$1);
10780
- preserve(normalizeTo_snake_case$1);
10781
- preserve(normalizeTo_PascalCase$1);
10782
- preserve(parseKeywords);
10783
- preserve(normalizeTo_SCREAMING_CASE$1);
10987
+ $preserve(capitalize$1);
10988
+ $preserve(decapitalize$1);
10989
+ $preserve(nameToUriPart$1);
10990
+ $preserve(nameToUriParts$1);
10991
+ $preserve(removeDiacritics$1);
10992
+ $preserve(normalizeWhitespaces$1);
10993
+ $preserve(normalizeToKebabCase$1);
10994
+ $preserve(normalizeTo_camelCase$1);
10995
+ $preserve(normalizeTo_snake_case$1);
10996
+ $preserve(normalizeTo_PascalCase$1);
10997
+ $preserve(parseKeywords);
10998
+ $preserve(normalizeTo_SCREAMING_CASE$1);
10784
10999
  //-------[/n12]---
10785
11000
  if (!script.includes('return')) {
10786
11001
  script = `return ${script}`;