@promptbook/markdown-utils 0.100.0-6 → 0.100.0-64
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 +7 -10
- package/esm/index.es.js +252 -23
- 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 +1 -2
- package/umd/index.umd.js +256 -27
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +0 -14
package/README.md
CHANGED
|
@@ -10,14 +10,18 @@ Write AI applications using plain human language across multiple models and plat
|
|
|
10
10
|
[ Promptbook](https://badge.fury.io/js/promptbook.svg)](https://www.npmjs.com/package/promptbook)
|
|
11
11
|
[ Promptbook](https://packagequality.com/shield/promptbook.svg)](https://packagequality.com/#?package=promptbook)
|
|
12
12
|
[](https://snyk.io/test/github/webgptorg/promptbook)
|
|
13
|
-
[](https://github.com/webgptorg/promptbook/actions/workflows/test-books.yml)
|
|
14
|
+
[](https://github.com/webgptorg/promptbook/actions/workflows/test-build.yml)
|
|
15
|
+
[](https://github.com/webgptorg/promptbook/actions/workflows/test-lint.yml)
|
|
16
|
+
[](https://github.com/webgptorg/promptbook/actions/workflows/test-spell-check.yml)
|
|
17
|
+
[](https://github.com/webgptorg/promptbook/actions/workflows/test-types.yml)
|
|
15
18
|
[](https://github.com/webgptorg/promptbook/issues)
|
|
16
19
|
|
|
17
20
|
|
|
18
21
|
|
|
19
22
|
## 🌟 New Features
|
|
20
23
|
|
|
24
|
+
- 🚀 **GPT-5 Support** - Now includes OpenAI's most advanced language model with unprecedented reasoning capabilities and 200K context window
|
|
21
25
|
- 💡 VS Code support for `.book` files with syntax highlighting and IntelliSense
|
|
22
26
|
- 🐳 Official Docker image (`hejny/promptbook`) for seamless containerized usage
|
|
23
27
|
- 🔥 Native support for OpenAI `o3-mini`, GPT-4 and other leading LLMs
|
|
@@ -60,8 +64,6 @@ Rest of the documentation is common for **entire promptbook ecosystem**:
|
|
|
60
64
|
|
|
61
65
|
During the computer revolution, we have seen [multiple generations of computer languages](https://github.com/webgptorg/promptbook/discussions/180), from the physical rewiring of the vacuum tubes through low-level machine code to the high-level languages like Python or JavaScript. And now, we're on the edge of the **next revolution**!
|
|
62
66
|
|
|
63
|
-
|
|
64
|
-
|
|
65
67
|
It's a revolution of writing software in **plain human language** that is understandable and executable by both humans and machines – and it's going to change everything!
|
|
66
68
|
|
|
67
69
|
The incredible growth in power of microprocessors and the Moore's Law have been the driving force behind the ever-more powerful languages, and it's been an amazing journey! Similarly, the large language models (like GPT or Claude) are the next big thing in language technology, and they're set to transform the way we interact with computers.
|
|
@@ -187,8 +189,6 @@ Join our growing community of developers and users:
|
|
|
187
189
|
|
|
188
190
|
_A concise, Markdown-based DSL for crafting AI workflows and automations._
|
|
189
191
|
|
|
190
|
-
|
|
191
|
-
|
|
192
192
|
### Introduction
|
|
193
193
|
|
|
194
194
|
Book is a Markdown-based language that simplifies the creation of AI applications, workflows, and automations. With human-readable commands, you can define inputs, outputs, personas, knowledge sources, and actions—without needing model-specific details.
|
|
@@ -238,8 +238,6 @@ Personas can have access to different knowledge, tools and actions. They can als
|
|
|
238
238
|
|
|
239
239
|
- [PERSONA](https://github.com/webgptorg/promptbook/blob/main/documents/commands/PERSONA.md)
|
|
240
240
|
|
|
241
|
-
|
|
242
|
-
|
|
243
241
|
### **3. How:** Knowledge, Instruments and Actions
|
|
244
242
|
|
|
245
243
|
The resources used by the personas are used to do the work.
|
|
@@ -314,6 +312,7 @@ Or you can install them separately:
|
|
|
314
312
|
- **[@promptbook/editable](https://www.npmjs.com/package/@promptbook/editable)** - Editable book as native javascript object with imperative object API
|
|
315
313
|
- **[@promptbook/templates](https://www.npmjs.com/package/@promptbook/templates)** - Useful templates and examples of books which can be used as a starting point
|
|
316
314
|
- **[@promptbook/types](https://www.npmjs.com/package/@promptbook/types)** - Just typescript types used in the library
|
|
315
|
+
- **[@promptbook/color](https://www.npmjs.com/package/@promptbook/color)** - Color manipulation library
|
|
317
316
|
- ⭐ **[@promptbook/cli](https://www.npmjs.com/package/@promptbook/cli)** - Command line interface utilities for promptbooks
|
|
318
317
|
- 🐋 **[Docker image](https://hub.docker.com/r/hejny/promptbook/)** - Promptbook server
|
|
319
318
|
|
|
@@ -339,8 +338,6 @@ The following glossary is used to clarify certain concepts:
|
|
|
339
338
|
|
|
340
339
|
_Note: This section is not a complete dictionary, more list of general AI / LLM terms that has connection with Promptbook_
|
|
341
340
|
|
|
342
|
-
|
|
343
|
-
|
|
344
341
|
### 💯 Core concepts
|
|
345
342
|
|
|
346
343
|
- [📚 Collection of pipelines](https://github.com/webgptorg/promptbook/discussions/65)
|
package/esm/index.es.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import spaceTrim, { spaceTrim as spaceTrim$1 } from 'spacetrim';
|
|
2
|
-
import { format } from 'prettier';
|
|
3
2
|
import parserHtml from 'prettier/parser-html';
|
|
3
|
+
import parserMarkdown from 'prettier/parser-markdown';
|
|
4
|
+
import { format } from 'prettier/standalone';
|
|
4
5
|
import { randomBytes } from 'crypto';
|
|
5
6
|
import { Subject } from 'rxjs';
|
|
6
7
|
import { forTime } from 'waitasecond';
|
|
@@ -25,7 +26,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
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-64';
|
|
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
|
|
@@ -347,6 +348,19 @@ let DEFAULT_IS_VERBOSE = false;
|
|
|
347
348
|
* @public exported from `@promptbook/core`
|
|
348
349
|
*/
|
|
349
350
|
const DEFAULT_IS_AUTO_INSTALLED = false;
|
|
351
|
+
/**
|
|
352
|
+
* Default simulated duration for a task in milliseconds (used for progress reporting)
|
|
353
|
+
*
|
|
354
|
+
* @public exported from `@promptbook/core`
|
|
355
|
+
*/
|
|
356
|
+
const DEFAULT_TASK_SIMULATED_DURATION_MS = 5 * 60 * 1000; // 5 minutes
|
|
357
|
+
/**
|
|
358
|
+
* API request timeout in milliseconds
|
|
359
|
+
* Can be overridden via API_REQUEST_TIMEOUT environment variable
|
|
360
|
+
*
|
|
361
|
+
* @public exported from `@promptbook/core`
|
|
362
|
+
*/
|
|
363
|
+
parseInt(process.env.API_REQUEST_TIMEOUT || '90000');
|
|
350
364
|
/**
|
|
351
365
|
* Indicates whether pipeline logic validation is enabled. When true, the pipeline logic is checked for consistency.
|
|
352
366
|
*
|
|
@@ -687,7 +701,7 @@ function prettifyMarkdown(content) {
|
|
|
687
701
|
try {
|
|
688
702
|
return format(content, {
|
|
689
703
|
parser: 'markdown',
|
|
690
|
-
plugins: [parserHtml],
|
|
704
|
+
plugins: [parserMarkdown, parserHtml],
|
|
691
705
|
// TODO: DRY - make some import or auto-copy of .prettierrc
|
|
692
706
|
endOfLine: 'lf',
|
|
693
707
|
tabWidth: 4,
|
|
@@ -2206,6 +2220,7 @@ function createTask(options) {
|
|
|
2206
2220
|
const errors = [];
|
|
2207
2221
|
const warnings = [];
|
|
2208
2222
|
let currentValue = {};
|
|
2223
|
+
let customTldr = null;
|
|
2209
2224
|
const partialResultSubject = new Subject();
|
|
2210
2225
|
// <- Note: Not using `BehaviorSubject` because on error we can't access the last value
|
|
2211
2226
|
const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
|
|
@@ -2216,6 +2231,9 @@ function createTask(options) {
|
|
|
2216
2231
|
Object.assign(currentValue, newOngoingResult);
|
|
2217
2232
|
// <- TODO: assign deep
|
|
2218
2233
|
partialResultSubject.next(newOngoingResult);
|
|
2234
|
+
}, (tldrInfo) => {
|
|
2235
|
+
customTldr = tldrInfo;
|
|
2236
|
+
updatedAt = new Date();
|
|
2219
2237
|
});
|
|
2220
2238
|
finalResultPromise
|
|
2221
2239
|
.catch((error) => {
|
|
@@ -2269,6 +2287,78 @@ function createTask(options) {
|
|
|
2269
2287
|
return status;
|
|
2270
2288
|
// <- Note: [1] --||--
|
|
2271
2289
|
},
|
|
2290
|
+
get tldr() {
|
|
2291
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2292
|
+
// Use custom tldr if available
|
|
2293
|
+
if (customTldr) {
|
|
2294
|
+
return customTldr;
|
|
2295
|
+
}
|
|
2296
|
+
// Fallback to default implementation
|
|
2297
|
+
const cv = currentValue;
|
|
2298
|
+
// If explicit percent is provided, use it
|
|
2299
|
+
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;
|
|
2300
|
+
// Simulate progress if not provided
|
|
2301
|
+
if (typeof percentRaw !== 'number') {
|
|
2302
|
+
// Simulate progress: evenly split across subtasks, based on elapsed time
|
|
2303
|
+
const now = new Date();
|
|
2304
|
+
const elapsedMs = now.getTime() - createdAt.getTime();
|
|
2305
|
+
const totalMs = DEFAULT_TASK_SIMULATED_DURATION_MS;
|
|
2306
|
+
// If subtasks are defined, split progress evenly
|
|
2307
|
+
const subtaskCount = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) ? cv.subtasks.length : 1;
|
|
2308
|
+
const completedSubtasks = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks)
|
|
2309
|
+
? cv.subtasks.filter((s) => s.done || s.completed).length
|
|
2310
|
+
: 0;
|
|
2311
|
+
// Progress from completed subtasks
|
|
2312
|
+
const subtaskProgress = subtaskCount > 0 ? completedSubtasks / subtaskCount : 0;
|
|
2313
|
+
// Progress from elapsed time for current subtask
|
|
2314
|
+
const timeProgress = Math.min(elapsedMs / totalMs, 1);
|
|
2315
|
+
// Combine: completed subtasks + time progress for current subtask
|
|
2316
|
+
percentRaw = Math.min(subtaskProgress + (1 / subtaskCount) * timeProgress, 1);
|
|
2317
|
+
if (status === 'FINISHED')
|
|
2318
|
+
percentRaw = 1;
|
|
2319
|
+
if (status === 'ERROR')
|
|
2320
|
+
percentRaw = 0;
|
|
2321
|
+
}
|
|
2322
|
+
// Clamp to [0,1]
|
|
2323
|
+
let percent = Number(percentRaw) || 0;
|
|
2324
|
+
if (percent < 0)
|
|
2325
|
+
percent = 0;
|
|
2326
|
+
if (percent > 1)
|
|
2327
|
+
percent = 1;
|
|
2328
|
+
// Build a short message: prefer explicit tldr.message, then common summary/message fields, then errors/warnings, then status
|
|
2329
|
+
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;
|
|
2330
|
+
let message = messageFromResult;
|
|
2331
|
+
if (!message) {
|
|
2332
|
+
// If subtasks, show current subtask
|
|
2333
|
+
if (Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) && cv.subtasks.length > 0) {
|
|
2334
|
+
const current = cv.subtasks.find((s) => !s.done && !s.completed);
|
|
2335
|
+
if (current && current.title) {
|
|
2336
|
+
message = `Working on ${current.title}`;
|
|
2337
|
+
}
|
|
2338
|
+
}
|
|
2339
|
+
if (!message) {
|
|
2340
|
+
if (errors.length) {
|
|
2341
|
+
message = errors[errors.length - 1].message || 'Error';
|
|
2342
|
+
}
|
|
2343
|
+
else if (warnings.length) {
|
|
2344
|
+
message = warnings[warnings.length - 1].message || 'Warning';
|
|
2345
|
+
}
|
|
2346
|
+
else if (status === 'FINISHED') {
|
|
2347
|
+
message = 'Finished';
|
|
2348
|
+
}
|
|
2349
|
+
else if (status === 'ERROR') {
|
|
2350
|
+
message = 'Error';
|
|
2351
|
+
}
|
|
2352
|
+
else {
|
|
2353
|
+
message = 'Running';
|
|
2354
|
+
}
|
|
2355
|
+
}
|
|
2356
|
+
}
|
|
2357
|
+
return {
|
|
2358
|
+
percent: percent,
|
|
2359
|
+
message,
|
|
2360
|
+
};
|
|
2361
|
+
},
|
|
2272
2362
|
get createdAt() {
|
|
2273
2363
|
return createdAt;
|
|
2274
2364
|
// <- Note: [1] --||--
|
|
@@ -2517,6 +2607,76 @@ function countUsage(llmTools) {
|
|
|
2517
2607
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
2518
2608
|
*/
|
|
2519
2609
|
|
|
2610
|
+
/**
|
|
2611
|
+
* Predefined profiles for LLM providers to maintain consistency across the application
|
|
2612
|
+
* These profiles represent each provider as a virtual persona in chat interfaces
|
|
2613
|
+
*
|
|
2614
|
+
* @private !!!!
|
|
2615
|
+
*/
|
|
2616
|
+
const LLM_PROVIDER_PROFILES = {
|
|
2617
|
+
OPENAI: {
|
|
2618
|
+
name: 'OPENAI',
|
|
2619
|
+
fullname: 'OpenAI GPT',
|
|
2620
|
+
color: '#10a37f', // OpenAI's signature green
|
|
2621
|
+
// Note: avatarSrc could be added when we have provider logos available
|
|
2622
|
+
},
|
|
2623
|
+
ANTHROPIC: {
|
|
2624
|
+
name: 'ANTHROPIC',
|
|
2625
|
+
fullname: 'Anthropic Claude',
|
|
2626
|
+
color: '#d97706', // Anthropic's orange/amber color
|
|
2627
|
+
},
|
|
2628
|
+
AZURE_OPENAI: {
|
|
2629
|
+
name: 'AZURE_OPENAI',
|
|
2630
|
+
fullname: 'Azure OpenAI',
|
|
2631
|
+
color: '#0078d4', // Microsoft Azure blue
|
|
2632
|
+
},
|
|
2633
|
+
GOOGLE: {
|
|
2634
|
+
name: 'GOOGLE',
|
|
2635
|
+
fullname: 'Google Gemini',
|
|
2636
|
+
color: '#4285f4', // Google blue
|
|
2637
|
+
},
|
|
2638
|
+
DEEPSEEK: {
|
|
2639
|
+
name: 'DEEPSEEK',
|
|
2640
|
+
fullname: 'DeepSeek',
|
|
2641
|
+
color: '#7c3aed', // Purple color for DeepSeek
|
|
2642
|
+
},
|
|
2643
|
+
OLLAMA: {
|
|
2644
|
+
name: 'OLLAMA',
|
|
2645
|
+
fullname: 'Ollama',
|
|
2646
|
+
color: '#059669', // Emerald green for local models
|
|
2647
|
+
},
|
|
2648
|
+
REMOTE: {
|
|
2649
|
+
name: 'REMOTE',
|
|
2650
|
+
fullname: 'Remote Server',
|
|
2651
|
+
color: '#6b7280', // Gray for remote/proxy connections
|
|
2652
|
+
},
|
|
2653
|
+
MOCKED_ECHO: {
|
|
2654
|
+
name: 'MOCKED_ECHO',
|
|
2655
|
+
fullname: 'Echo (Test)',
|
|
2656
|
+
color: '#8b5cf6', // Purple for test/mock tools
|
|
2657
|
+
},
|
|
2658
|
+
MOCKED_FAKE: {
|
|
2659
|
+
name: 'MOCKED_FAKE',
|
|
2660
|
+
fullname: 'Fake LLM (Test)',
|
|
2661
|
+
color: '#ec4899', // Pink for fake/test tools
|
|
2662
|
+
},
|
|
2663
|
+
VERCEL: {
|
|
2664
|
+
name: 'VERCEL',
|
|
2665
|
+
fullname: 'Vercel AI',
|
|
2666
|
+
color: '#000000', // Vercel's black
|
|
2667
|
+
},
|
|
2668
|
+
MULTIPLE: {
|
|
2669
|
+
name: 'MULTIPLE',
|
|
2670
|
+
fullname: 'Multiple Providers',
|
|
2671
|
+
color: '#6366f1', // Indigo for combined/multiple providers
|
|
2672
|
+
},
|
|
2673
|
+
};
|
|
2674
|
+
/**
|
|
2675
|
+
* TODO: Refactor this - each profile must be alongside the provider definition
|
|
2676
|
+
* TODO: Unite `AvatarProfileProps` and `ChatParticipant`
|
|
2677
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
2678
|
+
*/
|
|
2679
|
+
|
|
2520
2680
|
/**
|
|
2521
2681
|
* Multiple LLM Execution Tools is a proxy server that uses multiple execution tools internally and exposes the executor interface externally.
|
|
2522
2682
|
*
|
|
@@ -2542,7 +2702,7 @@ class MultipleLlmExecutionTools {
|
|
|
2542
2702
|
}
|
|
2543
2703
|
return spaceTrim((block) => `
|
|
2544
2704
|
${headLine}
|
|
2545
|
-
|
|
2705
|
+
|
|
2546
2706
|
${ /* <- Note: Indenting the description: */block(description)}
|
|
2547
2707
|
`);
|
|
2548
2708
|
})
|
|
@@ -2553,6 +2713,9 @@ class MultipleLlmExecutionTools {
|
|
|
2553
2713
|
${block(innerModelsTitlesAndDescriptions)}
|
|
2554
2714
|
`);
|
|
2555
2715
|
}
|
|
2716
|
+
get profile() {
|
|
2717
|
+
return LLM_PROVIDER_PROFILES.MULTIPLE;
|
|
2718
|
+
}
|
|
2556
2719
|
/**
|
|
2557
2720
|
* Check the configuration of all execution tools
|
|
2558
2721
|
*/
|
|
@@ -2597,25 +2760,22 @@ class MultipleLlmExecutionTools {
|
|
|
2597
2760
|
const errors = [];
|
|
2598
2761
|
llm: for (const llmExecutionTools of this.llmExecutionTools) {
|
|
2599
2762
|
try {
|
|
2600
|
-
|
|
2763
|
+
switch (prompt.modelRequirements.modelVariant) {
|
|
2601
2764
|
case 'CHAT':
|
|
2602
2765
|
if (llmExecutionTools.callChatModel === undefined) {
|
|
2603
2766
|
continue llm;
|
|
2604
2767
|
}
|
|
2605
2768
|
return await llmExecutionTools.callChatModel(prompt);
|
|
2606
|
-
break variant;
|
|
2607
2769
|
case 'COMPLETION':
|
|
2608
2770
|
if (llmExecutionTools.callCompletionModel === undefined) {
|
|
2609
2771
|
continue llm;
|
|
2610
2772
|
}
|
|
2611
2773
|
return await llmExecutionTools.callCompletionModel(prompt);
|
|
2612
|
-
break variant;
|
|
2613
2774
|
case 'EMBEDDING':
|
|
2614
2775
|
if (llmExecutionTools.callEmbeddingModel === undefined) {
|
|
2615
2776
|
continue llm;
|
|
2616
2777
|
}
|
|
2617
2778
|
return await llmExecutionTools.callEmbeddingModel(prompt);
|
|
2618
|
-
break variant;
|
|
2619
2779
|
// <- case [🤖]:
|
|
2620
2780
|
default:
|
|
2621
2781
|
throw new UnexpectedError(`Unknown model variant "${prompt.modelRequirements.modelVariant}"`);
|
|
@@ -2768,7 +2928,7 @@ async function preparePersona(personaDescription, tools, options) {
|
|
|
2768
2928
|
const result = await preparePersonaExecutor({
|
|
2769
2929
|
availableModels /* <- Note: Passing as JSON */,
|
|
2770
2930
|
personaDescription,
|
|
2771
|
-
}).asPromise();
|
|
2931
|
+
}).asPromise({ isCrashedOnError: true });
|
|
2772
2932
|
const { outputParameters } = result;
|
|
2773
2933
|
const { modelsRequirements: modelsRequirementsJson } = outputParameters;
|
|
2774
2934
|
let modelsRequirementsUnchecked = jsonParse(modelsRequirementsJson);
|
|
@@ -3919,7 +4079,7 @@ async function preparePipeline(pipeline, tools, options) {
|
|
|
3919
4079
|
});
|
|
3920
4080
|
const result = await prepareTitleExecutor({
|
|
3921
4081
|
book: sources.map(({ content }) => content).join('\n\n'),
|
|
3922
|
-
}).asPromise();
|
|
4082
|
+
}).asPromise({ isCrashedOnError: true });
|
|
3923
4083
|
const { outputParameters } = result;
|
|
3924
4084
|
const { title: titleRaw } = outputParameters;
|
|
3925
4085
|
if (isVerbose) {
|
|
@@ -4911,7 +5071,7 @@ function validatePromptResult(options) {
|
|
|
4911
5071
|
*/
|
|
4912
5072
|
async function executeAttempts(options) {
|
|
4913
5073
|
const { jokerParameterNames, priority, maxAttempts, // <- Note: [💂]
|
|
4914
|
-
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, } = options;
|
|
5074
|
+
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, } = options;
|
|
4915
5075
|
const $ongoingTaskResult = {
|
|
4916
5076
|
$result: null,
|
|
4917
5077
|
$resultString: null,
|
|
@@ -5155,6 +5315,10 @@ async function executeAttempts(options) {
|
|
|
5155
5315
|
result: $ongoingTaskResult.$resultString,
|
|
5156
5316
|
error: error,
|
|
5157
5317
|
});
|
|
5318
|
+
// Report failed attempt
|
|
5319
|
+
onProgress({
|
|
5320
|
+
errors: [error],
|
|
5321
|
+
});
|
|
5158
5322
|
}
|
|
5159
5323
|
finally {
|
|
5160
5324
|
if (!isJokerAttempt &&
|
|
@@ -6028,15 +6192,74 @@ function createPipelineExecutor(options) {
|
|
|
6028
6192
|
});
|
|
6029
6193
|
});
|
|
6030
6194
|
};
|
|
6031
|
-
const pipelineExecutor = (inputParameters) =>
|
|
6032
|
-
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
6195
|
+
const pipelineExecutor = (inputParameters) => {
|
|
6196
|
+
const startTime = new Date().getTime();
|
|
6197
|
+
return createTask({
|
|
6198
|
+
taskType: 'EXECUTION',
|
|
6199
|
+
title: pipeline.title,
|
|
6200
|
+
taskProcessCallback(updateOngoingResult, updateTldr) {
|
|
6201
|
+
return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
|
|
6202
|
+
var _a, _b;
|
|
6203
|
+
updateOngoingResult(newOngoingResult);
|
|
6204
|
+
// Calculate and update tldr based on pipeline progress
|
|
6205
|
+
const cv = newOngoingResult;
|
|
6206
|
+
// Calculate progress based on parameters resolved vs total parameters
|
|
6207
|
+
const totalParameters = pipeline.parameters.filter(p => !p.isInput).length;
|
|
6208
|
+
let resolvedParameters = 0;
|
|
6209
|
+
let currentTaskTitle = '';
|
|
6210
|
+
// Get the resolved parameters from output parameters
|
|
6211
|
+
if (cv === null || cv === void 0 ? void 0 : cv.outputParameters) {
|
|
6212
|
+
// Count how many output parameters have non-empty values
|
|
6213
|
+
resolvedParameters = Object.values(cv.outputParameters).filter(value => value !== undefined && value !== null && String(value).trim() !== '').length;
|
|
6214
|
+
}
|
|
6215
|
+
// Try to determine current task from execution report
|
|
6216
|
+
if (((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) && cv.executionReport.promptExecutions.length > 0) {
|
|
6217
|
+
const lastExecution = cv.executionReport.promptExecutions[cv.executionReport.promptExecutions.length - 1];
|
|
6218
|
+
if ((_b = lastExecution === null || lastExecution === void 0 ? void 0 : lastExecution.prompt) === null || _b === void 0 ? void 0 : _b.title) {
|
|
6219
|
+
currentTaskTitle = lastExecution.prompt.title;
|
|
6220
|
+
}
|
|
6221
|
+
}
|
|
6222
|
+
// Calculate base progress percentage
|
|
6223
|
+
let percent = totalParameters > 0 ? resolvedParameters / totalParameters : 0;
|
|
6224
|
+
// Add time-based progress for current task if we haven't completed all parameters
|
|
6225
|
+
if (resolvedParameters < totalParameters) {
|
|
6226
|
+
const elapsedMs = new Date().getTime() - startTime;
|
|
6227
|
+
const estimatedTotalMs = totalParameters * 30 * 1000; // Estimate 30 seconds per parameter
|
|
6228
|
+
const timeProgress = Math.min(elapsedMs / estimatedTotalMs, 0.9); // Cap at 90% for time-based progress
|
|
6229
|
+
// If we have time progress but no parameter progress, show time progress
|
|
6230
|
+
if (percent === 0 && timeProgress > 0) {
|
|
6231
|
+
percent = Math.min(timeProgress, 0.1); // Show some progress but not more than 10%
|
|
6232
|
+
}
|
|
6233
|
+
else if (percent < 1) {
|
|
6234
|
+
// Add partial progress for current task
|
|
6235
|
+
const taskProgress = totalParameters > 0 ? (1 / totalParameters) * 0.5 : 0; // 50% of task progress
|
|
6236
|
+
percent = Math.min(percent + taskProgress, 0.95); // Cap at 95% until fully complete
|
|
6237
|
+
}
|
|
6238
|
+
}
|
|
6239
|
+
// Clamp to [0,1]
|
|
6240
|
+
percent = Math.min(Math.max(percent, 0), 1);
|
|
6241
|
+
// Generate message
|
|
6242
|
+
let message = '';
|
|
6243
|
+
if (currentTaskTitle) {
|
|
6244
|
+
message = `Executing: ${currentTaskTitle}`;
|
|
6245
|
+
}
|
|
6246
|
+
else if (resolvedParameters === 0) {
|
|
6247
|
+
message = 'Starting pipeline execution';
|
|
6248
|
+
}
|
|
6249
|
+
else if (resolvedParameters < totalParameters) {
|
|
6250
|
+
message = `Processing pipeline (${resolvedParameters}/${totalParameters} parameters resolved)`;
|
|
6251
|
+
}
|
|
6252
|
+
else {
|
|
6253
|
+
message = 'Completing pipeline execution';
|
|
6254
|
+
}
|
|
6255
|
+
updateTldr({
|
|
6256
|
+
percent: percent,
|
|
6257
|
+
message,
|
|
6258
|
+
});
|
|
6259
|
+
});
|
|
6260
|
+
},
|
|
6261
|
+
});
|
|
6262
|
+
};
|
|
6040
6263
|
// <- TODO: Make types such as there is no need to do `as` for `createTask`
|
|
6041
6264
|
return pipelineExecutor;
|
|
6042
6265
|
}
|
|
@@ -6121,7 +6344,9 @@ class MarkdownScraper {
|
|
|
6121
6344
|
},
|
|
6122
6345
|
});
|
|
6123
6346
|
const knowledgeContent = await source.asText();
|
|
6124
|
-
const result = await prepareKnowledgeFromMarkdownExecutor({ knowledgeContent }).asPromise(
|
|
6347
|
+
const result = await prepareKnowledgeFromMarkdownExecutor({ knowledgeContent }).asPromise({
|
|
6348
|
+
isCrashedOnError: true,
|
|
6349
|
+
});
|
|
6125
6350
|
const { outputParameters } = result;
|
|
6126
6351
|
const { knowledgePieces: knowledgePiecesRaw } = outputParameters;
|
|
6127
6352
|
const knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
|
|
@@ -6145,12 +6370,16 @@ class MarkdownScraper {
|
|
|
6145
6370
|
];
|
|
6146
6371
|
*/
|
|
6147
6372
|
try {
|
|
6148
|
-
const titleResult = await prepareTitleExecutor({ knowledgePieceContent }).asPromise(
|
|
6373
|
+
const titleResult = await prepareTitleExecutor({ knowledgePieceContent }).asPromise({
|
|
6374
|
+
isCrashedOnError: true,
|
|
6375
|
+
});
|
|
6149
6376
|
const { title: titleRaw = 'Untitled' } = titleResult.outputParameters;
|
|
6150
6377
|
title = spaceTrim(titleRaw) /* <- TODO: Maybe do in pipeline */;
|
|
6151
6378
|
name = titleToName(title);
|
|
6152
6379
|
// --- Keywords
|
|
6153
|
-
const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise(
|
|
6380
|
+
const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise({
|
|
6381
|
+
isCrashedOnError: true,
|
|
6382
|
+
});
|
|
6154
6383
|
const { keywords: keywordsRaw = '' } = keywordsResult.outputParameters;
|
|
6155
6384
|
keywords = (keywordsRaw || '')
|
|
6156
6385
|
.split(',')
|