@promptbook/remote-server 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/esm/index.es.js CHANGED
@@ -33,7 +33,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
33
33
  * @generated
34
34
  * @see https://github.com/webgptorg/promptbook
35
35
  */
36
- const PROMPTBOOK_ENGINE_VERSION = '0.100.0-43';
36
+ const PROMPTBOOK_ENGINE_VERSION = '0.100.0-45';
37
37
  /**
38
38
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
39
39
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -2006,7 +2006,7 @@ function assertsTaskSuccessful(executionResult) {
2006
2006
  * @private internal helper function
2007
2007
  */
2008
2008
  function createTask(options) {
2009
- const { taskType, taskProcessCallback, tldrProvider } = options;
2009
+ const { taskType, taskProcessCallback } = options;
2010
2010
  let { title } = options;
2011
2011
  // TODO: [🐙] DRY
2012
2012
  const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid similar char conflicts */)}`;
@@ -2016,6 +2016,7 @@ function createTask(options) {
2016
2016
  const errors = [];
2017
2017
  const warnings = [];
2018
2018
  let currentValue = {};
2019
+ let customTldr = null;
2019
2020
  const partialResultSubject = new Subject();
2020
2021
  // <- Note: Not using `BehaviorSubject` because on error we can't access the last value
2021
2022
  const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
@@ -2026,6 +2027,9 @@ function createTask(options) {
2026
2027
  Object.assign(currentValue, newOngoingResult);
2027
2028
  // <- TODO: assign deep
2028
2029
  partialResultSubject.next(newOngoingResult);
2030
+ }, (tldrInfo) => {
2031
+ customTldr = tldrInfo;
2032
+ updatedAt = new Date();
2029
2033
  });
2030
2034
  finalResultPromise
2031
2035
  .catch((error) => {
@@ -2081,9 +2085,9 @@ function createTask(options) {
2081
2085
  },
2082
2086
  get tldr() {
2083
2087
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
2084
- // Use custom tldr provider if available
2085
- if (tldrProvider) {
2086
- return tldrProvider(createdAt, status, currentValue, errors, warnings);
2088
+ // Use custom tldr if available
2089
+ if (customTldr) {
2090
+ return customTldr;
2087
2091
  }
2088
2092
  // Fallback to default implementation
2089
2093
  const cv = currentValue;
@@ -6484,75 +6488,59 @@ function createPipelineExecutor(options) {
6484
6488
  const pipelineExecutor = (inputParameters) => createTask({
6485
6489
  taskType: 'EXECUTION',
6486
6490
  title: pipeline.title,
6487
- taskProcessCallback(updateOngoingResult) {
6491
+ taskProcessCallback(updateOngoingResult, updateTldr) {
6488
6492
  return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
6493
+ var _a;
6489
6494
  updateOngoingResult(newOngoingResult);
6490
- });
6491
- },
6492
- tldrProvider(createdAt, status, currentValue, errors) {
6493
- var _a;
6494
- // Better progress estimation based on pipeline structure
6495
- const cv = currentValue;
6496
- // Handle finished/error states
6497
- if (status === 'FINISHED') {
6498
- return {
6499
- percent: 1,
6500
- message: 'Finished',
6501
- };
6502
- }
6503
- if (status === 'ERROR') {
6504
- const errorMessage = errors.length > 0 ? errors[errors.length - 1].message : 'Error';
6505
- return {
6506
- percent: 0,
6507
- message: errorMessage,
6508
- };
6509
- }
6510
- // Calculate progress based on pipeline tasks
6511
- const totalTasks = pipeline.tasks.length;
6512
- let completedTasks = 0;
6513
- let currentTaskName = '';
6514
- // Check execution report for completed tasks
6515
- if ((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) {
6516
- const executedTaskTitles = new Set(cv.executionReport.promptExecutions.map((execution) => execution.prompt.title));
6517
- // Count completed tasks by matching titles
6518
- const completedTasksByTitle = pipeline.tasks.filter(task => executedTaskTitles.has(task.title));
6519
- completedTasks = completedTasksByTitle.length;
6520
- // Find current task being executed (first task not yet completed)
6521
- const remainingTasks = pipeline.tasks.filter(task => !executedTaskTitles.has(task.title));
6522
- if (remainingTasks.length > 0) {
6523
- currentTaskName = remainingTasks[0].name;
6495
+ // Calculate and update tldr based on pipeline progress
6496
+ const cv = newOngoingResult;
6497
+ // Calculate progress based on pipeline tasks
6498
+ const totalTasks = pipeline.tasks.length;
6499
+ let completedTasks = 0;
6500
+ let currentTaskName = '';
6501
+ // Check execution report for completed tasks
6502
+ if ((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) {
6503
+ const executedTaskTitles = new Set(cv.executionReport.promptExecutions.map((execution) => execution.prompt.title));
6504
+ // Count completed tasks by matching titles
6505
+ const completedTasksByTitle = pipeline.tasks.filter((task) => executedTaskTitles.has(task.title));
6506
+ completedTasks = completedTasksByTitle.length;
6507
+ // Find current task being executed (first task not yet completed)
6508
+ const remainingTasks = pipeline.tasks.filter((task) => !executedTaskTitles.has(task.title));
6509
+ if (remainingTasks.length > 0) {
6510
+ currentTaskName = remainingTasks[0].name;
6511
+ }
6524
6512
  }
6525
- }
6526
- // Calculate progress percentage
6527
- let percent = totalTasks > 0 ? completedTasks / totalTasks : 0;
6528
- // Add time-based progress for current task (assuming 5 minutes total)
6529
- if (completedTasks < totalTasks) {
6530
- const elapsedMs = new Date().getTime() - createdAt.getTime();
6531
- const totalMs = 5 * 60 * 1000; // 5 minutes
6532
- const timeProgress = Math.min(elapsedMs / totalMs, 1);
6533
- // Add partial progress for current task
6534
- percent += (1 / totalTasks) * timeProgress;
6535
- }
6536
- // Clamp to [0,1]
6537
- percent = Math.min(Math.max(percent, 0), 1);
6538
- // Generate message
6539
- let message = '';
6540
- if (currentTaskName) {
6541
- // Find the task to get its title
6542
- const currentTask = pipeline.tasks.find(task => task.name === currentTaskName);
6543
- const taskTitle = (currentTask === null || currentTask === void 0 ? void 0 : currentTask.title) || currentTaskName;
6544
- message = `Working on task ${taskTitle}`;
6545
- }
6546
- else if (completedTasks === 0) {
6547
- message = 'Starting pipeline execution';
6548
- }
6549
- else {
6550
- message = `Processing pipeline (${completedTasks}/${totalTasks} tasks completed)`;
6551
- }
6552
- return {
6553
- percent,
6554
- message,
6555
- };
6513
+ // Calculate progress percentage
6514
+ let percent = totalTasks > 0 ? completedTasks / totalTasks : 0;
6515
+ // Add time-based progress for current task (assuming 5 minutes total)
6516
+ if (completedTasks < totalTasks) {
6517
+ const elapsedMs = new Date().getTime() - new Date().getTime(); // Will be overridden by actual elapsed time in task
6518
+ const totalMs = 5 * 60 * 1000; // 5 minutes
6519
+ const timeProgress = Math.min(elapsedMs / totalMs, 1);
6520
+ // Add partial progress for current task
6521
+ percent += (1 / totalTasks) * timeProgress;
6522
+ }
6523
+ // Clamp to [0,1]
6524
+ percent = Math.min(Math.max(percent, 0), 1);
6525
+ // Generate message
6526
+ let message = '';
6527
+ if (currentTaskName) {
6528
+ // Find the task to get its title
6529
+ const currentTask = pipeline.tasks.find((task) => task.name === currentTaskName);
6530
+ const taskTitle = (currentTask === null || currentTask === void 0 ? void 0 : currentTask.title) || currentTaskName;
6531
+ message = `Working on task ${taskTitle}`;
6532
+ }
6533
+ else if (completedTasks === 0) {
6534
+ message = 'Starting pipeline execution';
6535
+ }
6536
+ else {
6537
+ message = `Processing pipeline (${completedTasks}/${totalTasks} tasks completed)`;
6538
+ }
6539
+ updateTldr({
6540
+ percent: percent,
6541
+ message,
6542
+ });
6543
+ });
6556
6544
  },
6557
6545
  });
6558
6546
  // <- TODO: Make types such as there is no need to do `as` for `createTask`