@promptbook/markdown-utils 0.103.0-42 → 0.103.0-44
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 +6 -18
- package/esm/index.es.js +47 -114
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +6 -0
- package/esm/typings/src/_packages/node.index.d.ts +0 -2
- package/esm/typings/src/_packages/types.index.d.ts +22 -0
- package/esm/typings/src/_packages/utils.index.d.ts +2 -0
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +2 -4
- package/esm/typings/src/book-2.0/agent-source/padBook.d.ts +1 -1
- package/esm/typings/src/book-2.0/agent-source/string_book.d.ts +1 -0
- package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.d.ts +6 -1
- package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/save/_common/ChatSaveFormatDefinition.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/types/ChatParticipant.d.ts +1 -1
- package/esm/typings/src/book-components/Qr/BrandedQrCode.d.ts +1 -1
- package/esm/typings/src/book-components/Qr/useQrCode.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/_boilerplate.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/about.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/hello.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/list-models.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/list-scrapers.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/login.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/make.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/prettify.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/run.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/start-agents-server.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/start-pipelines-server.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/test-command.d.ts +1 -1
- package/esm/typings/src/cli/common/$addGlobalOptionsToCommand.d.ts +1 -1
- package/esm/typings/src/collection/agent-collection/AgentCollection.d.ts +2 -29
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +107 -0
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentsDatabaseSchema.d.ts +129 -0
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +1 -1
- package/esm/typings/src/config.d.ts +1 -1
- package/esm/typings/src/errors/0-index.d.ts +3 -0
- package/esm/typings/src/errors/DatabaseError.d.ts +12 -0
- package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +1 -1
- package/esm/typings/src/high-level-abstractions/_common/HighLevelAbstraction.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/$registeredLlmToolsMessage.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/LlmToolsMetadata.d.ts +1 -1
- package/esm/typings/src/llm-providers/_multiple/getSingleLlmExecutionTools.d.ts +1 -0
- package/esm/typings/src/llm-providers/_multiple/joinLlmExecutionTools.d.ts +1 -0
- package/esm/typings/src/llm-providers/agent/Agent.d.ts +5 -2
- package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/agent/AgentOptions.d.ts +4 -2
- package/esm/typings/src/llm-providers/agent/CreateAgentLlmExecutionToolsOptions.d.ts +4 -3
- package/esm/typings/src/llm-providers/agent/createAgentLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/google/google-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
- package/esm/typings/src/prepare/PrepareAndScrapeOptions.d.ts +1 -0
- package/esm/typings/src/remote-server/startAgentServer.d.ts +2 -2
- package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +0 -19
- package/esm/typings/src/storage/env-storage/$EnvStorage.d.ts +1 -1
- package/esm/typings/src/transpilers/_common/BookTranspiler.d.ts +5 -1
- package/esm/typings/src/transpilers/_common/BookTranspilerOptions.d.ts +1 -1
- package/esm/typings/src/transpilers/_common/register/$bookTranspilersRegister.d.ts +1 -1
- package/esm/typings/src/transpilers/formatted-book-in-markdown/FormattedBookInMarkdownTranspiler.d.ts +4 -1
- package/esm/typings/src/transpilers/formatted-book-in-markdown/register.d.ts +1 -1
- package/esm/typings/src/transpilers/openai-sdk/OpenAiSdkTranspiler.d.ts +4 -1
- package/esm/typings/src/transpilers/openai-sdk/register.d.ts +1 -1
- package/esm/typings/src/types/typeAliases.d.ts +19 -1
- package/esm/typings/src/utils/color/$randomColor.d.ts +1 -0
- package/esm/typings/src/utils/color/operators/darken.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/grayscale.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/lighten.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/mixWithColor.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/saturate.d.ts +1 -1
- package/esm/typings/src/utils/environment/$detectRuntimeEnvironment.d.ts +16 -0
- package/esm/typings/src/utils/execCommand/$execCommand.d.ts +1 -1
- package/esm/typings/src/utils/execCommand/$execCommands.d.ts +1 -1
- package/esm/typings/src/utils/files/$induceBookDownload.d.ts +2 -2
- package/esm/typings/src/utils/files/$induceFileDownload.d.ts +2 -2
- package/esm/typings/src/utils/files/ObjectUrl.d.ts +1 -1
- package/esm/typings/src/utils/misc/aboutPromptbookInformation.d.ts +6 -0
- package/esm/typings/src/utils/organization/$side_effect.d.ts +1 -1
- package/esm/typings/src/utils/random/$generateBookBoilerplate.d.ts +25 -0
- package/esm/typings/src/utils/random/$randomAgentPersona.d.ts +9 -0
- package/esm/typings/src/utils/random/$randomFullnameWithColor.d.ts +13 -0
- package/esm/typings/src/utils/random/$randomItem.d.ts +9 -0
- package/esm/typings/src/utils/random/$randomSeed.d.ts +3 -0
- package/esm/typings/src/utils/random/$randomToken.d.ts +2 -0
- package/esm/typings/src/utils/serialization/$deepFreeze.d.ts +1 -1
- package/esm/typings/src/utils/serialization/serializeToPromptbookJavascript.d.ts +2 -2
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +47 -114
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/collection/agent-collection/constructors/AgentCollectionInDirectory.d.ts +0 -89
- package/esm/typings/src/collection/agent-collection/constructors/AgentCollectionInDirectory.test.d.ts +0 -1
- package/esm/typings/src/commands/_common/parseCommand.test.d.ts +0 -1
- package/esm/typings/src/execution/utils/logLlmCall.d.ts +0 -8
package/umd/index.umd.js
CHANGED
|
@@ -17,14 +17,14 @@
|
|
|
17
17
|
* @generated
|
|
18
18
|
* @see https://github.com/webgptorg/book
|
|
19
19
|
*/
|
|
20
|
-
const BOOK_LANGUAGE_VERSION = '
|
|
20
|
+
const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
21
21
|
/**
|
|
22
22
|
* The version of the Promptbook engine
|
|
23
23
|
*
|
|
24
24
|
* @generated
|
|
25
25
|
* @see https://github.com/webgptorg/promptbook
|
|
26
26
|
*/
|
|
27
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-
|
|
27
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-44';
|
|
28
28
|
/**
|
|
29
29
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
30
30
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -831,6 +831,23 @@
|
|
|
831
831
|
* TODO: Maybe connect with textures
|
|
832
832
|
*/
|
|
833
833
|
|
|
834
|
+
/**
|
|
835
|
+
* Makes color transformer which returns a grayscale version of the color
|
|
836
|
+
*
|
|
837
|
+
* @param amount from 0 to 1
|
|
838
|
+
*
|
|
839
|
+
* @public exported from `@promptbook/color`
|
|
840
|
+
*/
|
|
841
|
+
function grayscale(amount) {
|
|
842
|
+
return ({ red, green, blue, alpha }) => {
|
|
843
|
+
const average = (red + green + blue) / 3;
|
|
844
|
+
red = Math.round(average * amount + red * (1 - amount));
|
|
845
|
+
green = Math.round(average * amount + green * (1 - amount));
|
|
846
|
+
blue = Math.round(average * amount + blue * (1 - amount));
|
|
847
|
+
return Color.fromValues(red, green, blue, alpha);
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
|
|
834
851
|
/**
|
|
835
852
|
* Converts HSL values to RGB values
|
|
836
853
|
*
|
|
@@ -946,102 +963,6 @@
|
|
|
946
963
|
* TODO: Maybe implement by mix+hsl
|
|
947
964
|
*/
|
|
948
965
|
|
|
949
|
-
/**
|
|
950
|
-
* Calculates distance between two colors
|
|
951
|
-
*
|
|
952
|
-
* @param color1 first color
|
|
953
|
-
* @param color2 second color
|
|
954
|
-
*
|
|
955
|
-
* Note: This function is inefficient. Use colorDistanceSquared instead if possible.
|
|
956
|
-
*
|
|
957
|
-
* @public exported from `@promptbook/color`
|
|
958
|
-
*/
|
|
959
|
-
/**
|
|
960
|
-
* Calculates distance between two colors without square root
|
|
961
|
-
*
|
|
962
|
-
* @param color1 first color
|
|
963
|
-
* @param color2 second color
|
|
964
|
-
*
|
|
965
|
-
* @public exported from `@promptbook/color`
|
|
966
|
-
*/
|
|
967
|
-
function colorDistanceSquared(color1, color2) {
|
|
968
|
-
const rmean = (color1.red + color2.red) / 2;
|
|
969
|
-
const r = color1.red - color2.red;
|
|
970
|
-
const g = color1.green - color2.green;
|
|
971
|
-
const b = color1.blue - color2.blue;
|
|
972
|
-
const weightR = 2 + rmean / 256;
|
|
973
|
-
const weightG = 4.0;
|
|
974
|
-
const weightB = 2 + (255 - rmean) / 256;
|
|
975
|
-
const distance = weightR * r * r + weightG * g * g + weightB * b * b;
|
|
976
|
-
return distance;
|
|
977
|
-
}
|
|
978
|
-
|
|
979
|
-
/**
|
|
980
|
-
* Makes color transformer which finds the nearest color from the given list
|
|
981
|
-
*
|
|
982
|
-
* @param colors array of colors to choose from
|
|
983
|
-
*
|
|
984
|
-
* @public exported from `@promptbook/color`
|
|
985
|
-
*/
|
|
986
|
-
function nearest(...colors) {
|
|
987
|
-
return (color) => {
|
|
988
|
-
const distances = colors.map((c) => colorDistanceSquared(c, color));
|
|
989
|
-
const minDistance = Math.min(...distances);
|
|
990
|
-
const minIndex = distances.indexOf(minDistance);
|
|
991
|
-
const nearestColor = colors[minIndex];
|
|
992
|
-
return nearestColor;
|
|
993
|
-
};
|
|
994
|
-
}
|
|
995
|
-
|
|
996
|
-
/**
|
|
997
|
-
* Color transformer which returns the negative color
|
|
998
|
-
*
|
|
999
|
-
* @public exported from `@promptbook/color`
|
|
1000
|
-
*/
|
|
1001
|
-
function negative(color) {
|
|
1002
|
-
const r = 255 - color.red;
|
|
1003
|
-
const g = 255 - color.green;
|
|
1004
|
-
const b = 255 - color.blue;
|
|
1005
|
-
return Color.fromValues(r, g, b, color.alpha);
|
|
1006
|
-
}
|
|
1007
|
-
|
|
1008
|
-
/**
|
|
1009
|
-
* Makes color transformer which finds the furthest color from the given list
|
|
1010
|
-
*
|
|
1011
|
-
* @param colors array of colors to choose from
|
|
1012
|
-
*
|
|
1013
|
-
* @public exported from `@promptbook/color`
|
|
1014
|
-
*/
|
|
1015
|
-
function furthest(...colors) {
|
|
1016
|
-
return (color) => {
|
|
1017
|
-
const furthestColor = negative(nearest(...colors.map(negative))(color));
|
|
1018
|
-
return furthestColor;
|
|
1019
|
-
};
|
|
1020
|
-
}
|
|
1021
|
-
/**
|
|
1022
|
-
* Makes color transformer which finds the best text color (black or white) for the given background color
|
|
1023
|
-
*
|
|
1024
|
-
* @public exported from `@promptbook/color`
|
|
1025
|
-
*/
|
|
1026
|
-
furthest(Color.get('white'), Color.from('black'));
|
|
1027
|
-
|
|
1028
|
-
/**
|
|
1029
|
-
* Makes color transformer which returns a grayscale version of the color
|
|
1030
|
-
*
|
|
1031
|
-
* @param amount from 0 to 1
|
|
1032
|
-
*
|
|
1033
|
-
* @public exported from `@promptbook/color`
|
|
1034
|
-
*/
|
|
1035
|
-
function grayscale(amount) {
|
|
1036
|
-
return ({ red, green, blue, alpha }) => {
|
|
1037
|
-
const average = (red + green + blue) / 3;
|
|
1038
|
-
red = Math.round(average * amount + red * (1 - amount));
|
|
1039
|
-
green = Math.round(average * amount + green * (1 - amount));
|
|
1040
|
-
blue = Math.round(average * amount + blue * (1 - amount));
|
|
1041
|
-
return Color.fromValues(red, green, blue, alpha);
|
|
1042
|
-
};
|
|
1043
|
-
}
|
|
1044
|
-
|
|
1045
966
|
/**
|
|
1046
967
|
* Makes color transformer which saturate the given color
|
|
1047
968
|
*
|
|
@@ -2679,6 +2600,7 @@
|
|
|
2679
2600
|
/**
|
|
2680
2601
|
* Generates random token
|
|
2681
2602
|
*
|
|
2603
|
+
* Note: `$` is used to indicate that this function is not a pure function - it is not deterministic
|
|
2682
2604
|
* Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
|
|
2683
2605
|
*
|
|
2684
2606
|
* @private internal helper function
|
|
@@ -2688,6 +2610,7 @@
|
|
|
2688
2610
|
return crypto.randomBytes(randomness).toString('hex');
|
|
2689
2611
|
}
|
|
2690
2612
|
/**
|
|
2613
|
+
* TODO: [🤶] Maybe export through `@promptbook/utils` or `@promptbook/random` package
|
|
2691
2614
|
* TODO: Maybe use nanoid instead https://github.com/ai/nanoid
|
|
2692
2615
|
*/
|
|
2693
2616
|
|
|
@@ -2806,6 +2729,22 @@
|
|
|
2806
2729
|
}
|
|
2807
2730
|
}
|
|
2808
2731
|
|
|
2732
|
+
/**
|
|
2733
|
+
* This error indicates error from the database
|
|
2734
|
+
*
|
|
2735
|
+
* @public exported from `@promptbook/core`
|
|
2736
|
+
*/
|
|
2737
|
+
class DatabaseError extends Error {
|
|
2738
|
+
constructor(message) {
|
|
2739
|
+
super(message);
|
|
2740
|
+
this.name = 'DatabaseError';
|
|
2741
|
+
Object.setPrototypeOf(this, DatabaseError.prototype);
|
|
2742
|
+
}
|
|
2743
|
+
}
|
|
2744
|
+
/**
|
|
2745
|
+
* TODO: !!!! Explain that NotFoundError (!!! and other specific errors) has priority over DatabaseError in some contexts
|
|
2746
|
+
*/
|
|
2747
|
+
|
|
2809
2748
|
/**
|
|
2810
2749
|
* This error type indicates that you try to use a feature that is not available in the current environment
|
|
2811
2750
|
*
|
|
@@ -2935,6 +2874,7 @@
|
|
|
2935
2874
|
UnexpectedError,
|
|
2936
2875
|
WrappedError,
|
|
2937
2876
|
NotAllowed,
|
|
2877
|
+
DatabaseError,
|
|
2938
2878
|
// TODO: [🪑]> VersionMismatchError,
|
|
2939
2879
|
};
|
|
2940
2880
|
/**
|
|
@@ -3771,6 +3711,7 @@
|
|
|
3771
3711
|
return new MultipleLlmExecutionTools(title || 'Multiple LLM Providers joined by `joinLlmExecutionTools`', ...llmExecutionTools);
|
|
3772
3712
|
}
|
|
3773
3713
|
/**
|
|
3714
|
+
* TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
3774
3715
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
3775
3716
|
*/
|
|
3776
3717
|
|
|
@@ -3787,6 +3728,7 @@
|
|
|
3787
3728
|
return llmTools;
|
|
3788
3729
|
}
|
|
3789
3730
|
/**
|
|
3731
|
+
* TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
3790
3732
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
3791
3733
|
*/
|
|
3792
3734
|
|
|
@@ -5763,18 +5705,6 @@
|
|
|
5763
5705
|
return replacedTemplates;
|
|
5764
5706
|
}
|
|
5765
5707
|
|
|
5766
|
-
/**
|
|
5767
|
-
* Logs an LLM call with the given report.
|
|
5768
|
-
*
|
|
5769
|
-
* @private internal utility of `createPipelineExecutor`
|
|
5770
|
-
*/
|
|
5771
|
-
function logLlmCall(logLlmCall, report) {
|
|
5772
|
-
logLlmCall({
|
|
5773
|
-
modelName: 'model' /* <- TODO: How to get model name from the report */,
|
|
5774
|
-
report,
|
|
5775
|
-
});
|
|
5776
|
-
}
|
|
5777
|
-
|
|
5778
5708
|
/**
|
|
5779
5709
|
* Counts number of characters in the text
|
|
5780
5710
|
*
|
|
@@ -6018,7 +5948,7 @@
|
|
|
6018
5948
|
*/
|
|
6019
5949
|
async function executeAttempts(options) {
|
|
6020
5950
|
const { jokerParameterNames, priority, maxAttempts, // <- Note: [💂]
|
|
6021
|
-
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, logLlmCall
|
|
5951
|
+
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, logLlmCall, } = options;
|
|
6022
5952
|
const $ongoingTaskResult = {
|
|
6023
5953
|
$result: null,
|
|
6024
5954
|
$resultString: null,
|
|
@@ -6280,8 +6210,11 @@
|
|
|
6280
6210
|
: serializeError($ongoingTaskResult.$expectError),
|
|
6281
6211
|
};
|
|
6282
6212
|
$executionReport.promptExecutions.push(executionPromptReport);
|
|
6283
|
-
if (logLlmCall
|
|
6284
|
-
logLlmCall(
|
|
6213
|
+
if (logLlmCall) {
|
|
6214
|
+
logLlmCall({
|
|
6215
|
+
modelName: 'model' /* <- TODO: How to get model name from the report */,
|
|
6216
|
+
report: executionPromptReport,
|
|
6217
|
+
});
|
|
6285
6218
|
}
|
|
6286
6219
|
}
|
|
6287
6220
|
}
|
|
@@ -6555,7 +6488,7 @@
|
|
|
6555
6488
|
},
|
|
6556
6489
|
content: task.content,
|
|
6557
6490
|
parameters,
|
|
6558
|
-
};
|
|
6491
|
+
}; /* <- Note: [🤛] */
|
|
6559
6492
|
const taskEmbeddingResult = await llmTools.callEmbeddingModel(taskEmbeddingPrompt);
|
|
6560
6493
|
const knowledgePiecesWithRelevance = preparedPipeline.knowledgePieces.map((knowledgePiece) => {
|
|
6561
6494
|
const { index } = knowledgePiece;
|