@promptbook/pdf 0.100.0-44 → 0.100.0-46
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.
- package/esm/index.es.js +98 -86
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/components.index.d.ts +14 -0
- package/esm/typings/src/_packages/core.index.d.ts +4 -0
- package/esm/typings/src/_packages/types.index.d.ts +8 -0
- package/esm/typings/src/book-2.0/commitments/_misc/AgentModelRequirements.d.ts +1 -1
- package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.d.ts +26 -0
- package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfileFromSource.d.ts +19 -0
- package/esm/typings/src/book-components/BookEditor/BookEditorInner.d.ts +15 -0
- package/esm/typings/src/book-components/Chat/Chat/Chat.d.ts +128 -0
- package/esm/typings/src/book-components/Chat/interfaces/ChatMessage.d.ts +16 -0
- package/esm/typings/src/book-components/Chat/interfaces/ChatParticipant.d.ts +12 -0
- package/esm/typings/src/book-components/Chat/utils/ExportFormat.d.ts +4 -0
- package/esm/typings/src/book-components/Chat/utils/addUtmParamsToUrl.d.ts +7 -0
- package/esm/typings/src/book-components/Chat/utils/createShortLinkForChat.d.ts +7 -0
- package/esm/typings/src/book-components/Chat/utils/downloadFile.d.ts +6 -0
- package/esm/typings/src/book-components/Chat/utils/exportChatHistory.d.ts +11 -0
- package/esm/typings/src/book-components/Chat/utils/generatePdfContent.d.ts +10 -0
- package/esm/typings/src/book-components/Chat/utils/generateQrDataUrl.d.ts +7 -0
- package/esm/typings/src/book-components/Chat/utils/getPromptbookBranding.d.ts +6 -0
- package/esm/typings/src/book-components/Chat/utils/messagesToHtml.d.ts +10 -0
- package/esm/typings/src/book-components/Chat/utils/messagesToJson.d.ts +7 -0
- package/esm/typings/src/book-components/Chat/utils/messagesToMarkdown.d.ts +10 -0
- package/esm/typings/src/book-components/Chat/utils/messagesToText.d.ts +10 -0
- package/esm/typings/src/config.d.ts +13 -0
- package/esm/typings/src/execution/ExecutionTask.d.ts +12 -13
- package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +8 -0
- package/esm/typings/src/playground/permanent/error-handling-playground.d.ts +5 -0
- package/esm/typings/src/utils/organization/preserve.d.ts +21 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -3
- package/umd/index.umd.js +102 -90
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +0 -14
package/umd/index.umd.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('fs/promises'), require('spacetrim'), require('crypto-js'), require('crypto-js/enc-hex'), require('path'), require('prettier'), require('prettier/parser-
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'fs/promises', 'spacetrim', 'crypto-js', 'crypto-js/enc-hex', 'path', 'prettier', 'prettier/parser-
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-pdf"] = {}, global.promises, global.spaceTrim, global.cryptoJs, global.hexEncoder, global.path, global.
|
|
5
|
-
})(this, (function (exports, promises, spaceTrim, cryptoJs, hexEncoder, path,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('fs/promises'), require('spacetrim'), require('crypto-js'), require('crypto-js/enc-hex'), require('path'), require('prettier/parser-html'), require('prettier/parser-markdown'), require('prettier/standalone'), require('crypto'), require('rxjs'), require('waitasecond'), require('crypto-js/sha256'), require('mime-types'), require('papaparse')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'fs/promises', 'spacetrim', 'crypto-js', 'crypto-js/enc-hex', 'path', 'prettier/parser-html', 'prettier/parser-markdown', 'prettier/standalone', 'crypto', 'rxjs', 'waitasecond', 'crypto-js/sha256', 'mime-types', 'papaparse'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-pdf"] = {}, global.promises, global.spaceTrim, global.cryptoJs, global.hexEncoder, global.path, global.parserHtml, global.parserMarkdown, global.standalone, global.crypto, global.rxjs, global.waitasecond, global.sha256, global.mimeTypes, global.papaparse));
|
|
5
|
+
})(this, (function (exports, promises, spaceTrim, cryptoJs, hexEncoder, path, parserHtml, parserMarkdown, standalone, crypto, rxjs, waitasecond, sha256, mimeTypes, papaparse) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
9
9
|
var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim);
|
|
10
10
|
var hexEncoder__default = /*#__PURE__*/_interopDefaultLegacy(hexEncoder);
|
|
11
11
|
var parserHtml__default = /*#__PURE__*/_interopDefaultLegacy(parserHtml);
|
|
12
|
+
var parserMarkdown__default = /*#__PURE__*/_interopDefaultLegacy(parserMarkdown);
|
|
12
13
|
var sha256__default = /*#__PURE__*/_interopDefaultLegacy(sha256);
|
|
13
14
|
|
|
14
15
|
// ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
|
|
@@ -25,7 +26,7 @@
|
|
|
25
26
|
* @generated
|
|
26
27
|
* @see https://github.com/webgptorg/promptbook
|
|
27
28
|
*/
|
|
28
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-
|
|
29
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-46';
|
|
29
30
|
/**
|
|
30
31
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
31
32
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -223,6 +224,13 @@
|
|
|
223
224
|
* @public exported from `@promptbook/core`
|
|
224
225
|
*/
|
|
225
226
|
const DEFAULT_TASK_SIMULATED_DURATION_MS = 5 * 60 * 1000; // 5 minutes
|
|
227
|
+
/**
|
|
228
|
+
* API request timeout in milliseconds
|
|
229
|
+
* Can be overridden via API_REQUEST_TIMEOUT environment variable
|
|
230
|
+
*
|
|
231
|
+
* @public exported from `@promptbook/core`
|
|
232
|
+
*/
|
|
233
|
+
parseInt(process.env.API_REQUEST_TIMEOUT || '90000');
|
|
226
234
|
/**
|
|
227
235
|
* Indicates whether pipeline logic validation is enabled. When true, the pipeline logic is checked for consistency.
|
|
228
236
|
*
|
|
@@ -1037,9 +1045,9 @@
|
|
|
1037
1045
|
*/
|
|
1038
1046
|
function prettifyMarkdown(content) {
|
|
1039
1047
|
try {
|
|
1040
|
-
return
|
|
1048
|
+
return standalone.format(content, {
|
|
1041
1049
|
parser: 'markdown',
|
|
1042
|
-
plugins: [parserHtml__default["default"]],
|
|
1050
|
+
plugins: [parserMarkdown__default["default"], parserHtml__default["default"]],
|
|
1043
1051
|
// TODO: DRY - make some import or auto-copy of .prettierrc
|
|
1044
1052
|
endOfLine: 'lf',
|
|
1045
1053
|
tabWidth: 4,
|
|
@@ -2531,7 +2539,7 @@
|
|
|
2531
2539
|
* @private internal helper function
|
|
2532
2540
|
*/
|
|
2533
2541
|
function createTask(options) {
|
|
2534
|
-
const { taskType, taskProcessCallback
|
|
2542
|
+
const { taskType, taskProcessCallback } = options;
|
|
2535
2543
|
let { title } = options;
|
|
2536
2544
|
// TODO: [🐙] DRY
|
|
2537
2545
|
const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid similar char conflicts */)}`;
|
|
@@ -2541,6 +2549,7 @@
|
|
|
2541
2549
|
const errors = [];
|
|
2542
2550
|
const warnings = [];
|
|
2543
2551
|
let currentValue = {};
|
|
2552
|
+
let customTldr = null;
|
|
2544
2553
|
const partialResultSubject = new rxjs.Subject();
|
|
2545
2554
|
// <- Note: Not using `BehaviorSubject` because on error we can't access the last value
|
|
2546
2555
|
const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
|
|
@@ -2551,6 +2560,9 @@
|
|
|
2551
2560
|
Object.assign(currentValue, newOngoingResult);
|
|
2552
2561
|
// <- TODO: assign deep
|
|
2553
2562
|
partialResultSubject.next(newOngoingResult);
|
|
2563
|
+
}, (tldrInfo) => {
|
|
2564
|
+
customTldr = tldrInfo;
|
|
2565
|
+
updatedAt = new Date();
|
|
2554
2566
|
});
|
|
2555
2567
|
finalResultPromise
|
|
2556
2568
|
.catch((error) => {
|
|
@@ -2606,9 +2618,9 @@
|
|
|
2606
2618
|
},
|
|
2607
2619
|
get tldr() {
|
|
2608
2620
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2609
|
-
// Use custom tldr
|
|
2610
|
-
if (
|
|
2611
|
-
return
|
|
2621
|
+
// Use custom tldr if available
|
|
2622
|
+
if (customTldr) {
|
|
2623
|
+
return customTldr;
|
|
2612
2624
|
}
|
|
2613
2625
|
// Fallback to default implementation
|
|
2614
2626
|
const cv = currentValue;
|
|
@@ -3175,7 +3187,7 @@
|
|
|
3175
3187
|
const result = await preparePersonaExecutor({
|
|
3176
3188
|
availableModels /* <- Note: Passing as JSON */,
|
|
3177
3189
|
personaDescription,
|
|
3178
|
-
}).asPromise();
|
|
3190
|
+
}).asPromise({ isCrashedOnError: true });
|
|
3179
3191
|
const { outputParameters } = result;
|
|
3180
3192
|
const { modelsRequirements: modelsRequirementsJson } = outputParameters;
|
|
3181
3193
|
let modelsRequirementsUnchecked = jsonParse(modelsRequirementsJson);
|
|
@@ -3939,7 +3951,7 @@
|
|
|
3939
3951
|
});
|
|
3940
3952
|
const result = await prepareTitleExecutor({
|
|
3941
3953
|
book: sources.map(({ content }) => content).join('\n\n'),
|
|
3942
|
-
}).asPromise();
|
|
3954
|
+
}).asPromise({ isCrashedOnError: true });
|
|
3943
3955
|
const { outputParameters } = result;
|
|
3944
3956
|
const { title: titleRaw } = outputParameters;
|
|
3945
3957
|
if (isVerbose) {
|
|
@@ -6154,80 +6166,74 @@
|
|
|
6154
6166
|
});
|
|
6155
6167
|
});
|
|
6156
6168
|
};
|
|
6157
|
-
const pipelineExecutor = (inputParameters) =>
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
|
|
6162
|
-
|
|
6163
|
-
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
|
|
6169
|
-
|
|
6170
|
-
|
|
6171
|
-
|
|
6172
|
-
|
|
6173
|
-
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6197
|
-
|
|
6198
|
-
|
|
6199
|
-
|
|
6200
|
-
|
|
6201
|
-
|
|
6202
|
-
|
|
6203
|
-
|
|
6204
|
-
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
|
|
6208
|
-
|
|
6209
|
-
|
|
6210
|
-
|
|
6211
|
-
|
|
6212
|
-
|
|
6213
|
-
|
|
6214
|
-
|
|
6215
|
-
|
|
6216
|
-
|
|
6217
|
-
|
|
6218
|
-
|
|
6219
|
-
|
|
6220
|
-
|
|
6221
|
-
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
return {
|
|
6226
|
-
percent,
|
|
6227
|
-
message,
|
|
6228
|
-
};
|
|
6229
|
-
},
|
|
6230
|
-
});
|
|
6169
|
+
const pipelineExecutor = (inputParameters) => {
|
|
6170
|
+
const startTime = new Date().getTime();
|
|
6171
|
+
return createTask({
|
|
6172
|
+
taskType: 'EXECUTION',
|
|
6173
|
+
title: pipeline.title,
|
|
6174
|
+
taskProcessCallback(updateOngoingResult, updateTldr) {
|
|
6175
|
+
return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
|
|
6176
|
+
var _a, _b;
|
|
6177
|
+
updateOngoingResult(newOngoingResult);
|
|
6178
|
+
// Calculate and update tldr based on pipeline progress
|
|
6179
|
+
const cv = newOngoingResult;
|
|
6180
|
+
// Calculate progress based on parameters resolved vs total parameters
|
|
6181
|
+
const totalParameters = pipeline.parameters.filter(p => !p.isInput).length;
|
|
6182
|
+
let resolvedParameters = 0;
|
|
6183
|
+
let currentTaskTitle = '';
|
|
6184
|
+
// Get the resolved parameters from output parameters
|
|
6185
|
+
if (cv === null || cv === void 0 ? void 0 : cv.outputParameters) {
|
|
6186
|
+
// Count how many output parameters have non-empty values
|
|
6187
|
+
resolvedParameters = Object.values(cv.outputParameters).filter(value => value !== undefined && value !== null && String(value).trim() !== '').length;
|
|
6188
|
+
}
|
|
6189
|
+
// Try to determine current task from execution report
|
|
6190
|
+
if (((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) && cv.executionReport.promptExecutions.length > 0) {
|
|
6191
|
+
const lastExecution = cv.executionReport.promptExecutions[cv.executionReport.promptExecutions.length - 1];
|
|
6192
|
+
if ((_b = lastExecution === null || lastExecution === void 0 ? void 0 : lastExecution.prompt) === null || _b === void 0 ? void 0 : _b.title) {
|
|
6193
|
+
currentTaskTitle = lastExecution.prompt.title;
|
|
6194
|
+
}
|
|
6195
|
+
}
|
|
6196
|
+
// Calculate base progress percentage
|
|
6197
|
+
let percent = totalParameters > 0 ? resolvedParameters / totalParameters : 0;
|
|
6198
|
+
// Add time-based progress for current task if we haven't completed all parameters
|
|
6199
|
+
if (resolvedParameters < totalParameters) {
|
|
6200
|
+
const elapsedMs = new Date().getTime() - startTime;
|
|
6201
|
+
const estimatedTotalMs = totalParameters * 30 * 1000; // Estimate 30 seconds per parameter
|
|
6202
|
+
const timeProgress = Math.min(elapsedMs / estimatedTotalMs, 0.9); // Cap at 90% for time-based progress
|
|
6203
|
+
// If we have time progress but no parameter progress, show time progress
|
|
6204
|
+
if (percent === 0 && timeProgress > 0) {
|
|
6205
|
+
percent = Math.min(timeProgress, 0.1); // Show some progress but not more than 10%
|
|
6206
|
+
}
|
|
6207
|
+
else if (percent < 1) {
|
|
6208
|
+
// Add partial progress for current task
|
|
6209
|
+
const taskProgress = totalParameters > 0 ? (1 / totalParameters) * 0.5 : 0; // 50% of task progress
|
|
6210
|
+
percent = Math.min(percent + taskProgress, 0.95); // Cap at 95% until fully complete
|
|
6211
|
+
}
|
|
6212
|
+
}
|
|
6213
|
+
// Clamp to [0,1]
|
|
6214
|
+
percent = Math.min(Math.max(percent, 0), 1);
|
|
6215
|
+
// Generate message
|
|
6216
|
+
let message = '';
|
|
6217
|
+
if (currentTaskTitle) {
|
|
6218
|
+
message = `Executing: ${currentTaskTitle}`;
|
|
6219
|
+
}
|
|
6220
|
+
else if (resolvedParameters === 0) {
|
|
6221
|
+
message = 'Starting pipeline execution';
|
|
6222
|
+
}
|
|
6223
|
+
else if (resolvedParameters < totalParameters) {
|
|
6224
|
+
message = `Processing pipeline (${resolvedParameters}/${totalParameters} parameters resolved)`;
|
|
6225
|
+
}
|
|
6226
|
+
else {
|
|
6227
|
+
message = 'Completing pipeline execution';
|
|
6228
|
+
}
|
|
6229
|
+
updateTldr({
|
|
6230
|
+
percent: percent,
|
|
6231
|
+
message,
|
|
6232
|
+
});
|
|
6233
|
+
});
|
|
6234
|
+
},
|
|
6235
|
+
});
|
|
6236
|
+
};
|
|
6231
6237
|
// <- TODO: Make types such as there is no need to do `as` for `createTask`
|
|
6232
6238
|
return pipelineExecutor;
|
|
6233
6239
|
}
|
|
@@ -6312,7 +6318,9 @@
|
|
|
6312
6318
|
},
|
|
6313
6319
|
});
|
|
6314
6320
|
const knowledgeContent = await source.asText();
|
|
6315
|
-
const result = await prepareKnowledgeFromMarkdownExecutor({ knowledgeContent }).asPromise(
|
|
6321
|
+
const result = await prepareKnowledgeFromMarkdownExecutor({ knowledgeContent }).asPromise({
|
|
6322
|
+
isCrashedOnError: true,
|
|
6323
|
+
});
|
|
6316
6324
|
const { outputParameters } = result;
|
|
6317
6325
|
const { knowledgePieces: knowledgePiecesRaw } = outputParameters;
|
|
6318
6326
|
const knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
|
|
@@ -6336,12 +6344,16 @@
|
|
|
6336
6344
|
];
|
|
6337
6345
|
*/
|
|
6338
6346
|
try {
|
|
6339
|
-
const titleResult = await prepareTitleExecutor({ knowledgePieceContent }).asPromise(
|
|
6347
|
+
const titleResult = await prepareTitleExecutor({ knowledgePieceContent }).asPromise({
|
|
6348
|
+
isCrashedOnError: true,
|
|
6349
|
+
});
|
|
6340
6350
|
const { title: titleRaw = 'Untitled' } = titleResult.outputParameters;
|
|
6341
6351
|
title = spaceTrim__default["default"](titleRaw) /* <- TODO: Maybe do in pipeline */;
|
|
6342
6352
|
name = titleToName(title);
|
|
6343
6353
|
// --- Keywords
|
|
6344
|
-
const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise(
|
|
6354
|
+
const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise({
|
|
6355
|
+
isCrashedOnError: true,
|
|
6356
|
+
});
|
|
6345
6357
|
const { keywords: keywordsRaw = '' } = keywordsResult.outputParameters;
|
|
6346
6358
|
keywords = (keywordsRaw || '')
|
|
6347
6359
|
.split(',')
|