@promptbook/pdf 0.101.0-2 → 0.101.0-20

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 (76) hide show
  1. package/esm/index.es.js +59 -51
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/components.index.d.ts +20 -0
  4. package/esm/typings/src/_packages/core.index.d.ts +14 -0
  5. package/esm/typings/src/_packages/types.index.d.ts +14 -0
  6. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +41 -3
  7. package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +3 -0
  8. package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirements.d.ts +4 -22
  9. package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.d.ts +1 -26
  10. package/esm/typings/src/book-2.0/agent-source/parseParameters.d.ts +13 -0
  11. package/esm/typings/src/book-2.0/commitments/ACTION/ACTION.d.ts +8 -2
  12. package/esm/typings/src/book-2.0/commitments/DELETE/DELETE.d.ts +59 -0
  13. package/esm/typings/src/book-2.0/commitments/FORMAT/FORMAT.d.ts +8 -2
  14. package/esm/typings/src/book-2.0/commitments/GOAL/GOAL.d.ts +45 -0
  15. package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/KNOWLEDGE.d.ts +1 -1
  16. package/esm/typings/src/book-2.0/commitments/MEMORY/MEMORY.d.ts +46 -0
  17. package/esm/typings/src/book-2.0/commitments/MESSAGE/MESSAGE.d.ts +47 -0
  18. package/esm/typings/src/book-2.0/commitments/META/META.d.ts +62 -0
  19. package/esm/typings/src/book-2.0/commitments/MODEL/MODEL.d.ts +31 -4
  20. package/esm/typings/src/book-2.0/commitments/NOTE/NOTE.d.ts +20 -2
  21. package/esm/typings/src/book-2.0/commitments/PERSONA/PERSONA.d.ts +8 -2
  22. package/esm/typings/src/book-2.0/commitments/SCENARIO/SCENARIO.d.ts +46 -0
  23. package/esm/typings/src/book-2.0/commitments/STYLE/STYLE.d.ts +8 -2
  24. package/esm/typings/src/book-2.0/commitments/index.d.ts +7 -3
  25. package/esm/typings/src/book-2.0/utils/generatePlaceholderAgentProfileImageUrl.d.ts +3 -0
  26. package/esm/typings/src/book-components/AvatarProfile/AvatarChip/AvatarChip.d.ts +2 -2
  27. package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/MockedChat.d.ts +63 -0
  28. package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/index.d.ts +3 -0
  29. package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +15 -0
  30. package/esm/typings/src/book-components/BookEditor/BookEditorInner.d.ts +4 -0
  31. package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +26 -0
  32. package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +13 -0
  33. package/esm/typings/src/book-components/Chat/hooks/index.d.ts +2 -0
  34. package/esm/typings/src/book-components/Chat/hooks/useChatAutoScroll.d.ts +41 -0
  35. package/esm/typings/src/book-components/Chat/hooks/useSendMessageToLlmChat.d.ts +44 -0
  36. package/esm/typings/src/book-components/Chat/utils/parseMessageButtons.d.ts +22 -0
  37. package/esm/typings/src/book-components/icons/PauseIcon.d.ts +8 -0
  38. package/esm/typings/src/book-components/icons/PlayIcon.d.ts +8 -0
  39. package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +1 -2
  40. package/esm/typings/src/execution/createPipelineExecutor/getKnowledgeForTask.d.ts +1 -3
  41. package/esm/typings/src/formats/csv/CsvFormatError.d.ts +1 -1
  42. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.d.ts +1 -1
  43. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts +1 -1
  44. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizardOrCli.d.ts +1 -2
  45. package/esm/typings/src/llm-providers/_common/register/createLlmToolsFromConfiguration.d.ts +8 -2
  46. package/esm/typings/src/llm-providers/_common/utils/removeUnsupportedModelRequirements.d.ts +25 -0
  47. package/esm/typings/src/llm-providers/_multiple/MultipleLlmExecutionTools.d.ts +5 -13
  48. package/esm/typings/src/llm-providers/_multiple/getSingleLlmExecutionTools.d.ts +11 -0
  49. package/esm/typings/src/llm-providers/_multiple/joinLlmExecutionTools.d.ts +2 -1
  50. package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +54 -0
  51. package/esm/typings/src/llm-providers/agent/createAgentLlmExecutionTools.d.ts +29 -0
  52. package/esm/typings/src/llm-providers/agent/playground/playground.d.ts +8 -0
  53. package/esm/typings/src/llm-providers/agent/register-configuration.d.ts +11 -0
  54. package/esm/typings/src/llm-providers/agent/register-constructor.d.ts +13 -0
  55. package/esm/typings/src/llm-providers/mocked/$fakeTextToExpectations.d.ts +1 -0
  56. package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +2 -5
  57. package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +2 -6
  58. package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +15 -8
  59. package/esm/typings/src/personas/preparePersona.d.ts +1 -0
  60. package/esm/typings/src/remote-server/openapi-types.d.ts +31 -31
  61. package/esm/typings/src/scrapers/markdown/MarkdownScraper.d.ts +1 -2
  62. package/esm/typings/src/types/ModelRequirements.d.ts +2 -4
  63. package/esm/typings/src/utils/color/utils/colorSaturation.d.ts +1 -1
  64. package/esm/typings/src/utils/editable/edit-pipeline-string/addPipelineCommand.d.ts +1 -1
  65. package/esm/typings/src/utils/markdown/humanizeAiText.d.ts +1 -0
  66. package/esm/typings/src/version.d.ts +1 -1
  67. package/package.json +2 -2
  68. package/umd/index.umd.js +59 -51
  69. package/umd/index.umd.js.map +1 -1
  70. package/esm/typings/src/book-2.0/utils/extractAgentMetadata.d.ts +0 -17
  71. package/esm/typings/src/book-2.0/utils/extractProfileImageFromSystemMessage.d.ts +0 -12
  72. package/esm/typings/src/llm-providers/mocked/test/joker.test.d.ts +0 -4
  73. package/esm/typings/src/llm-providers/mocked/test/mocked-chat.test.d.ts +0 -5
  74. package/esm/typings/src/llm-providers/mocked/test/mocked-completion.test.d.ts +0 -4
  75. package/esm/typings/src/scripting/_test/postprocessing.test.d.ts +0 -1
  76. /package/esm/typings/src/{cli/test/ptbk.test.d.ts → llm-providers/_common/utils/removeUnsupportedModelRequirements.test.d.ts} +0 -0
@@ -14,4 +14,4 @@ export {};
14
14
  /**
15
15
  * TODO: [🧠] What is the better solution - `- xxx`, - `- xxx` or preserve (see also next TODO)
16
16
  * TODO: When existing commands 1) as 2) number 3) list, add 4) new command as next number
17
- */
17
+ */
@@ -9,5 +9,6 @@ import { string_markdown } from '../../types/typeAliases';
9
9
  */
10
10
  export declare function humanizeAiText(aiText: string_markdown): string_markdown;
11
11
  /**
12
+ * TODO: [🧠] Maybe this should be exported from `@promptbook/utils` not `@promptbook/markdown-utils`
12
13
  * TODO: [🅾️] !!! Use this across the project where AI text is involved
13
14
  */
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
15
15
  export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
16
16
  /**
17
17
  * Represents the version string of the Promptbook engine.
18
- * It follows semantic versioning (e.g., `0.101.0-1`).
18
+ * It follows semantic versioning (e.g., `0.101.0-19`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/pdf",
3
- "version": "0.101.0-2",
3
+ "version": "0.101.0-20",
4
4
  "description": "Promptbook: Run AI apps in plain human language across multiple models and platforms",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -94,7 +94,7 @@
94
94
  "module": "./esm/index.es.js",
95
95
  "typings": "./esm/typings/src/_packages/pdf.index.d.ts",
96
96
  "peerDependencies": {
97
- "@promptbook/core": "0.101.0-2"
97
+ "@promptbook/core": "0.101.0-20"
98
98
  },
99
99
  "dependencies": {
100
100
  "crypto": "1.0.1",
package/umd/index.umd.js CHANGED
@@ -24,7 +24,7 @@
24
24
  * @generated
25
25
  * @see https://github.com/webgptorg/promptbook
26
26
  */
27
- const PROMPTBOOK_ENGINE_VERSION = '0.101.0-2';
27
+ const PROMPTBOOK_ENGINE_VERSION = '0.101.0-20';
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
@@ -877,11 +877,12 @@
877
877
  catch (error) {
878
878
  // Note: If we can't create cache directory, continue without it
879
879
  // This handles read-only filesystems, permission issues, and missing parent directories
880
- if (error instanceof Error && (error.message.includes('EROFS') ||
881
- error.message.includes('read-only') ||
882
- error.message.includes('EACCES') ||
883
- error.message.includes('EPERM') ||
884
- error.message.includes('ENOENT'))) ;
880
+ if (error instanceof Error &&
881
+ (error.message.includes('EROFS') ||
882
+ error.message.includes('read-only') ||
883
+ error.message.includes('EACCES') ||
884
+ error.message.includes('EPERM') ||
885
+ error.message.includes('ENOENT'))) ;
885
886
  else {
886
887
  // Re-throw other unexpected errors
887
888
  throw error;
@@ -2959,6 +2960,25 @@
2959
2960
  * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
2960
2961
  */
2961
2962
 
2963
+ /**
2964
+ * Takes an item or an array of items and returns an array of items
2965
+ *
2966
+ * 1) Any item except array and undefined returns array with that one item (also null)
2967
+ * 2) Undefined returns empty array
2968
+ * 3) Array returns itself
2969
+ *
2970
+ * @private internal utility
2971
+ */
2972
+ function arrayableToArray(input) {
2973
+ if (input === undefined) {
2974
+ return [];
2975
+ }
2976
+ if (input instanceof Array) {
2977
+ return input;
2978
+ }
2979
+ return [input];
2980
+ }
2981
+
2962
2982
  /**
2963
2983
  * Predefined profiles for LLM providers to maintain consistency across the application
2964
2984
  * These profiles represent each provider as a virtual persona in chat interfaces
@@ -3039,12 +3059,10 @@
3039
3059
  /**
3040
3060
  * Gets array of execution tools in order of priority
3041
3061
  */
3042
- constructor(...llmExecutionTools) {
3062
+ constructor(title, ...llmExecutionTools) {
3063
+ this.title = title;
3043
3064
  this.llmExecutionTools = llmExecutionTools;
3044
3065
  }
3045
- get title() {
3046
- return 'Multiple LLM Providers';
3047
- }
3048
3066
  get description() {
3049
3067
  const innerModelsTitlesAndDescriptions = this.llmExecutionTools
3050
3068
  .map(({ title, description }, index) => {
@@ -3130,7 +3148,7 @@
3130
3148
  return await llmExecutionTools.callEmbeddingModel(prompt);
3131
3149
  // <- case [🤖]:
3132
3150
  default:
3133
- throw new UnexpectedError(`Unknown model variant "${prompt.modelRequirements.modelVariant}"`);
3151
+ throw new UnexpectedError(`Unknown model variant "${prompt.modelRequirements.modelVariant}" in ${llmExecutionTools.title}`);
3134
3152
  }
3135
3153
  }
3136
3154
  catch (error) {
@@ -3151,7 +3169,7 @@
3151
3169
  // 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
3152
3170
  // 3) ...
3153
3171
  spaceTrim__default["default"]((block) => `
3154
- All execution tools failed:
3172
+ All execution tools of ${this.title} failed:
3155
3173
 
3156
3174
  ${block(errors
3157
3175
  .map(({ error, llmExecutionTools }, i) => `${i + 1}) **${llmExecutionTools.title}** thrown **${error.name || 'Error'}:** ${error.message}`)
@@ -3160,11 +3178,11 @@
3160
3178
  `));
3161
3179
  }
3162
3180
  else if (this.llmExecutionTools.length === 0) {
3163
- throw new PipelineExecutionError(`You have not provided any \`LlmExecutionTools\``);
3181
+ throw new PipelineExecutionError(`You have not provided any \`LlmExecutionTools\` into ${this.title}`);
3164
3182
  }
3165
3183
  else {
3166
3184
  throw new PipelineExecutionError(spaceTrim__default["default"]((block) => `
3167
- You have not provided any \`LlmExecutionTools\` that support model variant "${prompt.modelRequirements.modelVariant}"
3185
+ You have not provided any \`LlmExecutionTools\` that support model variant "${prompt.modelRequirements.modelVariant}" into ${this.title}
3168
3186
 
3169
3187
  Available \`LlmExecutionTools\`:
3170
3188
  ${block(this.description)}
@@ -3194,7 +3212,7 @@
3194
3212
  *
3195
3213
  * @public exported from `@promptbook/core`
3196
3214
  */
3197
- function joinLlmExecutionTools(...llmExecutionTools) {
3215
+ function joinLlmExecutionTools(title, ...llmExecutionTools) {
3198
3216
  if (llmExecutionTools.length === 0) {
3199
3217
  const warningMessage = spaceTrim__default["default"](`
3200
3218
  You have not provided any \`LlmExecutionTools\`
@@ -3226,30 +3244,27 @@
3226
3244
  };
3227
3245
  */
3228
3246
  }
3229
- return new MultipleLlmExecutionTools(...llmExecutionTools);
3247
+ return new MultipleLlmExecutionTools(title || 'Multiple LLM Providers joined by `joinLlmExecutionTools`', ...llmExecutionTools);
3230
3248
  }
3231
3249
  /**
3232
3250
  * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
3233
3251
  */
3234
3252
 
3235
3253
  /**
3236
- * Takes an item or an array of items and returns an array of items
3254
+ * Just returns the given `LlmExecutionTools` or joins multiple into one
3237
3255
  *
3238
- * 1) Any item except array and undefined returns array with that one item (also null)
3239
- * 2) Undefined returns empty array
3240
- * 3) Array returns itself
3241
- *
3242
- * @private internal utility
3256
+ * @public exported from `@promptbook/core`
3243
3257
  */
3244
- function arrayableToArray(input) {
3245
- if (input === undefined) {
3246
- return [];
3247
- }
3248
- if (input instanceof Array) {
3249
- return input;
3250
- }
3251
- return [input];
3258
+ function getSingleLlmExecutionTools(oneOrMoreLlmExecutionTools) {
3259
+ const _llms = arrayableToArray(oneOrMoreLlmExecutionTools);
3260
+ const llmTools = _llms.length === 1
3261
+ ? _llms[0]
3262
+ : joinLlmExecutionTools('Multiple LLM Providers joined by `getSingleLlmExecutionTools`', ..._llms);
3263
+ return llmTools;
3252
3264
  }
3265
+ /**
3266
+ * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
3267
+ */
3253
3268
 
3254
3269
  /**
3255
3270
  * Prepares the persona for the pipeline
@@ -3268,8 +3283,7 @@
3268
3283
  pipeline: await collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.book'),
3269
3284
  tools,
3270
3285
  });
3271
- const _llms = arrayableToArray(tools.llm);
3272
- const llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools(..._llms);
3286
+ const llmTools = getSingleLlmExecutionTools(tools.llm);
3273
3287
  const availableModels = (await llmTools.listModels())
3274
3288
  .filter(({ modelVariant }) => modelVariant === 'CHAT')
3275
3289
  .map(({ modelName, modelDescription }) => ({
@@ -3313,6 +3327,7 @@
3313
3327
  };
3314
3328
  }
3315
3329
  /**
3330
+ * TODO: [😩] DRY `preparePersona` and `selectBestModelFromAvailable`
3316
3331
  * TODO: [🔃][main] If the persona was prepared with different version or different set of models, prepare it once again
3317
3332
  * TODO: [🏢] Check validity of `modelName` in pipeline
3318
3333
  * TODO: [🏢] Check validity of `systemMessage` in pipeline
@@ -4040,9 +4055,7 @@
4040
4055
  if (tools === undefined || tools.llm === undefined) {
4041
4056
  throw new MissingToolsError('LLM tools are required for preparing the pipeline');
4042
4057
  }
4043
- // TODO: [🚐] Make arrayable LLMs -> single LLM DRY
4044
- const _llms = arrayableToArray(tools.llm);
4045
- const llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools(..._llms);
4058
+ const llmTools = getSingleLlmExecutionTools(tools.llm);
4046
4059
  const llmToolsWithUsage = countUsage(llmTools);
4047
4060
  // <- TODO: [🌯]
4048
4061
  /*
@@ -5185,9 +5198,7 @@
5185
5198
  $scriptPipelineExecutionErrors: [],
5186
5199
  $failedResults: [], // Track all failed attempts
5187
5200
  };
5188
- // TODO: [🚐] Make arrayable LLMs -> single LLM DRY
5189
- const _llms = arrayableToArray(tools.llm);
5190
- const llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools(..._llms);
5201
+ const llmTools = getSingleLlmExecutionTools(tools.llm);
5191
5202
  attempts: for (let attemptIndex = -jokerParameterNames.length; attemptIndex < maxAttempts; attemptIndex++) {
5192
5203
  const isJokerAttempt = attemptIndex < 0;
5193
5204
  const jokerParameterName = jokerParameterNames[jokerParameterNames.length + attemptIndex];
@@ -5707,9 +5718,7 @@
5707
5718
  return ''; // <- Note: Np knowledge present, return empty string
5708
5719
  }
5709
5720
  try {
5710
- // TODO: [🚐] Make arrayable LLMs -> single LLM DRY
5711
- const _llms = arrayableToArray(tools.llm);
5712
- const llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools(..._llms);
5721
+ const llmTools = getSingleLlmExecutionTools(tools.llm);
5713
5722
  const taskEmbeddingPrompt = {
5714
5723
  title: 'Knowledge Search',
5715
5724
  modelRequirements: {
@@ -6310,13 +6319,13 @@
6310
6319
  // Calculate and update tldr based on pipeline progress
6311
6320
  const cv = newOngoingResult;
6312
6321
  // Calculate progress based on parameters resolved vs total parameters
6313
- const totalParameters = pipeline.parameters.filter(p => !p.isInput).length;
6322
+ const totalParameters = pipeline.parameters.filter((p) => !p.isInput).length;
6314
6323
  let resolvedParameters = 0;
6315
6324
  let currentTaskTitle = '';
6316
6325
  // Get the resolved parameters from output parameters
6317
6326
  if (cv === null || cv === void 0 ? void 0 : cv.outputParameters) {
6318
6327
  // Count how many output parameters have non-empty values
6319
- resolvedParameters = Object.values(cv.outputParameters).filter(value => value !== undefined && value !== null && String(value).trim() !== '').length;
6328
+ resolvedParameters = Object.values(cv.outputParameters).filter((value) => value !== undefined && value !== null && String(value).trim() !== '').length;
6320
6329
  }
6321
6330
  // Try to determine current task from execution report
6322
6331
  if (((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) && cv.executionReport.promptExecutions.length > 0) {
@@ -6426,9 +6435,7 @@
6426
6435
  throw new MissingToolsError('LLM tools are required for scraping external files');
6427
6436
  // <- Note: This scraper is used in all other scrapers, so saying "external files" not "markdown files"
6428
6437
  }
6429
- // TODO: [🚐] Make arrayable LLMs -> single LLM DRY
6430
- const _llms = arrayableToArray(llm);
6431
- const llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools(..._llms);
6438
+ const llmTools = getSingleLlmExecutionTools(llm);
6432
6439
  // TODO: [🌼] In future use `ptbk make` and made getPipelineCollection
6433
6440
  const collection = createCollectionFromJson(...PipelineCollection);
6434
6441
  const prepareKnowledgeFromMarkdownExecutor = createPipelineExecutor({
@@ -6647,11 +6654,12 @@
6647
6654
  catch (error) {
6648
6655
  // Note: If we can't write to cache, we'll continue without caching
6649
6656
  // This handles read-only filesystems like Vercel
6650
- if (error instanceof Error && (error.message.includes('EROFS') ||
6651
- error.message.includes('read-only') ||
6652
- error.message.includes('EACCES') ||
6653
- error.message.includes('EPERM') ||
6654
- error.message.includes('ENOENT'))) ;
6657
+ if (error instanceof Error &&
6658
+ (error.message.includes('EROFS') ||
6659
+ error.message.includes('read-only') ||
6660
+ error.message.includes('EACCES') ||
6661
+ error.message.includes('EPERM') ||
6662
+ error.message.includes('ENOENT'))) ;
6655
6663
  else {
6656
6664
  // Re-throw other unexpected errors
6657
6665
  throw error;