@promptbook/node 0.104.0-9 → 0.105.0-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/esm/index.es.js +45 -28
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/components.index.d.ts +0 -6
- package/esm/typings/src/_packages/core.index.d.ts +10 -6
- package/esm/typings/src/_packages/types.index.d.ts +8 -0
- package/esm/typings/src/_packages/utils.index.d.ts +2 -0
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +24 -0
- package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +16 -2
- package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirements.tools.test.d.ts +1 -0
- package/esm/typings/src/book-2.0/utils/generatePlaceholderAgentProfileImageUrl.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/save/_common/string_chat_format_name.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/types/ChatMessage.d.ts +23 -3
- package/esm/typings/src/book-components/_common/Dropdown/Dropdown.d.ts +5 -1
- package/esm/typings/src/book-components/_common/HamburgerMenu/HamburgerMenu.d.ts +5 -1
- package/esm/typings/src/book-components/icons/AboutIcon.d.ts +5 -1
- package/esm/typings/src/book-components/icons/AttachmentIcon.d.ts +6 -2
- package/esm/typings/src/book-components/icons/CameraIcon.d.ts +6 -2
- package/esm/typings/src/book-components/icons/DownloadIcon.d.ts +5 -1
- package/esm/typings/src/book-components/icons/MenuIcon.d.ts +5 -1
- package/esm/typings/src/book-components/icons/SaveIcon.d.ts +6 -2
- package/esm/typings/src/collection/agent-collection/AgentCollection.d.ts +1 -1
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +9 -7
- package/esm/typings/src/commands/_common/types/Command.d.ts +1 -1
- package/esm/typings/src/commitments/IMPORT/IMPORT.d.ts +34 -0
- package/esm/typings/src/commitments/META/META_DESCRIPTION.d.ts +41 -0
- package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +2 -2
- package/esm/typings/src/commitments/_base/BookCommitment.d.ts +1 -1
- package/esm/typings/src/commitments/index.d.ts +2 -1
- package/esm/typings/src/config.d.ts +14 -1
- package/esm/typings/src/errors/utils/deserializeError.d.ts +1 -1
- package/esm/typings/src/execution/PromptResult.d.ts +24 -1
- package/esm/typings/src/formfactors/_common/FormfactorDefinition.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizardOrCli.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/utils/count-total-usage/LlmExecutionToolsWithTotalUsage.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/utils/count-total-usage/countUsage.d.ts +8 -4
- package/esm/typings/src/llm-providers/_common/utils/count-total-usage/limitTotalUsage.d.ts +1 -1
- package/esm/typings/src/llm-providers/_multiple/getSingleLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/_multiple/joinLlmExecutionTools.d.ts +12 -8
- package/esm/typings/src/llm-providers/agent/Agent.d.ts +7 -1
- package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionToolsOptions.d.ts +5 -0
- package/esm/typings/src/llm-providers/openai/utils/mapToolsToOpenAi.d.ts +8 -0
- package/esm/typings/src/remote-server/ui/ServerApp.d.ts +5 -1
- package/esm/typings/src/scrapers/_common/utils/promptbookFetch.test.d.ts +1 -0
- package/esm/typings/src/search-engines/SearchEngine.d.ts +9 -0
- package/esm/typings/src/search-engines/SearchResult.d.ts +18 -0
- package/esm/typings/src/search-engines/bing/BingSearchEngine.d.ts +15 -0
- package/esm/typings/src/search-engines/dummy/DummySearchEngine.d.ts +15 -0
- package/esm/typings/src/types/LlmToolDefinition.d.ts +27 -0
- package/esm/typings/src/types/ModelRequirements.d.ts +13 -0
- package/esm/typings/src/types/Prompt.d.ts +13 -0
- package/esm/typings/src/types/typeAliasEmoji.d.ts +2 -2
- package/esm/typings/src/utils/misc/parseNumber.d.ts +1 -1
- package/esm/typings/src/utils/random/$randomAgentPersona.d.ts +7 -2
- package/esm/typings/src/utils/random/$randomItem.d.ts +1 -1
- package/esm/typings/src/utils/random/$randomSeed.d.ts +1 -1
- package/esm/typings/src/utils/validators/url/isValidAgentUrl.d.ts +16 -0
- package/esm/typings/src/utils/validators/url/isValidAgentUrl.test.d.ts +1 -0
- package/esm/typings/src/utils/validators/url/isValidPipelineUrl.d.ts +2 -1
- package/esm/typings/src/utils/validators/url/isValidUrl.d.ts +4 -3
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +45 -28
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/servers.d.ts +0 -50
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
import type { string_persona_description } from '../../types/typeAliases';
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
+
* Generates a random agent persona description.
|
|
3
4
|
*
|
|
5
|
+
* This function selects a random personality profile from a predefined pool
|
|
6
|
+
* of common AI agent characteristics (e.g., friendly, professional, creative).
|
|
7
|
+
*
|
|
8
|
+
* @returns A string describing the agent's persona
|
|
4
9
|
* @private internal helper function
|
|
5
10
|
*/
|
|
6
|
-
export declare function $randomAgentPersona():
|
|
11
|
+
export declare function $randomAgentPersona(): string_persona_description;
|
|
7
12
|
/**
|
|
8
13
|
* TODO: [🤶] Maybe export through `@promptbook/utils` or `@promptbook/random` package
|
|
9
14
|
*/
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { string_agent_url } from '../../../types/typeAliases';
|
|
2
|
+
import type { really_unknown } from '../../organization/really_unknown';
|
|
3
|
+
/**
|
|
4
|
+
* Tests if given string is valid agent URL
|
|
5
|
+
*
|
|
6
|
+
* Note: There are few similar functions:
|
|
7
|
+
* - `isValidUrl` which tests any URL
|
|
8
|
+
* - `isValidAgentUrl` *(this one)* which tests just agent URL
|
|
9
|
+
* - `isValidPipelineUrl` which tests just pipeline URL
|
|
10
|
+
*
|
|
11
|
+
* @public exported from `@promptbook/utils`
|
|
12
|
+
*/
|
|
13
|
+
export declare function isValidAgentUrl(url: really_unknown): url is string_agent_url;
|
|
14
|
+
/**
|
|
15
|
+
* TODO: [🐠] Maybe more info why the URL is invalid
|
|
16
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,8 +3,9 @@ import type { really_unknown } from '../../organization/really_unknown';
|
|
|
3
3
|
/**
|
|
4
4
|
* Tests if given string is valid pipeline URL URL.
|
|
5
5
|
*
|
|
6
|
-
* Note: There are
|
|
6
|
+
* Note: There are few similar functions:
|
|
7
7
|
* - `isValidUrl` which tests any URL
|
|
8
|
+
* - `isValidAgentUrl` which tests just agent URL
|
|
8
9
|
* - `isValidPipelineUrl` *(this one)* which tests just pipeline URL
|
|
9
10
|
*
|
|
10
11
|
* @public exported from `@promptbook/utils`
|
|
@@ -5,9 +5,10 @@ import type { really_unknown } from '../../organization/really_unknown';
|
|
|
5
5
|
*
|
|
6
6
|
* Note: [🔂] This function is idempotent.
|
|
7
7
|
* Note: Dataurl are considered perfectly valid.
|
|
8
|
-
* Note: There are
|
|
9
|
-
* - `isValidUrl` which tests any URL
|
|
10
|
-
* - `
|
|
8
|
+
* Note: There are few similar functions:
|
|
9
|
+
* - `isValidUrl` *(this one)* which tests any URL
|
|
10
|
+
* - `isValidAgentUrl` which tests just agent URL
|
|
11
|
+
* - `isValidPipelineUrl` which tests just pipeline URL
|
|
11
12
|
*
|
|
12
13
|
* @public exported from `@promptbook/utils`
|
|
13
14
|
*/
|
|
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
|
|
|
15
15
|
export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
|
|
16
16
|
/**
|
|
17
17
|
* Represents the version string of the Promptbook engine.
|
|
18
|
-
* It follows semantic versioning (e.g., `0.104.0
|
|
18
|
+
* It follows semantic versioning (e.g., `0.104.0`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/node",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.105.0-0",
|
|
4
4
|
"description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"module": "./esm/index.es.js",
|
|
94
94
|
"typings": "./esm/typings/src/_packages/node.index.d.ts",
|
|
95
95
|
"peerDependencies": {
|
|
96
|
-
"@promptbook/core": "0.
|
|
96
|
+
"@promptbook/core": "0.105.0-0"
|
|
97
97
|
},
|
|
98
98
|
"dependencies": {
|
|
99
99
|
"colors": "1.4.0",
|
package/umd/index.umd.js
CHANGED
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
* @generated
|
|
46
46
|
* @see https://github.com/webgptorg/promptbook
|
|
47
47
|
*/
|
|
48
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.
|
|
48
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.105.0-0';
|
|
49
49
|
/**
|
|
50
50
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
51
51
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -1724,9 +1724,10 @@
|
|
|
1724
1724
|
*
|
|
1725
1725
|
* Note: [🔂] This function is idempotent.
|
|
1726
1726
|
* Note: Dataurl are considered perfectly valid.
|
|
1727
|
-
* Note: There are
|
|
1728
|
-
* - `isValidUrl` which tests any URL
|
|
1729
|
-
* - `
|
|
1727
|
+
* Note: There are few similar functions:
|
|
1728
|
+
* - `isValidUrl` *(this one)* which tests any URL
|
|
1729
|
+
* - `isValidAgentUrl` which tests just agent URL
|
|
1730
|
+
* - `isValidPipelineUrl` which tests just pipeline URL
|
|
1730
1731
|
*
|
|
1731
1732
|
* @public exported from `@promptbook/utils`
|
|
1732
1733
|
*/
|
|
@@ -1752,8 +1753,9 @@
|
|
|
1752
1753
|
/**
|
|
1753
1754
|
* Tests if given string is valid pipeline URL URL.
|
|
1754
1755
|
*
|
|
1755
|
-
* Note: There are
|
|
1756
|
+
* Note: There are few similar functions:
|
|
1756
1757
|
* - `isValidUrl` which tests any URL
|
|
1758
|
+
* - `isValidAgentUrl` which tests just agent URL
|
|
1757
1759
|
* - `isValidPipelineUrl` *(this one)* which tests just pipeline URL
|
|
1758
1760
|
*
|
|
1759
1761
|
* @public exported from `@promptbook/utils`
|
|
@@ -2986,7 +2988,7 @@
|
|
|
2986
2988
|
*
|
|
2987
2989
|
* @public exported from `@promptbook/utils`
|
|
2988
2990
|
*/
|
|
2989
|
-
function deserializeError(error) {
|
|
2991
|
+
function deserializeError(error, isStackAddedToMessage = true) {
|
|
2990
2992
|
const { name, stack, id } = error; // Added id
|
|
2991
2993
|
let { message } = error;
|
|
2992
2994
|
let ErrorClass = ALL_ERRORS[error.name];
|
|
@@ -2994,7 +2996,7 @@
|
|
|
2994
2996
|
ErrorClass = Error;
|
|
2995
2997
|
message = `${name}: ${message}`;
|
|
2996
2998
|
}
|
|
2997
|
-
if (stack !== undefined && stack !== '') {
|
|
2999
|
+
if (isStackAddedToMessage && stack !== undefined && stack !== '') {
|
|
2998
3000
|
message = spaceTrim__default["default"]((block) => `
|
|
2999
3001
|
${block(message)}
|
|
3000
3002
|
|
|
@@ -4145,17 +4147,21 @@
|
|
|
4145
4147
|
*/
|
|
4146
4148
|
|
|
4147
4149
|
/**
|
|
4148
|
-
* Joins multiple LLM Execution Tools into one
|
|
4150
|
+
* Joins multiple LLM Execution Tools into one.
|
|
4149
4151
|
*
|
|
4150
|
-
*
|
|
4152
|
+
* This function takes a list of `LlmExecutionTools` and returns a single unified
|
|
4153
|
+
* `MultipleLlmExecutionTools` object. It provides failover and aggregation logic:
|
|
4151
4154
|
*
|
|
4152
|
-
*
|
|
4153
|
-
*
|
|
4154
|
-
* 2
|
|
4155
|
-
* 3
|
|
4155
|
+
* 1. **Failover**: When a model call is made, it tries providers in the order they were provided.
|
|
4156
|
+
* If the first provider doesn't support the requested model or fails, it tries the next one.
|
|
4157
|
+
* 2. **Aggregation**: `listModels` returns a combined list of all models available from all providers.
|
|
4158
|
+
* 3. **Empty case**: If no tools are provided, it logs a warning (as Promptbook requires LLMs to function).
|
|
4156
4159
|
*
|
|
4160
|
+
* @param title - A descriptive title for this collection of joined tools
|
|
4161
|
+
* @param llmExecutionTools - An array of execution tools to be joined
|
|
4162
|
+
* @returns A single unified execution tool wrapper
|
|
4157
4163
|
*
|
|
4158
|
-
* Tip: You don't have to use this function directly, just pass an array of LlmExecutionTools to the `ExecutionTools
|
|
4164
|
+
* Tip: You don't have to use this function directly, just pass an array of LlmExecutionTools to the `ExecutionTools`.
|
|
4159
4165
|
*
|
|
4160
4166
|
* @public exported from `@promptbook/core`
|
|
4161
4167
|
*/
|
|
@@ -4195,7 +4201,7 @@
|
|
|
4195
4201
|
}
|
|
4196
4202
|
/**
|
|
4197
4203
|
* TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
4198
|
-
* TODO: [👷♂️]
|
|
4204
|
+
* TODO: [👷♂️] Write a comprehensive manual about how to construct and use LLM execution tools in Promptbook
|
|
4199
4205
|
*/
|
|
4200
4206
|
|
|
4201
4207
|
/**
|
|
@@ -4212,7 +4218,7 @@
|
|
|
4212
4218
|
}
|
|
4213
4219
|
/**
|
|
4214
4220
|
* TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
4215
|
-
* TODO: [👷♂️]
|
|
4221
|
+
* TODO: [👷♂️] Write a comprehensive manual about how to construct and use LLM execution tools in Promptbook
|
|
4216
4222
|
*/
|
|
4217
4223
|
|
|
4218
4224
|
/**
|
|
@@ -4766,8 +4772,8 @@
|
|
|
4766
4772
|
*/
|
|
4767
4773
|
function removeDiacritics(input) {
|
|
4768
4774
|
/*eslint no-control-regex: "off"*/
|
|
4769
|
-
return input.replace(/[^\u0000-\u007E]/g, (
|
|
4770
|
-
return DIACRITIC_VARIANTS_LETTERS[
|
|
4775
|
+
return input.replace(/[^\u0000-\u007E]/g, (character) => {
|
|
4776
|
+
return DIACRITIC_VARIANTS_LETTERS[character] || character;
|
|
4771
4777
|
});
|
|
4772
4778
|
}
|
|
4773
4779
|
/**
|
|
@@ -5458,7 +5464,7 @@
|
|
|
5458
5464
|
const taskEmbeddingResult = await llmTools.callEmbeddingModel(taskEmbeddingPrompt);
|
|
5459
5465
|
const knowledgePiecesWithRelevance = preparedPipeline.knowledgePieces.map((knowledgePiece) => {
|
|
5460
5466
|
const { index } = knowledgePiece;
|
|
5461
|
-
const knowledgePieceIndex = index.find((
|
|
5467
|
+
const knowledgePieceIndex = index.find((knowledgePieceIndex) => knowledgePieceIndex.modelName === firstKnowledgeIndex.modelName);
|
|
5462
5468
|
// <- TODO: Do not use just first knowledge piece and first index to determine embedding model
|
|
5463
5469
|
if (knowledgePieceIndex === undefined) {
|
|
5464
5470
|
return {
|
|
@@ -5906,7 +5912,7 @@
|
|
|
5906
5912
|
resovedParameterNames = [...resovedParameterNames, currentTask.resultingParameterName];
|
|
5907
5913
|
})
|
|
5908
5914
|
.then(() => {
|
|
5909
|
-
resolving = resolving.filter((
|
|
5915
|
+
resolving = resolving.filter((workItem) => workItem !== work);
|
|
5910
5916
|
});
|
|
5911
5917
|
// <- Note: Errors are catched here [3]
|
|
5912
5918
|
// TODO: BUT if in multiple tasks are errors, only the first one is catched so maybe we should catch errors here and save them to errors array here
|
|
@@ -6072,7 +6078,7 @@
|
|
|
6072
6078
|
// Calculate and update tldr based on pipeline progress
|
|
6073
6079
|
const cv = newOngoingResult;
|
|
6074
6080
|
// Calculate progress based on parameters resolved vs total parameters
|
|
6075
|
-
const totalParameters = pipeline.parameters.filter((
|
|
6081
|
+
const totalParameters = pipeline.parameters.filter((parameter) => !parameter.isInput).length;
|
|
6076
6082
|
let resolvedParameters = 0;
|
|
6077
6083
|
let currentTaskTitle = '';
|
|
6078
6084
|
// Get the resolved parameters from output parameters
|
|
@@ -6152,7 +6158,7 @@
|
|
|
6152
6158
|
tasks.push(task);
|
|
6153
6159
|
runningTasks.push(task);
|
|
6154
6160
|
/* not await */ Promise.resolve(task).then(() => {
|
|
6155
|
-
runningTasks = runningTasks.filter((
|
|
6161
|
+
runningTasks = runningTasks.filter((runningTask) => runningTask !== task);
|
|
6156
6162
|
});
|
|
6157
6163
|
if (maxParallelCount < runningTasks.length) {
|
|
6158
6164
|
await Promise.race(runningTasks);
|
|
@@ -6162,10 +6168,14 @@
|
|
|
6162
6168
|
}
|
|
6163
6169
|
|
|
6164
6170
|
/**
|
|
6165
|
-
* Intercepts LLM tools and counts total usage of the tools
|
|
6171
|
+
* Intercepts LLM tools and counts total usage of the tools.
|
|
6172
|
+
*
|
|
6173
|
+
* This function wraps the provided `LlmExecutionTools` with a proxy that tracks the cumulative
|
|
6174
|
+
* usage (tokens, cost, etc.) across all model calls. It provides a way to monitor spending
|
|
6175
|
+
* in real-time through an observable.
|
|
6166
6176
|
*
|
|
6167
|
-
* @param llmTools LLM tools to be intercepted
|
|
6168
|
-
* @returns
|
|
6177
|
+
* @param llmTools - The LLM tools to be intercepted and tracked
|
|
6178
|
+
* @returns An augmented version of the tools that includes usage tracking capabilities
|
|
6169
6179
|
* @public exported from `@promptbook/core`
|
|
6170
6180
|
*/
|
|
6171
6181
|
function countUsage(llmTools) {
|
|
@@ -6240,7 +6250,7 @@
|
|
|
6240
6250
|
* TODO: [🧠] Is there some meaningfull way how to test this util
|
|
6241
6251
|
* TODO: [🧠][🌯] Maybe a way how to hide ability to `get totalUsage`
|
|
6242
6252
|
* > const [llmToolsWithUsage,getUsage] = countTotalUsage(llmTools);
|
|
6243
|
-
* TODO: [👷♂️]
|
|
6253
|
+
* TODO: [👷♂️] Write a comprehensive manual explaining the construction and usage of LLM tools in the Promptbook ecosystem
|
|
6244
6254
|
*/
|
|
6245
6255
|
|
|
6246
6256
|
/**
|
|
@@ -6777,7 +6787,6 @@
|
|
|
6777
6787
|
* @public exported from `@promptbook/core`
|
|
6778
6788
|
*/
|
|
6779
6789
|
async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
6780
|
-
// console.log('!! makeKnowledgeSourceHandler', knowledgeSource);
|
|
6781
6790
|
var _a;
|
|
6782
6791
|
const { fetch = promptbookFetch } = tools;
|
|
6783
6792
|
const { knowledgeSourceContent } = knowledgeSource;
|
|
@@ -7798,6 +7807,9 @@
|
|
|
7798
7807
|
* @public exported from `@promptbook/utils`
|
|
7799
7808
|
*/
|
|
7800
7809
|
function parseNumber(value) {
|
|
7810
|
+
if (value === null || value === undefined) {
|
|
7811
|
+
return 0;
|
|
7812
|
+
}
|
|
7801
7813
|
const originalValue = value;
|
|
7802
7814
|
if (typeof value === 'number') {
|
|
7803
7815
|
value = value.toString(); // <- TODO: Maybe more efficient way to do this
|
|
@@ -8832,7 +8844,12 @@
|
|
|
8832
8844
|
* @see {@link ModelVariant}
|
|
8833
8845
|
* @public exported from `@promptbook/core`
|
|
8834
8846
|
*/
|
|
8835
|
-
const MODEL_VARIANTS = [
|
|
8847
|
+
const MODEL_VARIANTS = [
|
|
8848
|
+
'COMPLETION',
|
|
8849
|
+
'CHAT',
|
|
8850
|
+
'IMAGE_GENERATION',
|
|
8851
|
+
'EMBEDDING' /* <- TODO [🏳] */ /* <- [🤖] */,
|
|
8852
|
+
];
|
|
8836
8853
|
|
|
8837
8854
|
/**
|
|
8838
8855
|
* Parses the model command
|