@promptbook/cli 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
@@ -47,7 +47,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
47
47
  * @generated
48
48
  * @see https://github.com/webgptorg/promptbook
49
49
  */
50
- const PROMPTBOOK_ENGINE_VERSION = '0.100.0-43';
50
+ const PROMPTBOOK_ENGINE_VERSION = '0.100.0-45';
51
51
  /**
52
52
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
53
53
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -5593,7 +5593,7 @@ function assertsTaskSuccessful(executionResult) {
5593
5593
  * @private internal helper function
5594
5594
  */
5595
5595
  function createTask(options) {
5596
- const { taskType, taskProcessCallback, tldrProvider } = options;
5596
+ const { taskType, taskProcessCallback } = options;
5597
5597
  let { title } = options;
5598
5598
  // TODO: [🐙] DRY
5599
5599
  const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid similar char conflicts */)}`;
@@ -5603,6 +5603,7 @@ function createTask(options) {
5603
5603
  const errors = [];
5604
5604
  const warnings = [];
5605
5605
  let currentValue = {};
5606
+ let customTldr = null;
5606
5607
  const partialResultSubject = new Subject();
5607
5608
  // <- Note: Not using `BehaviorSubject` because on error we can't access the last value
5608
5609
  const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
@@ -5613,6 +5614,9 @@ function createTask(options) {
5613
5614
  Object.assign(currentValue, newOngoingResult);
5614
5615
  // <- TODO: assign deep
5615
5616
  partialResultSubject.next(newOngoingResult);
5617
+ }, (tldrInfo) => {
5618
+ customTldr = tldrInfo;
5619
+ updatedAt = new Date();
5616
5620
  });
5617
5621
  finalResultPromise
5618
5622
  .catch((error) => {
@@ -5668,9 +5672,9 @@ function createTask(options) {
5668
5672
  },
5669
5673
  get tldr() {
5670
5674
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
5671
- // Use custom tldr provider if available
5672
- if (tldrProvider) {
5673
- return tldrProvider(createdAt, status, currentValue, errors, warnings);
5675
+ // Use custom tldr if available
5676
+ if (customTldr) {
5677
+ return customTldr;
5674
5678
  }
5675
5679
  // Fallback to default implementation
5676
5680
  const cv = currentValue;
@@ -7595,75 +7599,59 @@ function createPipelineExecutor(options) {
7595
7599
  const pipelineExecutor = (inputParameters) => createTask({
7596
7600
  taskType: 'EXECUTION',
7597
7601
  title: pipeline.title,
7598
- taskProcessCallback(updateOngoingResult) {
7602
+ taskProcessCallback(updateOngoingResult, updateTldr) {
7599
7603
  return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
7604
+ var _a;
7600
7605
  updateOngoingResult(newOngoingResult);
7601
- });
7602
- },
7603
- tldrProvider(createdAt, status, currentValue, errors) {
7604
- var _a;
7605
- // Better progress estimation based on pipeline structure
7606
- const cv = currentValue;
7607
- // Handle finished/error states
7608
- if (status === 'FINISHED') {
7609
- return {
7610
- percent: 1,
7611
- message: 'Finished',
7612
- };
7613
- }
7614
- if (status === 'ERROR') {
7615
- const errorMessage = errors.length > 0 ? errors[errors.length - 1].message : 'Error';
7616
- return {
7617
- percent: 0,
7618
- message: errorMessage,
7619
- };
7620
- }
7621
- // Calculate progress based on pipeline tasks
7622
- const totalTasks = pipeline.tasks.length;
7623
- let completedTasks = 0;
7624
- let currentTaskName = '';
7625
- // Check execution report for completed tasks
7626
- if ((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) {
7627
- const executedTaskTitles = new Set(cv.executionReport.promptExecutions.map((execution) => execution.prompt.title));
7628
- // Count completed tasks by matching titles
7629
- const completedTasksByTitle = pipeline.tasks.filter(task => executedTaskTitles.has(task.title));
7630
- completedTasks = completedTasksByTitle.length;
7631
- // Find current task being executed (first task not yet completed)
7632
- const remainingTasks = pipeline.tasks.filter(task => !executedTaskTitles.has(task.title));
7633
- if (remainingTasks.length > 0) {
7634
- currentTaskName = remainingTasks[0].name;
7606
+ // Calculate and update tldr based on pipeline progress
7607
+ const cv = newOngoingResult;
7608
+ // Calculate progress based on pipeline tasks
7609
+ const totalTasks = pipeline.tasks.length;
7610
+ let completedTasks = 0;
7611
+ let currentTaskName = '';
7612
+ // Check execution report for completed tasks
7613
+ if ((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) {
7614
+ const executedTaskTitles = new Set(cv.executionReport.promptExecutions.map((execution) => execution.prompt.title));
7615
+ // Count completed tasks by matching titles
7616
+ const completedTasksByTitle = pipeline.tasks.filter((task) => executedTaskTitles.has(task.title));
7617
+ completedTasks = completedTasksByTitle.length;
7618
+ // Find current task being executed (first task not yet completed)
7619
+ const remainingTasks = pipeline.tasks.filter((task) => !executedTaskTitles.has(task.title));
7620
+ if (remainingTasks.length > 0) {
7621
+ currentTaskName = remainingTasks[0].name;
7622
+ }
7635
7623
  }
7636
- }
7637
- // Calculate progress percentage
7638
- let percent = totalTasks > 0 ? completedTasks / totalTasks : 0;
7639
- // Add time-based progress for current task (assuming 5 minutes total)
7640
- if (completedTasks < totalTasks) {
7641
- const elapsedMs = new Date().getTime() - createdAt.getTime();
7642
- const totalMs = 5 * 60 * 1000; // 5 minutes
7643
- const timeProgress = Math.min(elapsedMs / totalMs, 1);
7644
- // Add partial progress for current task
7645
- percent += (1 / totalTasks) * timeProgress;
7646
- }
7647
- // Clamp to [0,1]
7648
- percent = Math.min(Math.max(percent, 0), 1);
7649
- // Generate message
7650
- let message = '';
7651
- if (currentTaskName) {
7652
- // Find the task to get its title
7653
- const currentTask = pipeline.tasks.find(task => task.name === currentTaskName);
7654
- const taskTitle = (currentTask === null || currentTask === void 0 ? void 0 : currentTask.title) || currentTaskName;
7655
- message = `Working on task ${taskTitle}`;
7656
- }
7657
- else if (completedTasks === 0) {
7658
- message = 'Starting pipeline execution';
7659
- }
7660
- else {
7661
- message = `Processing pipeline (${completedTasks}/${totalTasks} tasks completed)`;
7662
- }
7663
- return {
7664
- percent,
7665
- message,
7666
- };
7624
+ // Calculate progress percentage
7625
+ let percent = totalTasks > 0 ? completedTasks / totalTasks : 0;
7626
+ // Add time-based progress for current task (assuming 5 minutes total)
7627
+ if (completedTasks < totalTasks) {
7628
+ const elapsedMs = new Date().getTime() - new Date().getTime(); // Will be overridden by actual elapsed time in task
7629
+ const totalMs = 5 * 60 * 1000; // 5 minutes
7630
+ const timeProgress = Math.min(elapsedMs / totalMs, 1);
7631
+ // Add partial progress for current task
7632
+ percent += (1 / totalTasks) * timeProgress;
7633
+ }
7634
+ // Clamp to [0,1]
7635
+ percent = Math.min(Math.max(percent, 0), 1);
7636
+ // Generate message
7637
+ let message = '';
7638
+ if (currentTaskName) {
7639
+ // Find the task to get its title
7640
+ const currentTask = pipeline.tasks.find((task) => task.name === currentTaskName);
7641
+ const taskTitle = (currentTask === null || currentTask === void 0 ? void 0 : currentTask.title) || currentTaskName;
7642
+ message = `Working on task ${taskTitle}`;
7643
+ }
7644
+ else if (completedTasks === 0) {
7645
+ message = 'Starting pipeline execution';
7646
+ }
7647
+ else {
7648
+ message = `Processing pipeline (${completedTasks}/${totalTasks} tasks completed)`;
7649
+ }
7650
+ updateTldr({
7651
+ percent: percent,
7652
+ message,
7653
+ });
7654
+ });
7667
7655
  },
7668
7656
  });
7669
7657
  // <- TODO: Make types such as there is no need to do `as` for `createTask`