@promptbook/markdown-utils 0.100.0-43 → 0.100.0-45

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 (28) hide show
  1. package/esm/index.es.js +59 -71
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/components.index.d.ts +10 -0
  4. package/esm/typings/src/_packages/core.index.d.ts +2 -0
  5. package/esm/typings/src/_packages/types.index.d.ts +12 -0
  6. package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.d.ts +26 -0
  7. package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfileFromSource.d.ts +19 -0
  8. package/esm/typings/src/book-components/BookEditor/BookEditorInner.d.ts +15 -0
  9. package/esm/typings/src/book-components/Chat/Chat/Chat.d.ts +134 -0
  10. package/esm/typings/src/book-components/Chat/interfaces/ChatMessage.d.ts +30 -0
  11. package/esm/typings/src/book-components/Chat/utils/ExportFormat.d.ts +4 -0
  12. package/esm/typings/src/book-components/Chat/utils/addUtmParamsToUrl.d.ts +7 -0
  13. package/esm/typings/src/book-components/Chat/utils/createShortLinkForChat.d.ts +7 -0
  14. package/esm/typings/src/book-components/Chat/utils/downloadFile.d.ts +6 -0
  15. package/esm/typings/src/book-components/Chat/utils/exportChatHistory.d.ts +11 -0
  16. package/esm/typings/src/book-components/Chat/utils/generatePdfContent.d.ts +10 -0
  17. package/esm/typings/src/book-components/Chat/utils/generateQrDataUrl.d.ts +7 -0
  18. package/esm/typings/src/book-components/Chat/utils/getPromptbookBranding.d.ts +6 -0
  19. package/esm/typings/src/book-components/Chat/utils/messagesToHtml.d.ts +10 -0
  20. package/esm/typings/src/book-components/Chat/utils/messagesToJson.d.ts +7 -0
  21. package/esm/typings/src/book-components/Chat/utils/messagesToMarkdown.d.ts +10 -0
  22. package/esm/typings/src/book-components/Chat/utils/messagesToText.d.ts +10 -0
  23. package/esm/typings/src/config.d.ts +6 -0
  24. package/esm/typings/src/execution/ExecutionTask.d.ts +4 -13
  25. package/esm/typings/src/version.d.ts +1 -1
  26. package/package.json +1 -1
  27. package/umd/index.umd.js +59 -71
  28. package/umd/index.umd.js.map +1 -1
package/esm/index.es.js CHANGED
@@ -25,7 +25,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
25
25
  * @generated
26
26
  * @see https://github.com/webgptorg/promptbook
27
27
  */
28
- const PROMPTBOOK_ENGINE_VERSION = '0.100.0-43';
28
+ const PROMPTBOOK_ENGINE_VERSION = '0.100.0-45';
29
29
  /**
30
30
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
31
31
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -2202,7 +2202,7 @@ function assertsTaskSuccessful(executionResult) {
2202
2202
  * @private internal helper function
2203
2203
  */
2204
2204
  function createTask(options) {
2205
- const { taskType, taskProcessCallback, tldrProvider } = options;
2205
+ const { taskType, taskProcessCallback } = options;
2206
2206
  let { title } = options;
2207
2207
  // TODO: [🐙] DRY
2208
2208
  const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid similar char conflicts */)}`;
@@ -2212,6 +2212,7 @@ function createTask(options) {
2212
2212
  const errors = [];
2213
2213
  const warnings = [];
2214
2214
  let currentValue = {};
2215
+ let customTldr = null;
2215
2216
  const partialResultSubject = new Subject();
2216
2217
  // <- Note: Not using `BehaviorSubject` because on error we can't access the last value
2217
2218
  const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
@@ -2222,6 +2223,9 @@ function createTask(options) {
2222
2223
  Object.assign(currentValue, newOngoingResult);
2223
2224
  // <- TODO: assign deep
2224
2225
  partialResultSubject.next(newOngoingResult);
2226
+ }, (tldrInfo) => {
2227
+ customTldr = tldrInfo;
2228
+ updatedAt = new Date();
2225
2229
  });
2226
2230
  finalResultPromise
2227
2231
  .catch((error) => {
@@ -2277,9 +2281,9 @@ function createTask(options) {
2277
2281
  },
2278
2282
  get tldr() {
2279
2283
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
2280
- // Use custom tldr provider if available
2281
- if (tldrProvider) {
2282
- return tldrProvider(createdAt, status, currentValue, errors, warnings);
2284
+ // Use custom tldr if available
2285
+ if (customTldr) {
2286
+ return customTldr;
2283
2287
  }
2284
2288
  // Fallback to default implementation
2285
2289
  const cv = currentValue;
@@ -6113,75 +6117,59 @@ function createPipelineExecutor(options) {
6113
6117
  const pipelineExecutor = (inputParameters) => createTask({
6114
6118
  taskType: 'EXECUTION',
6115
6119
  title: pipeline.title,
6116
- taskProcessCallback(updateOngoingResult) {
6120
+ taskProcessCallback(updateOngoingResult, updateTldr) {
6117
6121
  return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
6122
+ var _a;
6118
6123
  updateOngoingResult(newOngoingResult);
6119
- });
6120
- },
6121
- tldrProvider(createdAt, status, currentValue, errors) {
6122
- var _a;
6123
- // Better progress estimation based on pipeline structure
6124
- const cv = currentValue;
6125
- // Handle finished/error states
6126
- if (status === 'FINISHED') {
6127
- return {
6128
- percent: 1,
6129
- message: 'Finished',
6130
- };
6131
- }
6132
- if (status === 'ERROR') {
6133
- const errorMessage = errors.length > 0 ? errors[errors.length - 1].message : 'Error';
6134
- return {
6135
- percent: 0,
6136
- message: errorMessage,
6137
- };
6138
- }
6139
- // Calculate progress based on pipeline tasks
6140
- const totalTasks = pipeline.tasks.length;
6141
- let completedTasks = 0;
6142
- let currentTaskName = '';
6143
- // Check execution report for completed tasks
6144
- if ((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) {
6145
- const executedTaskTitles = new Set(cv.executionReport.promptExecutions.map((execution) => execution.prompt.title));
6146
- // Count completed tasks by matching titles
6147
- const completedTasksByTitle = pipeline.tasks.filter(task => executedTaskTitles.has(task.title));
6148
- completedTasks = completedTasksByTitle.length;
6149
- // Find current task being executed (first task not yet completed)
6150
- const remainingTasks = pipeline.tasks.filter(task => !executedTaskTitles.has(task.title));
6151
- if (remainingTasks.length > 0) {
6152
- currentTaskName = remainingTasks[0].name;
6124
+ // Calculate and update tldr based on pipeline progress
6125
+ const cv = newOngoingResult;
6126
+ // Calculate progress based on pipeline tasks
6127
+ const totalTasks = pipeline.tasks.length;
6128
+ let completedTasks = 0;
6129
+ let currentTaskName = '';
6130
+ // Check execution report for completed tasks
6131
+ if ((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) {
6132
+ const executedTaskTitles = new Set(cv.executionReport.promptExecutions.map((execution) => execution.prompt.title));
6133
+ // Count completed tasks by matching titles
6134
+ const completedTasksByTitle = pipeline.tasks.filter((task) => executedTaskTitles.has(task.title));
6135
+ completedTasks = completedTasksByTitle.length;
6136
+ // Find current task being executed (first task not yet completed)
6137
+ const remainingTasks = pipeline.tasks.filter((task) => !executedTaskTitles.has(task.title));
6138
+ if (remainingTasks.length > 0) {
6139
+ currentTaskName = remainingTasks[0].name;
6140
+ }
6153
6141
  }
6154
- }
6155
- // Calculate progress percentage
6156
- let percent = totalTasks > 0 ? completedTasks / totalTasks : 0;
6157
- // Add time-based progress for current task (assuming 5 minutes total)
6158
- if (completedTasks < totalTasks) {
6159
- const elapsedMs = new Date().getTime() - createdAt.getTime();
6160
- const totalMs = 5 * 60 * 1000; // 5 minutes
6161
- const timeProgress = Math.min(elapsedMs / totalMs, 1);
6162
- // Add partial progress for current task
6163
- percent += (1 / totalTasks) * timeProgress;
6164
- }
6165
- // Clamp to [0,1]
6166
- percent = Math.min(Math.max(percent, 0), 1);
6167
- // Generate message
6168
- let message = '';
6169
- if (currentTaskName) {
6170
- // Find the task to get its title
6171
- const currentTask = pipeline.tasks.find(task => task.name === currentTaskName);
6172
- const taskTitle = (currentTask === null || currentTask === void 0 ? void 0 : currentTask.title) || currentTaskName;
6173
- message = `Working on task ${taskTitle}`;
6174
- }
6175
- else if (completedTasks === 0) {
6176
- message = 'Starting pipeline execution';
6177
- }
6178
- else {
6179
- message = `Processing pipeline (${completedTasks}/${totalTasks} tasks completed)`;
6180
- }
6181
- return {
6182
- percent,
6183
- message,
6184
- };
6142
+ // Calculate progress percentage
6143
+ let percent = totalTasks > 0 ? completedTasks / totalTasks : 0;
6144
+ // Add time-based progress for current task (assuming 5 minutes total)
6145
+ if (completedTasks < totalTasks) {
6146
+ const elapsedMs = new Date().getTime() - new Date().getTime(); // Will be overridden by actual elapsed time in task
6147
+ const totalMs = 5 * 60 * 1000; // 5 minutes
6148
+ const timeProgress = Math.min(elapsedMs / totalMs, 1);
6149
+ // Add partial progress for current task
6150
+ percent += (1 / totalTasks) * timeProgress;
6151
+ }
6152
+ // Clamp to [0,1]
6153
+ percent = Math.min(Math.max(percent, 0), 1);
6154
+ // Generate message
6155
+ let message = '';
6156
+ if (currentTaskName) {
6157
+ // Find the task to get its title
6158
+ const currentTask = pipeline.tasks.find((task) => task.name === currentTaskName);
6159
+ const taskTitle = (currentTask === null || currentTask === void 0 ? void 0 : currentTask.title) || currentTaskName;
6160
+ message = `Working on task ${taskTitle}`;
6161
+ }
6162
+ else if (completedTasks === 0) {
6163
+ message = 'Starting pipeline execution';
6164
+ }
6165
+ else {
6166
+ message = `Processing pipeline (${completedTasks}/${totalTasks} tasks completed)`;
6167
+ }
6168
+ updateTldr({
6169
+ percent: percent,
6170
+ message,
6171
+ });
6172
+ });
6185
6173
  },
6186
6174
  });
6187
6175
  // <- TODO: Make types such as there is no need to do `as` for `createTask`