@promptbook/wizard 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 +214 -129
- 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 +218 -133
- 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,8 +1,8 @@
|
|
1
1
|
(function (global, factory) {
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim'), require('crypto'), require('socket.io-client'), require('@anthropic-ai/sdk'), require('bottleneck'), require('colors'), require('@azure/openai'), require('openai'), require('fs/promises'), require('child_process'), require('waitasecond'), require('crypto-js'), require('crypto-js/enc-hex'), require('path'), require('prettier'), require('prettier/parser-
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'crypto', 'socket.io-client', '@anthropic-ai/sdk', 'bottleneck', 'colors', '@azure/openai', 'openai', 'fs/promises', 'child_process', 'waitasecond', 'crypto-js', 'crypto-js/enc-hex', 'path', 'prettier', 'prettier/parser-
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-wizard"] = {}, global.spaceTrim, global.crypto, global.socket_ioClient, global.Anthropic, global.Bottleneck, global.colors, global.openai, global.OpenAI, global.promises, global.child_process, global.waitasecond, global.cryptoJs, global.hexEncoder, global.path, global.
|
5
|
-
})(this, (function (exports, spaceTrim, crypto, socket_ioClient, Anthropic, Bottleneck, colors, openai, OpenAI, promises, child_process, waitasecond, cryptoJs, hexEncoder, path,
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim'), require('crypto'), require('socket.io-client'), require('@anthropic-ai/sdk'), require('bottleneck'), require('colors'), require('@azure/openai'), require('openai'), require('fs/promises'), require('child_process'), require('waitasecond'), require('crypto-js'), require('crypto-js/enc-hex'), require('path'), require('prettier/parser-html'), require('prettier/parser-markdown'), require('prettier/standalone'), require('rxjs'), require('crypto-js/sha256'), require('mime-types'), require('papaparse'), require('@mozilla/readability'), require('jsdom'), require('showdown'), require('dotenv'), require('jszip')) :
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'crypto', 'socket.io-client', '@anthropic-ai/sdk', 'bottleneck', 'colors', '@azure/openai', 'openai', 'fs/promises', 'child_process', 'waitasecond', 'crypto-js', 'crypto-js/enc-hex', 'path', 'prettier/parser-html', 'prettier/parser-markdown', 'prettier/standalone', 'rxjs', 'crypto-js/sha256', 'mime-types', 'papaparse', '@mozilla/readability', 'jsdom', 'showdown', 'dotenv', 'jszip'], factory) :
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-wizard"] = {}, global.spaceTrim, global.crypto, global.socket_ioClient, global.Anthropic, global.Bottleneck, global.colors, global.openai, global.OpenAI, global.promises, global.child_process, global.waitasecond, global.cryptoJs, global.hexEncoder, global.path, global.parserHtml, global.parserMarkdown, global.standalone, global.rxjs, global.sha256, global.mimeTypes, global.papaparse, global.readability, global.jsdom, global.showdown, global.dotenv, global.JSZip));
|
5
|
+
})(this, (function (exports, spaceTrim, crypto, socket_ioClient, Anthropic, Bottleneck, colors, openai, OpenAI, promises, child_process, waitasecond, cryptoJs, hexEncoder, path, parserHtml, parserMarkdown, standalone, rxjs, sha256, mimeTypes, papaparse, readability, jsdom, showdown, dotenv, JSZip) { 'use strict';
|
6
6
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
8
8
|
|
@@ -31,6 +31,7 @@
|
|
31
31
|
var OpenAI__default = /*#__PURE__*/_interopDefaultLegacy(OpenAI);
|
32
32
|
var hexEncoder__default = /*#__PURE__*/_interopDefaultLegacy(hexEncoder);
|
33
33
|
var parserHtml__default = /*#__PURE__*/_interopDefaultLegacy(parserHtml);
|
34
|
+
var parserMarkdown__default = /*#__PURE__*/_interopDefaultLegacy(parserMarkdown);
|
34
35
|
var sha256__default = /*#__PURE__*/_interopDefaultLegacy(sha256);
|
35
36
|
var dotenv__namespace = /*#__PURE__*/_interopNamespace(dotenv);
|
36
37
|
var JSZip__default = /*#__PURE__*/_interopDefaultLegacy(JSZip);
|
@@ -49,7 +50,7 @@
|
|
49
50
|
* @generated
|
50
51
|
* @see https://github.com/webgptorg/promptbook
|
51
52
|
*/
|
52
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-
|
53
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-46';
|
53
54
|
/**
|
54
55
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
55
56
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
@@ -337,6 +338,13 @@
|
|
337
338
|
* @public exported from `@promptbook/core`
|
338
339
|
*/
|
339
340
|
const DEFAULT_MAX_REQUESTS_PER_MINUTE = 60;
|
341
|
+
/**
|
342
|
+
* API request timeout in milliseconds
|
343
|
+
* Can be overridden via API_REQUEST_TIMEOUT environment variable
|
344
|
+
*
|
345
|
+
* @public exported from `@promptbook/core`
|
346
|
+
*/
|
347
|
+
const API_REQUEST_TIMEOUT = parseInt(process.env.API_REQUEST_TIMEOUT || '90000');
|
340
348
|
/**
|
341
349
|
* Indicates whether pipeline logic validation is enabled. When true, the pipeline logic is checked for consistency.
|
342
350
|
*
|
@@ -4565,7 +4573,18 @@
|
|
4565
4573
|
const openAiOptions = { ...this.options };
|
4566
4574
|
delete openAiOptions.isVerbose;
|
4567
4575
|
delete openAiOptions.userId;
|
4568
|
-
|
4576
|
+
// Enhanced configuration for better ECONNRESET handling
|
4577
|
+
const enhancedOptions = {
|
4578
|
+
...openAiOptions,
|
4579
|
+
timeout: API_REQUEST_TIMEOUT,
|
4580
|
+
maxRetries: CONNECTION_RETRIES_LIMIT,
|
4581
|
+
defaultHeaders: {
|
4582
|
+
Connection: 'keep-alive',
|
4583
|
+
'Keep-Alive': 'timeout=30, max=100',
|
4584
|
+
...openAiOptions.defaultHeaders,
|
4585
|
+
},
|
4586
|
+
};
|
4587
|
+
this.client = new OpenAI__default["default"](enhancedOptions);
|
4569
4588
|
}
|
4570
4589
|
return this.client;
|
4571
4590
|
}
|
@@ -4653,7 +4672,7 @@
|
|
4653
4672
|
console.info(colors__default["default"].bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
|
4654
4673
|
}
|
4655
4674
|
const rawResponse = await this.limiter
|
4656
|
-
.schedule(() => client.chat.completions.create(rawRequest))
|
4675
|
+
.schedule(() => this.makeRequestWithRetry(() => client.chat.completions.create(rawRequest)))
|
4657
4676
|
.catch((error) => {
|
4658
4677
|
assertsError(error);
|
4659
4678
|
if (this.options.isVerbose) {
|
@@ -4729,7 +4748,7 @@
|
|
4729
4748
|
console.info(colors__default["default"].bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
|
4730
4749
|
}
|
4731
4750
|
const rawResponse = await this.limiter
|
4732
|
-
.schedule(() => client.completions.create(rawRequest))
|
4751
|
+
.schedule(() => this.makeRequestWithRetry(() => client.completions.create(rawRequest)))
|
4733
4752
|
.catch((error) => {
|
4734
4753
|
assertsError(error);
|
4735
4754
|
if (this.options.isVerbose) {
|
@@ -4793,7 +4812,7 @@
|
|
4793
4812
|
console.info(colors__default["default"].bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
|
4794
4813
|
}
|
4795
4814
|
const rawResponse = await this.limiter
|
4796
|
-
.schedule(() => client.embeddings.create(rawRequest))
|
4815
|
+
.schedule(() => this.makeRequestWithRetry(() => client.embeddings.create(rawRequest)))
|
4797
4816
|
.catch((error) => {
|
4798
4817
|
assertsError(error);
|
4799
4818
|
if (this.options.isVerbose) {
|
@@ -4851,6 +4870,76 @@
|
|
4851
4870
|
}
|
4852
4871
|
return model;
|
4853
4872
|
}
|
4873
|
+
// <- Note: [🤖] getDefaultXxxModel
|
4874
|
+
/**
|
4875
|
+
* Makes a request with retry logic for network errors like ECONNRESET
|
4876
|
+
*/
|
4877
|
+
async makeRequestWithRetry(requestFn) {
|
4878
|
+
let lastError;
|
4879
|
+
for (let attempt = 1; attempt <= CONNECTION_RETRIES_LIMIT; attempt++) {
|
4880
|
+
try {
|
4881
|
+
return await requestFn();
|
4882
|
+
}
|
4883
|
+
catch (error) {
|
4884
|
+
assertsError(error);
|
4885
|
+
lastError = error;
|
4886
|
+
// Check if this is a retryable network error
|
4887
|
+
const isRetryableError = this.isRetryableNetworkError(error);
|
4888
|
+
if (!isRetryableError || attempt === CONNECTION_RETRIES_LIMIT) {
|
4889
|
+
if (this.options.isVerbose) {
|
4890
|
+
console.info(colors__default["default"].bgRed('Final error after retries'), `Attempt ${attempt}/${CONNECTION_RETRIES_LIMIT}:`, error);
|
4891
|
+
}
|
4892
|
+
throw error;
|
4893
|
+
}
|
4894
|
+
// Calculate exponential backoff delay
|
4895
|
+
const baseDelay = 1000; // 1 second
|
4896
|
+
const backoffDelay = baseDelay * Math.pow(2, attempt - 1);
|
4897
|
+
const jitterDelay = Math.random() * 500; // Add some randomness
|
4898
|
+
const totalDelay = backoffDelay + jitterDelay;
|
4899
|
+
if (this.options.isVerbose) {
|
4900
|
+
console.info(colors__default["default"].bgYellow('Retrying request'), `Attempt ${attempt}/${CONNECTION_RETRIES_LIMIT}, waiting ${Math.round(totalDelay)}ms:`, error.message);
|
4901
|
+
}
|
4902
|
+
// Wait before retrying
|
4903
|
+
await new Promise((resolve) => setTimeout(resolve, totalDelay));
|
4904
|
+
}
|
4905
|
+
}
|
4906
|
+
throw lastError;
|
4907
|
+
}
|
4908
|
+
/**
|
4909
|
+
* Determines if an error is retryable (network-related errors)
|
4910
|
+
*/
|
4911
|
+
isRetryableNetworkError(error) {
|
4912
|
+
const errorMessage = error.message.toLowerCase();
|
4913
|
+
const errorCode = error.code;
|
4914
|
+
// Network connection errors that should be retried
|
4915
|
+
const retryableErrors = [
|
4916
|
+
'econnreset',
|
4917
|
+
'enotfound',
|
4918
|
+
'econnrefused',
|
4919
|
+
'etimedout',
|
4920
|
+
'socket hang up',
|
4921
|
+
'network error',
|
4922
|
+
'fetch failed',
|
4923
|
+
'connection reset',
|
4924
|
+
'connection refused',
|
4925
|
+
'timeout',
|
4926
|
+
];
|
4927
|
+
// Check error message
|
4928
|
+
if (retryableErrors.some((retryableError) => errorMessage.includes(retryableError))) {
|
4929
|
+
return true;
|
4930
|
+
}
|
4931
|
+
// Check error code
|
4932
|
+
if (errorCode && retryableErrors.includes(errorCode.toLowerCase())) {
|
4933
|
+
return true;
|
4934
|
+
}
|
4935
|
+
// Check for specific HTTP status codes that are retryable
|
4936
|
+
const errorWithStatus = error;
|
4937
|
+
const httpStatus = errorWithStatus.status || errorWithStatus.statusCode;
|
4938
|
+
if (httpStatus && [429, 500, 502, 503, 504].includes(httpStatus)) {
|
4939
|
+
return true;
|
4940
|
+
}
|
4941
|
+
return false;
|
4942
|
+
}
|
4854
4943
|
}
|
4855
4944
|
/**
|
4856
4945
|
* TODO: [🛄] Some way how to re-wrap the errors from `OpenAiCompatibleExecutionTools`
|
@@ -6291,9 +6380,9 @@
|
|
6291
6380
|
*/
|
6292
6381
|
function prettifyMarkdown(content) {
|
6293
6382
|
try {
|
6294
|
-
return
|
6383
|
+
return standalone.format(content, {
|
6295
6384
|
parser: 'markdown',
|
6296
|
-
plugins: [parserHtml__default["default"]],
|
6385
|
+
plugins: [parserMarkdown__default["default"], parserHtml__default["default"]],
|
6297
6386
|
// TODO: DRY - make some import or auto-copy of .prettierrc
|
6298
6387
|
endOfLine: 'lf',
|
6299
6388
|
tabWidth: 4,
|
@@ -7182,7 +7271,7 @@
|
|
7182
7271
|
* @private internal helper function
|
7183
7272
|
*/
|
7184
7273
|
function createTask(options) {
|
7185
|
-
const { taskType, taskProcessCallback
|
7274
|
+
const { taskType, taskProcessCallback } = options;
|
7186
7275
|
let { title } = options;
|
7187
7276
|
// TODO: [🐙] DRY
|
7188
7277
|
const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid similar char conflicts */)}`;
|
@@ -7192,6 +7281,7 @@
|
|
7192
7281
|
const errors = [];
|
7193
7282
|
const warnings = [];
|
7194
7283
|
let currentValue = {};
|
7284
|
+
let customTldr = null;
|
7195
7285
|
const partialResultSubject = new rxjs.Subject();
|
7196
7286
|
// <- Note: Not using `BehaviorSubject` because on error we can't access the last value
|
7197
7287
|
const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
|
@@ -7202,6 +7292,9 @@
|
|
7202
7292
|
Object.assign(currentValue, newOngoingResult);
|
7203
7293
|
// <- TODO: assign deep
|
7204
7294
|
partialResultSubject.next(newOngoingResult);
|
7295
|
+
}, (tldrInfo) => {
|
7296
|
+
customTldr = tldrInfo;
|
7297
|
+
updatedAt = new Date();
|
7205
7298
|
});
|
7206
7299
|
finalResultPromise
|
7207
7300
|
.catch((error) => {
|
@@ -7257,9 +7350,9 @@
|
|
7257
7350
|
},
|
7258
7351
|
get tldr() {
|
7259
7352
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
7260
|
-
// Use custom tldr
|
7261
|
-
if (
|
7262
|
-
return
|
7353
|
+
// Use custom tldr if available
|
7354
|
+
if (customTldr) {
|
7355
|
+
return customTldr;
|
7263
7356
|
}
|
7264
7357
|
// Fallback to default implementation
|
7265
7358
|
const cv = currentValue;
|
@@ -7758,7 +7851,7 @@
|
|
7758
7851
|
const result = await preparePersonaExecutor({
|
7759
7852
|
availableModels /* <- Note: Passing as JSON */,
|
7760
7853
|
personaDescription,
|
7761
|
-
}).asPromise();
|
7854
|
+
}).asPromise({ isCrashedOnError: true });
|
7762
7855
|
const { outputParameters } = result;
|
7763
7856
|
const { modelsRequirements: modelsRequirementsJson } = outputParameters;
|
7764
7857
|
let modelsRequirementsUnchecked = jsonParse(modelsRequirementsJson);
|
@@ -8371,7 +8464,7 @@
|
|
8371
8464
|
});
|
8372
8465
|
const result = await prepareTitleExecutor({
|
8373
8466
|
book: sources.map(({ content }) => content).join('\n\n'),
|
8374
|
-
}).asPromise();
|
8467
|
+
}).asPromise({ isCrashedOnError: true });
|
8375
8468
|
const { outputParameters } = result;
|
8376
8469
|
const { title: titleRaw } = outputParameters;
|
8377
8470
|
if (isVerbose) {
|
@@ -10320,80 +10413,74 @@
|
|
10320
10413
|
});
|
10321
10414
|
});
|
10322
10415
|
};
|
10323
|
-
const pipelineExecutor = (inputParameters) =>
|
10324
|
-
|
10325
|
-
|
10326
|
-
|
10327
|
-
|
10328
|
-
|
10329
|
-
|
10330
|
-
|
10331
|
-
|
10332
|
-
|
10333
|
-
|
10334
|
-
|
10335
|
-
|
10336
|
-
|
10337
|
-
|
10338
|
-
|
10339
|
-
|
10340
|
-
|
10341
|
-
|
10342
|
-
|
10343
|
-
|
10344
|
-
|
10345
|
-
|
10346
|
-
|
10347
|
-
|
10348
|
-
|
10349
|
-
|
10350
|
-
|
10351
|
-
|
10352
|
-
|
10353
|
-
|
10354
|
-
|
10355
|
-
|
10356
|
-
|
10357
|
-
|
10358
|
-
|
10359
|
-
|
10360
|
-
|
10361
|
-
|
10362
|
-
|
10363
|
-
|
10364
|
-
|
10365
|
-
|
10366
|
-
|
10367
|
-
|
10368
|
-
|
10369
|
-
|
10370
|
-
|
10371
|
-
|
10372
|
-
|
10373
|
-
|
10374
|
-
|
10375
|
-
|
10376
|
-
|
10377
|
-
|
10378
|
-
|
10379
|
-
|
10380
|
-
|
10381
|
-
|
10382
|
-
|
10383
|
-
|
10384
|
-
|
10385
|
-
|
10386
|
-
|
10387
|
-
|
10388
|
-
|
10389
|
-
|
10390
|
-
|
10391
|
-
return {
|
10392
|
-
percent,
|
10393
|
-
message,
|
10394
|
-
};
|
10395
|
-
},
|
10396
|
-
});
|
10416
|
+
const pipelineExecutor = (inputParameters) => {
|
10417
|
+
const startTime = new Date().getTime();
|
10418
|
+
return createTask({
|
10419
|
+
taskType: 'EXECUTION',
|
10420
|
+
title: pipeline.title,
|
10421
|
+
taskProcessCallback(updateOngoingResult, updateTldr) {
|
10422
|
+
return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
|
10423
|
+
var _a, _b;
|
10424
|
+
updateOngoingResult(newOngoingResult);
|
10425
|
+
// Calculate and update tldr based on pipeline progress
|
10426
|
+
const cv = newOngoingResult;
|
10427
|
+
// Calculate progress based on parameters resolved vs total parameters
|
10428
|
+
const totalParameters = pipeline.parameters.filter(p => !p.isInput).length;
|
10429
|
+
let resolvedParameters = 0;
|
10430
|
+
let currentTaskTitle = '';
|
10431
|
+
// Get the resolved parameters from output parameters
|
10432
|
+
if (cv === null || cv === void 0 ? void 0 : cv.outputParameters) {
|
10433
|
+
// Count how many output parameters have non-empty values
|
10434
|
+
resolvedParameters = Object.values(cv.outputParameters).filter(value => value !== undefined && value !== null && String(value).trim() !== '').length;
|
10435
|
+
}
|
10436
|
+
// Try to determine current task from execution report
|
10437
|
+
if (((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) && cv.executionReport.promptExecutions.length > 0) {
|
10438
|
+
const lastExecution = cv.executionReport.promptExecutions[cv.executionReport.promptExecutions.length - 1];
|
10439
|
+
if ((_b = lastExecution === null || lastExecution === void 0 ? void 0 : lastExecution.prompt) === null || _b === void 0 ? void 0 : _b.title) {
|
10440
|
+
currentTaskTitle = lastExecution.prompt.title;
|
10441
|
+
}
|
10442
|
+
}
|
10443
|
+
// Calculate base progress percentage
|
10444
|
+
let percent = totalParameters > 0 ? resolvedParameters / totalParameters : 0;
|
10445
|
+
// Add time-based progress for current task if we haven't completed all parameters
|
10446
|
+
if (resolvedParameters < totalParameters) {
|
10447
|
+
const elapsedMs = new Date().getTime() - startTime;
|
10448
|
+
const estimatedTotalMs = totalParameters * 30 * 1000; // Estimate 30 seconds per parameter
|
10449
|
+
const timeProgress = Math.min(elapsedMs / estimatedTotalMs, 0.9); // Cap at 90% for time-based progress
|
10450
|
+
// If we have time progress but no parameter progress, show time progress
|
10451
|
+
if (percent === 0 && timeProgress > 0) {
|
10452
|
+
percent = Math.min(timeProgress, 0.1); // Show some progress but not more than 10%
|
10453
|
+
}
|
10454
|
+
else if (percent < 1) {
|
10455
|
+
// Add partial progress for current task
|
10456
|
+
const taskProgress = totalParameters > 0 ? (1 / totalParameters) * 0.5 : 0; // 50% of task progress
|
10457
|
+
percent = Math.min(percent + taskProgress, 0.95); // Cap at 95% until fully complete
|
10458
|
+
}
|
10459
|
+
}
|
10460
|
+
// Clamp to [0,1]
|
10461
|
+
percent = Math.min(Math.max(percent, 0), 1);
|
10462
|
+
// Generate message
|
10463
|
+
let message = '';
|
10464
|
+
if (currentTaskTitle) {
|
10465
|
+
message = `Executing: ${currentTaskTitle}`;
|
10466
|
+
}
|
10467
|
+
else if (resolvedParameters === 0) {
|
10468
|
+
message = 'Starting pipeline execution';
|
10469
|
+
}
|
10470
|
+
else if (resolvedParameters < totalParameters) {
|
10471
|
+
message = `Processing pipeline (${resolvedParameters}/${totalParameters} parameters resolved)`;
|
10472
|
+
}
|
10473
|
+
else {
|
10474
|
+
message = 'Completing pipeline execution';
|
10475
|
+
}
|
10476
|
+
updateTldr({
|
10477
|
+
percent: percent,
|
10478
|
+
message,
|
10479
|
+
});
|
10480
|
+
});
|
10481
|
+
},
|
10482
|
+
});
|
10483
|
+
};
|
10397
10484
|
// <- TODO: Make types such as there is no need to do `as` for `createTask`
|
10398
10485
|
return pipelineExecutor;
|
10399
10486
|
}
|
@@ -10478,7 +10565,9 @@
|
|
10478
10565
|
},
|
10479
10566
|
});
|
10480
10567
|
const knowledgeContent = await source.asText();
|
10481
|
-
const result = await prepareKnowledgeFromMarkdownExecutor({ knowledgeContent }).asPromise(
|
10568
|
+
const result = await prepareKnowledgeFromMarkdownExecutor({ knowledgeContent }).asPromise({
|
10569
|
+
isCrashedOnError: true,
|
10570
|
+
});
|
10482
10571
|
const { outputParameters } = result;
|
10483
10572
|
const { knowledgePieces: knowledgePiecesRaw } = outputParameters;
|
10484
10573
|
const knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
|
@@ -10502,12 +10591,16 @@
|
|
10502
10591
|
];
|
10503
10592
|
*/
|
10504
10593
|
try {
|
10505
|
-
const titleResult = await prepareTitleExecutor({ knowledgePieceContent }).asPromise(
|
10594
|
+
const titleResult = await prepareTitleExecutor({ knowledgePieceContent }).asPromise({
|
10595
|
+
isCrashedOnError: true,
|
10596
|
+
});
|
10506
10597
|
const { title: titleRaw = 'Untitled' } = titleResult.outputParameters;
|
10507
10598
|
title = spaceTrim__default["default"](titleRaw) /* <- TODO: Maybe do in pipeline */;
|
10508
10599
|
name = titleToName(title);
|
10509
10600
|
// --- Keywords
|
10510
|
-
const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise(
|
10601
|
+
const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise({
|
10602
|
+
isCrashedOnError: true,
|
10603
|
+
});
|
10511
10604
|
const { keywords: keywordsRaw = '' } = keywordsResult.outputParameters;
|
10512
10605
|
keywords = (keywordsRaw || '')
|
10513
10606
|
.split(',')
|
@@ -13174,31 +13267,23 @@
|
|
13174
13267
|
return content;
|
13175
13268
|
}
|
13176
13269
|
|
13270
|
+
/**
|
13271
|
+
* @private internal for `preserve`
|
13272
|
+
*/
|
13273
|
+
const _preserved = [];
|
13177
13274
|
/**
|
13178
13275
|
* Does nothing, but preserves the function in the bundle
|
13179
13276
|
* Compiler is tricked into thinking the function is used
|
13180
13277
|
*
|
13181
13278
|
* @param value any function to preserve
|
13182
13279
|
* @returns nothing
|
13183
|
-
* @private
|
13184
|
-
*/
|
13185
|
-
function preserve(
|
13186
|
-
|
13187
|
-
(async () => {
|
13188
|
-
// TODO: [💩] Change to `await forEver` or `forTime(Infinity)`
|
13189
|
-
await waitasecond.forTime(100000000);
|
13190
|
-
// [1]
|
13191
|
-
try {
|
13192
|
-
await func();
|
13193
|
-
}
|
13194
|
-
finally {
|
13195
|
-
// do nothing
|
13196
|
-
}
|
13197
|
-
})();
|
13280
|
+
* @private within the repository
|
13281
|
+
*/
|
13282
|
+
function $preserve(...value) {
|
13283
|
+
_preserved.push(...value);
|
13198
13284
|
}
|
13199
13285
|
/**
|
13200
|
-
*
|
13201
|
-
* TODO: [1] This maybe does memory leak
|
13286
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
13202
13287
|
*/
|
13203
13288
|
|
13204
13289
|
// Note: [💎]
|
@@ -13226,25 +13311,25 @@
|
|
13226
13311
|
// Note: [💎]
|
13227
13312
|
// Note: Using direct eval, following variables are in same scope as eval call so they are accessible from inside the evaluated script:
|
13228
13313
|
const spaceTrim = (_) => spaceTrim__default["default"](_);
|
13229
|
-
preserve(spaceTrim);
|
13314
|
+
$preserve(spaceTrim);
|
13230
13315
|
const removeQuotes$1 = removeQuotes;
|
13231
|
-
preserve(removeQuotes$1);
|
13316
|
+
$preserve(removeQuotes$1);
|
13232
13317
|
const unwrapResult$1 = unwrapResult;
|
13233
|
-
preserve(unwrapResult$1);
|
13318
|
+
$preserve(unwrapResult$1);
|
13234
13319
|
const trimEndOfCodeBlock$1 = trimEndOfCodeBlock;
|
13235
|
-
preserve(trimEndOfCodeBlock$1);
|
13320
|
+
$preserve(trimEndOfCodeBlock$1);
|
13236
13321
|
const trimCodeBlock$1 = trimCodeBlock;
|
13237
|
-
preserve(trimCodeBlock$1);
|
13322
|
+
$preserve(trimCodeBlock$1);
|
13238
13323
|
// TODO: DRY [🍯]
|
13239
13324
|
const trim = (str) => str.trim();
|
13240
|
-
preserve(trim);
|
13325
|
+
$preserve(trim);
|
13241
13326
|
// TODO: DRY [🍯]
|
13242
13327
|
const reverse = (str) => str.split('').reverse().join('');
|
13243
|
-
preserve(reverse);
|
13328
|
+
$preserve(reverse);
|
13244
13329
|
const removeEmojis$1 = removeEmojis;
|
13245
|
-
preserve(removeEmojis$1);
|
13330
|
+
$preserve(removeEmojis$1);
|
13246
13331
|
const prettifyMarkdown$1 = prettifyMarkdown;
|
13247
|
-
preserve(prettifyMarkdown$1);
|
13332
|
+
$preserve(prettifyMarkdown$1);
|
13248
13333
|
//-------[n12:]---
|
13249
13334
|
const capitalize$1 = capitalize;
|
13250
13335
|
const decapitalize$1 = decapitalize;
|
@@ -13260,18 +13345,18 @@
|
|
13260
13345
|
// TODO: DRY [🍯]
|
13261
13346
|
Array.from(parseKeywordsFromString(input)).join(', '); /* <- TODO: [🧠] What is the best format comma list, bullet list,...? */
|
13262
13347
|
const normalizeTo_SCREAMING_CASE$1 = normalizeTo_SCREAMING_CASE;
|
13263
|
-
preserve(capitalize$1);
|
13264
|
-
preserve(decapitalize$1);
|
13265
|
-
preserve(nameToUriPart$1);
|
13266
|
-
preserve(nameToUriParts$1);
|
13267
|
-
preserve(removeDiacritics$1);
|
13268
|
-
preserve(normalizeWhitespaces$1);
|
13269
|
-
preserve(normalizeToKebabCase$1);
|
13270
|
-
preserve(normalizeTo_camelCase$1);
|
13271
|
-
preserve(normalizeTo_snake_case$1);
|
13272
|
-
preserve(normalizeTo_PascalCase$1);
|
13273
|
-
preserve(parseKeywords);
|
13274
|
-
preserve(normalizeTo_SCREAMING_CASE$1);
|
13348
|
+
$preserve(capitalize$1);
|
13349
|
+
$preserve(decapitalize$1);
|
13350
|
+
$preserve(nameToUriPart$1);
|
13351
|
+
$preserve(nameToUriParts$1);
|
13352
|
+
$preserve(removeDiacritics$1);
|
13353
|
+
$preserve(normalizeWhitespaces$1);
|
13354
|
+
$preserve(normalizeToKebabCase$1);
|
13355
|
+
$preserve(normalizeTo_camelCase$1);
|
13356
|
+
$preserve(normalizeTo_snake_case$1);
|
13357
|
+
$preserve(normalizeTo_PascalCase$1);
|
13358
|
+
$preserve(parseKeywords);
|
13359
|
+
$preserve(normalizeTo_SCREAMING_CASE$1);
|
13275
13360
|
//-------[/n12]---
|
13276
13361
|
if (!script.includes('return')) {
|
13277
13362
|
script = `return ${script}`;
|
@@ -17320,7 +17405,7 @@
|
|
17320
17405
|
// ▶ Create executor - the function that will execute the Pipeline
|
17321
17406
|
const pipelineExecutor = createPipelineExecutor({ pipeline, tools });
|
17322
17407
|
// 🚀▶ Execute the Pipeline
|
17323
|
-
const result = await pipelineExecutor(inputParameters).asPromise();
|
17408
|
+
const result = await pipelineExecutor(inputParameters).asPromise({ isCrashedOnError: true });
|
17324
17409
|
const { outputParameters } = result;
|
17325
17410
|
const outputParametersLength = Object.keys(outputParameters).length;
|
17326
17411
|
let resultString;
|