@promptbook/remote-server 0.100.0-45 → 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 +109 -99
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/components.index.d.ts +4 -0
- package/esm/typings/src/_packages/core.index.d.ts +2 -0
- package/esm/typings/src/_packages/types.index.d.ts +2 -6
- package/esm/typings/src/book-2.0/commitments/_misc/AgentModelRequirements.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/Chat/Chat.d.ts +4 -10
- package/esm/typings/src/book-components/Chat/interfaces/ChatMessage.d.ts +12 -26
- package/esm/typings/src/book-components/Chat/interfaces/ChatParticipant.d.ts +12 -0
- package/esm/typings/src/config.d.ts +7 -0
- package/esm/typings/src/execution/ExecutionTask.d.ts +8 -0
- 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 +113 -103
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +0 -14
package/esm/index.es.js
CHANGED
|
@@ -11,8 +11,9 @@ import { spawn } from 'child_process';
|
|
|
11
11
|
import { stat, access, constants, readFile, writeFile, readdir, mkdir } from 'fs/promises';
|
|
12
12
|
import { join, basename, dirname } from 'path';
|
|
13
13
|
import { Subject } from 'rxjs';
|
|
14
|
-
import { format } from 'prettier';
|
|
15
14
|
import parserHtml from 'prettier/parser-html';
|
|
15
|
+
import parserMarkdown from 'prettier/parser-markdown';
|
|
16
|
+
import { format } from 'prettier/standalone';
|
|
16
17
|
import hexEncoder from 'crypto-js/enc-hex';
|
|
17
18
|
import sha256 from 'crypto-js/sha256';
|
|
18
19
|
import { SHA256 } from 'crypto-js';
|
|
@@ -33,7 +34,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
33
34
|
* @generated
|
|
34
35
|
* @see https://github.com/webgptorg/promptbook
|
|
35
36
|
*/
|
|
36
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-
|
|
37
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-46';
|
|
37
38
|
/**
|
|
38
39
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
39
40
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -222,6 +223,13 @@ const DEFAULT_IS_AUTO_INSTALLED = false;
|
|
|
222
223
|
* @public exported from `@promptbook/core`
|
|
223
224
|
*/
|
|
224
225
|
const DEFAULT_TASK_SIMULATED_DURATION_MS = 5 * 60 * 1000; // 5 minutes
|
|
226
|
+
/**
|
|
227
|
+
* API request timeout in milliseconds
|
|
228
|
+
* Can be overridden via API_REQUEST_TIMEOUT environment variable
|
|
229
|
+
*
|
|
230
|
+
* @public exported from `@promptbook/core`
|
|
231
|
+
*/
|
|
232
|
+
parseInt(process.env.API_REQUEST_TIMEOUT || '90000');
|
|
225
233
|
/**
|
|
226
234
|
* Indicates whether pipeline logic validation is enabled. When true, the pipeline logic is checked for consistency.
|
|
227
235
|
*
|
|
@@ -2360,7 +2368,7 @@ function prettifyMarkdown(content) {
|
|
|
2360
2368
|
try {
|
|
2361
2369
|
return format(content, {
|
|
2362
2370
|
parser: 'markdown',
|
|
2363
|
-
plugins: [parserHtml],
|
|
2371
|
+
plugins: [parserMarkdown, parserHtml],
|
|
2364
2372
|
// TODO: DRY - make some import or auto-copy of .prettierrc
|
|
2365
2373
|
endOfLine: 'lf',
|
|
2366
2374
|
tabWidth: 4,
|
|
@@ -3102,7 +3110,7 @@ async function preparePersona(personaDescription, tools, options) {
|
|
|
3102
3110
|
const result = await preparePersonaExecutor({
|
|
3103
3111
|
availableModels /* <- Note: Passing as JSON */,
|
|
3104
3112
|
personaDescription,
|
|
3105
|
-
}).asPromise();
|
|
3113
|
+
}).asPromise({ isCrashedOnError: true });
|
|
3106
3114
|
const { outputParameters } = result;
|
|
3107
3115
|
const { modelsRequirements: modelsRequirementsJson } = outputParameters;
|
|
3108
3116
|
let modelsRequirementsUnchecked = jsonParse(modelsRequirementsJson);
|
|
@@ -4253,7 +4261,7 @@ async function preparePipeline(pipeline, tools, options) {
|
|
|
4253
4261
|
});
|
|
4254
4262
|
const result = await prepareTitleExecutor({
|
|
4255
4263
|
book: sources.map(({ content }) => content).join('\n\n'),
|
|
4256
|
-
}).asPromise();
|
|
4264
|
+
}).asPromise({ isCrashedOnError: true });
|
|
4257
4265
|
const { outputParameters } = result;
|
|
4258
4266
|
const { title: titleRaw } = outputParameters;
|
|
4259
4267
|
if (isVerbose) {
|
|
@@ -6485,64 +6493,74 @@ function createPipelineExecutor(options) {
|
|
|
6485
6493
|
});
|
|
6486
6494
|
});
|
|
6487
6495
|
};
|
|
6488
|
-
const pipelineExecutor = (inputParameters) =>
|
|
6489
|
-
|
|
6490
|
-
|
|
6491
|
-
|
|
6492
|
-
|
|
6493
|
-
|
|
6494
|
-
|
|
6495
|
-
|
|
6496
|
-
|
|
6497
|
-
|
|
6498
|
-
|
|
6499
|
-
|
|
6500
|
-
|
|
6501
|
-
|
|
6502
|
-
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
|
|
6506
|
-
|
|
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;
|
|
6496
|
+
const pipelineExecutor = (inputParameters) => {
|
|
6497
|
+
const startTime = new Date().getTime();
|
|
6498
|
+
return createTask({
|
|
6499
|
+
taskType: 'EXECUTION',
|
|
6500
|
+
title: pipeline.title,
|
|
6501
|
+
taskProcessCallback(updateOngoingResult, updateTldr) {
|
|
6502
|
+
return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
|
|
6503
|
+
var _a, _b;
|
|
6504
|
+
updateOngoingResult(newOngoingResult);
|
|
6505
|
+
// Calculate and update tldr based on pipeline progress
|
|
6506
|
+
const cv = newOngoingResult;
|
|
6507
|
+
// Calculate progress based on parameters resolved vs total parameters
|
|
6508
|
+
const totalParameters = pipeline.parameters.filter(p => !p.isInput).length;
|
|
6509
|
+
let resolvedParameters = 0;
|
|
6510
|
+
let currentTaskTitle = '';
|
|
6511
|
+
// Get the resolved parameters from output parameters
|
|
6512
|
+
if (cv === null || cv === void 0 ? void 0 : cv.outputParameters) {
|
|
6513
|
+
// Count how many output parameters have non-empty values
|
|
6514
|
+
resolvedParameters = Object.values(cv.outputParameters).filter(value => value !== undefined && value !== null && String(value).trim() !== '').length;
|
|
6511
6515
|
}
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
|
|
6515
|
-
|
|
6516
|
-
|
|
6517
|
-
|
|
6518
|
-
|
|
6519
|
-
|
|
6520
|
-
|
|
6521
|
-
|
|
6522
|
-
|
|
6523
|
-
|
|
6524
|
-
|
|
6525
|
-
|
|
6526
|
-
|
|
6527
|
-
|
|
6528
|
-
|
|
6529
|
-
|
|
6530
|
-
|
|
6531
|
-
|
|
6532
|
-
|
|
6533
|
-
|
|
6534
|
-
|
|
6535
|
-
|
|
6536
|
-
|
|
6537
|
-
|
|
6538
|
-
|
|
6539
|
-
|
|
6540
|
-
|
|
6541
|
-
|
|
6516
|
+
// Try to determine current task from execution report
|
|
6517
|
+
if (((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) && cv.executionReport.promptExecutions.length > 0) {
|
|
6518
|
+
const lastExecution = cv.executionReport.promptExecutions[cv.executionReport.promptExecutions.length - 1];
|
|
6519
|
+
if ((_b = lastExecution === null || lastExecution === void 0 ? void 0 : lastExecution.prompt) === null || _b === void 0 ? void 0 : _b.title) {
|
|
6520
|
+
currentTaskTitle = lastExecution.prompt.title;
|
|
6521
|
+
}
|
|
6522
|
+
}
|
|
6523
|
+
// Calculate base progress percentage
|
|
6524
|
+
let percent = totalParameters > 0 ? resolvedParameters / totalParameters : 0;
|
|
6525
|
+
// Add time-based progress for current task if we haven't completed all parameters
|
|
6526
|
+
if (resolvedParameters < totalParameters) {
|
|
6527
|
+
const elapsedMs = new Date().getTime() - startTime;
|
|
6528
|
+
const estimatedTotalMs = totalParameters * 30 * 1000; // Estimate 30 seconds per parameter
|
|
6529
|
+
const timeProgress = Math.min(elapsedMs / estimatedTotalMs, 0.9); // Cap at 90% for time-based progress
|
|
6530
|
+
// If we have time progress but no parameter progress, show time progress
|
|
6531
|
+
if (percent === 0 && timeProgress > 0) {
|
|
6532
|
+
percent = Math.min(timeProgress, 0.1); // Show some progress but not more than 10%
|
|
6533
|
+
}
|
|
6534
|
+
else if (percent < 1) {
|
|
6535
|
+
// Add partial progress for current task
|
|
6536
|
+
const taskProgress = totalParameters > 0 ? (1 / totalParameters) * 0.5 : 0; // 50% of task progress
|
|
6537
|
+
percent = Math.min(percent + taskProgress, 0.95); // Cap at 95% until fully complete
|
|
6538
|
+
}
|
|
6539
|
+
}
|
|
6540
|
+
// Clamp to [0,1]
|
|
6541
|
+
percent = Math.min(Math.max(percent, 0), 1);
|
|
6542
|
+
// Generate message
|
|
6543
|
+
let message = '';
|
|
6544
|
+
if (currentTaskTitle) {
|
|
6545
|
+
message = `Executing: ${currentTaskTitle}`;
|
|
6546
|
+
}
|
|
6547
|
+
else if (resolvedParameters === 0) {
|
|
6548
|
+
message = 'Starting pipeline execution';
|
|
6549
|
+
}
|
|
6550
|
+
else if (resolvedParameters < totalParameters) {
|
|
6551
|
+
message = `Processing pipeline (${resolvedParameters}/${totalParameters} parameters resolved)`;
|
|
6552
|
+
}
|
|
6553
|
+
else {
|
|
6554
|
+
message = 'Completing pipeline execution';
|
|
6555
|
+
}
|
|
6556
|
+
updateTldr({
|
|
6557
|
+
percent: percent,
|
|
6558
|
+
message,
|
|
6559
|
+
});
|
|
6542
6560
|
});
|
|
6543
|
-
}
|
|
6544
|
-
}
|
|
6545
|
-
}
|
|
6561
|
+
},
|
|
6562
|
+
});
|
|
6563
|
+
};
|
|
6546
6564
|
// <- TODO: Make types such as there is no need to do `as` for `createTask`
|
|
6547
6565
|
return pipelineExecutor;
|
|
6548
6566
|
}
|
|
@@ -7149,31 +7167,23 @@ function extractBlock(markdown) {
|
|
|
7149
7167
|
return content;
|
|
7150
7168
|
}
|
|
7151
7169
|
|
|
7170
|
+
/**
|
|
7171
|
+
* @private internal for `preserve`
|
|
7172
|
+
*/
|
|
7173
|
+
const _preserved = [];
|
|
7152
7174
|
/**
|
|
7153
7175
|
* Does nothing, but preserves the function in the bundle
|
|
7154
7176
|
* Compiler is tricked into thinking the function is used
|
|
7155
7177
|
*
|
|
7156
7178
|
* @param value any function to preserve
|
|
7157
7179
|
* @returns nothing
|
|
7158
|
-
* @private
|
|
7159
|
-
*/
|
|
7160
|
-
function preserve(
|
|
7161
|
-
|
|
7162
|
-
(async () => {
|
|
7163
|
-
// TODO: [💩] Change to `await forEver` or `forTime(Infinity)`
|
|
7164
|
-
await forTime(100000000);
|
|
7165
|
-
// [1]
|
|
7166
|
-
try {
|
|
7167
|
-
await func();
|
|
7168
|
-
}
|
|
7169
|
-
finally {
|
|
7170
|
-
// do nothing
|
|
7171
|
-
}
|
|
7172
|
-
})();
|
|
7180
|
+
* @private within the repository
|
|
7181
|
+
*/
|
|
7182
|
+
function $preserve(...value) {
|
|
7183
|
+
_preserved.push(...value);
|
|
7173
7184
|
}
|
|
7174
7185
|
/**
|
|
7175
|
-
*
|
|
7176
|
-
* TODO: [1] This maybe does memory leak
|
|
7186
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
7177
7187
|
*/
|
|
7178
7188
|
|
|
7179
7189
|
// Note: [💎]
|
|
@@ -7201,25 +7211,25 @@ class JavascriptEvalExecutionTools {
|
|
|
7201
7211
|
// Note: [💎]
|
|
7202
7212
|
// Note: Using direct eval, following variables are in same scope as eval call so they are accessible from inside the evaluated script:
|
|
7203
7213
|
const spaceTrim$1 = (_) => spaceTrim(_);
|
|
7204
|
-
preserve(spaceTrim$1);
|
|
7214
|
+
$preserve(spaceTrim$1);
|
|
7205
7215
|
const removeQuotes$1 = removeQuotes;
|
|
7206
|
-
preserve(removeQuotes$1);
|
|
7216
|
+
$preserve(removeQuotes$1);
|
|
7207
7217
|
const unwrapResult$1 = unwrapResult;
|
|
7208
|
-
preserve(unwrapResult$1);
|
|
7218
|
+
$preserve(unwrapResult$1);
|
|
7209
7219
|
const trimEndOfCodeBlock$1 = trimEndOfCodeBlock;
|
|
7210
|
-
preserve(trimEndOfCodeBlock$1);
|
|
7220
|
+
$preserve(trimEndOfCodeBlock$1);
|
|
7211
7221
|
const trimCodeBlock$1 = trimCodeBlock;
|
|
7212
|
-
preserve(trimCodeBlock$1);
|
|
7222
|
+
$preserve(trimCodeBlock$1);
|
|
7213
7223
|
// TODO: DRY [🍯]
|
|
7214
7224
|
const trim = (str) => str.trim();
|
|
7215
|
-
preserve(trim);
|
|
7225
|
+
$preserve(trim);
|
|
7216
7226
|
// TODO: DRY [🍯]
|
|
7217
7227
|
const reverse = (str) => str.split('').reverse().join('');
|
|
7218
|
-
preserve(reverse);
|
|
7228
|
+
$preserve(reverse);
|
|
7219
7229
|
const removeEmojis$1 = removeEmojis;
|
|
7220
|
-
preserve(removeEmojis$1);
|
|
7230
|
+
$preserve(removeEmojis$1);
|
|
7221
7231
|
const prettifyMarkdown$1 = prettifyMarkdown;
|
|
7222
|
-
preserve(prettifyMarkdown$1);
|
|
7232
|
+
$preserve(prettifyMarkdown$1);
|
|
7223
7233
|
//-------[n12:]---
|
|
7224
7234
|
const capitalize$1 = capitalize;
|
|
7225
7235
|
const decapitalize$1 = decapitalize;
|
|
@@ -7235,18 +7245,18 @@ class JavascriptEvalExecutionTools {
|
|
|
7235
7245
|
// TODO: DRY [🍯]
|
|
7236
7246
|
Array.from(parseKeywordsFromString(input)).join(', '); /* <- TODO: [🧠] What is the best format comma list, bullet list,...? */
|
|
7237
7247
|
const normalizeTo_SCREAMING_CASE$1 = normalizeTo_SCREAMING_CASE;
|
|
7238
|
-
preserve(capitalize$1);
|
|
7239
|
-
preserve(decapitalize$1);
|
|
7240
|
-
preserve(nameToUriPart$1);
|
|
7241
|
-
preserve(nameToUriParts$1);
|
|
7242
|
-
preserve(removeDiacritics$1);
|
|
7243
|
-
preserve(normalizeWhitespaces$1);
|
|
7244
|
-
preserve(normalizeToKebabCase$1);
|
|
7245
|
-
preserve(normalizeTo_camelCase$1);
|
|
7246
|
-
preserve(normalizeTo_snake_case$1);
|
|
7247
|
-
preserve(normalizeTo_PascalCase$1);
|
|
7248
|
-
preserve(parseKeywords);
|
|
7249
|
-
preserve(normalizeTo_SCREAMING_CASE$1);
|
|
7248
|
+
$preserve(capitalize$1);
|
|
7249
|
+
$preserve(decapitalize$1);
|
|
7250
|
+
$preserve(nameToUriPart$1);
|
|
7251
|
+
$preserve(nameToUriParts$1);
|
|
7252
|
+
$preserve(removeDiacritics$1);
|
|
7253
|
+
$preserve(normalizeWhitespaces$1);
|
|
7254
|
+
$preserve(normalizeToKebabCase$1);
|
|
7255
|
+
$preserve(normalizeTo_camelCase$1);
|
|
7256
|
+
$preserve(normalizeTo_snake_case$1);
|
|
7257
|
+
$preserve(normalizeTo_PascalCase$1);
|
|
7258
|
+
$preserve(parseKeywords);
|
|
7259
|
+
$preserve(normalizeTo_SCREAMING_CASE$1);
|
|
7250
7260
|
//-------[/n12]---
|
|
7251
7261
|
if (!script.includes('return')) {
|
|
7252
7262
|
script = `return ${script}`;
|