@promptbook/wizard 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 +44 -31
  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 +2 -2
  27. package/umd/index.umd.js +44 -31
  28. package/umd/index.umd.js.map +1 -1
package/umd/index.umd.js CHANGED
@@ -48,7 +48,7 @@
48
48
  * @generated
49
49
  * @see https://github.com/webgptorg/promptbook
50
50
  */
51
- const PROMPTBOOK_ENGINE_VERSION = '0.104.0-12';
51
+ const PROMPTBOOK_ENGINE_VERSION = '0.104.0-14';
52
52
  /**
53
53
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
54
54
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -3277,8 +3277,8 @@
3277
3277
  */
3278
3278
  function removeDiacritics(input) {
3279
3279
  /*eslint no-control-regex: "off"*/
3280
- return input.replace(/[^\u0000-\u007E]/g, (a) => {
3281
- return DIACRITIC_VARIANTS_LETTERS[a] || a;
3280
+ return input.replace(/[^\u0000-\u007E]/g, (character) => {
3281
+ return DIACRITIC_VARIANTS_LETTERS[character] || character;
3282
3282
  });
3283
3283
  }
3284
3284
  /**
@@ -9336,7 +9336,7 @@
9336
9336
  tasks.push(task);
9337
9337
  runningTasks.push(task);
9338
9338
  /* not await */ Promise.resolve(task).then(() => {
9339
- runningTasks = runningTasks.filter((t) => t !== task);
9339
+ runningTasks = runningTasks.filter((runningTask) => runningTask !== task);
9340
9340
  });
9341
9341
  if (maxParallelCount < runningTasks.length) {
9342
9342
  await Promise.race(runningTasks);
@@ -9393,10 +9393,14 @@
9393
9393
  }
9394
9394
 
9395
9395
  /**
9396
- * Intercepts LLM tools and counts total usage of the tools
9396
+ * Intercepts LLM tools and counts total usage of the tools.
9397
9397
  *
9398
- * @param llmTools LLM tools to be intercepted with usage counting
9399
- * @returns LLM tools with same functionality with added total cost counting
9398
+ * This function wraps the provided `LlmExecutionTools` with a proxy that tracks the cumulative
9399
+ * usage (tokens, cost, etc.) across all model calls. It provides a way to monitor spending
9400
+ * in real-time through an observable.
9401
+ *
9402
+ * @param llmTools - The LLM tools to be intercepted and tracked
9403
+ * @returns An augmented version of the tools that includes usage tracking capabilities
9400
9404
  * @public exported from `@promptbook/core`
9401
9405
  */
9402
9406
  function countUsage(llmTools) {
@@ -9661,17 +9665,21 @@
9661
9665
  */
9662
9666
 
9663
9667
  /**
9664
- * Joins multiple LLM Execution Tools into one
9668
+ * Joins multiple LLM Execution Tools into one.
9665
9669
  *
9666
- * @returns {LlmExecutionTools} Single wrapper for multiple LlmExecutionTools
9670
+ * This function takes a list of `LlmExecutionTools` and returns a single unified
9671
+ * `MultipleLlmExecutionTools` object. It provides failover and aggregation logic:
9667
9672
  *
9668
- * 0) If there is no LlmExecutionTools, it warns and returns valid but empty LlmExecutionTools
9669
- * 1) If there is only one LlmExecutionTools, it returns it wrapped in a proxy object
9670
- * 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.
9671
- * 3) When all LlmExecutionTools fail, it throws an error with a list of all errors merged into one
9673
+ * 1. **Failover**: When a model call is made, it tries providers in the order they were provided.
9674
+ * If the first provider doesn't support the requested model or fails, it tries the next one.
9675
+ * 2. **Aggregation**: `listModels` returns a combined list of all models available from all providers.
9676
+ * 3. **Empty case**: If no tools are provided, it logs a warning (as Promptbook requires LLMs to function).
9672
9677
  *
9678
+ * @param title - A descriptive title for this collection of joined tools
9679
+ * @param llmExecutionTools - An array of execution tools to be joined
9680
+ * @returns A single unified execution tool wrapper
9673
9681
  *
9674
- * Tip: You don't have to use this function directly, just pass an array of LlmExecutionTools to the `ExecutionTools`
9682
+ * Tip: You don't have to use this function directly, just pass an array of LlmExecutionTools to the `ExecutionTools`.
9675
9683
  *
9676
9684
  * @public exported from `@promptbook/core`
9677
9685
  */
@@ -11774,7 +11782,7 @@
11774
11782
  const taskEmbeddingResult = await llmTools.callEmbeddingModel(taskEmbeddingPrompt);
11775
11783
  const knowledgePiecesWithRelevance = preparedPipeline.knowledgePieces.map((knowledgePiece) => {
11776
11784
  const { index } = knowledgePiece;
11777
- const knowledgePieceIndex = index.find((i) => i.modelName === firstKnowledgeIndex.modelName);
11785
+ const knowledgePieceIndex = index.find((knowledgePieceIndex) => knowledgePieceIndex.modelName === firstKnowledgeIndex.modelName);
11778
11786
  // <- TODO: Do not use just first knowledge piece and first index to determine embedding model
11779
11787
  if (knowledgePieceIndex === undefined) {
11780
11788
  return {
@@ -12222,7 +12230,7 @@
12222
12230
  resovedParameterNames = [...resovedParameterNames, currentTask.resultingParameterName];
12223
12231
  })
12224
12232
  .then(() => {
12225
- resolving = resolving.filter((w) => w !== work);
12233
+ resolving = resolving.filter((workItem) => workItem !== work);
12226
12234
  });
12227
12235
  // <- Note: Errors are catched here [3]
12228
12236
  // 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
@@ -12388,7 +12396,7 @@
12388
12396
  // Calculate and update tldr based on pipeline progress
12389
12397
  const cv = newOngoingResult;
12390
12398
  // Calculate progress based on parameters resolved vs total parameters
12391
- const totalParameters = pipeline.parameters.filter((p) => !p.isInput).length;
12399
+ const totalParameters = pipeline.parameters.filter((parameter) => !parameter.isInput).length;
12392
12400
  let resolvedParameters = 0;
12393
12401
  let currentTaskTitle = '';
12394
12402
  // Get the resolved parameters from output parameters
@@ -13735,8 +13743,8 @@
13735
13743
  */
13736
13744
  function createCommitmentRegex(commitment, aliases = [], requiresContent = true) {
13737
13745
  const allCommitments = [commitment, ...aliases];
13738
- const patterns = allCommitments.map((c) => {
13739
- const escapedCommitment = c.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
13746
+ const patterns = allCommitments.map((commitment) => {
13747
+ const escapedCommitment = commitment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
13740
13748
  return escapedCommitment.split(/\s+/).join('\\s+');
13741
13749
  });
13742
13750
  const keywordPattern = patterns.join('|');
@@ -13758,8 +13766,8 @@
13758
13766
  */
13759
13767
  function createCommitmentTypeRegex(commitment, aliases = []) {
13760
13768
  const allCommitments = [commitment, ...aliases];
13761
- const patterns = allCommitments.map((c) => {
13762
- const escapedCommitment = c.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
13769
+ const patterns = allCommitments.map((commitment) => {
13770
+ const escapedCommitment = commitment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
13763
13771
  return escapedCommitment.split(/\s+/).join('\\s+');
13764
13772
  });
13765
13773
  const keywordPattern = patterns.join('|');
@@ -14269,9 +14277,7 @@
14269
14277
  // Get existing dictionary entries from metadata
14270
14278
  const existingDictionary = ((_a = requirements.metadata) === null || _a === void 0 ? void 0 : _a.DICTIONARY) || '';
14271
14279
  // Merge the new dictionary entry with existing entries
14272
- const mergedDictionary = existingDictionary
14273
- ? `${existingDictionary}\n${trimmedContent}`
14274
- : trimmedContent;
14280
+ const mergedDictionary = existingDictionary ? `${existingDictionary}\n${trimmedContent}` : trimmedContent;
14275
14281
  // Store the merged dictionary in metadata for debugging and inspection
14276
14282
  const updatedMetadata = {
14277
14283
  ...requirements.metadata,
@@ -17423,8 +17429,8 @@
17423
17429
  return match;
17424
17430
  });
17425
17431
  // Remove duplicates based on name (keep the first occurrence)
17426
- const uniqueParameters = parameters.filter((param, index, array) => {
17427
- return array.findIndex((p) => p.name === param.name) === index;
17432
+ const uniqueParameters = parameters.filter((parameter, index, array) => {
17433
+ return array.findIndex((parameterItem) => parameterItem.name === parameter.name) === index;
17428
17434
  });
17429
17435
  return uniqueParameters;
17430
17436
  }
@@ -17471,7 +17477,7 @@
17471
17477
  commitment.type === 'DISCARD' ||
17472
17478
  commitment.type === 'REMOVE') {
17473
17479
  const targets = parseParameters(commitment.content)
17474
- .map((p) => p.name.trim().toLowerCase())
17480
+ .map((parameter) => parameter.name.trim().toLowerCase())
17475
17481
  .filter(Boolean);
17476
17482
  if (targets.length === 0) {
17477
17483
  // Ignore DELETE with no targets; also don't pass the DELETE further
@@ -17480,8 +17486,8 @@
17480
17486
  // Drop prior kept commitments that contain any of the targeted tags
17481
17487
  for (let i = filteredCommitments.length - 1; i >= 0; i--) {
17482
17488
  const prev = filteredCommitments[i];
17483
- const prevParams = parseParameters(prev.content).map((p) => p.name.trim().toLowerCase());
17484
- const hasIntersection = prevParams.some((n) => targets.includes(n));
17489
+ const prevParams = parseParameters(prev.content).map((parameter) => parameter.name.trim().toLowerCase());
17490
+ const hasIntersection = prevParams.some((parameterName) => targets.includes(parameterName));
17485
17491
  if (hasIntersection) {
17486
17492
  filteredCommitments.splice(i, 1);
17487
17493
  }
@@ -21316,7 +21322,12 @@
21316
21322
  * @see {@link ModelVariant}
21317
21323
  * @public exported from `@promptbook/core`
21318
21324
  */
21319
- const MODEL_VARIANTS = ['COMPLETION', 'CHAT', 'IMAGE_GENERATION', 'EMBEDDING' /* <- TODO [🏳] */ /* <- [🤖] */];
21325
+ const MODEL_VARIANTS = [
21326
+ 'COMPLETION',
21327
+ 'CHAT',
21328
+ 'IMAGE_GENERATION',
21329
+ 'EMBEDDING' /* <- TODO [🏳] */ /* <- [🤖] */,
21330
+ ];
21320
21331
 
21321
21332
  /**
21322
21333
  * Parses the model command
@@ -23842,7 +23853,9 @@
23842
23853
  // ▶ Create executor - the function that will execute the Pipeline
23843
23854
  const pipelineExecutor = createPipelineExecutor({ pipeline, tools });
23844
23855
  // 🚀▶ Execute the Pipeline
23845
- const result = await pipelineExecutor(inputParameters).asPromise({ isCrashedOnError: true });
23856
+ const result = await pipelineExecutor(inputParameters).asPromise({
23857
+ isCrashedOnError: true,
23858
+ });
23846
23859
  const { outputParameters } = result;
23847
23860
  const outputParametersLength = Object.keys(outputParameters).length;
23848
23861
  let resultString;