@promptbook/documents 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 +2 -2
- 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
|
@@ -18,14 +18,14 @@
|
|
|
18
18
|
* @generated
|
|
19
19
|
* @see https://github.com/webgptorg/book
|
|
20
20
|
*/
|
|
21
|
-
const BOOK_LANGUAGE_VERSION = '
|
|
21
|
+
const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
22
22
|
/**
|
|
23
23
|
* The version of the Promptbook engine
|
|
24
24
|
*
|
|
25
25
|
* @generated
|
|
26
26
|
* @see https://github.com/webgptorg/promptbook
|
|
27
27
|
*/
|
|
28
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-
|
|
28
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-44';
|
|
29
29
|
/**
|
|
30
30
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
31
31
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -706,6 +706,23 @@
|
|
|
706
706
|
* TODO: Maybe connect with textures
|
|
707
707
|
*/
|
|
708
708
|
|
|
709
|
+
/**
|
|
710
|
+
* Makes color transformer which returns a grayscale version of the color
|
|
711
|
+
*
|
|
712
|
+
* @param amount from 0 to 1
|
|
713
|
+
*
|
|
714
|
+
* @public exported from `@promptbook/color`
|
|
715
|
+
*/
|
|
716
|
+
function grayscale(amount) {
|
|
717
|
+
return ({ red, green, blue, alpha }) => {
|
|
718
|
+
const average = (red + green + blue) / 3;
|
|
719
|
+
red = Math.round(average * amount + red * (1 - amount));
|
|
720
|
+
green = Math.round(average * amount + green * (1 - amount));
|
|
721
|
+
blue = Math.round(average * amount + blue * (1 - amount));
|
|
722
|
+
return Color.fromValues(red, green, blue, alpha);
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
|
|
709
726
|
/**
|
|
710
727
|
* Converts HSL values to RGB values
|
|
711
728
|
*
|
|
@@ -821,102 +838,6 @@
|
|
|
821
838
|
* TODO: Maybe implement by mix+hsl
|
|
822
839
|
*/
|
|
823
840
|
|
|
824
|
-
/**
|
|
825
|
-
* Calculates distance between two colors
|
|
826
|
-
*
|
|
827
|
-
* @param color1 first color
|
|
828
|
-
* @param color2 second color
|
|
829
|
-
*
|
|
830
|
-
* Note: This function is inefficient. Use colorDistanceSquared instead if possible.
|
|
831
|
-
*
|
|
832
|
-
* @public exported from `@promptbook/color`
|
|
833
|
-
*/
|
|
834
|
-
/**
|
|
835
|
-
* Calculates distance between two colors without square root
|
|
836
|
-
*
|
|
837
|
-
* @param color1 first color
|
|
838
|
-
* @param color2 second color
|
|
839
|
-
*
|
|
840
|
-
* @public exported from `@promptbook/color`
|
|
841
|
-
*/
|
|
842
|
-
function colorDistanceSquared(color1, color2) {
|
|
843
|
-
const rmean = (color1.red + color2.red) / 2;
|
|
844
|
-
const r = color1.red - color2.red;
|
|
845
|
-
const g = color1.green - color2.green;
|
|
846
|
-
const b = color1.blue - color2.blue;
|
|
847
|
-
const weightR = 2 + rmean / 256;
|
|
848
|
-
const weightG = 4.0;
|
|
849
|
-
const weightB = 2 + (255 - rmean) / 256;
|
|
850
|
-
const distance = weightR * r * r + weightG * g * g + weightB * b * b;
|
|
851
|
-
return distance;
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
/**
|
|
855
|
-
* Makes color transformer which finds the nearest color from the given list
|
|
856
|
-
*
|
|
857
|
-
* @param colors array of colors to choose from
|
|
858
|
-
*
|
|
859
|
-
* @public exported from `@promptbook/color`
|
|
860
|
-
*/
|
|
861
|
-
function nearest(...colors) {
|
|
862
|
-
return (color) => {
|
|
863
|
-
const distances = colors.map((c) => colorDistanceSquared(c, color));
|
|
864
|
-
const minDistance = Math.min(...distances);
|
|
865
|
-
const minIndex = distances.indexOf(minDistance);
|
|
866
|
-
const nearestColor = colors[minIndex];
|
|
867
|
-
return nearestColor;
|
|
868
|
-
};
|
|
869
|
-
}
|
|
870
|
-
|
|
871
|
-
/**
|
|
872
|
-
* Color transformer which returns the negative color
|
|
873
|
-
*
|
|
874
|
-
* @public exported from `@promptbook/color`
|
|
875
|
-
*/
|
|
876
|
-
function negative(color) {
|
|
877
|
-
const r = 255 - color.red;
|
|
878
|
-
const g = 255 - color.green;
|
|
879
|
-
const b = 255 - color.blue;
|
|
880
|
-
return Color.fromValues(r, g, b, color.alpha);
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
/**
|
|
884
|
-
* Makes color transformer which finds the furthest color from the given list
|
|
885
|
-
*
|
|
886
|
-
* @param colors array of colors to choose from
|
|
887
|
-
*
|
|
888
|
-
* @public exported from `@promptbook/color`
|
|
889
|
-
*/
|
|
890
|
-
function furthest(...colors) {
|
|
891
|
-
return (color) => {
|
|
892
|
-
const furthestColor = negative(nearest(...colors.map(negative))(color));
|
|
893
|
-
return furthestColor;
|
|
894
|
-
};
|
|
895
|
-
}
|
|
896
|
-
/**
|
|
897
|
-
* Makes color transformer which finds the best text color (black or white) for the given background color
|
|
898
|
-
*
|
|
899
|
-
* @public exported from `@promptbook/color`
|
|
900
|
-
*/
|
|
901
|
-
furthest(Color.get('white'), Color.from('black'));
|
|
902
|
-
|
|
903
|
-
/**
|
|
904
|
-
* Makes color transformer which returns a grayscale version of the color
|
|
905
|
-
*
|
|
906
|
-
* @param amount from 0 to 1
|
|
907
|
-
*
|
|
908
|
-
* @public exported from `@promptbook/color`
|
|
909
|
-
*/
|
|
910
|
-
function grayscale(amount) {
|
|
911
|
-
return ({ red, green, blue, alpha }) => {
|
|
912
|
-
const average = (red + green + blue) / 3;
|
|
913
|
-
red = Math.round(average * amount + red * (1 - amount));
|
|
914
|
-
green = Math.round(average * amount + green * (1 - amount));
|
|
915
|
-
blue = Math.round(average * amount + blue * (1 - amount));
|
|
916
|
-
return Color.fromValues(red, green, blue, alpha);
|
|
917
|
-
};
|
|
918
|
-
}
|
|
919
|
-
|
|
920
841
|
/**
|
|
921
842
|
* Makes color transformer which saturate the given color
|
|
922
843
|
*
|
|
@@ -3199,6 +3120,7 @@
|
|
|
3199
3120
|
/**
|
|
3200
3121
|
* Generates random token
|
|
3201
3122
|
*
|
|
3123
|
+
* Note: `$` is used to indicate that this function is not a pure function - it is not deterministic
|
|
3202
3124
|
* Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
|
|
3203
3125
|
*
|
|
3204
3126
|
* @private internal helper function
|
|
@@ -3208,6 +3130,7 @@
|
|
|
3208
3130
|
return crypto.randomBytes(randomness).toString('hex');
|
|
3209
3131
|
}
|
|
3210
3132
|
/**
|
|
3133
|
+
* TODO: [🤶] Maybe export through `@promptbook/utils` or `@promptbook/random` package
|
|
3211
3134
|
* TODO: Maybe use nanoid instead https://github.com/ai/nanoid
|
|
3212
3135
|
*/
|
|
3213
3136
|
|
|
@@ -3326,6 +3249,22 @@
|
|
|
3326
3249
|
}
|
|
3327
3250
|
}
|
|
3328
3251
|
|
|
3252
|
+
/**
|
|
3253
|
+
* This error indicates error from the database
|
|
3254
|
+
*
|
|
3255
|
+
* @public exported from `@promptbook/core`
|
|
3256
|
+
*/
|
|
3257
|
+
class DatabaseError extends Error {
|
|
3258
|
+
constructor(message) {
|
|
3259
|
+
super(message);
|
|
3260
|
+
this.name = 'DatabaseError';
|
|
3261
|
+
Object.setPrototypeOf(this, DatabaseError.prototype);
|
|
3262
|
+
}
|
|
3263
|
+
}
|
|
3264
|
+
/**
|
|
3265
|
+
* TODO: !!!! Explain that NotFoundError (!!! and other specific errors) has priority over DatabaseError in some contexts
|
|
3266
|
+
*/
|
|
3267
|
+
|
|
3329
3268
|
/**
|
|
3330
3269
|
* This error occurs when some expectation is not met in the execution of the pipeline
|
|
3331
3270
|
*
|
|
@@ -3429,6 +3368,7 @@
|
|
|
3429
3368
|
UnexpectedError,
|
|
3430
3369
|
WrappedError,
|
|
3431
3370
|
NotAllowed,
|
|
3371
|
+
DatabaseError,
|
|
3432
3372
|
// TODO: [🪑]> VersionMismatchError,
|
|
3433
3373
|
};
|
|
3434
3374
|
/**
|
|
@@ -4265,6 +4205,7 @@
|
|
|
4265
4205
|
return new MultipleLlmExecutionTools(title || 'Multiple LLM Providers joined by `joinLlmExecutionTools`', ...llmExecutionTools);
|
|
4266
4206
|
}
|
|
4267
4207
|
/**
|
|
4208
|
+
* TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
4268
4209
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
4269
4210
|
*/
|
|
4270
4211
|
|
|
@@ -4281,6 +4222,7 @@
|
|
|
4281
4222
|
return llmTools;
|
|
4282
4223
|
}
|
|
4283
4224
|
/**
|
|
4225
|
+
* TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
4284
4226
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
4285
4227
|
*/
|
|
4286
4228
|
|
|
@@ -5856,18 +5798,6 @@
|
|
|
5856
5798
|
return replacedTemplates;
|
|
5857
5799
|
}
|
|
5858
5800
|
|
|
5859
|
-
/**
|
|
5860
|
-
* Logs an LLM call with the given report.
|
|
5861
|
-
*
|
|
5862
|
-
* @private internal utility of `createPipelineExecutor`
|
|
5863
|
-
*/
|
|
5864
|
-
function logLlmCall(logLlmCall, report) {
|
|
5865
|
-
logLlmCall({
|
|
5866
|
-
modelName: 'model' /* <- TODO: How to get model name from the report */,
|
|
5867
|
-
report,
|
|
5868
|
-
});
|
|
5869
|
-
}
|
|
5870
|
-
|
|
5871
5801
|
/**
|
|
5872
5802
|
* Extracts all code blocks from markdown.
|
|
5873
5803
|
*
|
|
@@ -6213,7 +6143,7 @@
|
|
|
6213
6143
|
*/
|
|
6214
6144
|
async function executeAttempts(options) {
|
|
6215
6145
|
const { jokerParameterNames, priority, maxAttempts, // <- Note: [💂]
|
|
6216
|
-
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, logLlmCall
|
|
6146
|
+
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, logLlmCall, } = options;
|
|
6217
6147
|
const $ongoingTaskResult = {
|
|
6218
6148
|
$result: null,
|
|
6219
6149
|
$resultString: null,
|
|
@@ -6475,8 +6405,11 @@
|
|
|
6475
6405
|
: serializeError($ongoingTaskResult.$expectError),
|
|
6476
6406
|
};
|
|
6477
6407
|
$executionReport.promptExecutions.push(executionPromptReport);
|
|
6478
|
-
if (logLlmCall
|
|
6479
|
-
logLlmCall(
|
|
6408
|
+
if (logLlmCall) {
|
|
6409
|
+
logLlmCall({
|
|
6410
|
+
modelName: 'model' /* <- TODO: How to get model name from the report */,
|
|
6411
|
+
report: executionPromptReport,
|
|
6412
|
+
});
|
|
6480
6413
|
}
|
|
6481
6414
|
}
|
|
6482
6415
|
}
|
|
@@ -6750,7 +6683,7 @@
|
|
|
6750
6683
|
},
|
|
6751
6684
|
content: task.content,
|
|
6752
6685
|
parameters,
|
|
6753
|
-
};
|
|
6686
|
+
}; /* <- Note: [🤛] */
|
|
6754
6687
|
const taskEmbeddingResult = await llmTools.callEmbeddingModel(taskEmbeddingPrompt);
|
|
6755
6688
|
const knowledgePiecesWithRelevance = preparedPipeline.knowledgePieces.map((knowledgePiece) => {
|
|
6756
6689
|
const { index } = knowledgePiece;
|