@promptbook/remote-server 0.100.0-6 → 0.100.0-61
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/README.md +2 -8
- package/esm/index.es.js +276 -59
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/color.index.d.ts +50 -0
- package/esm/typings/src/_packages/components.index.d.ts +36 -0
- package/esm/typings/src/_packages/core.index.d.ts +30 -0
- package/esm/typings/src/_packages/types.index.d.ts +38 -0
- package/esm/typings/src/book-2.0/agent-source/parseAgentSource.d.ts +30 -0
- package/esm/typings/src/book-2.0/agent-source/parseAgentSource.test.d.ts +1 -0
- package/esm/typings/src/book-2.0/agent-source/string_book.d.ts +26 -0
- package/esm/typings/src/book-2.0/commitments/ACTION/ACTION.d.ts +38 -0
- package/esm/typings/src/book-2.0/commitments/FORMAT/FORMAT.d.ts +39 -0
- package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/KNOWLEDGE.d.ts +45 -0
- package/esm/typings/src/book-2.0/commitments/META_IMAGE/META_IMAGE.d.ts +44 -0
- package/esm/typings/src/book-2.0/commitments/META_LINK/META_LINK.d.ts +56 -0
- package/esm/typings/src/book-2.0/commitments/MODEL/MODEL.d.ts +39 -0
- package/esm/typings/src/book-2.0/commitments/NOTE/NOTE.d.ts +49 -0
- package/esm/typings/src/book-2.0/commitments/PERSONA/PERSONA.d.ts +46 -0
- package/esm/typings/src/book-2.0/commitments/RULE/RULE.d.ts +44 -0
- package/esm/typings/src/book-2.0/commitments/SAMPLE/SAMPLE.d.ts +44 -0
- package/esm/typings/src/book-2.0/commitments/STYLE/STYLE.d.ts +38 -0
- package/esm/typings/src/book-2.0/commitments/_base/BaseCommitmentDefinition.d.ts +52 -0
- package/esm/typings/src/book-2.0/commitments/_base/BookCommitment.d.ts +5 -0
- package/esm/typings/src/book-2.0/commitments/_base/CommitmentDefinition.d.ts +48 -0
- package/esm/typings/src/book-2.0/commitments/_base/NotYetImplementedCommitmentDefinition.d.ts +22 -0
- package/esm/typings/src/book-2.0/commitments/_base/createEmptyAgentModelRequirements.d.ts +19 -0
- package/esm/typings/src/book-2.0/commitments/_misc/AgentModelRequirements.d.ts +37 -0
- package/esm/typings/src/book-2.0/commitments/_misc/AgentSourceParseResult.d.ts +18 -0
- package/esm/typings/src/book-2.0/commitments/_misc/ParsedCommitment.d.ts +22 -0
- package/esm/typings/src/book-2.0/commitments/_misc/createAgentModelRequirements.d.ts +62 -0
- package/esm/typings/src/book-2.0/commitments/_misc/createAgentModelRequirementsWithCommitments.d.ts +36 -0
- package/esm/typings/src/book-2.0/commitments/_misc/createCommitmentRegex.d.ts +20 -0
- package/esm/typings/src/book-2.0/commitments/_misc/parseAgentSourceWithCommitments.d.ts +24 -0
- package/esm/typings/src/book-2.0/commitments/_misc/removeCommentsFromSystemMessage.d.ts +11 -0
- package/esm/typings/src/book-2.0/commitments/index.d.ts +56 -0
- package/esm/typings/src/book-2.0/utils/profileImageUtils.d.ts +39 -0
- package/esm/typings/src/book-components/AvatarProfile/AvatarChip/AvatarChip.d.ts +35 -0
- package/esm/typings/src/book-components/AvatarProfile/AvatarChip/AvatarChipFromSource.d.ts +21 -0
- package/esm/typings/src/book-components/AvatarProfile/AvatarChip/index.d.ts +2 -0
- 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/BookEditor.d.ts +35 -0
- package/esm/typings/src/book-components/BookEditor/BookEditorInner.d.ts +15 -0
- package/esm/typings/src/book-components/BookEditor/config.d.ts +10 -0
- package/esm/typings/src/book-components/BookEditor/injectCssModuleIntoShadowRoot.d.ts +11 -0
- package/esm/typings/src/book-components/Chat/Chat/Chat.d.ts +20 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +110 -0
- package/esm/typings/src/book-components/Chat/LlmChat/LlmChat.d.ts +14 -0
- package/esm/typings/src/book-components/Chat/LlmChat/LlmChat.test.d.ts +1 -0
- package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +24 -0
- package/esm/typings/src/book-components/Chat/types/ChatMessage.d.ts +16 -0
- package/esm/typings/src/book-components/Chat/types/ChatParticipant.d.ts +32 -0
- package/esm/typings/src/book-components/Chat/utils/ChatPersistence.d.ts +25 -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 +9 -0
- package/esm/typings/src/book-components/Chat/utils/generatePdfContent.d.ts +8 -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 +8 -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 +8 -0
- package/esm/typings/src/book-components/Chat/utils/messagesToText.d.ts +8 -0
- package/esm/typings/src/book-components/_common/react-utils/classNames.d.ts +7 -0
- package/esm/typings/src/book-components/_common/react-utils/collectCssTextsForClass.d.ts +7 -0
- package/esm/typings/src/book-components/_common/react-utils/escapeHtml.d.ts +6 -0
- package/esm/typings/src/book-components/_common/react-utils/escapeRegex.d.ts +6 -0
- package/esm/typings/src/config.d.ts +19 -0
- package/esm/typings/src/execution/AvailableModel.d.ts +4 -0
- package/esm/typings/src/execution/ExecutionTask.d.ts +27 -1
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +8 -0
- package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +6 -1
- package/esm/typings/src/llm-providers/_common/filterModels.d.ts +0 -3
- package/esm/typings/src/llm-providers/_common/profiles/llmProviderProfiles.d.ts +81 -0
- package/esm/typings/src/llm-providers/_common/profiles/test/llmProviderProfiles.test.d.ts +1 -0
- package/esm/typings/src/llm-providers/_multiple/MultipleLlmExecutionTools.d.ts +5 -0
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +5 -5
- package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/deepseek/deepseek-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/google/google-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +5 -0
- package/esm/typings/src/llm-providers/ollama/ollama-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +8 -0
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +5 -0
- package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +5 -0
- package/esm/typings/src/pipeline/book-notation.d.ts +2 -1
- package/esm/typings/src/playground/permanent/error-handling-playground.d.ts +5 -0
- package/esm/typings/src/types/ModelRequirements.d.ts +0 -2
- package/esm/typings/src/types/typeAliases.d.ts +6 -0
- package/esm/typings/src/utils/color/$randomColor.d.ts +11 -0
- package/esm/typings/src/utils/color/Color.d.ts +180 -0
- package/esm/typings/src/utils/color/css-colors.d.ts +159 -0
- package/esm/typings/src/utils/color/internal-utils/checkChannelValue.d.ts +14 -0
- package/esm/typings/src/utils/color/internal-utils/hslToRgb.d.ts +17 -0
- package/esm/typings/src/utils/color/internal-utils/rgbToHsl.d.ts +17 -0
- package/esm/typings/src/utils/color/operators/ColorTransformer.d.ts +5 -0
- package/esm/typings/src/utils/color/operators/darken.d.ts +9 -0
- package/esm/typings/src/utils/color/operators/furthest.d.ts +16 -0
- package/esm/typings/src/utils/color/operators/grayscale.d.ts +9 -0
- package/esm/typings/src/utils/color/operators/lighten.d.ts +12 -0
- package/esm/typings/src/utils/color/operators/mixWithColor.d.ts +11 -0
- package/esm/typings/src/utils/color/operators/nearest.d.ts +10 -0
- package/esm/typings/src/utils/color/operators/negative.d.ts +7 -0
- package/esm/typings/src/utils/color/operators/negativeLightness.d.ts +7 -0
- package/esm/typings/src/utils/color/operators/withAlpha.d.ts +9 -0
- package/esm/typings/src/utils/color/utils/areColorsEqual.d.ts +14 -0
- package/esm/typings/src/utils/color/utils/colorDistance.d.ts +21 -0
- package/esm/typings/src/utils/color/utils/colorHue.d.ts +11 -0
- package/esm/typings/src/utils/color/utils/colorHueDistance.d.ts +11 -0
- package/esm/typings/src/utils/color/utils/colorHueDistance.test.d.ts +1 -0
- package/esm/typings/src/utils/color/utils/colorLuminance.d.ts +9 -0
- package/esm/typings/src/utils/color/utils/colorSatulightion.d.ts +7 -0
- package/esm/typings/src/utils/color/utils/colorSaturation.d.ts +9 -0
- package/esm/typings/src/utils/color/utils/colorToDataUrl.d.ts +10 -0
- package/esm/typings/src/utils/color/utils/mixColors.d.ts +11 -0
- package/esm/typings/src/utils/organization/preserve.d.ts +21 -0
- package/esm/typings/src/utils/take/classes/TakeChain.d.ts +11 -0
- package/esm/typings/src/utils/take/interfaces/ITakeChain.d.ts +12 -0
- package/esm/typings/src/utils/take/interfaces/Takeable.d.ts +7 -0
- package/esm/typings/src/utils/take/take.d.ts +12 -0
- package/esm/typings/src/utils/take/take.test.d.ts +1 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -3
- package/umd/index.umd.js +280 -63
- 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('colors'), require('express'), require('express-openapi-validator'), require('http'), require('socket.io'), require('spacetrim'), require('swagger-ui-express'), require('waitasecond'), require('crypto'), require('child_process'), require('fs/promises'), require('path'), require('rxjs'), require('prettier'), require('prettier/parser-
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'colors', 'express', 'express-openapi-validator', 'http', 'socket.io', 'spacetrim', 'swagger-ui-express', 'waitasecond', 'crypto', 'child_process', 'fs/promises', 'path', 'rxjs', 'prettier', 'prettier/parser-
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-remote-server"] = {}, global.colors, global.express, global.OpenApiValidator, global.http, global.socket_io, global.spaceTrim, global.swaggerUi, global.waitasecond, global.crypto, global.child_process, global.promises, global.path, global.rxjs, global.
|
|
5
|
-
})(this, (function (exports, colors, express, OpenApiValidator, http, socket_io, spaceTrim, swaggerUi, waitasecond, crypto, child_process, promises, path, rxjs,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('colors'), require('express'), require('express-openapi-validator'), require('http'), require('socket.io'), require('spacetrim'), require('swagger-ui-express'), require('waitasecond'), require('crypto'), require('child_process'), require('fs/promises'), require('path'), require('rxjs'), require('prettier/parser-html'), require('prettier/parser-markdown'), require('prettier/standalone'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('crypto-js'), require('mime-types'), require('papaparse')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'colors', 'express', 'express-openapi-validator', 'http', 'socket.io', 'spacetrim', 'swagger-ui-express', 'waitasecond', 'crypto', 'child_process', 'fs/promises', 'path', 'rxjs', 'prettier/parser-html', 'prettier/parser-markdown', 'prettier/standalone', 'crypto-js/enc-hex', 'crypto-js/sha256', 'crypto-js', 'mime-types', 'papaparse'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-remote-server"] = {}, global.colors, global.express, global.OpenApiValidator, global.http, global.socket_io, global.spaceTrim, global.swaggerUi, global.waitasecond, global.crypto, global.child_process, global.promises, global.path, global.rxjs, global.parserHtml, global.parserMarkdown, global.standalone, global.hexEncoder, global.sha256, global.cryptoJs, global.mimeTypes, global.papaparse));
|
|
5
|
+
})(this, (function (exports, colors, express, OpenApiValidator, http, socket_io, spaceTrim, swaggerUi, waitasecond, crypto, child_process, promises, path, rxjs, parserHtml, parserMarkdown, standalone, hexEncoder, sha256, cryptoJs, mimeTypes, papaparse) { '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 spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim);
|
|
32
32
|
var swaggerUi__default = /*#__PURE__*/_interopDefaultLegacy(swaggerUi);
|
|
33
33
|
var parserHtml__default = /*#__PURE__*/_interopDefaultLegacy(parserHtml);
|
|
34
|
+
var parserMarkdown__default = /*#__PURE__*/_interopDefaultLegacy(parserMarkdown);
|
|
34
35
|
var hexEncoder__default = /*#__PURE__*/_interopDefaultLegacy(hexEncoder);
|
|
35
36
|
var sha256__default = /*#__PURE__*/_interopDefaultLegacy(sha256);
|
|
36
37
|
|
|
@@ -48,7 +49,7 @@
|
|
|
48
49
|
* @generated
|
|
49
50
|
* @see https://github.com/webgptorg/promptbook
|
|
50
51
|
*/
|
|
51
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-
|
|
52
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-61';
|
|
52
53
|
/**
|
|
53
54
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
54
55
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -231,6 +232,19 @@
|
|
|
231
232
|
* @public exported from `@promptbook/core`
|
|
232
233
|
*/
|
|
233
234
|
const DEFAULT_IS_AUTO_INSTALLED = false;
|
|
235
|
+
/**
|
|
236
|
+
* Default simulated duration for a task in milliseconds (used for progress reporting)
|
|
237
|
+
*
|
|
238
|
+
* @public exported from `@promptbook/core`
|
|
239
|
+
*/
|
|
240
|
+
const DEFAULT_TASK_SIMULATED_DURATION_MS = 5 * 60 * 1000; // 5 minutes
|
|
241
|
+
/**
|
|
242
|
+
* API request timeout in milliseconds
|
|
243
|
+
* Can be overridden via API_REQUEST_TIMEOUT environment variable
|
|
244
|
+
*
|
|
245
|
+
* @public exported from `@promptbook/core`
|
|
246
|
+
*/
|
|
247
|
+
parseInt(process.env.API_REQUEST_TIMEOUT || '90000');
|
|
234
248
|
/**
|
|
235
249
|
* Indicates whether pipeline logic validation is enabled. When true, the pipeline logic is checked for consistency.
|
|
236
250
|
*
|
|
@@ -2025,6 +2039,7 @@
|
|
|
2025
2039
|
const errors = [];
|
|
2026
2040
|
const warnings = [];
|
|
2027
2041
|
let currentValue = {};
|
|
2042
|
+
let customTldr = null;
|
|
2028
2043
|
const partialResultSubject = new rxjs.Subject();
|
|
2029
2044
|
// <- Note: Not using `BehaviorSubject` because on error we can't access the last value
|
|
2030
2045
|
const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
|
|
@@ -2035,6 +2050,9 @@
|
|
|
2035
2050
|
Object.assign(currentValue, newOngoingResult);
|
|
2036
2051
|
// <- TODO: assign deep
|
|
2037
2052
|
partialResultSubject.next(newOngoingResult);
|
|
2053
|
+
}, (tldrInfo) => {
|
|
2054
|
+
customTldr = tldrInfo;
|
|
2055
|
+
updatedAt = new Date();
|
|
2038
2056
|
});
|
|
2039
2057
|
finalResultPromise
|
|
2040
2058
|
.catch((error) => {
|
|
@@ -2088,6 +2106,78 @@
|
|
|
2088
2106
|
return status;
|
|
2089
2107
|
// <- Note: [1] --||--
|
|
2090
2108
|
},
|
|
2109
|
+
get tldr() {
|
|
2110
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2111
|
+
// Use custom tldr if available
|
|
2112
|
+
if (customTldr) {
|
|
2113
|
+
return customTldr;
|
|
2114
|
+
}
|
|
2115
|
+
// Fallback to default implementation
|
|
2116
|
+
const cv = currentValue;
|
|
2117
|
+
// If explicit percent is provided, use it
|
|
2118
|
+
let percentRaw = (_f = (_d = (_b = (_a = cv === null || cv === void 0 ? void 0 : cv.tldr) === null || _a === void 0 ? void 0 : _a.percent) !== null && _b !== void 0 ? _b : (_c = cv === null || cv === void 0 ? void 0 : cv.usage) === null || _c === void 0 ? void 0 : _c.percent) !== null && _d !== void 0 ? _d : (_e = cv === null || cv === void 0 ? void 0 : cv.progress) === null || _e === void 0 ? void 0 : _e.percent) !== null && _f !== void 0 ? _f : cv === null || cv === void 0 ? void 0 : cv.percent;
|
|
2119
|
+
// Simulate progress if not provided
|
|
2120
|
+
if (typeof percentRaw !== 'number') {
|
|
2121
|
+
// Simulate progress: evenly split across subtasks, based on elapsed time
|
|
2122
|
+
const now = new Date();
|
|
2123
|
+
const elapsedMs = now.getTime() - createdAt.getTime();
|
|
2124
|
+
const totalMs = DEFAULT_TASK_SIMULATED_DURATION_MS;
|
|
2125
|
+
// If subtasks are defined, split progress evenly
|
|
2126
|
+
const subtaskCount = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) ? cv.subtasks.length : 1;
|
|
2127
|
+
const completedSubtasks = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks)
|
|
2128
|
+
? cv.subtasks.filter((s) => s.done || s.completed).length
|
|
2129
|
+
: 0;
|
|
2130
|
+
// Progress from completed subtasks
|
|
2131
|
+
const subtaskProgress = subtaskCount > 0 ? completedSubtasks / subtaskCount : 0;
|
|
2132
|
+
// Progress from elapsed time for current subtask
|
|
2133
|
+
const timeProgress = Math.min(elapsedMs / totalMs, 1);
|
|
2134
|
+
// Combine: completed subtasks + time progress for current subtask
|
|
2135
|
+
percentRaw = Math.min(subtaskProgress + (1 / subtaskCount) * timeProgress, 1);
|
|
2136
|
+
if (status === 'FINISHED')
|
|
2137
|
+
percentRaw = 1;
|
|
2138
|
+
if (status === 'ERROR')
|
|
2139
|
+
percentRaw = 0;
|
|
2140
|
+
}
|
|
2141
|
+
// Clamp to [0,1]
|
|
2142
|
+
let percent = Number(percentRaw) || 0;
|
|
2143
|
+
if (percent < 0)
|
|
2144
|
+
percent = 0;
|
|
2145
|
+
if (percent > 1)
|
|
2146
|
+
percent = 1;
|
|
2147
|
+
// Build a short message: prefer explicit tldr.message, then common summary/message fields, then errors/warnings, then status
|
|
2148
|
+
const messageFromResult = (_k = (_j = (_h = (_g = cv === null || cv === void 0 ? void 0 : cv.tldr) === null || _g === void 0 ? void 0 : _g.message) !== null && _h !== void 0 ? _h : cv === null || cv === void 0 ? void 0 : cv.message) !== null && _j !== void 0 ? _j : cv === null || cv === void 0 ? void 0 : cv.summary) !== null && _k !== void 0 ? _k : cv === null || cv === void 0 ? void 0 : cv.statusMessage;
|
|
2149
|
+
let message = messageFromResult;
|
|
2150
|
+
if (!message) {
|
|
2151
|
+
// If subtasks, show current subtask
|
|
2152
|
+
if (Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) && cv.subtasks.length > 0) {
|
|
2153
|
+
const current = cv.subtasks.find((s) => !s.done && !s.completed);
|
|
2154
|
+
if (current && current.title) {
|
|
2155
|
+
message = `Working on ${current.title}`;
|
|
2156
|
+
}
|
|
2157
|
+
}
|
|
2158
|
+
if (!message) {
|
|
2159
|
+
if (errors.length) {
|
|
2160
|
+
message = errors[errors.length - 1].message || 'Error';
|
|
2161
|
+
}
|
|
2162
|
+
else if (warnings.length) {
|
|
2163
|
+
message = warnings[warnings.length - 1].message || 'Warning';
|
|
2164
|
+
}
|
|
2165
|
+
else if (status === 'FINISHED') {
|
|
2166
|
+
message = 'Finished';
|
|
2167
|
+
}
|
|
2168
|
+
else if (status === 'ERROR') {
|
|
2169
|
+
message = 'Error';
|
|
2170
|
+
}
|
|
2171
|
+
else {
|
|
2172
|
+
message = 'Running';
|
|
2173
|
+
}
|
|
2174
|
+
}
|
|
2175
|
+
}
|
|
2176
|
+
return {
|
|
2177
|
+
percent: percent,
|
|
2178
|
+
message,
|
|
2179
|
+
};
|
|
2180
|
+
},
|
|
2091
2181
|
get createdAt() {
|
|
2092
2182
|
return createdAt;
|
|
2093
2183
|
// <- Note: [1] --||--
|
|
@@ -2291,9 +2381,9 @@
|
|
|
2291
2381
|
*/
|
|
2292
2382
|
function prettifyMarkdown(content) {
|
|
2293
2383
|
try {
|
|
2294
|
-
return
|
|
2384
|
+
return standalone.format(content, {
|
|
2295
2385
|
parser: 'markdown',
|
|
2296
|
-
plugins: [parserHtml__default["default"]],
|
|
2386
|
+
plugins: [parserMarkdown__default["default"], parserHtml__default["default"]],
|
|
2297
2387
|
// TODO: DRY - make some import or auto-copy of .prettierrc
|
|
2298
2388
|
endOfLine: 'lf',
|
|
2299
2389
|
tabWidth: 4,
|
|
@@ -2784,6 +2874,76 @@
|
|
|
2784
2874
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
2785
2875
|
*/
|
|
2786
2876
|
|
|
2877
|
+
/**
|
|
2878
|
+
* Predefined profiles for LLM providers to maintain consistency across the application
|
|
2879
|
+
* These profiles represent each provider as a virtual persona in chat interfaces
|
|
2880
|
+
*
|
|
2881
|
+
* @private !!!!
|
|
2882
|
+
*/
|
|
2883
|
+
const LLM_PROVIDER_PROFILES = {
|
|
2884
|
+
OPENAI: {
|
|
2885
|
+
name: 'OPENAI',
|
|
2886
|
+
fullname: 'OpenAI GPT',
|
|
2887
|
+
color: '#10a37f', // OpenAI's signature green
|
|
2888
|
+
// Note: avatarSrc could be added when we have provider logos available
|
|
2889
|
+
},
|
|
2890
|
+
ANTHROPIC: {
|
|
2891
|
+
name: 'ANTHROPIC',
|
|
2892
|
+
fullname: 'Anthropic Claude',
|
|
2893
|
+
color: '#d97706', // Anthropic's orange/amber color
|
|
2894
|
+
},
|
|
2895
|
+
AZURE_OPENAI: {
|
|
2896
|
+
name: 'AZURE_OPENAI',
|
|
2897
|
+
fullname: 'Azure OpenAI',
|
|
2898
|
+
color: '#0078d4', // Microsoft Azure blue
|
|
2899
|
+
},
|
|
2900
|
+
GOOGLE: {
|
|
2901
|
+
name: 'GOOGLE',
|
|
2902
|
+
fullname: 'Google Gemini',
|
|
2903
|
+
color: '#4285f4', // Google blue
|
|
2904
|
+
},
|
|
2905
|
+
DEEPSEEK: {
|
|
2906
|
+
name: 'DEEPSEEK',
|
|
2907
|
+
fullname: 'DeepSeek',
|
|
2908
|
+
color: '#7c3aed', // Purple color for DeepSeek
|
|
2909
|
+
},
|
|
2910
|
+
OLLAMA: {
|
|
2911
|
+
name: 'OLLAMA',
|
|
2912
|
+
fullname: 'Ollama',
|
|
2913
|
+
color: '#059669', // Emerald green for local models
|
|
2914
|
+
},
|
|
2915
|
+
REMOTE: {
|
|
2916
|
+
name: 'REMOTE',
|
|
2917
|
+
fullname: 'Remote Server',
|
|
2918
|
+
color: '#6b7280', // Gray for remote/proxy connections
|
|
2919
|
+
},
|
|
2920
|
+
MOCKED_ECHO: {
|
|
2921
|
+
name: 'MOCKED_ECHO',
|
|
2922
|
+
fullname: 'Echo (Test)',
|
|
2923
|
+
color: '#8b5cf6', // Purple for test/mock tools
|
|
2924
|
+
},
|
|
2925
|
+
MOCKED_FAKE: {
|
|
2926
|
+
name: 'MOCKED_FAKE',
|
|
2927
|
+
fullname: 'Fake LLM (Test)',
|
|
2928
|
+
color: '#ec4899', // Pink for fake/test tools
|
|
2929
|
+
},
|
|
2930
|
+
VERCEL: {
|
|
2931
|
+
name: 'VERCEL',
|
|
2932
|
+
fullname: 'Vercel AI',
|
|
2933
|
+
color: '#000000', // Vercel's black
|
|
2934
|
+
},
|
|
2935
|
+
MULTIPLE: {
|
|
2936
|
+
name: 'MULTIPLE',
|
|
2937
|
+
fullname: 'Multiple Providers',
|
|
2938
|
+
color: '#6366f1', // Indigo for combined/multiple providers
|
|
2939
|
+
},
|
|
2940
|
+
};
|
|
2941
|
+
/**
|
|
2942
|
+
* TODO: Refactor this - each profile must be alongside the provider definition
|
|
2943
|
+
* TODO: Unite `AvatarProfileProps` and `ChatParticipant`
|
|
2944
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
2945
|
+
*/
|
|
2946
|
+
|
|
2787
2947
|
/**
|
|
2788
2948
|
* Multiple LLM Execution Tools is a proxy server that uses multiple execution tools internally and exposes the executor interface externally.
|
|
2789
2949
|
*
|
|
@@ -2809,7 +2969,7 @@
|
|
|
2809
2969
|
}
|
|
2810
2970
|
return spaceTrim__default["default"]((block) => `
|
|
2811
2971
|
${headLine}
|
|
2812
|
-
|
|
2972
|
+
|
|
2813
2973
|
${ /* <- Note: Indenting the description: */block(description)}
|
|
2814
2974
|
`);
|
|
2815
2975
|
})
|
|
@@ -2820,6 +2980,9 @@
|
|
|
2820
2980
|
${block(innerModelsTitlesAndDescriptions)}
|
|
2821
2981
|
`);
|
|
2822
2982
|
}
|
|
2983
|
+
get profile() {
|
|
2984
|
+
return LLM_PROVIDER_PROFILES.MULTIPLE;
|
|
2985
|
+
}
|
|
2823
2986
|
/**
|
|
2824
2987
|
* Check the configuration of all execution tools
|
|
2825
2988
|
*/
|
|
@@ -2864,25 +3027,22 @@
|
|
|
2864
3027
|
const errors = [];
|
|
2865
3028
|
llm: for (const llmExecutionTools of this.llmExecutionTools) {
|
|
2866
3029
|
try {
|
|
2867
|
-
|
|
3030
|
+
switch (prompt.modelRequirements.modelVariant) {
|
|
2868
3031
|
case 'CHAT':
|
|
2869
3032
|
if (llmExecutionTools.callChatModel === undefined) {
|
|
2870
3033
|
continue llm;
|
|
2871
3034
|
}
|
|
2872
3035
|
return await llmExecutionTools.callChatModel(prompt);
|
|
2873
|
-
break variant;
|
|
2874
3036
|
case 'COMPLETION':
|
|
2875
3037
|
if (llmExecutionTools.callCompletionModel === undefined) {
|
|
2876
3038
|
continue llm;
|
|
2877
3039
|
}
|
|
2878
3040
|
return await llmExecutionTools.callCompletionModel(prompt);
|
|
2879
|
-
break variant;
|
|
2880
3041
|
case 'EMBEDDING':
|
|
2881
3042
|
if (llmExecutionTools.callEmbeddingModel === undefined) {
|
|
2882
3043
|
continue llm;
|
|
2883
3044
|
}
|
|
2884
3045
|
return await llmExecutionTools.callEmbeddingModel(prompt);
|
|
2885
|
-
break variant;
|
|
2886
3046
|
// <- case [🤖]:
|
|
2887
3047
|
default:
|
|
2888
3048
|
throw new UnexpectedError(`Unknown model variant "${prompt.modelRequirements.modelVariant}"`);
|
|
@@ -3035,7 +3195,7 @@
|
|
|
3035
3195
|
const result = await preparePersonaExecutor({
|
|
3036
3196
|
availableModels /* <- Note: Passing as JSON */,
|
|
3037
3197
|
personaDescription,
|
|
3038
|
-
}).asPromise();
|
|
3198
|
+
}).asPromise({ isCrashedOnError: true });
|
|
3039
3199
|
const { outputParameters } = result;
|
|
3040
3200
|
const { modelsRequirements: modelsRequirementsJson } = outputParameters;
|
|
3041
3201
|
let modelsRequirementsUnchecked = jsonParse(modelsRequirementsJson);
|
|
@@ -4186,7 +4346,7 @@
|
|
|
4186
4346
|
});
|
|
4187
4347
|
const result = await prepareTitleExecutor({
|
|
4188
4348
|
book: sources.map(({ content }) => content).join('\n\n'),
|
|
4189
|
-
}).asPromise();
|
|
4349
|
+
}).asPromise({ isCrashedOnError: true });
|
|
4190
4350
|
const { outputParameters } = result;
|
|
4191
4351
|
const { title: titleRaw } = outputParameters;
|
|
4192
4352
|
if (isVerbose) {
|
|
@@ -5297,7 +5457,7 @@
|
|
|
5297
5457
|
*/
|
|
5298
5458
|
async function executeAttempts(options) {
|
|
5299
5459
|
const { jokerParameterNames, priority, maxAttempts, // <- Note: [💂]
|
|
5300
|
-
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, } = options;
|
|
5460
|
+
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, } = options;
|
|
5301
5461
|
const $ongoingTaskResult = {
|
|
5302
5462
|
$result: null,
|
|
5303
5463
|
$resultString: null,
|
|
@@ -5541,6 +5701,10 @@
|
|
|
5541
5701
|
result: $ongoingTaskResult.$resultString,
|
|
5542
5702
|
error: error,
|
|
5543
5703
|
});
|
|
5704
|
+
// Report failed attempt
|
|
5705
|
+
onProgress({
|
|
5706
|
+
errors: [error],
|
|
5707
|
+
});
|
|
5544
5708
|
}
|
|
5545
5709
|
finally {
|
|
5546
5710
|
if (!isJokerAttempt &&
|
|
@@ -6414,15 +6578,74 @@
|
|
|
6414
6578
|
});
|
|
6415
6579
|
});
|
|
6416
6580
|
};
|
|
6417
|
-
const pipelineExecutor = (inputParameters) =>
|
|
6418
|
-
|
|
6419
|
-
|
|
6420
|
-
|
|
6421
|
-
|
|
6422
|
-
|
|
6423
|
-
|
|
6424
|
-
|
|
6425
|
-
|
|
6581
|
+
const pipelineExecutor = (inputParameters) => {
|
|
6582
|
+
const startTime = new Date().getTime();
|
|
6583
|
+
return createTask({
|
|
6584
|
+
taskType: 'EXECUTION',
|
|
6585
|
+
title: pipeline.title,
|
|
6586
|
+
taskProcessCallback(updateOngoingResult, updateTldr) {
|
|
6587
|
+
return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
|
|
6588
|
+
var _a, _b;
|
|
6589
|
+
updateOngoingResult(newOngoingResult);
|
|
6590
|
+
// Calculate and update tldr based on pipeline progress
|
|
6591
|
+
const cv = newOngoingResult;
|
|
6592
|
+
// Calculate progress based on parameters resolved vs total parameters
|
|
6593
|
+
const totalParameters = pipeline.parameters.filter(p => !p.isInput).length;
|
|
6594
|
+
let resolvedParameters = 0;
|
|
6595
|
+
let currentTaskTitle = '';
|
|
6596
|
+
// Get the resolved parameters from output parameters
|
|
6597
|
+
if (cv === null || cv === void 0 ? void 0 : cv.outputParameters) {
|
|
6598
|
+
// Count how many output parameters have non-empty values
|
|
6599
|
+
resolvedParameters = Object.values(cv.outputParameters).filter(value => value !== undefined && value !== null && String(value).trim() !== '').length;
|
|
6600
|
+
}
|
|
6601
|
+
// Try to determine current task from execution report
|
|
6602
|
+
if (((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) && cv.executionReport.promptExecutions.length > 0) {
|
|
6603
|
+
const lastExecution = cv.executionReport.promptExecutions[cv.executionReport.promptExecutions.length - 1];
|
|
6604
|
+
if ((_b = lastExecution === null || lastExecution === void 0 ? void 0 : lastExecution.prompt) === null || _b === void 0 ? void 0 : _b.title) {
|
|
6605
|
+
currentTaskTitle = lastExecution.prompt.title;
|
|
6606
|
+
}
|
|
6607
|
+
}
|
|
6608
|
+
// Calculate base progress percentage
|
|
6609
|
+
let percent = totalParameters > 0 ? resolvedParameters / totalParameters : 0;
|
|
6610
|
+
// Add time-based progress for current task if we haven't completed all parameters
|
|
6611
|
+
if (resolvedParameters < totalParameters) {
|
|
6612
|
+
const elapsedMs = new Date().getTime() - startTime;
|
|
6613
|
+
const estimatedTotalMs = totalParameters * 30 * 1000; // Estimate 30 seconds per parameter
|
|
6614
|
+
const timeProgress = Math.min(elapsedMs / estimatedTotalMs, 0.9); // Cap at 90% for time-based progress
|
|
6615
|
+
// If we have time progress but no parameter progress, show time progress
|
|
6616
|
+
if (percent === 0 && timeProgress > 0) {
|
|
6617
|
+
percent = Math.min(timeProgress, 0.1); // Show some progress but not more than 10%
|
|
6618
|
+
}
|
|
6619
|
+
else if (percent < 1) {
|
|
6620
|
+
// Add partial progress for current task
|
|
6621
|
+
const taskProgress = totalParameters > 0 ? (1 / totalParameters) * 0.5 : 0; // 50% of task progress
|
|
6622
|
+
percent = Math.min(percent + taskProgress, 0.95); // Cap at 95% until fully complete
|
|
6623
|
+
}
|
|
6624
|
+
}
|
|
6625
|
+
// Clamp to [0,1]
|
|
6626
|
+
percent = Math.min(Math.max(percent, 0), 1);
|
|
6627
|
+
// Generate message
|
|
6628
|
+
let message = '';
|
|
6629
|
+
if (currentTaskTitle) {
|
|
6630
|
+
message = `Executing: ${currentTaskTitle}`;
|
|
6631
|
+
}
|
|
6632
|
+
else if (resolvedParameters === 0) {
|
|
6633
|
+
message = 'Starting pipeline execution';
|
|
6634
|
+
}
|
|
6635
|
+
else if (resolvedParameters < totalParameters) {
|
|
6636
|
+
message = `Processing pipeline (${resolvedParameters}/${totalParameters} parameters resolved)`;
|
|
6637
|
+
}
|
|
6638
|
+
else {
|
|
6639
|
+
message = 'Completing pipeline execution';
|
|
6640
|
+
}
|
|
6641
|
+
updateTldr({
|
|
6642
|
+
percent: percent,
|
|
6643
|
+
message,
|
|
6644
|
+
});
|
|
6645
|
+
});
|
|
6646
|
+
},
|
|
6647
|
+
});
|
|
6648
|
+
};
|
|
6426
6649
|
// <- TODO: Make types such as there is no need to do `as` for `createTask`
|
|
6427
6650
|
return pipelineExecutor;
|
|
6428
6651
|
}
|
|
@@ -7029,31 +7252,23 @@
|
|
|
7029
7252
|
return content;
|
|
7030
7253
|
}
|
|
7031
7254
|
|
|
7255
|
+
/**
|
|
7256
|
+
* @private internal for `preserve`
|
|
7257
|
+
*/
|
|
7258
|
+
const _preserved = [];
|
|
7032
7259
|
/**
|
|
7033
7260
|
* Does nothing, but preserves the function in the bundle
|
|
7034
7261
|
* Compiler is tricked into thinking the function is used
|
|
7035
7262
|
*
|
|
7036
7263
|
* @param value any function to preserve
|
|
7037
7264
|
* @returns nothing
|
|
7038
|
-
* @private
|
|
7039
|
-
*/
|
|
7040
|
-
function preserve(
|
|
7041
|
-
|
|
7042
|
-
(async () => {
|
|
7043
|
-
// TODO: [💩] Change to `await forEver` or `forTime(Infinity)`
|
|
7044
|
-
await waitasecond.forTime(100000000);
|
|
7045
|
-
// [1]
|
|
7046
|
-
try {
|
|
7047
|
-
await func();
|
|
7048
|
-
}
|
|
7049
|
-
finally {
|
|
7050
|
-
// do nothing
|
|
7051
|
-
}
|
|
7052
|
-
})();
|
|
7265
|
+
* @private within the repository
|
|
7266
|
+
*/
|
|
7267
|
+
function $preserve(...value) {
|
|
7268
|
+
_preserved.push(...value);
|
|
7053
7269
|
}
|
|
7054
7270
|
/**
|
|
7055
|
-
*
|
|
7056
|
-
* TODO: [1] This maybe does memory leak
|
|
7271
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
7057
7272
|
*/
|
|
7058
7273
|
|
|
7059
7274
|
// Note: [💎]
|
|
@@ -7081,25 +7296,25 @@
|
|
|
7081
7296
|
// Note: [💎]
|
|
7082
7297
|
// Note: Using direct eval, following variables are in same scope as eval call so they are accessible from inside the evaluated script:
|
|
7083
7298
|
const spaceTrim = (_) => spaceTrim__default["default"](_);
|
|
7084
|
-
preserve(spaceTrim);
|
|
7299
|
+
$preserve(spaceTrim);
|
|
7085
7300
|
const removeQuotes$1 = removeQuotes;
|
|
7086
|
-
preserve(removeQuotes$1);
|
|
7301
|
+
$preserve(removeQuotes$1);
|
|
7087
7302
|
const unwrapResult$1 = unwrapResult;
|
|
7088
|
-
preserve(unwrapResult$1);
|
|
7303
|
+
$preserve(unwrapResult$1);
|
|
7089
7304
|
const trimEndOfCodeBlock$1 = trimEndOfCodeBlock;
|
|
7090
|
-
preserve(trimEndOfCodeBlock$1);
|
|
7305
|
+
$preserve(trimEndOfCodeBlock$1);
|
|
7091
7306
|
const trimCodeBlock$1 = trimCodeBlock;
|
|
7092
|
-
preserve(trimCodeBlock$1);
|
|
7307
|
+
$preserve(trimCodeBlock$1);
|
|
7093
7308
|
// TODO: DRY [🍯]
|
|
7094
7309
|
const trim = (str) => str.trim();
|
|
7095
|
-
preserve(trim);
|
|
7310
|
+
$preserve(trim);
|
|
7096
7311
|
// TODO: DRY [🍯]
|
|
7097
7312
|
const reverse = (str) => str.split('').reverse().join('');
|
|
7098
|
-
preserve(reverse);
|
|
7313
|
+
$preserve(reverse);
|
|
7099
7314
|
const removeEmojis$1 = removeEmojis;
|
|
7100
|
-
preserve(removeEmojis$1);
|
|
7315
|
+
$preserve(removeEmojis$1);
|
|
7101
7316
|
const prettifyMarkdown$1 = prettifyMarkdown;
|
|
7102
|
-
preserve(prettifyMarkdown$1);
|
|
7317
|
+
$preserve(prettifyMarkdown$1);
|
|
7103
7318
|
//-------[n12:]---
|
|
7104
7319
|
const capitalize$1 = capitalize;
|
|
7105
7320
|
const decapitalize$1 = decapitalize;
|
|
@@ -7115,18 +7330,18 @@
|
|
|
7115
7330
|
// TODO: DRY [🍯]
|
|
7116
7331
|
Array.from(parseKeywordsFromString(input)).join(', '); /* <- TODO: [🧠] What is the best format comma list, bullet list,...? */
|
|
7117
7332
|
const normalizeTo_SCREAMING_CASE$1 = normalizeTo_SCREAMING_CASE;
|
|
7118
|
-
preserve(capitalize$1);
|
|
7119
|
-
preserve(decapitalize$1);
|
|
7120
|
-
preserve(nameToUriPart$1);
|
|
7121
|
-
preserve(nameToUriParts$1);
|
|
7122
|
-
preserve(removeDiacritics$1);
|
|
7123
|
-
preserve(normalizeWhitespaces$1);
|
|
7124
|
-
preserve(normalizeToKebabCase$1);
|
|
7125
|
-
preserve(normalizeTo_camelCase$1);
|
|
7126
|
-
preserve(normalizeTo_snake_case$1);
|
|
7127
|
-
preserve(normalizeTo_PascalCase$1);
|
|
7128
|
-
preserve(parseKeywords);
|
|
7129
|
-
preserve(normalizeTo_SCREAMING_CASE$1);
|
|
7333
|
+
$preserve(capitalize$1);
|
|
7334
|
+
$preserve(decapitalize$1);
|
|
7335
|
+
$preserve(nameToUriPart$1);
|
|
7336
|
+
$preserve(nameToUriParts$1);
|
|
7337
|
+
$preserve(removeDiacritics$1);
|
|
7338
|
+
$preserve(normalizeWhitespaces$1);
|
|
7339
|
+
$preserve(normalizeToKebabCase$1);
|
|
7340
|
+
$preserve(normalizeTo_camelCase$1);
|
|
7341
|
+
$preserve(normalizeTo_snake_case$1);
|
|
7342
|
+
$preserve(normalizeTo_PascalCase$1);
|
|
7343
|
+
$preserve(parseKeywords);
|
|
7344
|
+
$preserve(normalizeTo_SCREAMING_CASE$1);
|
|
7130
7345
|
//-------[/n12]---
|
|
7131
7346
|
if (!script.includes('return')) {
|
|
7132
7347
|
script = `return ${script}`;
|
|
@@ -8159,7 +8374,7 @@
|
|
|
8159
8374
|
});
|
|
8160
8375
|
function exportExecutionTask(executionTask, isFull) {
|
|
8161
8376
|
// <- TODO: [🧠] This should be maybe method of `ExecutionTask` itself
|
|
8162
|
-
const { taskType, promptbookVersion, taskId, title, status, errors, warnings, createdAt, updatedAt, currentValue, } = executionTask;
|
|
8377
|
+
const { taskType, promptbookVersion, taskId, title, status, errors, tldr, warnings, createdAt, updatedAt, currentValue, } = executionTask;
|
|
8163
8378
|
if (isFull) {
|
|
8164
8379
|
return {
|
|
8165
8380
|
taskId,
|
|
@@ -8167,6 +8382,7 @@
|
|
|
8167
8382
|
taskType,
|
|
8168
8383
|
promptbookVersion,
|
|
8169
8384
|
status,
|
|
8385
|
+
tldr,
|
|
8170
8386
|
errors: errors.map(serializeError),
|
|
8171
8387
|
warnings: warnings.map(serializeError),
|
|
8172
8388
|
createdAt,
|
|
@@ -8181,6 +8397,7 @@
|
|
|
8181
8397
|
taskType,
|
|
8182
8398
|
promptbookVersion,
|
|
8183
8399
|
status,
|
|
8400
|
+
tldr,
|
|
8184
8401
|
createdAt,
|
|
8185
8402
|
updatedAt,
|
|
8186
8403
|
};
|