@promptbook/wizard 0.100.0-44 → 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
@@ -38,7 +38,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
38
38
  * @generated
39
39
  * @see https://github.com/webgptorg/promptbook
40
40
  */
41
- const PROMPTBOOK_ENGINE_VERSION = '0.100.0-44';
41
+ const PROMPTBOOK_ENGINE_VERSION = '0.100.0-45';
42
42
  /**
43
43
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
44
44
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -7171,7 +7171,7 @@ function assertsTaskSuccessful(executionResult) {
7171
7171
  * @private internal helper function
7172
7172
  */
7173
7173
  function createTask(options) {
7174
- const { taskType, taskProcessCallback, tldrProvider } = options;
7174
+ const { taskType, taskProcessCallback } = options;
7175
7175
  let { title } = options;
7176
7176
  // TODO: [🐙] DRY
7177
7177
  const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid similar char conflicts */)}`;
@@ -7181,6 +7181,7 @@ function createTask(options) {
7181
7181
  const errors = [];
7182
7182
  const warnings = [];
7183
7183
  let currentValue = {};
7184
+ let customTldr = null;
7184
7185
  const partialResultSubject = new Subject();
7185
7186
  // <- Note: Not using `BehaviorSubject` because on error we can't access the last value
7186
7187
  const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
@@ -7191,6 +7192,9 @@ function createTask(options) {
7191
7192
  Object.assign(currentValue, newOngoingResult);
7192
7193
  // <- TODO: assign deep
7193
7194
  partialResultSubject.next(newOngoingResult);
7195
+ }, (tldrInfo) => {
7196
+ customTldr = tldrInfo;
7197
+ updatedAt = new Date();
7194
7198
  });
7195
7199
  finalResultPromise
7196
7200
  .catch((error) => {
@@ -7246,9 +7250,9 @@ function createTask(options) {
7246
7250
  },
7247
7251
  get tldr() {
7248
7252
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
7249
- // Use custom tldr provider if available
7250
- if (tldrProvider) {
7251
- return tldrProvider(createdAt, status, currentValue, errors, warnings);
7253
+ // Use custom tldr if available
7254
+ if (customTldr) {
7255
+ return customTldr;
7252
7256
  }
7253
7257
  // Fallback to default implementation
7254
7258
  const cv = currentValue;
@@ -10312,75 +10316,59 @@ function createPipelineExecutor(options) {
10312
10316
  const pipelineExecutor = (inputParameters) => createTask({
10313
10317
  taskType: 'EXECUTION',
10314
10318
  title: pipeline.title,
10315
- taskProcessCallback(updateOngoingResult) {
10319
+ taskProcessCallback(updateOngoingResult, updateTldr) {
10316
10320
  return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
10321
+ var _a;
10317
10322
  updateOngoingResult(newOngoingResult);
10318
- });
10319
- },
10320
- tldrProvider(createdAt, status, currentValue, errors) {
10321
- var _a;
10322
- // Better progress estimation based on pipeline structure
10323
- const cv = currentValue;
10324
- // Handle finished/error states
10325
- if (status === 'FINISHED') {
10326
- return {
10327
- percent: 1,
10328
- message: 'Finished',
10329
- };
10330
- }
10331
- if (status === 'ERROR') {
10332
- const errorMessage = errors.length > 0 ? errors[errors.length - 1].message : 'Error';
10333
- return {
10334
- percent: 0,
10335
- message: errorMessage,
10336
- };
10337
- }
10338
- // Calculate progress based on pipeline tasks
10339
- const totalTasks = pipeline.tasks.length;
10340
- let completedTasks = 0;
10341
- let currentTaskName = '';
10342
- // Check execution report for completed tasks
10343
- if ((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) {
10344
- const executedTaskTitles = new Set(cv.executionReport.promptExecutions.map((execution) => execution.prompt.title));
10345
- // Count completed tasks by matching titles
10346
- const completedTasksByTitle = pipeline.tasks.filter(task => executedTaskTitles.has(task.title));
10347
- completedTasks = completedTasksByTitle.length;
10348
- // Find current task being executed (first task not yet completed)
10349
- const remainingTasks = pipeline.tasks.filter(task => !executedTaskTitles.has(task.title));
10350
- if (remainingTasks.length > 0) {
10351
- currentTaskName = remainingTasks[0].name;
10323
+ // Calculate and update tldr based on pipeline progress
10324
+ const cv = newOngoingResult;
10325
+ // Calculate progress based on pipeline tasks
10326
+ const totalTasks = pipeline.tasks.length;
10327
+ let completedTasks = 0;
10328
+ let currentTaskName = '';
10329
+ // Check execution report for completed tasks
10330
+ if ((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) {
10331
+ const executedTaskTitles = new Set(cv.executionReport.promptExecutions.map((execution) => execution.prompt.title));
10332
+ // Count completed tasks by matching titles
10333
+ const completedTasksByTitle = pipeline.tasks.filter((task) => executedTaskTitles.has(task.title));
10334
+ completedTasks = completedTasksByTitle.length;
10335
+ // Find current task being executed (first task not yet completed)
10336
+ const remainingTasks = pipeline.tasks.filter((task) => !executedTaskTitles.has(task.title));
10337
+ if (remainingTasks.length > 0) {
10338
+ currentTaskName = remainingTasks[0].name;
10339
+ }
10352
10340
  }
10353
- }
10354
- // Calculate progress percentage
10355
- let percent = totalTasks > 0 ? completedTasks / totalTasks : 0;
10356
- // Add time-based progress for current task (assuming 5 minutes total)
10357
- if (completedTasks < totalTasks) {
10358
- const elapsedMs = new Date().getTime() - createdAt.getTime();
10359
- const totalMs = 5 * 60 * 1000; // 5 minutes
10360
- const timeProgress = Math.min(elapsedMs / totalMs, 1);
10361
- // Add partial progress for current task
10362
- percent += (1 / totalTasks) * timeProgress;
10363
- }
10364
- // Clamp to [0,1]
10365
- percent = Math.min(Math.max(percent, 0), 1);
10366
- // Generate message
10367
- let message = '';
10368
- if (currentTaskName) {
10369
- // Find the task to get its title
10370
- const currentTask = pipeline.tasks.find(task => task.name === currentTaskName);
10371
- const taskTitle = (currentTask === null || currentTask === void 0 ? void 0 : currentTask.title) || currentTaskName;
10372
- message = `Working on task ${taskTitle}`;
10373
- }
10374
- else if (completedTasks === 0) {
10375
- message = 'Starting pipeline execution';
10376
- }
10377
- else {
10378
- message = `Processing pipeline (${completedTasks}/${totalTasks} tasks completed)`;
10379
- }
10380
- return {
10381
- percent,
10382
- message,
10383
- };
10341
+ // Calculate progress percentage
10342
+ let percent = totalTasks > 0 ? completedTasks / totalTasks : 0;
10343
+ // Add time-based progress for current task (assuming 5 minutes total)
10344
+ if (completedTasks < totalTasks) {
10345
+ const elapsedMs = new Date().getTime() - new Date().getTime(); // Will be overridden by actual elapsed time in task
10346
+ const totalMs = 5 * 60 * 1000; // 5 minutes
10347
+ const timeProgress = Math.min(elapsedMs / totalMs, 1);
10348
+ // Add partial progress for current task
10349
+ percent += (1 / totalTasks) * timeProgress;
10350
+ }
10351
+ // Clamp to [0,1]
10352
+ percent = Math.min(Math.max(percent, 0), 1);
10353
+ // Generate message
10354
+ let message = '';
10355
+ if (currentTaskName) {
10356
+ // Find the task to get its title
10357
+ const currentTask = pipeline.tasks.find((task) => task.name === currentTaskName);
10358
+ const taskTitle = (currentTask === null || currentTask === void 0 ? void 0 : currentTask.title) || currentTaskName;
10359
+ message = `Working on task ${taskTitle}`;
10360
+ }
10361
+ else if (completedTasks === 0) {
10362
+ message = 'Starting pipeline execution';
10363
+ }
10364
+ else {
10365
+ message = `Processing pipeline (${completedTasks}/${totalTasks} tasks completed)`;
10366
+ }
10367
+ updateTldr({
10368
+ percent: percent,
10369
+ message,
10370
+ });
10371
+ });
10384
10372
  },
10385
10373
  });
10386
10374
  // <- TODO: Make types such as there is no need to do `as` for `createTask`