@promptbook/website-crawler 0.100.0-8 → 0.100.0
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 -14
- 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 +2 -3
- 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
|
|
@@ -25,10 +29,6 @@ Write AI applications using plain human language across multiple models and plat
|
|
|
25
29
|
|
|
26
30
|
|
|
27
31
|
|
|
28
|
-
<blockquote style="color: #ff8811">
|
|
29
|
-
<b>⚠ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>.
|
|
30
|
-
</blockquote>
|
|
31
|
-
|
|
32
32
|
## 📦 Package `@promptbook/website-crawler`
|
|
33
33
|
|
|
34
34
|
- Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
|
|
@@ -60,8 +60,6 @@ Rest of the documentation is common for **entire promptbook ecosystem**:
|
|
|
60
60
|
|
|
61
61
|
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
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
63
|
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
64
|
|
|
67
65
|
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 +185,6 @@ Join our growing community of developers and users:
|
|
|
187
185
|
|
|
188
186
|
_A concise, Markdown-based DSL for crafting AI workflows and automations._
|
|
189
187
|
|
|
190
|
-
|
|
191
|
-
|
|
192
188
|
### Introduction
|
|
193
189
|
|
|
194
190
|
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 +234,6 @@ Personas can have access to different knowledge, tools and actions. They can als
|
|
|
238
234
|
|
|
239
235
|
- [PERSONA](https://github.com/webgptorg/promptbook/blob/main/documents/commands/PERSONA.md)
|
|
240
236
|
|
|
241
|
-
|
|
242
|
-
|
|
243
237
|
### **3. How:** Knowledge, Instruments and Actions
|
|
244
238
|
|
|
245
239
|
The resources used by the personas are used to do the work.
|
|
@@ -314,6 +308,7 @@ Or you can install them separately:
|
|
|
314
308
|
- **[@promptbook/editable](https://www.npmjs.com/package/@promptbook/editable)** - Editable book as native javascript object with imperative object API
|
|
315
309
|
- **[@promptbook/templates](https://www.npmjs.com/package/@promptbook/templates)** - Useful templates and examples of books which can be used as a starting point
|
|
316
310
|
- **[@promptbook/types](https://www.npmjs.com/package/@promptbook/types)** - Just typescript types used in the library
|
|
311
|
+
- **[@promptbook/color](https://www.npmjs.com/package/@promptbook/color)** - Color manipulation library
|
|
317
312
|
- ⭐ **[@promptbook/cli](https://www.npmjs.com/package/@promptbook/cli)** - Command line interface utilities for promptbooks
|
|
318
313
|
- 🐋 **[Docker image](https://hub.docker.com/r/hejny/promptbook/)** - Promptbook server
|
|
319
314
|
|
|
@@ -339,8 +334,6 @@ The following glossary is used to clarify certain concepts:
|
|
|
339
334
|
|
|
340
335
|
_Note: This section is not a complete dictionary, more list of general AI / LLM terms that has connection with Promptbook_
|
|
341
336
|
|
|
342
|
-
|
|
343
|
-
|
|
344
337
|
### 💯 Core concepts
|
|
345
338
|
|
|
346
339
|
- [📚 Collection of pipelines](https://github.com/webgptorg/promptbook/discussions/65)
|
package/esm/index.es.js
CHANGED
|
@@ -5,8 +5,9 @@ import { SHA256 } from 'crypto-js';
|
|
|
5
5
|
import hexEncoder from 'crypto-js/enc-hex';
|
|
6
6
|
import { mkdir, rm } from 'fs/promises';
|
|
7
7
|
import { basename, join, dirname } from 'path';
|
|
8
|
-
import { format } from 'prettier';
|
|
9
8
|
import parserHtml from 'prettier/parser-html';
|
|
9
|
+
import parserMarkdown from 'prettier/parser-markdown';
|
|
10
|
+
import { format } from 'prettier/standalone';
|
|
10
11
|
import { randomBytes } from 'crypto';
|
|
11
12
|
import { Subject } from 'rxjs';
|
|
12
13
|
import { forTime } from 'waitasecond';
|
|
@@ -29,7 +30,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
29
30
|
* @generated
|
|
30
31
|
* @see https://github.com/webgptorg/promptbook
|
|
31
32
|
*/
|
|
32
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.0
|
|
33
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.0';
|
|
33
34
|
/**
|
|
34
35
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
35
36
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -248,6 +249,19 @@ let DEFAULT_IS_VERBOSE = false;
|
|
|
248
249
|
* @public exported from `@promptbook/core`
|
|
249
250
|
*/
|
|
250
251
|
const DEFAULT_IS_AUTO_INSTALLED = false;
|
|
252
|
+
/**
|
|
253
|
+
* Default simulated duration for a task in milliseconds (used for progress reporting)
|
|
254
|
+
*
|
|
255
|
+
* @public exported from `@promptbook/core`
|
|
256
|
+
*/
|
|
257
|
+
const DEFAULT_TASK_SIMULATED_DURATION_MS = 5 * 60 * 1000; // 5 minutes
|
|
258
|
+
/**
|
|
259
|
+
* API request timeout in milliseconds
|
|
260
|
+
* Can be overridden via API_REQUEST_TIMEOUT environment variable
|
|
261
|
+
*
|
|
262
|
+
* @public exported from `@promptbook/core`
|
|
263
|
+
*/
|
|
264
|
+
parseInt(process.env.API_REQUEST_TIMEOUT || '90000');
|
|
251
265
|
/**
|
|
252
266
|
* Indicates whether pipeline logic validation is enabled. When true, the pipeline logic is checked for consistency.
|
|
253
267
|
*
|
|
@@ -1200,7 +1214,7 @@ function prettifyMarkdown(content) {
|
|
|
1200
1214
|
try {
|
|
1201
1215
|
return format(content, {
|
|
1202
1216
|
parser: 'markdown',
|
|
1203
|
-
plugins: [parserHtml],
|
|
1217
|
+
plugins: [parserMarkdown, parserHtml],
|
|
1204
1218
|
// TODO: DRY - make some import or auto-copy of .prettierrc
|
|
1205
1219
|
endOfLine: 'lf',
|
|
1206
1220
|
tabWidth: 4,
|
|
@@ -2652,6 +2666,7 @@ function createTask(options) {
|
|
|
2652
2666
|
const errors = [];
|
|
2653
2667
|
const warnings = [];
|
|
2654
2668
|
let currentValue = {};
|
|
2669
|
+
let customTldr = null;
|
|
2655
2670
|
const partialResultSubject = new Subject();
|
|
2656
2671
|
// <- Note: Not using `BehaviorSubject` because on error we can't access the last value
|
|
2657
2672
|
const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
|
|
@@ -2662,6 +2677,9 @@ function createTask(options) {
|
|
|
2662
2677
|
Object.assign(currentValue, newOngoingResult);
|
|
2663
2678
|
// <- TODO: assign deep
|
|
2664
2679
|
partialResultSubject.next(newOngoingResult);
|
|
2680
|
+
}, (tldrInfo) => {
|
|
2681
|
+
customTldr = tldrInfo;
|
|
2682
|
+
updatedAt = new Date();
|
|
2665
2683
|
});
|
|
2666
2684
|
finalResultPromise
|
|
2667
2685
|
.catch((error) => {
|
|
@@ -2715,6 +2733,78 @@ function createTask(options) {
|
|
|
2715
2733
|
return status;
|
|
2716
2734
|
// <- Note: [1] --||--
|
|
2717
2735
|
},
|
|
2736
|
+
get tldr() {
|
|
2737
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2738
|
+
// Use custom tldr if available
|
|
2739
|
+
if (customTldr) {
|
|
2740
|
+
return customTldr;
|
|
2741
|
+
}
|
|
2742
|
+
// Fallback to default implementation
|
|
2743
|
+
const cv = currentValue;
|
|
2744
|
+
// If explicit percent is provided, use it
|
|
2745
|
+
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;
|
|
2746
|
+
// Simulate progress if not provided
|
|
2747
|
+
if (typeof percentRaw !== 'number') {
|
|
2748
|
+
// Simulate progress: evenly split across subtasks, based on elapsed time
|
|
2749
|
+
const now = new Date();
|
|
2750
|
+
const elapsedMs = now.getTime() - createdAt.getTime();
|
|
2751
|
+
const totalMs = DEFAULT_TASK_SIMULATED_DURATION_MS;
|
|
2752
|
+
// If subtasks are defined, split progress evenly
|
|
2753
|
+
const subtaskCount = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) ? cv.subtasks.length : 1;
|
|
2754
|
+
const completedSubtasks = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks)
|
|
2755
|
+
? cv.subtasks.filter((s) => s.done || s.completed).length
|
|
2756
|
+
: 0;
|
|
2757
|
+
// Progress from completed subtasks
|
|
2758
|
+
const subtaskProgress = subtaskCount > 0 ? completedSubtasks / subtaskCount : 0;
|
|
2759
|
+
// Progress from elapsed time for current subtask
|
|
2760
|
+
const timeProgress = Math.min(elapsedMs / totalMs, 1);
|
|
2761
|
+
// Combine: completed subtasks + time progress for current subtask
|
|
2762
|
+
percentRaw = Math.min(subtaskProgress + (1 / subtaskCount) * timeProgress, 1);
|
|
2763
|
+
if (status === 'FINISHED')
|
|
2764
|
+
percentRaw = 1;
|
|
2765
|
+
if (status === 'ERROR')
|
|
2766
|
+
percentRaw = 0;
|
|
2767
|
+
}
|
|
2768
|
+
// Clamp to [0,1]
|
|
2769
|
+
let percent = Number(percentRaw) || 0;
|
|
2770
|
+
if (percent < 0)
|
|
2771
|
+
percent = 0;
|
|
2772
|
+
if (percent > 1)
|
|
2773
|
+
percent = 1;
|
|
2774
|
+
// Build a short message: prefer explicit tldr.message, then common summary/message fields, then errors/warnings, then status
|
|
2775
|
+
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;
|
|
2776
|
+
let message = messageFromResult;
|
|
2777
|
+
if (!message) {
|
|
2778
|
+
// If subtasks, show current subtask
|
|
2779
|
+
if (Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) && cv.subtasks.length > 0) {
|
|
2780
|
+
const current = cv.subtasks.find((s) => !s.done && !s.completed);
|
|
2781
|
+
if (current && current.title) {
|
|
2782
|
+
message = `Working on ${current.title}`;
|
|
2783
|
+
}
|
|
2784
|
+
}
|
|
2785
|
+
if (!message) {
|
|
2786
|
+
if (errors.length) {
|
|
2787
|
+
message = errors[errors.length - 1].message || 'Error';
|
|
2788
|
+
}
|
|
2789
|
+
else if (warnings.length) {
|
|
2790
|
+
message = warnings[warnings.length - 1].message || 'Warning';
|
|
2791
|
+
}
|
|
2792
|
+
else if (status === 'FINISHED') {
|
|
2793
|
+
message = 'Finished';
|
|
2794
|
+
}
|
|
2795
|
+
else if (status === 'ERROR') {
|
|
2796
|
+
message = 'Error';
|
|
2797
|
+
}
|
|
2798
|
+
else {
|
|
2799
|
+
message = 'Running';
|
|
2800
|
+
}
|
|
2801
|
+
}
|
|
2802
|
+
}
|
|
2803
|
+
return {
|
|
2804
|
+
percent: percent,
|
|
2805
|
+
message,
|
|
2806
|
+
};
|
|
2807
|
+
},
|
|
2718
2808
|
get createdAt() {
|
|
2719
2809
|
return createdAt;
|
|
2720
2810
|
// <- Note: [1] --||--
|
|
@@ -2963,6 +3053,76 @@ function countUsage(llmTools) {
|
|
|
2963
3053
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
2964
3054
|
*/
|
|
2965
3055
|
|
|
3056
|
+
/**
|
|
3057
|
+
* Predefined profiles for LLM providers to maintain consistency across the application
|
|
3058
|
+
* These profiles represent each provider as a virtual persona in chat interfaces
|
|
3059
|
+
*
|
|
3060
|
+
* @private !!!!
|
|
3061
|
+
*/
|
|
3062
|
+
const LLM_PROVIDER_PROFILES = {
|
|
3063
|
+
OPENAI: {
|
|
3064
|
+
name: 'OPENAI',
|
|
3065
|
+
fullname: 'OpenAI GPT',
|
|
3066
|
+
color: '#10a37f', // OpenAI's signature green
|
|
3067
|
+
// Note: avatarSrc could be added when we have provider logos available
|
|
3068
|
+
},
|
|
3069
|
+
ANTHROPIC: {
|
|
3070
|
+
name: 'ANTHROPIC',
|
|
3071
|
+
fullname: 'Anthropic Claude',
|
|
3072
|
+
color: '#d97706', // Anthropic's orange/amber color
|
|
3073
|
+
},
|
|
3074
|
+
AZURE_OPENAI: {
|
|
3075
|
+
name: 'AZURE_OPENAI',
|
|
3076
|
+
fullname: 'Azure OpenAI',
|
|
3077
|
+
color: '#0078d4', // Microsoft Azure blue
|
|
3078
|
+
},
|
|
3079
|
+
GOOGLE: {
|
|
3080
|
+
name: 'GOOGLE',
|
|
3081
|
+
fullname: 'Google Gemini',
|
|
3082
|
+
color: '#4285f4', // Google blue
|
|
3083
|
+
},
|
|
3084
|
+
DEEPSEEK: {
|
|
3085
|
+
name: 'DEEPSEEK',
|
|
3086
|
+
fullname: 'DeepSeek',
|
|
3087
|
+
color: '#7c3aed', // Purple color for DeepSeek
|
|
3088
|
+
},
|
|
3089
|
+
OLLAMA: {
|
|
3090
|
+
name: 'OLLAMA',
|
|
3091
|
+
fullname: 'Ollama',
|
|
3092
|
+
color: '#059669', // Emerald green for local models
|
|
3093
|
+
},
|
|
3094
|
+
REMOTE: {
|
|
3095
|
+
name: 'REMOTE',
|
|
3096
|
+
fullname: 'Remote Server',
|
|
3097
|
+
color: '#6b7280', // Gray for remote/proxy connections
|
|
3098
|
+
},
|
|
3099
|
+
MOCKED_ECHO: {
|
|
3100
|
+
name: 'MOCKED_ECHO',
|
|
3101
|
+
fullname: 'Echo (Test)',
|
|
3102
|
+
color: '#8b5cf6', // Purple for test/mock tools
|
|
3103
|
+
},
|
|
3104
|
+
MOCKED_FAKE: {
|
|
3105
|
+
name: 'MOCKED_FAKE',
|
|
3106
|
+
fullname: 'Fake LLM (Test)',
|
|
3107
|
+
color: '#ec4899', // Pink for fake/test tools
|
|
3108
|
+
},
|
|
3109
|
+
VERCEL: {
|
|
3110
|
+
name: 'VERCEL',
|
|
3111
|
+
fullname: 'Vercel AI',
|
|
3112
|
+
color: '#000000', // Vercel's black
|
|
3113
|
+
},
|
|
3114
|
+
MULTIPLE: {
|
|
3115
|
+
name: 'MULTIPLE',
|
|
3116
|
+
fullname: 'Multiple Providers',
|
|
3117
|
+
color: '#6366f1', // Indigo for combined/multiple providers
|
|
3118
|
+
},
|
|
3119
|
+
};
|
|
3120
|
+
/**
|
|
3121
|
+
* TODO: Refactor this - each profile must be alongside the provider definition
|
|
3122
|
+
* TODO: Unite `AvatarProfileProps` and `ChatParticipant`
|
|
3123
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
3124
|
+
*/
|
|
3125
|
+
|
|
2966
3126
|
/**
|
|
2967
3127
|
* Multiple LLM Execution Tools is a proxy server that uses multiple execution tools internally and exposes the executor interface externally.
|
|
2968
3128
|
*
|
|
@@ -2988,7 +3148,7 @@ class MultipleLlmExecutionTools {
|
|
|
2988
3148
|
}
|
|
2989
3149
|
return spaceTrim$1((block) => `
|
|
2990
3150
|
${headLine}
|
|
2991
|
-
|
|
3151
|
+
|
|
2992
3152
|
${ /* <- Note: Indenting the description: */block(description)}
|
|
2993
3153
|
`);
|
|
2994
3154
|
})
|
|
@@ -2999,6 +3159,9 @@ class MultipleLlmExecutionTools {
|
|
|
2999
3159
|
${block(innerModelsTitlesAndDescriptions)}
|
|
3000
3160
|
`);
|
|
3001
3161
|
}
|
|
3162
|
+
get profile() {
|
|
3163
|
+
return LLM_PROVIDER_PROFILES.MULTIPLE;
|
|
3164
|
+
}
|
|
3002
3165
|
/**
|
|
3003
3166
|
* Check the configuration of all execution tools
|
|
3004
3167
|
*/
|
|
@@ -3043,25 +3206,22 @@ class MultipleLlmExecutionTools {
|
|
|
3043
3206
|
const errors = [];
|
|
3044
3207
|
llm: for (const llmExecutionTools of this.llmExecutionTools) {
|
|
3045
3208
|
try {
|
|
3046
|
-
|
|
3209
|
+
switch (prompt.modelRequirements.modelVariant) {
|
|
3047
3210
|
case 'CHAT':
|
|
3048
3211
|
if (llmExecutionTools.callChatModel === undefined) {
|
|
3049
3212
|
continue llm;
|
|
3050
3213
|
}
|
|
3051
3214
|
return await llmExecutionTools.callChatModel(prompt);
|
|
3052
|
-
break variant;
|
|
3053
3215
|
case 'COMPLETION':
|
|
3054
3216
|
if (llmExecutionTools.callCompletionModel === undefined) {
|
|
3055
3217
|
continue llm;
|
|
3056
3218
|
}
|
|
3057
3219
|
return await llmExecutionTools.callCompletionModel(prompt);
|
|
3058
|
-
break variant;
|
|
3059
3220
|
case 'EMBEDDING':
|
|
3060
3221
|
if (llmExecutionTools.callEmbeddingModel === undefined) {
|
|
3061
3222
|
continue llm;
|
|
3062
3223
|
}
|
|
3063
3224
|
return await llmExecutionTools.callEmbeddingModel(prompt);
|
|
3064
|
-
break variant;
|
|
3065
3225
|
// <- case [🤖]:
|
|
3066
3226
|
default:
|
|
3067
3227
|
throw new UnexpectedError(`Unknown model variant "${prompt.modelRequirements.modelVariant}"`);
|
|
@@ -3214,7 +3374,7 @@ async function preparePersona(personaDescription, tools, options) {
|
|
|
3214
3374
|
const result = await preparePersonaExecutor({
|
|
3215
3375
|
availableModels /* <- Note: Passing as JSON */,
|
|
3216
3376
|
personaDescription,
|
|
3217
|
-
}).asPromise();
|
|
3377
|
+
}).asPromise({ isCrashedOnError: true });
|
|
3218
3378
|
const { outputParameters } = result;
|
|
3219
3379
|
const { modelsRequirements: modelsRequirementsJson } = outputParameters;
|
|
3220
3380
|
let modelsRequirementsUnchecked = jsonParse(modelsRequirementsJson);
|
|
@@ -3863,7 +4023,7 @@ async function preparePipeline(pipeline, tools, options) {
|
|
|
3863
4023
|
});
|
|
3864
4024
|
const result = await prepareTitleExecutor({
|
|
3865
4025
|
book: sources.map(({ content }) => content).join('\n\n'),
|
|
3866
|
-
}).asPromise();
|
|
4026
|
+
}).asPromise({ isCrashedOnError: true });
|
|
3867
4027
|
const { outputParameters } = result;
|
|
3868
4028
|
const { title: titleRaw } = outputParameters;
|
|
3869
4029
|
if (isVerbose) {
|
|
@@ -4957,7 +5117,7 @@ function validatePromptResult(options) {
|
|
|
4957
5117
|
*/
|
|
4958
5118
|
async function executeAttempts(options) {
|
|
4959
5119
|
const { jokerParameterNames, priority, maxAttempts, // <- Note: [💂]
|
|
4960
|
-
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, } = options;
|
|
5120
|
+
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, } = options;
|
|
4961
5121
|
const $ongoingTaskResult = {
|
|
4962
5122
|
$result: null,
|
|
4963
5123
|
$resultString: null,
|
|
@@ -5201,6 +5361,10 @@ async function executeAttempts(options) {
|
|
|
5201
5361
|
result: $ongoingTaskResult.$resultString,
|
|
5202
5362
|
error: error,
|
|
5203
5363
|
});
|
|
5364
|
+
// Report failed attempt
|
|
5365
|
+
onProgress({
|
|
5366
|
+
errors: [error],
|
|
5367
|
+
});
|
|
5204
5368
|
}
|
|
5205
5369
|
finally {
|
|
5206
5370
|
if (!isJokerAttempt &&
|
|
@@ -6074,15 +6238,74 @@ function createPipelineExecutor(options) {
|
|
|
6074
6238
|
});
|
|
6075
6239
|
});
|
|
6076
6240
|
};
|
|
6077
|
-
const pipelineExecutor = (inputParameters) =>
|
|
6078
|
-
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
|
|
6241
|
+
const pipelineExecutor = (inputParameters) => {
|
|
6242
|
+
const startTime = new Date().getTime();
|
|
6243
|
+
return createTask({
|
|
6244
|
+
taskType: 'EXECUTION',
|
|
6245
|
+
title: pipeline.title,
|
|
6246
|
+
taskProcessCallback(updateOngoingResult, updateTldr) {
|
|
6247
|
+
return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
|
|
6248
|
+
var _a, _b;
|
|
6249
|
+
updateOngoingResult(newOngoingResult);
|
|
6250
|
+
// Calculate and update tldr based on pipeline progress
|
|
6251
|
+
const cv = newOngoingResult;
|
|
6252
|
+
// Calculate progress based on parameters resolved vs total parameters
|
|
6253
|
+
const totalParameters = pipeline.parameters.filter(p => !p.isInput).length;
|
|
6254
|
+
let resolvedParameters = 0;
|
|
6255
|
+
let currentTaskTitle = '';
|
|
6256
|
+
// Get the resolved parameters from output parameters
|
|
6257
|
+
if (cv === null || cv === void 0 ? void 0 : cv.outputParameters) {
|
|
6258
|
+
// Count how many output parameters have non-empty values
|
|
6259
|
+
resolvedParameters = Object.values(cv.outputParameters).filter(value => value !== undefined && value !== null && String(value).trim() !== '').length;
|
|
6260
|
+
}
|
|
6261
|
+
// Try to determine current task from execution report
|
|
6262
|
+
if (((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) && cv.executionReport.promptExecutions.length > 0) {
|
|
6263
|
+
const lastExecution = cv.executionReport.promptExecutions[cv.executionReport.promptExecutions.length - 1];
|
|
6264
|
+
if ((_b = lastExecution === null || lastExecution === void 0 ? void 0 : lastExecution.prompt) === null || _b === void 0 ? void 0 : _b.title) {
|
|
6265
|
+
currentTaskTitle = lastExecution.prompt.title;
|
|
6266
|
+
}
|
|
6267
|
+
}
|
|
6268
|
+
// Calculate base progress percentage
|
|
6269
|
+
let percent = totalParameters > 0 ? resolvedParameters / totalParameters : 0;
|
|
6270
|
+
// Add time-based progress for current task if we haven't completed all parameters
|
|
6271
|
+
if (resolvedParameters < totalParameters) {
|
|
6272
|
+
const elapsedMs = new Date().getTime() - startTime;
|
|
6273
|
+
const estimatedTotalMs = totalParameters * 30 * 1000; // Estimate 30 seconds per parameter
|
|
6274
|
+
const timeProgress = Math.min(elapsedMs / estimatedTotalMs, 0.9); // Cap at 90% for time-based progress
|
|
6275
|
+
// If we have time progress but no parameter progress, show time progress
|
|
6276
|
+
if (percent === 0 && timeProgress > 0) {
|
|
6277
|
+
percent = Math.min(timeProgress, 0.1); // Show some progress but not more than 10%
|
|
6278
|
+
}
|
|
6279
|
+
else if (percent < 1) {
|
|
6280
|
+
// Add partial progress for current task
|
|
6281
|
+
const taskProgress = totalParameters > 0 ? (1 / totalParameters) * 0.5 : 0; // 50% of task progress
|
|
6282
|
+
percent = Math.min(percent + taskProgress, 0.95); // Cap at 95% until fully complete
|
|
6283
|
+
}
|
|
6284
|
+
}
|
|
6285
|
+
// Clamp to [0,1]
|
|
6286
|
+
percent = Math.min(Math.max(percent, 0), 1);
|
|
6287
|
+
// Generate message
|
|
6288
|
+
let message = '';
|
|
6289
|
+
if (currentTaskTitle) {
|
|
6290
|
+
message = `Executing: ${currentTaskTitle}`;
|
|
6291
|
+
}
|
|
6292
|
+
else if (resolvedParameters === 0) {
|
|
6293
|
+
message = 'Starting pipeline execution';
|
|
6294
|
+
}
|
|
6295
|
+
else if (resolvedParameters < totalParameters) {
|
|
6296
|
+
message = `Processing pipeline (${resolvedParameters}/${totalParameters} parameters resolved)`;
|
|
6297
|
+
}
|
|
6298
|
+
else {
|
|
6299
|
+
message = 'Completing pipeline execution';
|
|
6300
|
+
}
|
|
6301
|
+
updateTldr({
|
|
6302
|
+
percent: percent,
|
|
6303
|
+
message,
|
|
6304
|
+
});
|
|
6305
|
+
});
|
|
6306
|
+
},
|
|
6307
|
+
});
|
|
6308
|
+
};
|
|
6086
6309
|
// <- TODO: Make types such as there is no need to do `as` for `createTask`
|
|
6087
6310
|
return pipelineExecutor;
|
|
6088
6311
|
}
|
|
@@ -6167,7 +6390,9 @@ class MarkdownScraper {
|
|
|
6167
6390
|
},
|
|
6168
6391
|
});
|
|
6169
6392
|
const knowledgeContent = await source.asText();
|
|
6170
|
-
const result = await prepareKnowledgeFromMarkdownExecutor({ knowledgeContent }).asPromise(
|
|
6393
|
+
const result = await prepareKnowledgeFromMarkdownExecutor({ knowledgeContent }).asPromise({
|
|
6394
|
+
isCrashedOnError: true,
|
|
6395
|
+
});
|
|
6171
6396
|
const { outputParameters } = result;
|
|
6172
6397
|
const { knowledgePieces: knowledgePiecesRaw } = outputParameters;
|
|
6173
6398
|
const knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
|
|
@@ -6191,12 +6416,16 @@ class MarkdownScraper {
|
|
|
6191
6416
|
];
|
|
6192
6417
|
*/
|
|
6193
6418
|
try {
|
|
6194
|
-
const titleResult = await prepareTitleExecutor({ knowledgePieceContent }).asPromise(
|
|
6419
|
+
const titleResult = await prepareTitleExecutor({ knowledgePieceContent }).asPromise({
|
|
6420
|
+
isCrashedOnError: true,
|
|
6421
|
+
});
|
|
6195
6422
|
const { title: titleRaw = 'Untitled' } = titleResult.outputParameters;
|
|
6196
6423
|
title = spaceTrim$1(titleRaw) /* <- TODO: Maybe do in pipeline */;
|
|
6197
6424
|
name = titleToName(title);
|
|
6198
6425
|
// --- Keywords
|
|
6199
|
-
const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise(
|
|
6426
|
+
const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise({
|
|
6427
|
+
isCrashedOnError: true,
|
|
6428
|
+
});
|
|
6200
6429
|
const { keywords: keywordsRaw = '' } = keywordsResult.outputParameters;
|
|
6201
6430
|
keywords = (keywordsRaw || '')
|
|
6202
6431
|
.split(',')
|