@promptbook/core 0.104.0-12 → 0.104.0-14

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.
Files changed (28) hide show
  1. package/esm/index.es.js +53 -36
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/components.index.d.ts +0 -6
  4. package/esm/typings/src/book-components/Chat/save/_common/string_chat_format_name.d.ts +1 -1
  5. package/esm/typings/src/book-components/Chat/types/ChatMessage.d.ts +4 -1
  6. package/esm/typings/src/book-components/_common/Dropdown/Dropdown.d.ts +5 -1
  7. package/esm/typings/src/book-components/_common/HamburgerMenu/HamburgerMenu.d.ts +4 -0
  8. package/esm/typings/src/book-components/icons/AboutIcon.d.ts +5 -1
  9. package/esm/typings/src/book-components/icons/AttachmentIcon.d.ts +6 -2
  10. package/esm/typings/src/book-components/icons/CameraIcon.d.ts +6 -2
  11. package/esm/typings/src/book-components/icons/DownloadIcon.d.ts +5 -1
  12. package/esm/typings/src/book-components/icons/MenuIcon.d.ts +5 -1
  13. package/esm/typings/src/book-components/icons/SaveIcon.d.ts +6 -2
  14. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +7 -5
  15. package/esm/typings/src/commands/_common/types/Command.d.ts +1 -1
  16. package/esm/typings/src/commitments/_base/BookCommitment.d.ts +1 -1
  17. package/esm/typings/src/formfactors/_common/FormfactorDefinition.d.ts +1 -1
  18. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/countUsage.d.ts +7 -3
  19. package/esm/typings/src/llm-providers/_multiple/joinLlmExecutionTools.d.ts +11 -7
  20. package/esm/typings/src/remote-server/ui/ServerApp.d.ts +5 -1
  21. package/esm/typings/src/types/typeAliasEmoji.d.ts +2 -2
  22. package/esm/typings/src/utils/random/$randomAgentPersona.d.ts +4 -0
  23. package/esm/typings/src/utils/random/$randomItem.d.ts +1 -1
  24. package/esm/typings/src/utils/random/$randomSeed.d.ts +1 -1
  25. package/esm/typings/src/version.d.ts +1 -1
  26. package/package.json +1 -1
  27. package/umd/index.umd.js +53 -36
  28. package/umd/index.umd.js.map +1 -1
package/umd/index.umd.js CHANGED
@@ -28,7 +28,7 @@
28
28
  * @generated
29
29
  * @see https://github.com/webgptorg/promptbook
30
30
  */
31
- const PROMPTBOOK_ENGINE_VERSION = '0.104.0-12';
31
+ const PROMPTBOOK_ENGINE_VERSION = '0.104.0-14';
32
32
  /**
33
33
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
34
34
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -3629,7 +3629,7 @@
3629
3629
  tasks.push(task);
3630
3630
  runningTasks.push(task);
3631
3631
  /* not await */ Promise.resolve(task).then(() => {
3632
- runningTasks = runningTasks.filter((t) => t !== task);
3632
+ runningTasks = runningTasks.filter((runningTask) => runningTask !== task);
3633
3633
  });
3634
3634
  if (maxParallelCount < runningTasks.length) {
3635
3635
  await Promise.race(runningTasks);
@@ -3686,10 +3686,14 @@
3686
3686
  }
3687
3687
 
3688
3688
  /**
3689
- * Intercepts LLM tools and counts total usage of the tools
3689
+ * Intercepts LLM tools and counts total usage of the tools.
3690
3690
  *
3691
- * @param llmTools LLM tools to be intercepted with usage counting
3692
- * @returns LLM tools with same functionality with added total cost counting
3691
+ * This function wraps the provided `LlmExecutionTools` with a proxy that tracks the cumulative
3692
+ * usage (tokens, cost, etc.) across all model calls. It provides a way to monitor spending
3693
+ * in real-time through an observable.
3694
+ *
3695
+ * @param llmTools - The LLM tools to be intercepted and tracked
3696
+ * @returns An augmented version of the tools that includes usage tracking capabilities
3693
3697
  * @public exported from `@promptbook/core`
3694
3698
  */
3695
3699
  function countUsage(llmTools) {
@@ -3954,17 +3958,21 @@
3954
3958
  */
3955
3959
 
3956
3960
  /**
3957
- * Joins multiple LLM Execution Tools into one
3961
+ * Joins multiple LLM Execution Tools into one.
3958
3962
  *
3959
- * @returns {LlmExecutionTools} Single wrapper for multiple LlmExecutionTools
3963
+ * This function takes a list of `LlmExecutionTools` and returns a single unified
3964
+ * `MultipleLlmExecutionTools` object. It provides failover and aggregation logic:
3960
3965
  *
3961
- * 0) If there is no LlmExecutionTools, it warns and returns valid but empty LlmExecutionTools
3962
- * 1) If there is only one LlmExecutionTools, it returns it wrapped in a proxy object
3963
- * 2) If there are multiple LlmExecutionTools, first will be used first, second will be used if the first hasn`t defined model variant or fails, etc.
3964
- * 3) When all LlmExecutionTools fail, it throws an error with a list of all errors merged into one
3966
+ * 1. **Failover**: When a model call is made, it tries providers in the order they were provided.
3967
+ * If the first provider doesn't support the requested model or fails, it tries the next one.
3968
+ * 2. **Aggregation**: `listModels` returns a combined list of all models available from all providers.
3969
+ * 3. **Empty case**: If no tools are provided, it logs a warning (as Promptbook requires LLMs to function).
3965
3970
  *
3971
+ * @param title - A descriptive title for this collection of joined tools
3972
+ * @param llmExecutionTools - An array of execution tools to be joined
3973
+ * @returns A single unified execution tool wrapper
3966
3974
  *
3967
- * Tip: You don't have to use this function directly, just pass an array of LlmExecutionTools to the `ExecutionTools`
3975
+ * Tip: You don't have to use this function directly, just pass an array of LlmExecutionTools to the `ExecutionTools`.
3968
3976
  *
3969
3977
  * @public exported from `@promptbook/core`
3970
3978
  */
@@ -4529,8 +4537,8 @@
4529
4537
  */
4530
4538
  function removeDiacritics(input) {
4531
4539
  /*eslint no-control-regex: "off"*/
4532
- return input.replace(/[^\u0000-\u007E]/g, (a) => {
4533
- return DIACRITIC_VARIANTS_LETTERS[a] || a;
4540
+ return input.replace(/[^\u0000-\u007E]/g, (character) => {
4541
+ return DIACRITIC_VARIANTS_LETTERS[character] || character;
4534
4542
  });
4535
4543
  }
4536
4544
  /**
@@ -6789,7 +6797,7 @@
6789
6797
  const taskEmbeddingResult = await llmTools.callEmbeddingModel(taskEmbeddingPrompt);
6790
6798
  const knowledgePiecesWithRelevance = preparedPipeline.knowledgePieces.map((knowledgePiece) => {
6791
6799
  const { index } = knowledgePiece;
6792
- const knowledgePieceIndex = index.find((i) => i.modelName === firstKnowledgeIndex.modelName);
6800
+ const knowledgePieceIndex = index.find((knowledgePieceIndex) => knowledgePieceIndex.modelName === firstKnowledgeIndex.modelName);
6793
6801
  // <- TODO: Do not use just first knowledge piece and first index to determine embedding model
6794
6802
  if (knowledgePieceIndex === undefined) {
6795
6803
  return {
@@ -7237,7 +7245,7 @@
7237
7245
  resovedParameterNames = [...resovedParameterNames, currentTask.resultingParameterName];
7238
7246
  })
7239
7247
  .then(() => {
7240
- resolving = resolving.filter((w) => w !== work);
7248
+ resolving = resolving.filter((workItem) => workItem !== work);
7241
7249
  });
7242
7250
  // <- Note: Errors are catched here [3]
7243
7251
  // 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
@@ -7403,7 +7411,7 @@
7403
7411
  // Calculate and update tldr based on pipeline progress
7404
7412
  const cv = newOngoingResult;
7405
7413
  // Calculate progress based on parameters resolved vs total parameters
7406
- const totalParameters = pipeline.parameters.filter((p) => !p.isInput).length;
7414
+ const totalParameters = pipeline.parameters.filter((parameter) => !parameter.isInput).length;
7407
7415
  let resolvedParameters = 0;
7408
7416
  let currentTaskTitle = '';
7409
7417
  // Get the resolved parameters from output parameters
@@ -7541,8 +7549,8 @@
7541
7549
  */
7542
7550
  function createCommitmentRegex(commitment, aliases = [], requiresContent = true) {
7543
7551
  const allCommitments = [commitment, ...aliases];
7544
- const patterns = allCommitments.map((c) => {
7545
- const escapedCommitment = c.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
7552
+ const patterns = allCommitments.map((commitment) => {
7553
+ const escapedCommitment = commitment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
7546
7554
  return escapedCommitment.split(/\s+/).join('\\s+');
7547
7555
  });
7548
7556
  const keywordPattern = patterns.join('|');
@@ -7564,8 +7572,8 @@
7564
7572
  */
7565
7573
  function createCommitmentTypeRegex(commitment, aliases = []) {
7566
7574
  const allCommitments = [commitment, ...aliases];
7567
- const patterns = allCommitments.map((c) => {
7568
- const escapedCommitment = c.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
7575
+ const patterns = allCommitments.map((commitment) => {
7576
+ const escapedCommitment = commitment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
7569
7577
  return escapedCommitment.split(/\s+/).join('\\s+');
7570
7578
  });
7571
7579
  const keywordPattern = patterns.join('|');
@@ -8075,9 +8083,7 @@
8075
8083
  // Get existing dictionary entries from metadata
8076
8084
  const existingDictionary = ((_a = requirements.metadata) === null || _a === void 0 ? void 0 : _a.DICTIONARY) || '';
8077
8085
  // Merge the new dictionary entry with existing entries
8078
- const mergedDictionary = existingDictionary
8079
- ? `${existingDictionary}\n${trimmedContent}`
8080
- : trimmedContent;
8086
+ const mergedDictionary = existingDictionary ? `${existingDictionary}\n${trimmedContent}` : trimmedContent;
8081
8087
  // Store the merged dictionary in metadata for debugging and inspection
8082
8088
  const updatedMetadata = {
8083
8089
  ...requirements.metadata,
@@ -11296,8 +11302,8 @@
11296
11302
  return match;
11297
11303
  });
11298
11304
  // Remove duplicates based on name (keep the first occurrence)
11299
- const uniqueParameters = parameters.filter((param, index, array) => {
11300
- return array.findIndex((p) => p.name === param.name) === index;
11305
+ const uniqueParameters = parameters.filter((parameter, index, array) => {
11306
+ return array.findIndex((parameterItem) => parameterItem.name === parameter.name) === index;
11301
11307
  });
11302
11308
  return uniqueParameters;
11303
11309
  }
@@ -11344,7 +11350,7 @@
11344
11350
  commitment.type === 'DISCARD' ||
11345
11351
  commitment.type === 'REMOVE') {
11346
11352
  const targets = parseParameters(commitment.content)
11347
- .map((p) => p.name.trim().toLowerCase())
11353
+ .map((parameter) => parameter.name.trim().toLowerCase())
11348
11354
  .filter(Boolean);
11349
11355
  if (targets.length === 0) {
11350
11356
  // Ignore DELETE with no targets; also don't pass the DELETE further
@@ -11353,8 +11359,8 @@
11353
11359
  // Drop prior kept commitments that contain any of the targeted tags
11354
11360
  for (let i = filteredCommitments.length - 1; i >= 0; i--) {
11355
11361
  const prev = filteredCommitments[i];
11356
- const prevParams = parseParameters(prev.content).map((p) => p.name.trim().toLowerCase());
11357
- const hasIntersection = prevParams.some((n) => targets.includes(n));
11362
+ const prevParams = parseParameters(prev.content).map((parameter) => parameter.name.trim().toLowerCase());
11363
+ const hasIntersection = prevParams.some((parameterName) => targets.includes(parameterName));
11358
11364
  if (hasIntersection) {
11359
11365
  filteredCommitments.splice(i, 1);
11360
11366
  }
@@ -12277,18 +12283,20 @@
12277
12283
  // import { getTableName } from '../../../../../apps/agents-server/src/database/getTableName';
12278
12284
  // <- TODO: [🐱‍🚀] Prevent imports from `/apps` -> `/src`
12279
12285
  /**
12280
- * Agent collection stored in Supabase table
12286
+ * Agent collection stored in a Supabase table.
12281
12287
  *
12282
- * Note: This object can work both from Node.js and browser environment depending on the Supabase client provided
12288
+ * This class provides a way to manage a collection of agents (pipelines) using Supabase
12289
+ * as the storage backend. It supports listing, creating, updating, and soft-deleting agents.
12290
+ *
12291
+ * Note: This object can work both from Node.js and browser environment depending on the Supabase client provided.
12283
12292
  *
12284
12293
  * @public exported from `@promptbook/core`
12285
12294
  * <- TODO: [🐱‍🚀] Move to `@promptbook/supabase` package
12286
12295
  */
12287
12296
  class AgentCollectionInSupabase /* TODO: [🐱‍🚀] implements Agent */ {
12288
12297
  /**
12289
- * @param rootPath - path to the directory with agents
12290
- * @param tools - Execution tools to be used in [🐱‍🚀] `Agent` itself and listing the agents
12291
- * @param options - Options for the collection creation
12298
+ * @param supabaseClient - The initialized Supabase client
12299
+ * @param options - Configuration options for the collection (e.g., table prefix, verbosity)
12292
12300
  */
12293
12301
  constructor(supabaseClient,
12294
12302
  /// TODO: [🐱‍🚀] Remove> private readonly tools?: Pick<ExecutionTools, 'llm' | 'fs' | 'scrapers'>,
@@ -14176,7 +14184,12 @@
14176
14184
  * @see {@link ModelVariant}
14177
14185
  * @public exported from `@promptbook/core`
14178
14186
  */
14179
- const MODEL_VARIANTS = ['COMPLETION', 'CHAT', 'IMAGE_GENERATION', 'EMBEDDING' /* <- TODO [🏳] */ /* <- [🤖] */];
14187
+ const MODEL_VARIANTS = [
14188
+ 'COMPLETION',
14189
+ 'CHAT',
14190
+ 'IMAGE_GENERATION',
14191
+ 'EMBEDDING' /* <- TODO [🏳] */ /* <- [🤖] */,
14192
+ ];
14180
14193
 
14181
14194
  /**
14182
14195
  * Parses the model command
@@ -19742,7 +19755,7 @@
19742
19755
  const modelRequirements = await this.getAgentModelRequirements();
19743
19756
  if (modelRequirements.samples) {
19744
19757
  const normalizedPrompt = normalizeMessageText(prompt.content);
19745
- const sample = modelRequirements.samples.find((s) => normalizeMessageText(s.question) === normalizedPrompt);
19758
+ const sample = modelRequirements.samples.find((sample) => normalizeMessageText(sample.question) === normalizedPrompt);
19746
19759
  if (sample) {
19747
19760
  const now = new Date().toISOString();
19748
19761
  const result = {
@@ -21300,6 +21313,10 @@
21300
21313
  /**
21301
21314
  * Generates a random agent persona description.
21302
21315
  *
21316
+ * This function selects a random personality profile from a predefined pool
21317
+ * of common AI agent characteristics (e.g., friendly, professional, creative).
21318
+ *
21319
+ * @returns A string describing the agent's persona
21303
21320
  * @private internal helper function
21304
21321
  */
21305
21322
  function $randomAgentPersona() {