@promptbook/website-crawler 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 +2 -2
  27. package/umd/index.umd.js +59 -71
  28. package/umd/index.umd.js.map +1 -1
package/umd/index.umd.js CHANGED
@@ -25,7 +25,7 @@
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
@@ -2644,7 +2644,7 @@
2644
2644
  * @private internal helper function
2645
2645
  */
2646
2646
  function createTask(options) {
2647
- const { taskType, taskProcessCallback, tldrProvider } = options;
2647
+ const { taskType, taskProcessCallback } = options;
2648
2648
  let { title } = options;
2649
2649
  // TODO: [🐙] DRY
2650
2650
  const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid similar char conflicts */)}`;
@@ -2654,6 +2654,7 @@
2654
2654
  const errors = [];
2655
2655
  const warnings = [];
2656
2656
  let currentValue = {};
2657
+ let customTldr = null;
2657
2658
  const partialResultSubject = new rxjs.Subject();
2658
2659
  // <- Note: Not using `BehaviorSubject` because on error we can't access the last value
2659
2660
  const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
@@ -2664,6 +2665,9 @@
2664
2665
  Object.assign(currentValue, newOngoingResult);
2665
2666
  // <- TODO: assign deep
2666
2667
  partialResultSubject.next(newOngoingResult);
2668
+ }, (tldrInfo) => {
2669
+ customTldr = tldrInfo;
2670
+ updatedAt = new Date();
2667
2671
  });
2668
2672
  finalResultPromise
2669
2673
  .catch((error) => {
@@ -2719,9 +2723,9 @@
2719
2723
  },
2720
2724
  get tldr() {
2721
2725
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
2722
- // Use custom tldr provider if available
2723
- if (tldrProvider) {
2724
- return tldrProvider(createdAt, status, currentValue, errors, warnings);
2726
+ // Use custom tldr if available
2727
+ if (customTldr) {
2728
+ return customTldr;
2725
2729
  }
2726
2730
  // Fallback to default implementation
2727
2731
  const cv = currentValue;
@@ -6155,75 +6159,59 @@
6155
6159
  const pipelineExecutor = (inputParameters) => createTask({
6156
6160
  taskType: 'EXECUTION',
6157
6161
  title: pipeline.title,
6158
- taskProcessCallback(updateOngoingResult) {
6162
+ taskProcessCallback(updateOngoingResult, updateTldr) {
6159
6163
  return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
6164
+ var _a;
6160
6165
  updateOngoingResult(newOngoingResult);
6161
- });
6162
- },
6163
- tldrProvider(createdAt, status, currentValue, errors) {
6164
- var _a;
6165
- // Better progress estimation based on pipeline structure
6166
- const cv = currentValue;
6167
- // Handle finished/error states
6168
- if (status === 'FINISHED') {
6169
- return {
6170
- percent: 1,
6171
- message: 'Finished',
6172
- };
6173
- }
6174
- if (status === 'ERROR') {
6175
- const errorMessage = errors.length > 0 ? errors[errors.length - 1].message : 'Error';
6176
- return {
6177
- percent: 0,
6178
- message: errorMessage,
6179
- };
6180
- }
6181
- // Calculate progress based on pipeline tasks
6182
- const totalTasks = pipeline.tasks.length;
6183
- let completedTasks = 0;
6184
- let currentTaskName = '';
6185
- // Check execution report for completed tasks
6186
- if ((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) {
6187
- const executedTaskTitles = new Set(cv.executionReport.promptExecutions.map((execution) => execution.prompt.title));
6188
- // Count completed tasks by matching titles
6189
- const completedTasksByTitle = pipeline.tasks.filter(task => executedTaskTitles.has(task.title));
6190
- completedTasks = completedTasksByTitle.length;
6191
- // Find current task being executed (first task not yet completed)
6192
- const remainingTasks = pipeline.tasks.filter(task => !executedTaskTitles.has(task.title));
6193
- if (remainingTasks.length > 0) {
6194
- currentTaskName = remainingTasks[0].name;
6166
+ // Calculate and update tldr based on pipeline progress
6167
+ const cv = newOngoingResult;
6168
+ // Calculate progress based on pipeline tasks
6169
+ const totalTasks = pipeline.tasks.length;
6170
+ let completedTasks = 0;
6171
+ let currentTaskName = '';
6172
+ // Check execution report for completed tasks
6173
+ if ((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) {
6174
+ const executedTaskTitles = new Set(cv.executionReport.promptExecutions.map((execution) => execution.prompt.title));
6175
+ // Count completed tasks by matching titles
6176
+ const completedTasksByTitle = pipeline.tasks.filter((task) => executedTaskTitles.has(task.title));
6177
+ completedTasks = completedTasksByTitle.length;
6178
+ // Find current task being executed (first task not yet completed)
6179
+ const remainingTasks = pipeline.tasks.filter((task) => !executedTaskTitles.has(task.title));
6180
+ if (remainingTasks.length > 0) {
6181
+ currentTaskName = remainingTasks[0].name;
6182
+ }
6195
6183
  }
6196
- }
6197
- // Calculate progress percentage
6198
- let percent = totalTasks > 0 ? completedTasks / totalTasks : 0;
6199
- // Add time-based progress for current task (assuming 5 minutes total)
6200
- if (completedTasks < totalTasks) {
6201
- const elapsedMs = new Date().getTime() - createdAt.getTime();
6202
- const totalMs = 5 * 60 * 1000; // 5 minutes
6203
- const timeProgress = Math.min(elapsedMs / totalMs, 1);
6204
- // Add partial progress for current task
6205
- percent += (1 / totalTasks) * timeProgress;
6206
- }
6207
- // Clamp to [0,1]
6208
- percent = Math.min(Math.max(percent, 0), 1);
6209
- // Generate message
6210
- let message = '';
6211
- if (currentTaskName) {
6212
- // Find the task to get its title
6213
- const currentTask = pipeline.tasks.find(task => task.name === currentTaskName);
6214
- const taskTitle = (currentTask === null || currentTask === void 0 ? void 0 : currentTask.title) || currentTaskName;
6215
- message = `Working on task ${taskTitle}`;
6216
- }
6217
- else if (completedTasks === 0) {
6218
- message = 'Starting pipeline execution';
6219
- }
6220
- else {
6221
- message = `Processing pipeline (${completedTasks}/${totalTasks} tasks completed)`;
6222
- }
6223
- return {
6224
- percent,
6225
- message,
6226
- };
6184
+ // Calculate progress percentage
6185
+ let percent = totalTasks > 0 ? completedTasks / totalTasks : 0;
6186
+ // Add time-based progress for current task (assuming 5 minutes total)
6187
+ if (completedTasks < totalTasks) {
6188
+ const elapsedMs = new Date().getTime() - new Date().getTime(); // Will be overridden by actual elapsed time in task
6189
+ const totalMs = 5 * 60 * 1000; // 5 minutes
6190
+ const timeProgress = Math.min(elapsedMs / totalMs, 1);
6191
+ // Add partial progress for current task
6192
+ percent += (1 / totalTasks) * timeProgress;
6193
+ }
6194
+ // Clamp to [0,1]
6195
+ percent = Math.min(Math.max(percent, 0), 1);
6196
+ // Generate message
6197
+ let message = '';
6198
+ if (currentTaskName) {
6199
+ // Find the task to get its title
6200
+ const currentTask = pipeline.tasks.find((task) => task.name === currentTaskName);
6201
+ const taskTitle = (currentTask === null || currentTask === void 0 ? void 0 : currentTask.title) || currentTaskName;
6202
+ message = `Working on task ${taskTitle}`;
6203
+ }
6204
+ else if (completedTasks === 0) {
6205
+ message = 'Starting pipeline execution';
6206
+ }
6207
+ else {
6208
+ message = `Processing pipeline (${completedTasks}/${totalTasks} tasks completed)`;
6209
+ }
6210
+ updateTldr({
6211
+ percent: percent,
6212
+ message,
6213
+ });
6214
+ });
6227
6215
  },
6228
6216
  });
6229
6217
  // <- TODO: Make types such as there is no need to do `as` for `createTask`