@promptbook/pdf 0.103.0-42 → 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 +11 -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 +2 -2
- 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 -89
- 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
|
@@ -24,7 +24,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
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-43';
|
|
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
|
|
@@ -718,6 +718,23 @@ class Color {
|
|
|
718
718
|
* TODO: Maybe connect with textures
|
|
719
719
|
*/
|
|
720
720
|
|
|
721
|
+
/**
|
|
722
|
+
* Makes color transformer which returns a grayscale version of the color
|
|
723
|
+
*
|
|
724
|
+
* @param amount from 0 to 1
|
|
725
|
+
*
|
|
726
|
+
* @public exported from `@promptbook/color`
|
|
727
|
+
*/
|
|
728
|
+
function grayscale(amount) {
|
|
729
|
+
return ({ red, green, blue, alpha }) => {
|
|
730
|
+
const average = (red + green + blue) / 3;
|
|
731
|
+
red = Math.round(average * amount + red * (1 - amount));
|
|
732
|
+
green = Math.round(average * amount + green * (1 - amount));
|
|
733
|
+
blue = Math.round(average * amount + blue * (1 - amount));
|
|
734
|
+
return Color.fromValues(red, green, blue, alpha);
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
|
|
721
738
|
/**
|
|
722
739
|
* Converts HSL values to RGB values
|
|
723
740
|
*
|
|
@@ -833,102 +850,6 @@ function lighten(amount) {
|
|
|
833
850
|
* TODO: Maybe implement by mix+hsl
|
|
834
851
|
*/
|
|
835
852
|
|
|
836
|
-
/**
|
|
837
|
-
* Calculates distance between two colors
|
|
838
|
-
*
|
|
839
|
-
* @param color1 first color
|
|
840
|
-
* @param color2 second color
|
|
841
|
-
*
|
|
842
|
-
* Note: This function is inefficient. Use colorDistanceSquared instead if possible.
|
|
843
|
-
*
|
|
844
|
-
* @public exported from `@promptbook/color`
|
|
845
|
-
*/
|
|
846
|
-
/**
|
|
847
|
-
* Calculates distance between two colors without square root
|
|
848
|
-
*
|
|
849
|
-
* @param color1 first color
|
|
850
|
-
* @param color2 second color
|
|
851
|
-
*
|
|
852
|
-
* @public exported from `@promptbook/color`
|
|
853
|
-
*/
|
|
854
|
-
function colorDistanceSquared(color1, color2) {
|
|
855
|
-
const rmean = (color1.red + color2.red) / 2;
|
|
856
|
-
const r = color1.red - color2.red;
|
|
857
|
-
const g = color1.green - color2.green;
|
|
858
|
-
const b = color1.blue - color2.blue;
|
|
859
|
-
const weightR = 2 + rmean / 256;
|
|
860
|
-
const weightG = 4.0;
|
|
861
|
-
const weightB = 2 + (255 - rmean) / 256;
|
|
862
|
-
const distance = weightR * r * r + weightG * g * g + weightB * b * b;
|
|
863
|
-
return distance;
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
/**
|
|
867
|
-
* Makes color transformer which finds the nearest color from the given list
|
|
868
|
-
*
|
|
869
|
-
* @param colors array of colors to choose from
|
|
870
|
-
*
|
|
871
|
-
* @public exported from `@promptbook/color`
|
|
872
|
-
*/
|
|
873
|
-
function nearest(...colors) {
|
|
874
|
-
return (color) => {
|
|
875
|
-
const distances = colors.map((c) => colorDistanceSquared(c, color));
|
|
876
|
-
const minDistance = Math.min(...distances);
|
|
877
|
-
const minIndex = distances.indexOf(minDistance);
|
|
878
|
-
const nearestColor = colors[minIndex];
|
|
879
|
-
return nearestColor;
|
|
880
|
-
};
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
/**
|
|
884
|
-
* Color transformer which returns the negative color
|
|
885
|
-
*
|
|
886
|
-
* @public exported from `@promptbook/color`
|
|
887
|
-
*/
|
|
888
|
-
function negative(color) {
|
|
889
|
-
const r = 255 - color.red;
|
|
890
|
-
const g = 255 - color.green;
|
|
891
|
-
const b = 255 - color.blue;
|
|
892
|
-
return Color.fromValues(r, g, b, color.alpha);
|
|
893
|
-
}
|
|
894
|
-
|
|
895
|
-
/**
|
|
896
|
-
* Makes color transformer which finds the furthest color from the given list
|
|
897
|
-
*
|
|
898
|
-
* @param colors array of colors to choose from
|
|
899
|
-
*
|
|
900
|
-
* @public exported from `@promptbook/color`
|
|
901
|
-
*/
|
|
902
|
-
function furthest(...colors) {
|
|
903
|
-
return (color) => {
|
|
904
|
-
const furthestColor = negative(nearest(...colors.map(negative))(color));
|
|
905
|
-
return furthestColor;
|
|
906
|
-
};
|
|
907
|
-
}
|
|
908
|
-
/**
|
|
909
|
-
* Makes color transformer which finds the best text color (black or white) for the given background color
|
|
910
|
-
*
|
|
911
|
-
* @public exported from `@promptbook/color`
|
|
912
|
-
*/
|
|
913
|
-
furthest(Color.get('white'), Color.from('black'));
|
|
914
|
-
|
|
915
|
-
/**
|
|
916
|
-
* Makes color transformer which returns a grayscale version of the color
|
|
917
|
-
*
|
|
918
|
-
* @param amount from 0 to 1
|
|
919
|
-
*
|
|
920
|
-
* @public exported from `@promptbook/color`
|
|
921
|
-
*/
|
|
922
|
-
function grayscale(amount) {
|
|
923
|
-
return ({ red, green, blue, alpha }) => {
|
|
924
|
-
const average = (red + green + blue) / 3;
|
|
925
|
-
red = Math.round(average * amount + red * (1 - amount));
|
|
926
|
-
green = Math.round(average * amount + green * (1 - amount));
|
|
927
|
-
blue = Math.round(average * amount + blue * (1 - amount));
|
|
928
|
-
return Color.fromValues(red, green, blue, alpha);
|
|
929
|
-
};
|
|
930
|
-
}
|
|
931
|
-
|
|
932
853
|
/**
|
|
933
854
|
* Makes color transformer which saturate the given color
|
|
934
855
|
*
|
|
@@ -3039,6 +2960,7 @@ class MissingToolsError extends Error {
|
|
|
3039
2960
|
/**
|
|
3040
2961
|
* Generates random token
|
|
3041
2962
|
*
|
|
2963
|
+
* Note: `$` is used to indicate that this function is not a pure function - it is not deterministic
|
|
3042
2964
|
* Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
|
|
3043
2965
|
*
|
|
3044
2966
|
* @private internal helper function
|
|
@@ -3166,6 +3088,19 @@ class CollectionError extends Error {
|
|
|
3166
3088
|
}
|
|
3167
3089
|
}
|
|
3168
3090
|
|
|
3091
|
+
/**
|
|
3092
|
+
* This error indicates error from the database
|
|
3093
|
+
*
|
|
3094
|
+
* @public exported from `@promptbook/core`
|
|
3095
|
+
*/
|
|
3096
|
+
class DatabaseError extends Error {
|
|
3097
|
+
constructor(message) {
|
|
3098
|
+
super(message);
|
|
3099
|
+
this.name = 'DatabaseError';
|
|
3100
|
+
Object.setPrototypeOf(this, DatabaseError.prototype);
|
|
3101
|
+
}
|
|
3102
|
+
}
|
|
3103
|
+
|
|
3169
3104
|
/**
|
|
3170
3105
|
* This error occurs when some expectation is not met in the execution of the pipeline
|
|
3171
3106
|
*
|
|
@@ -3269,6 +3204,7 @@ const PROMPTBOOK_ERRORS = {
|
|
|
3269
3204
|
UnexpectedError,
|
|
3270
3205
|
WrappedError,
|
|
3271
3206
|
NotAllowed,
|
|
3207
|
+
DatabaseError,
|
|
3272
3208
|
// TODO: [🪑]> VersionMismatchError,
|
|
3273
3209
|
};
|
|
3274
3210
|
/**
|
|
@@ -5706,18 +5642,6 @@ function templateParameters(template, parameters) {
|
|
|
5706
5642
|
return replacedTemplates;
|
|
5707
5643
|
}
|
|
5708
5644
|
|
|
5709
|
-
/**
|
|
5710
|
-
* Logs an LLM call with the given report.
|
|
5711
|
-
*
|
|
5712
|
-
* @private internal utility of `createPipelineExecutor`
|
|
5713
|
-
*/
|
|
5714
|
-
function logLlmCall(logLlmCall, report) {
|
|
5715
|
-
logLlmCall({
|
|
5716
|
-
modelName: 'model' /* <- TODO: How to get model name from the report */,
|
|
5717
|
-
report,
|
|
5718
|
-
});
|
|
5719
|
-
}
|
|
5720
|
-
|
|
5721
5645
|
/**
|
|
5722
5646
|
* Extracts all code blocks from markdown.
|
|
5723
5647
|
*
|
|
@@ -6063,7 +5987,7 @@ function validatePromptResult(options) {
|
|
|
6063
5987
|
*/
|
|
6064
5988
|
async function executeAttempts(options) {
|
|
6065
5989
|
const { jokerParameterNames, priority, maxAttempts, // <- Note: [💂]
|
|
6066
|
-
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, logLlmCall
|
|
5990
|
+
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, logLlmCall, } = options;
|
|
6067
5991
|
const $ongoingTaskResult = {
|
|
6068
5992
|
$result: null,
|
|
6069
5993
|
$resultString: null,
|
|
@@ -6325,8 +6249,11 @@ async function executeAttempts(options) {
|
|
|
6325
6249
|
: serializeError($ongoingTaskResult.$expectError),
|
|
6326
6250
|
};
|
|
6327
6251
|
$executionReport.promptExecutions.push(executionPromptReport);
|
|
6328
|
-
if (logLlmCall
|
|
6329
|
-
logLlmCall(
|
|
6252
|
+
if (logLlmCall) {
|
|
6253
|
+
logLlmCall({
|
|
6254
|
+
modelName: 'model' /* <- TODO: How to get model name from the report */,
|
|
6255
|
+
report: executionPromptReport,
|
|
6256
|
+
});
|
|
6330
6257
|
}
|
|
6331
6258
|
}
|
|
6332
6259
|
}
|
|
@@ -6600,7 +6527,7 @@ async function getKnowledgeForTask(options) {
|
|
|
6600
6527
|
},
|
|
6601
6528
|
content: task.content,
|
|
6602
6529
|
parameters,
|
|
6603
|
-
};
|
|
6530
|
+
}; /* <- Note: [🤛] */
|
|
6604
6531
|
const taskEmbeddingResult = await llmTools.callEmbeddingModel(taskEmbeddingPrompt);
|
|
6605
6532
|
const knowledgePiecesWithRelevance = preparedPipeline.knowledgePieces.map((knowledgePiece) => {
|
|
6606
6533
|
const { index } = knowledgePiece;
|