@promptbook/markdown-utils 0.103.0-41 → 0.103.0-43
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 +40 -113
- 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 +14 -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 +1 -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 +14 -12
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +55 -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 +9 -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/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 +2 -2
- package/esm/typings/src/llm-providers/agent/createAgentLlmExecutionTools.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/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 +22 -0
- package/esm/typings/src/utils/random/$randomToken.d.ts +1 -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 +40 -113
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/collection/agent-collection/constructors/AgentCollectionInDirectory.d.ts +0 -88
- package/esm/typings/src/collection/agent-collection/constructors/AgentCollectionInDirectory.test.d.ts +0 -1
- package/esm/typings/src/execution/utils/logLlmCall.d.ts +0 -8
package/esm/index.es.js
CHANGED
|
@@ -23,7 +23,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
23
23
|
* @generated
|
|
24
24
|
* @see https://github.com/webgptorg/promptbook
|
|
25
25
|
*/
|
|
26
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-
|
|
26
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-43';
|
|
27
27
|
/**
|
|
28
28
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
29
29
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -830,6 +830,23 @@ class Color {
|
|
|
830
830
|
* TODO: Maybe connect with textures
|
|
831
831
|
*/
|
|
832
832
|
|
|
833
|
+
/**
|
|
834
|
+
* Makes color transformer which returns a grayscale version of the color
|
|
835
|
+
*
|
|
836
|
+
* @param amount from 0 to 1
|
|
837
|
+
*
|
|
838
|
+
* @public exported from `@promptbook/color`
|
|
839
|
+
*/
|
|
840
|
+
function grayscale(amount) {
|
|
841
|
+
return ({ red, green, blue, alpha }) => {
|
|
842
|
+
const average = (red + green + blue) / 3;
|
|
843
|
+
red = Math.round(average * amount + red * (1 - amount));
|
|
844
|
+
green = Math.round(average * amount + green * (1 - amount));
|
|
845
|
+
blue = Math.round(average * amount + blue * (1 - amount));
|
|
846
|
+
return Color.fromValues(red, green, blue, alpha);
|
|
847
|
+
};
|
|
848
|
+
}
|
|
849
|
+
|
|
833
850
|
/**
|
|
834
851
|
* Converts HSL values to RGB values
|
|
835
852
|
*
|
|
@@ -945,102 +962,6 @@ function lighten(amount) {
|
|
|
945
962
|
* TODO: Maybe implement by mix+hsl
|
|
946
963
|
*/
|
|
947
964
|
|
|
948
|
-
/**
|
|
949
|
-
* Calculates distance between two colors
|
|
950
|
-
*
|
|
951
|
-
* @param color1 first color
|
|
952
|
-
* @param color2 second color
|
|
953
|
-
*
|
|
954
|
-
* Note: This function is inefficient. Use colorDistanceSquared instead if possible.
|
|
955
|
-
*
|
|
956
|
-
* @public exported from `@promptbook/color`
|
|
957
|
-
*/
|
|
958
|
-
/**
|
|
959
|
-
* Calculates distance between two colors without square root
|
|
960
|
-
*
|
|
961
|
-
* @param color1 first color
|
|
962
|
-
* @param color2 second color
|
|
963
|
-
*
|
|
964
|
-
* @public exported from `@promptbook/color`
|
|
965
|
-
*/
|
|
966
|
-
function colorDistanceSquared(color1, color2) {
|
|
967
|
-
const rmean = (color1.red + color2.red) / 2;
|
|
968
|
-
const r = color1.red - color2.red;
|
|
969
|
-
const g = color1.green - color2.green;
|
|
970
|
-
const b = color1.blue - color2.blue;
|
|
971
|
-
const weightR = 2 + rmean / 256;
|
|
972
|
-
const weightG = 4.0;
|
|
973
|
-
const weightB = 2 + (255 - rmean) / 256;
|
|
974
|
-
const distance = weightR * r * r + weightG * g * g + weightB * b * b;
|
|
975
|
-
return distance;
|
|
976
|
-
}
|
|
977
|
-
|
|
978
|
-
/**
|
|
979
|
-
* Makes color transformer which finds the nearest color from the given list
|
|
980
|
-
*
|
|
981
|
-
* @param colors array of colors to choose from
|
|
982
|
-
*
|
|
983
|
-
* @public exported from `@promptbook/color`
|
|
984
|
-
*/
|
|
985
|
-
function nearest(...colors) {
|
|
986
|
-
return (color) => {
|
|
987
|
-
const distances = colors.map((c) => colorDistanceSquared(c, color));
|
|
988
|
-
const minDistance = Math.min(...distances);
|
|
989
|
-
const minIndex = distances.indexOf(minDistance);
|
|
990
|
-
const nearestColor = colors[minIndex];
|
|
991
|
-
return nearestColor;
|
|
992
|
-
};
|
|
993
|
-
}
|
|
994
|
-
|
|
995
|
-
/**
|
|
996
|
-
* Color transformer which returns the negative color
|
|
997
|
-
*
|
|
998
|
-
* @public exported from `@promptbook/color`
|
|
999
|
-
*/
|
|
1000
|
-
function negative(color) {
|
|
1001
|
-
const r = 255 - color.red;
|
|
1002
|
-
const g = 255 - color.green;
|
|
1003
|
-
const b = 255 - color.blue;
|
|
1004
|
-
return Color.fromValues(r, g, b, color.alpha);
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
/**
|
|
1008
|
-
* Makes color transformer which finds the furthest color from the given list
|
|
1009
|
-
*
|
|
1010
|
-
* @param colors array of colors to choose from
|
|
1011
|
-
*
|
|
1012
|
-
* @public exported from `@promptbook/color`
|
|
1013
|
-
*/
|
|
1014
|
-
function furthest(...colors) {
|
|
1015
|
-
return (color) => {
|
|
1016
|
-
const furthestColor = negative(nearest(...colors.map(negative))(color));
|
|
1017
|
-
return furthestColor;
|
|
1018
|
-
};
|
|
1019
|
-
}
|
|
1020
|
-
/**
|
|
1021
|
-
* Makes color transformer which finds the best text color (black or white) for the given background color
|
|
1022
|
-
*
|
|
1023
|
-
* @public exported from `@promptbook/color`
|
|
1024
|
-
*/
|
|
1025
|
-
furthest(Color.get('white'), Color.from('black'));
|
|
1026
|
-
|
|
1027
|
-
/**
|
|
1028
|
-
* Makes color transformer which returns a grayscale version of the color
|
|
1029
|
-
*
|
|
1030
|
-
* @param amount from 0 to 1
|
|
1031
|
-
*
|
|
1032
|
-
* @public exported from `@promptbook/color`
|
|
1033
|
-
*/
|
|
1034
|
-
function grayscale(amount) {
|
|
1035
|
-
return ({ red, green, blue, alpha }) => {
|
|
1036
|
-
const average = (red + green + blue) / 3;
|
|
1037
|
-
red = Math.round(average * amount + red * (1 - amount));
|
|
1038
|
-
green = Math.round(average * amount + green * (1 - amount));
|
|
1039
|
-
blue = Math.round(average * amount + blue * (1 - amount));
|
|
1040
|
-
return Color.fromValues(red, green, blue, alpha);
|
|
1041
|
-
};
|
|
1042
|
-
}
|
|
1043
|
-
|
|
1044
965
|
/**
|
|
1045
966
|
* Makes color transformer which saturate the given color
|
|
1046
967
|
*
|
|
@@ -2678,6 +2599,7 @@ class MissingToolsError extends Error {
|
|
|
2678
2599
|
/**
|
|
2679
2600
|
* Generates random token
|
|
2680
2601
|
*
|
|
2602
|
+
* Note: `$` is used to indicate that this function is not a pure function - it is not deterministic
|
|
2681
2603
|
* Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
|
|
2682
2604
|
*
|
|
2683
2605
|
* @private internal helper function
|
|
@@ -2805,6 +2727,19 @@ class CollectionError extends Error {
|
|
|
2805
2727
|
}
|
|
2806
2728
|
}
|
|
2807
2729
|
|
|
2730
|
+
/**
|
|
2731
|
+
* This error indicates error from the database
|
|
2732
|
+
*
|
|
2733
|
+
* @public exported from `@promptbook/core`
|
|
2734
|
+
*/
|
|
2735
|
+
class DatabaseError extends Error {
|
|
2736
|
+
constructor(message) {
|
|
2737
|
+
super(message);
|
|
2738
|
+
this.name = 'DatabaseError';
|
|
2739
|
+
Object.setPrototypeOf(this, DatabaseError.prototype);
|
|
2740
|
+
}
|
|
2741
|
+
}
|
|
2742
|
+
|
|
2808
2743
|
/**
|
|
2809
2744
|
* This error type indicates that you try to use a feature that is not available in the current environment
|
|
2810
2745
|
*
|
|
@@ -2934,6 +2869,7 @@ const PROMPTBOOK_ERRORS = {
|
|
|
2934
2869
|
UnexpectedError,
|
|
2935
2870
|
WrappedError,
|
|
2936
2871
|
NotAllowed,
|
|
2872
|
+
DatabaseError,
|
|
2937
2873
|
// TODO: [🪑]> VersionMismatchError,
|
|
2938
2874
|
};
|
|
2939
2875
|
/**
|
|
@@ -5762,18 +5698,6 @@ function templateParameters(template, parameters) {
|
|
|
5762
5698
|
return replacedTemplates;
|
|
5763
5699
|
}
|
|
5764
5700
|
|
|
5765
|
-
/**
|
|
5766
|
-
* Logs an LLM call with the given report.
|
|
5767
|
-
*
|
|
5768
|
-
* @private internal utility of `createPipelineExecutor`
|
|
5769
|
-
*/
|
|
5770
|
-
function logLlmCall(logLlmCall, report) {
|
|
5771
|
-
logLlmCall({
|
|
5772
|
-
modelName: 'model' /* <- TODO: How to get model name from the report */,
|
|
5773
|
-
report,
|
|
5774
|
-
});
|
|
5775
|
-
}
|
|
5776
|
-
|
|
5777
5701
|
/**
|
|
5778
5702
|
* Counts number of characters in the text
|
|
5779
5703
|
*
|
|
@@ -6017,7 +5941,7 @@ function validatePromptResult(options) {
|
|
|
6017
5941
|
*/
|
|
6018
5942
|
async function executeAttempts(options) {
|
|
6019
5943
|
const { jokerParameterNames, priority, maxAttempts, // <- Note: [💂]
|
|
6020
|
-
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, logLlmCall
|
|
5944
|
+
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, logLlmCall, } = options;
|
|
6021
5945
|
const $ongoingTaskResult = {
|
|
6022
5946
|
$result: null,
|
|
6023
5947
|
$resultString: null,
|
|
@@ -6279,8 +6203,11 @@ async function executeAttempts(options) {
|
|
|
6279
6203
|
: serializeError($ongoingTaskResult.$expectError),
|
|
6280
6204
|
};
|
|
6281
6205
|
$executionReport.promptExecutions.push(executionPromptReport);
|
|
6282
|
-
if (logLlmCall
|
|
6283
|
-
logLlmCall(
|
|
6206
|
+
if (logLlmCall) {
|
|
6207
|
+
logLlmCall({
|
|
6208
|
+
modelName: 'model' /* <- TODO: How to get model name from the report */,
|
|
6209
|
+
report: executionPromptReport,
|
|
6210
|
+
});
|
|
6284
6211
|
}
|
|
6285
6212
|
}
|
|
6286
6213
|
}
|
|
@@ -6554,7 +6481,7 @@ async function getKnowledgeForTask(options) {
|
|
|
6554
6481
|
},
|
|
6555
6482
|
content: task.content,
|
|
6556
6483
|
parameters,
|
|
6557
|
-
};
|
|
6484
|
+
}; /* <- Note: [🤛] */
|
|
6558
6485
|
const taskEmbeddingResult = await llmTools.callEmbeddingModel(taskEmbeddingPrompt);
|
|
6559
6486
|
const knowledgePiecesWithRelevance = preparedPipeline.knowledgePieces.map((knowledgePiece) => {
|
|
6560
6487
|
const { index } = knowledgePiece;
|