@promptbook/cli 0.100.0-8 → 0.100.0

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 (129) hide show
  1. package/README.md +7 -14
  2. package/esm/index.es.js +654 -151
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/color.index.d.ts +50 -0
  5. package/esm/typings/src/_packages/components.index.d.ts +36 -0
  6. package/esm/typings/src/_packages/core.index.d.ts +30 -0
  7. package/esm/typings/src/_packages/types.index.d.ts +38 -0
  8. package/esm/typings/src/book-2.0/agent-source/parseAgentSource.d.ts +30 -0
  9. package/esm/typings/src/book-2.0/agent-source/parseAgentSource.test.d.ts +1 -0
  10. package/esm/typings/src/book-2.0/agent-source/string_book.d.ts +26 -0
  11. package/esm/typings/src/book-2.0/commitments/ACTION/ACTION.d.ts +38 -0
  12. package/esm/typings/src/book-2.0/commitments/FORMAT/FORMAT.d.ts +39 -0
  13. package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/KNOWLEDGE.d.ts +45 -0
  14. package/esm/typings/src/book-2.0/commitments/META_IMAGE/META_IMAGE.d.ts +44 -0
  15. package/esm/typings/src/book-2.0/commitments/META_LINK/META_LINK.d.ts +56 -0
  16. package/esm/typings/src/book-2.0/commitments/MODEL/MODEL.d.ts +39 -0
  17. package/esm/typings/src/book-2.0/commitments/NOTE/NOTE.d.ts +49 -0
  18. package/esm/typings/src/book-2.0/commitments/PERSONA/PERSONA.d.ts +46 -0
  19. package/esm/typings/src/book-2.0/commitments/RULE/RULE.d.ts +44 -0
  20. package/esm/typings/src/book-2.0/commitments/SAMPLE/SAMPLE.d.ts +44 -0
  21. package/esm/typings/src/book-2.0/commitments/STYLE/STYLE.d.ts +38 -0
  22. package/esm/typings/src/book-2.0/commitments/_base/BaseCommitmentDefinition.d.ts +52 -0
  23. package/esm/typings/src/book-2.0/commitments/_base/BookCommitment.d.ts +5 -0
  24. package/esm/typings/src/book-2.0/commitments/_base/CommitmentDefinition.d.ts +48 -0
  25. package/esm/typings/src/book-2.0/commitments/_base/NotYetImplementedCommitmentDefinition.d.ts +22 -0
  26. package/esm/typings/src/book-2.0/commitments/_base/createEmptyAgentModelRequirements.d.ts +19 -0
  27. package/esm/typings/src/book-2.0/commitments/_misc/AgentModelRequirements.d.ts +37 -0
  28. package/esm/typings/src/book-2.0/commitments/_misc/AgentSourceParseResult.d.ts +18 -0
  29. package/esm/typings/src/book-2.0/commitments/_misc/ParsedCommitment.d.ts +22 -0
  30. package/esm/typings/src/book-2.0/commitments/_misc/createAgentModelRequirements.d.ts +62 -0
  31. package/esm/typings/src/book-2.0/commitments/_misc/createAgentModelRequirementsWithCommitments.d.ts +36 -0
  32. package/esm/typings/src/book-2.0/commitments/_misc/createCommitmentRegex.d.ts +20 -0
  33. package/esm/typings/src/book-2.0/commitments/_misc/parseAgentSourceWithCommitments.d.ts +24 -0
  34. package/esm/typings/src/book-2.0/commitments/_misc/removeCommentsFromSystemMessage.d.ts +11 -0
  35. package/esm/typings/src/book-2.0/commitments/index.d.ts +56 -0
  36. package/esm/typings/src/book-2.0/utils/profileImageUtils.d.ts +39 -0
  37. package/esm/typings/src/book-components/AvatarProfile/AvatarChip/AvatarChip.d.ts +35 -0
  38. package/esm/typings/src/book-components/AvatarProfile/AvatarChip/AvatarChipFromSource.d.ts +21 -0
  39. package/esm/typings/src/book-components/AvatarProfile/AvatarChip/index.d.ts +2 -0
  40. package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.d.ts +26 -0
  41. package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfileFromSource.d.ts +19 -0
  42. package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +35 -0
  43. package/esm/typings/src/book-components/BookEditor/BookEditorInner.d.ts +15 -0
  44. package/esm/typings/src/book-components/BookEditor/config.d.ts +10 -0
  45. package/esm/typings/src/book-components/BookEditor/injectCssModuleIntoShadowRoot.d.ts +11 -0
  46. package/esm/typings/src/book-components/Chat/Chat/Chat.d.ts +20 -0
  47. package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +110 -0
  48. package/esm/typings/src/book-components/Chat/LlmChat/LlmChat.d.ts +14 -0
  49. package/esm/typings/src/book-components/Chat/LlmChat/LlmChat.test.d.ts +1 -0
  50. package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +24 -0
  51. package/esm/typings/src/book-components/Chat/types/ChatMessage.d.ts +16 -0
  52. package/esm/typings/src/book-components/Chat/types/ChatParticipant.d.ts +32 -0
  53. package/esm/typings/src/book-components/Chat/utils/ChatPersistence.d.ts +25 -0
  54. package/esm/typings/src/book-components/Chat/utils/ExportFormat.d.ts +4 -0
  55. package/esm/typings/src/book-components/Chat/utils/addUtmParamsToUrl.d.ts +7 -0
  56. package/esm/typings/src/book-components/Chat/utils/createShortLinkForChat.d.ts +7 -0
  57. package/esm/typings/src/book-components/Chat/utils/downloadFile.d.ts +6 -0
  58. package/esm/typings/src/book-components/Chat/utils/exportChatHistory.d.ts +9 -0
  59. package/esm/typings/src/book-components/Chat/utils/generatePdfContent.d.ts +8 -0
  60. package/esm/typings/src/book-components/Chat/utils/generateQrDataUrl.d.ts +7 -0
  61. package/esm/typings/src/book-components/Chat/utils/getPromptbookBranding.d.ts +6 -0
  62. package/esm/typings/src/book-components/Chat/utils/messagesToHtml.d.ts +8 -0
  63. package/esm/typings/src/book-components/Chat/utils/messagesToJson.d.ts +7 -0
  64. package/esm/typings/src/book-components/Chat/utils/messagesToMarkdown.d.ts +8 -0
  65. package/esm/typings/src/book-components/Chat/utils/messagesToText.d.ts +8 -0
  66. package/esm/typings/src/book-components/_common/react-utils/classNames.d.ts +7 -0
  67. package/esm/typings/src/book-components/_common/react-utils/collectCssTextsForClass.d.ts +7 -0
  68. package/esm/typings/src/book-components/_common/react-utils/escapeHtml.d.ts +6 -0
  69. package/esm/typings/src/book-components/_common/react-utils/escapeRegex.d.ts +6 -0
  70. package/esm/typings/src/config.d.ts +19 -0
  71. package/esm/typings/src/execution/AvailableModel.d.ts +4 -0
  72. package/esm/typings/src/execution/ExecutionTask.d.ts +27 -1
  73. package/esm/typings/src/execution/LlmExecutionTools.d.ts +8 -0
  74. package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +6 -1
  75. package/esm/typings/src/llm-providers/_common/filterModels.d.ts +0 -3
  76. package/esm/typings/src/llm-providers/_common/profiles/llmProviderProfiles.d.ts +81 -0
  77. package/esm/typings/src/llm-providers/_common/profiles/test/llmProviderProfiles.test.d.ts +1 -0
  78. package/esm/typings/src/llm-providers/_multiple/MultipleLlmExecutionTools.d.ts +5 -0
  79. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +5 -5
  80. package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
  81. package/esm/typings/src/llm-providers/deepseek/deepseek-models.d.ts +1 -1
  82. package/esm/typings/src/llm-providers/google/google-models.d.ts +1 -1
  83. package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +5 -0
  84. package/esm/typings/src/llm-providers/ollama/ollama-models.d.ts +1 -1
  85. package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +8 -0
  86. package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +5 -0
  87. package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
  88. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +5 -0
  89. package/esm/typings/src/pipeline/book-notation.d.ts +2 -1
  90. package/esm/typings/src/playground/permanent/error-handling-playground.d.ts +5 -0
  91. package/esm/typings/src/types/ModelRequirements.d.ts +0 -2
  92. package/esm/typings/src/types/typeAliases.d.ts +6 -0
  93. package/esm/typings/src/utils/color/$randomColor.d.ts +11 -0
  94. package/esm/typings/src/utils/color/Color.d.ts +180 -0
  95. package/esm/typings/src/utils/color/css-colors.d.ts +159 -0
  96. package/esm/typings/src/utils/color/internal-utils/checkChannelValue.d.ts +14 -0
  97. package/esm/typings/src/utils/color/internal-utils/hslToRgb.d.ts +17 -0
  98. package/esm/typings/src/utils/color/internal-utils/rgbToHsl.d.ts +17 -0
  99. package/esm/typings/src/utils/color/operators/ColorTransformer.d.ts +5 -0
  100. package/esm/typings/src/utils/color/operators/darken.d.ts +9 -0
  101. package/esm/typings/src/utils/color/operators/furthest.d.ts +16 -0
  102. package/esm/typings/src/utils/color/operators/grayscale.d.ts +9 -0
  103. package/esm/typings/src/utils/color/operators/lighten.d.ts +12 -0
  104. package/esm/typings/src/utils/color/operators/mixWithColor.d.ts +11 -0
  105. package/esm/typings/src/utils/color/operators/nearest.d.ts +10 -0
  106. package/esm/typings/src/utils/color/operators/negative.d.ts +7 -0
  107. package/esm/typings/src/utils/color/operators/negativeLightness.d.ts +7 -0
  108. package/esm/typings/src/utils/color/operators/withAlpha.d.ts +9 -0
  109. package/esm/typings/src/utils/color/utils/areColorsEqual.d.ts +14 -0
  110. package/esm/typings/src/utils/color/utils/colorDistance.d.ts +21 -0
  111. package/esm/typings/src/utils/color/utils/colorHue.d.ts +11 -0
  112. package/esm/typings/src/utils/color/utils/colorHueDistance.d.ts +11 -0
  113. package/esm/typings/src/utils/color/utils/colorHueDistance.test.d.ts +1 -0
  114. package/esm/typings/src/utils/color/utils/colorLuminance.d.ts +9 -0
  115. package/esm/typings/src/utils/color/utils/colorSatulightion.d.ts +7 -0
  116. package/esm/typings/src/utils/color/utils/colorSaturation.d.ts +9 -0
  117. package/esm/typings/src/utils/color/utils/colorToDataUrl.d.ts +10 -0
  118. package/esm/typings/src/utils/color/utils/mixColors.d.ts +11 -0
  119. package/esm/typings/src/utils/organization/preserve.d.ts +21 -0
  120. package/esm/typings/src/utils/take/classes/TakeChain.d.ts +11 -0
  121. package/esm/typings/src/utils/take/interfaces/ITakeChain.d.ts +12 -0
  122. package/esm/typings/src/utils/take/interfaces/Takeable.d.ts +7 -0
  123. package/esm/typings/src/utils/take/take.d.ts +12 -0
  124. package/esm/typings/src/utils/take/take.test.d.ts +1 -0
  125. package/esm/typings/src/version.d.ts +1 -1
  126. package/package.json +1 -2
  127. package/umd/index.umd.js +658 -155
  128. package/umd/index.umd.js.map +1 -1
  129. package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +0 -14
package/umd/index.umd.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('colors'), require('commander'), require('spacetrim'), require('waitasecond'), require('prompts'), require('path'), require('fs/promises'), require('dotenv'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('crypto'), require('socket.io-client'), require('rxjs'), require('child_process'), require('jszip'), require('prettier'), require('prettier/parser-html'), require('papaparse'), require('crypto-js'), require('mime-types'), require('glob-promise'), require('moment'), require('express'), require('express-openapi-validator'), require('http'), require('socket.io'), require('swagger-ui-express'), require('@anthropic-ai/sdk'), require('bottleneck'), require('@azure/openai'), require('openai'), require('@mozilla/readability'), require('jsdom'), require('showdown')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'colors', 'commander', 'spacetrim', 'waitasecond', 'prompts', 'path', 'fs/promises', 'dotenv', 'crypto-js/enc-hex', 'crypto-js/sha256', 'crypto', 'socket.io-client', 'rxjs', 'child_process', 'jszip', 'prettier', 'prettier/parser-html', 'papaparse', 'crypto-js', 'mime-types', 'glob-promise', 'moment', 'express', 'express-openapi-validator', 'http', 'socket.io', 'swagger-ui-express', '@anthropic-ai/sdk', 'bottleneck', '@azure/openai', 'openai', '@mozilla/readability', 'jsdom', 'showdown'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-cli"] = {}, global.colors, global.commander, global.spaceTrim, global.waitasecond, global.prompts, global.path, global.promises, global.dotenv, global.hexEncoder, global.sha256, global.crypto, global.socket_ioClient, global.rxjs, global.child_process, global.JSZip, global.prettier, global.parserHtml, global.papaparse, global.cryptoJs, global.mimeTypes, global.glob, global.moment, global.express, global.OpenApiValidator, global.http, global.socket_io, global.swaggerUi, global.Anthropic, global.Bottleneck, global.openai, global.OpenAI, global.readability, global.jsdom, global.showdown));
5
- })(this, (function (exports, colors, commander, spaceTrim, waitasecond, prompts, path, promises, dotenv, hexEncoder, sha256, crypto, socket_ioClient, rxjs, child_process, JSZip, prettier, parserHtml, papaparse, cryptoJs, mimeTypes, glob, moment, express, OpenApiValidator, http, socket_io, swaggerUi, Anthropic, Bottleneck, openai, OpenAI, readability, jsdom, showdown) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('colors'), require('commander'), require('spacetrim'), require('waitasecond'), require('prompts'), require('path'), require('fs/promises'), require('dotenv'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('crypto'), require('socket.io-client'), require('rxjs'), require('child_process'), require('jszip'), require('prettier/parser-html'), require('prettier/parser-markdown'), require('prettier/standalone'), require('papaparse'), require('crypto-js'), require('mime-types'), require('glob-promise'), require('moment'), require('express'), require('express-openapi-validator'), require('http'), require('socket.io'), require('swagger-ui-express'), require('@anthropic-ai/sdk'), require('bottleneck'), require('@azure/openai'), require('openai'), require('@mozilla/readability'), require('jsdom'), require('showdown')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'colors', 'commander', 'spacetrim', 'waitasecond', 'prompts', 'path', 'fs/promises', 'dotenv', 'crypto-js/enc-hex', 'crypto-js/sha256', 'crypto', 'socket.io-client', 'rxjs', 'child_process', 'jszip', 'prettier/parser-html', 'prettier/parser-markdown', 'prettier/standalone', 'papaparse', 'crypto-js', 'mime-types', 'glob-promise', 'moment', 'express', 'express-openapi-validator', 'http', 'socket.io', 'swagger-ui-express', '@anthropic-ai/sdk', 'bottleneck', '@azure/openai', 'openai', '@mozilla/readability', 'jsdom', 'showdown'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-cli"] = {}, global.colors, global.commander, global.spaceTrim, global.waitasecond, global.prompts, global.path, global.promises, global.dotenv, global.hexEncoder, global.sha256, global.crypto, global.socket_ioClient, global.rxjs, global.child_process, global.JSZip, global.parserHtml, global.parserMarkdown, global.standalone, global.papaparse, global.cryptoJs, global.mimeTypes, global.glob, global.moment, global.express, global.OpenApiValidator, global.http, global.socket_io, global.swaggerUi, global.Anthropic, global.Bottleneck, global.openai, global.OpenAI, global.readability, global.jsdom, global.showdown));
5
+ })(this, (function (exports, colors, commander, spaceTrim, waitasecond, prompts, path, promises, dotenv, hexEncoder, sha256, crypto, socket_ioClient, rxjs, child_process, JSZip, parserHtml, parserMarkdown, standalone, papaparse, cryptoJs, mimeTypes, glob, moment, express, OpenApiValidator, http, socket_io, swaggerUi, Anthropic, Bottleneck, openai, OpenAI, readability, jsdom, showdown) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -33,6 +33,7 @@
33
33
  var sha256__default = /*#__PURE__*/_interopDefaultLegacy(sha256);
34
34
  var JSZip__default = /*#__PURE__*/_interopDefaultLegacy(JSZip);
35
35
  var parserHtml__default = /*#__PURE__*/_interopDefaultLegacy(parserHtml);
36
+ var parserMarkdown__default = /*#__PURE__*/_interopDefaultLegacy(parserMarkdown);
36
37
  var glob__default = /*#__PURE__*/_interopDefaultLegacy(glob);
37
38
  var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
38
39
  var express__default = /*#__PURE__*/_interopDefaultLegacy(express);
@@ -57,7 +58,7 @@
57
58
  * @generated
58
59
  * @see https://github.com/webgptorg/promptbook
59
60
  */
60
- const PROMPTBOOK_ENGINE_VERSION = '0.100.0-8';
61
+ const PROMPTBOOK_ENGINE_VERSION = '0.100.0';
61
62
  /**
62
63
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
63
64
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -366,6 +367,12 @@
366
367
  * @public exported from `@promptbook/core`
367
368
  */
368
369
  const DEFAULT_IS_AUTO_INSTALLED = false;
370
+ /**
371
+ * Default simulated duration for a task in milliseconds (used for progress reporting)
372
+ *
373
+ * @public exported from `@promptbook/core`
374
+ */
375
+ const DEFAULT_TASK_SIMULATED_DURATION_MS = 5 * 60 * 1000; // 5 minutes
369
376
  /**
370
377
  * Function name for generated function via `ptbk make` to get the pipeline collection
371
378
  *
@@ -380,6 +387,13 @@
380
387
  * @public exported from `@promptbook/core`
381
388
  */
382
389
  const DEFAULT_MAX_REQUESTS_PER_MINUTE = 60;
390
+ /**
391
+ * API request timeout in milliseconds
392
+ * Can be overridden via API_REQUEST_TIMEOUT environment variable
393
+ *
394
+ * @public exported from `@promptbook/core`
395
+ */
396
+ const API_REQUEST_TIMEOUT = parseInt(process.env.API_REQUEST_TIMEOUT || '90000');
383
397
  /**
384
398
  * Indicates whether pipeline logic validation is enabled. When true, the pipeline logic is checked for consistency.
385
399
  *
@@ -2553,6 +2567,76 @@
2553
2567
  return deserializedError;
2554
2568
  }
2555
2569
 
2570
+ /**
2571
+ * Predefined profiles for LLM providers to maintain consistency across the application
2572
+ * These profiles represent each provider as a virtual persona in chat interfaces
2573
+ *
2574
+ * @private !!!!
2575
+ */
2576
+ const LLM_PROVIDER_PROFILES = {
2577
+ OPENAI: {
2578
+ name: 'OPENAI',
2579
+ fullname: 'OpenAI GPT',
2580
+ color: '#10a37f', // OpenAI's signature green
2581
+ // Note: avatarSrc could be added when we have provider logos available
2582
+ },
2583
+ ANTHROPIC: {
2584
+ name: 'ANTHROPIC',
2585
+ fullname: 'Anthropic Claude',
2586
+ color: '#d97706', // Anthropic's orange/amber color
2587
+ },
2588
+ AZURE_OPENAI: {
2589
+ name: 'AZURE_OPENAI',
2590
+ fullname: 'Azure OpenAI',
2591
+ color: '#0078d4', // Microsoft Azure blue
2592
+ },
2593
+ GOOGLE: {
2594
+ name: 'GOOGLE',
2595
+ fullname: 'Google Gemini',
2596
+ color: '#4285f4', // Google blue
2597
+ },
2598
+ DEEPSEEK: {
2599
+ name: 'DEEPSEEK',
2600
+ fullname: 'DeepSeek',
2601
+ color: '#7c3aed', // Purple color for DeepSeek
2602
+ },
2603
+ OLLAMA: {
2604
+ name: 'OLLAMA',
2605
+ fullname: 'Ollama',
2606
+ color: '#059669', // Emerald green for local models
2607
+ },
2608
+ REMOTE: {
2609
+ name: 'REMOTE',
2610
+ fullname: 'Remote Server',
2611
+ color: '#6b7280', // Gray for remote/proxy connections
2612
+ },
2613
+ MOCKED_ECHO: {
2614
+ name: 'MOCKED_ECHO',
2615
+ fullname: 'Echo (Test)',
2616
+ color: '#8b5cf6', // Purple for test/mock tools
2617
+ },
2618
+ MOCKED_FAKE: {
2619
+ name: 'MOCKED_FAKE',
2620
+ fullname: 'Fake LLM (Test)',
2621
+ color: '#ec4899', // Pink for fake/test tools
2622
+ },
2623
+ VERCEL: {
2624
+ name: 'VERCEL',
2625
+ fullname: 'Vercel AI',
2626
+ color: '#000000', // Vercel's black
2627
+ },
2628
+ MULTIPLE: {
2629
+ name: 'MULTIPLE',
2630
+ fullname: 'Multiple Providers',
2631
+ color: '#6366f1', // Indigo for combined/multiple providers
2632
+ },
2633
+ };
2634
+ /**
2635
+ * TODO: Refactor this - each profile must be alongside the provider definition
2636
+ * TODO: Unite `AvatarProfileProps` and `ChatParticipant`
2637
+ * Note: [💞] Ignore a discrepancy between file name and entity name
2638
+ */
2639
+
2556
2640
  /**
2557
2641
  * Creates a connection to the remote proxy server.
2558
2642
  *
@@ -2620,6 +2704,9 @@
2620
2704
  get description() {
2621
2705
  return `Models from Promptbook remote server ${this.options.remoteServerUrl}`;
2622
2706
  }
2707
+ get profile() {
2708
+ return LLM_PROVIDER_PROFILES.REMOTE;
2709
+ }
2623
2710
  /**
2624
2711
  * Check the configuration of all execution tools
2625
2712
  */
@@ -3560,7 +3647,7 @@
3560
3647
  }
3561
3648
  return spaceTrim__default["default"]((block) => `
3562
3649
  ${headLine}
3563
-
3650
+
3564
3651
  ${ /* <- Note: Indenting the description: */block(description)}
3565
3652
  `);
3566
3653
  })
@@ -3571,6 +3658,9 @@
3571
3658
  ${block(innerModelsTitlesAndDescriptions)}
3572
3659
  `);
3573
3660
  }
3661
+ get profile() {
3662
+ return LLM_PROVIDER_PROFILES.MULTIPLE;
3663
+ }
3574
3664
  /**
3575
3665
  * Check the configuration of all execution tools
3576
3666
  */
@@ -3615,25 +3705,22 @@
3615
3705
  const errors = [];
3616
3706
  llm: for (const llmExecutionTools of this.llmExecutionTools) {
3617
3707
  try {
3618
- variant: switch (prompt.modelRequirements.modelVariant) {
3708
+ switch (prompt.modelRequirements.modelVariant) {
3619
3709
  case 'CHAT':
3620
3710
  if (llmExecutionTools.callChatModel === undefined) {
3621
3711
  continue llm;
3622
3712
  }
3623
3713
  return await llmExecutionTools.callChatModel(prompt);
3624
- break variant;
3625
3714
  case 'COMPLETION':
3626
3715
  if (llmExecutionTools.callCompletionModel === undefined) {
3627
3716
  continue llm;
3628
3717
  }
3629
3718
  return await llmExecutionTools.callCompletionModel(prompt);
3630
- break variant;
3631
3719
  case 'EMBEDDING':
3632
3720
  if (llmExecutionTools.callEmbeddingModel === undefined) {
3633
3721
  continue llm;
3634
3722
  }
3635
3723
  return await llmExecutionTools.callEmbeddingModel(prompt);
3636
- break variant;
3637
3724
  // <- case [🤖]:
3638
3725
  default:
3639
3726
  throw new UnexpectedError(`Unknown model variant "${prompt.modelRequirements.modelVariant}"`);
@@ -5133,9 +5220,9 @@
5133
5220
  */
5134
5221
  function prettifyMarkdown(content) {
5135
5222
  try {
5136
- return prettier.format(content, {
5223
+ return standalone.format(content, {
5137
5224
  parser: 'markdown',
5138
- plugins: [parserHtml__default["default"]],
5225
+ plugins: [parserMarkdown__default["default"], parserHtml__default["default"]],
5139
5226
  // TODO: DRY - make some import or auto-copy of .prettierrc
5140
5227
  endOfLine: 'lf',
5141
5228
  tabWidth: 4,
@@ -5607,6 +5694,7 @@
5607
5694
  const errors = [];
5608
5695
  const warnings = [];
5609
5696
  let currentValue = {};
5697
+ let customTldr = null;
5610
5698
  const partialResultSubject = new rxjs.Subject();
5611
5699
  // <- Note: Not using `BehaviorSubject` because on error we can't access the last value
5612
5700
  const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
@@ -5617,6 +5705,9 @@
5617
5705
  Object.assign(currentValue, newOngoingResult);
5618
5706
  // <- TODO: assign deep
5619
5707
  partialResultSubject.next(newOngoingResult);
5708
+ }, (tldrInfo) => {
5709
+ customTldr = tldrInfo;
5710
+ updatedAt = new Date();
5620
5711
  });
5621
5712
  finalResultPromise
5622
5713
  .catch((error) => {
@@ -5670,6 +5761,78 @@
5670
5761
  return status;
5671
5762
  // <- Note: [1] --||--
5672
5763
  },
5764
+ get tldr() {
5765
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
5766
+ // Use custom tldr if available
5767
+ if (customTldr) {
5768
+ return customTldr;
5769
+ }
5770
+ // Fallback to default implementation
5771
+ const cv = currentValue;
5772
+ // If explicit percent is provided, use it
5773
+ let percentRaw = (_f = (_d = (_b = (_a = cv === null || cv === void 0 ? void 0 : cv.tldr) === null || _a === void 0 ? void 0 : _a.percent) !== null && _b !== void 0 ? _b : (_c = cv === null || cv === void 0 ? void 0 : cv.usage) === null || _c === void 0 ? void 0 : _c.percent) !== null && _d !== void 0 ? _d : (_e = cv === null || cv === void 0 ? void 0 : cv.progress) === null || _e === void 0 ? void 0 : _e.percent) !== null && _f !== void 0 ? _f : cv === null || cv === void 0 ? void 0 : cv.percent;
5774
+ // Simulate progress if not provided
5775
+ if (typeof percentRaw !== 'number') {
5776
+ // Simulate progress: evenly split across subtasks, based on elapsed time
5777
+ const now = new Date();
5778
+ const elapsedMs = now.getTime() - createdAt.getTime();
5779
+ const totalMs = DEFAULT_TASK_SIMULATED_DURATION_MS;
5780
+ // If subtasks are defined, split progress evenly
5781
+ const subtaskCount = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) ? cv.subtasks.length : 1;
5782
+ const completedSubtasks = Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks)
5783
+ ? cv.subtasks.filter((s) => s.done || s.completed).length
5784
+ : 0;
5785
+ // Progress from completed subtasks
5786
+ const subtaskProgress = subtaskCount > 0 ? completedSubtasks / subtaskCount : 0;
5787
+ // Progress from elapsed time for current subtask
5788
+ const timeProgress = Math.min(elapsedMs / totalMs, 1);
5789
+ // Combine: completed subtasks + time progress for current subtask
5790
+ percentRaw = Math.min(subtaskProgress + (1 / subtaskCount) * timeProgress, 1);
5791
+ if (status === 'FINISHED')
5792
+ percentRaw = 1;
5793
+ if (status === 'ERROR')
5794
+ percentRaw = 0;
5795
+ }
5796
+ // Clamp to [0,1]
5797
+ let percent = Number(percentRaw) || 0;
5798
+ if (percent < 0)
5799
+ percent = 0;
5800
+ if (percent > 1)
5801
+ percent = 1;
5802
+ // Build a short message: prefer explicit tldr.message, then common summary/message fields, then errors/warnings, then status
5803
+ const messageFromResult = (_k = (_j = (_h = (_g = cv === null || cv === void 0 ? void 0 : cv.tldr) === null || _g === void 0 ? void 0 : _g.message) !== null && _h !== void 0 ? _h : cv === null || cv === void 0 ? void 0 : cv.message) !== null && _j !== void 0 ? _j : cv === null || cv === void 0 ? void 0 : cv.summary) !== null && _k !== void 0 ? _k : cv === null || cv === void 0 ? void 0 : cv.statusMessage;
5804
+ let message = messageFromResult;
5805
+ if (!message) {
5806
+ // If subtasks, show current subtask
5807
+ if (Array.isArray(cv === null || cv === void 0 ? void 0 : cv.subtasks) && cv.subtasks.length > 0) {
5808
+ const current = cv.subtasks.find((s) => !s.done && !s.completed);
5809
+ if (current && current.title) {
5810
+ message = `Working on ${current.title}`;
5811
+ }
5812
+ }
5813
+ if (!message) {
5814
+ if (errors.length) {
5815
+ message = errors[errors.length - 1].message || 'Error';
5816
+ }
5817
+ else if (warnings.length) {
5818
+ message = warnings[warnings.length - 1].message || 'Warning';
5819
+ }
5820
+ else if (status === 'FINISHED') {
5821
+ message = 'Finished';
5822
+ }
5823
+ else if (status === 'ERROR') {
5824
+ message = 'Error';
5825
+ }
5826
+ else {
5827
+ message = 'Running';
5828
+ }
5829
+ }
5830
+ }
5831
+ return {
5832
+ percent: percent,
5833
+ message,
5834
+ };
5835
+ },
5673
5836
  get createdAt() {
5674
5837
  return createdAt;
5675
5838
  // <- Note: [1] --||--
@@ -6403,7 +6566,7 @@
6403
6566
  */
6404
6567
  async function executeAttempts(options) {
6405
6568
  const { jokerParameterNames, priority, maxAttempts, // <- Note: [💂]
6406
- preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, } = options;
6569
+ preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, } = options;
6407
6570
  const $ongoingTaskResult = {
6408
6571
  $result: null,
6409
6572
  $resultString: null,
@@ -6647,6 +6810,10 @@
6647
6810
  result: $ongoingTaskResult.$resultString,
6648
6811
  error: error,
6649
6812
  });
6813
+ // Report failed attempt
6814
+ onProgress({
6815
+ errors: [error],
6816
+ });
6650
6817
  }
6651
6818
  finally {
6652
6819
  if (!isJokerAttempt &&
@@ -7520,15 +7687,74 @@
7520
7687
  });
7521
7688
  });
7522
7689
  };
7523
- const pipelineExecutor = (inputParameters) => createTask({
7524
- taskType: 'EXECUTION',
7525
- title: pipeline.title,
7526
- taskProcessCallback(updateOngoingResult) {
7527
- return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
7528
- updateOngoingResult(newOngoingResult);
7529
- });
7530
- },
7531
- });
7690
+ const pipelineExecutor = (inputParameters) => {
7691
+ const startTime = new Date().getTime();
7692
+ return createTask({
7693
+ taskType: 'EXECUTION',
7694
+ title: pipeline.title,
7695
+ taskProcessCallback(updateOngoingResult, updateTldr) {
7696
+ return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
7697
+ var _a, _b;
7698
+ updateOngoingResult(newOngoingResult);
7699
+ // Calculate and update tldr based on pipeline progress
7700
+ const cv = newOngoingResult;
7701
+ // Calculate progress based on parameters resolved vs total parameters
7702
+ const totalParameters = pipeline.parameters.filter(p => !p.isInput).length;
7703
+ let resolvedParameters = 0;
7704
+ let currentTaskTitle = '';
7705
+ // Get the resolved parameters from output parameters
7706
+ if (cv === null || cv === void 0 ? void 0 : cv.outputParameters) {
7707
+ // Count how many output parameters have non-empty values
7708
+ resolvedParameters = Object.values(cv.outputParameters).filter(value => value !== undefined && value !== null && String(value).trim() !== '').length;
7709
+ }
7710
+ // Try to determine current task from execution report
7711
+ if (((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) && cv.executionReport.promptExecutions.length > 0) {
7712
+ const lastExecution = cv.executionReport.promptExecutions[cv.executionReport.promptExecutions.length - 1];
7713
+ if ((_b = lastExecution === null || lastExecution === void 0 ? void 0 : lastExecution.prompt) === null || _b === void 0 ? void 0 : _b.title) {
7714
+ currentTaskTitle = lastExecution.prompt.title;
7715
+ }
7716
+ }
7717
+ // Calculate base progress percentage
7718
+ let percent = totalParameters > 0 ? resolvedParameters / totalParameters : 0;
7719
+ // Add time-based progress for current task if we haven't completed all parameters
7720
+ if (resolvedParameters < totalParameters) {
7721
+ const elapsedMs = new Date().getTime() - startTime;
7722
+ const estimatedTotalMs = totalParameters * 30 * 1000; // Estimate 30 seconds per parameter
7723
+ const timeProgress = Math.min(elapsedMs / estimatedTotalMs, 0.9); // Cap at 90% for time-based progress
7724
+ // If we have time progress but no parameter progress, show time progress
7725
+ if (percent === 0 && timeProgress > 0) {
7726
+ percent = Math.min(timeProgress, 0.1); // Show some progress but not more than 10%
7727
+ }
7728
+ else if (percent < 1) {
7729
+ // Add partial progress for current task
7730
+ const taskProgress = totalParameters > 0 ? (1 / totalParameters) * 0.5 : 0; // 50% of task progress
7731
+ percent = Math.min(percent + taskProgress, 0.95); // Cap at 95% until fully complete
7732
+ }
7733
+ }
7734
+ // Clamp to [0,1]
7735
+ percent = Math.min(Math.max(percent, 0), 1);
7736
+ // Generate message
7737
+ let message = '';
7738
+ if (currentTaskTitle) {
7739
+ message = `Executing: ${currentTaskTitle}`;
7740
+ }
7741
+ else if (resolvedParameters === 0) {
7742
+ message = 'Starting pipeline execution';
7743
+ }
7744
+ else if (resolvedParameters < totalParameters) {
7745
+ message = `Processing pipeline (${resolvedParameters}/${totalParameters} parameters resolved)`;
7746
+ }
7747
+ else {
7748
+ message = 'Completing pipeline execution';
7749
+ }
7750
+ updateTldr({
7751
+ percent: percent,
7752
+ message,
7753
+ });
7754
+ });
7755
+ },
7756
+ });
7757
+ };
7532
7758
  // <- TODO: Make types such as there is no need to do `as` for `createTask`
7533
7759
  return pipelineExecutor;
7534
7760
  }
@@ -7591,7 +7817,7 @@
7591
7817
  const result = await preparePersonaExecutor({
7592
7818
  availableModels /* <- Note: Passing as JSON */,
7593
7819
  personaDescription,
7594
- }).asPromise();
7820
+ }).asPromise({ isCrashedOnError: true });
7595
7821
  const { outputParameters } = result;
7596
7822
  const { modelsRequirements: modelsRequirementsJson } = outputParameters;
7597
7823
  let modelsRequirementsUnchecked = jsonParse(modelsRequirementsJson);
@@ -8084,7 +8310,7 @@
8084
8310
  });
8085
8311
  const result = await prepareTitleExecutor({
8086
8312
  book: sources.map(({ content }) => content).join('\n\n'),
8087
- }).asPromise();
8313
+ }).asPromise({ isCrashedOnError: true });
8088
8314
  const { outputParameters } = result;
8089
8315
  const { title: titleRaw } = outputParameters;
8090
8316
  if (isVerbose) {
@@ -11999,31 +12225,23 @@
11999
12225
  return content;
12000
12226
  }
12001
12227
 
12228
+ /**
12229
+ * @private internal for `preserve`
12230
+ */
12231
+ const _preserved = [];
12002
12232
  /**
12003
12233
  * Does nothing, but preserves the function in the bundle
12004
12234
  * Compiler is tricked into thinking the function is used
12005
12235
  *
12006
12236
  * @param value any function to preserve
12007
12237
  * @returns nothing
12008
- * @private internal function of `JavascriptExecutionTools` and `JavascriptEvalExecutionTools`
12009
- */
12010
- function preserve(func) {
12011
- // Note: NOT calling the function
12012
- (async () => {
12013
- // TODO: [💩] Change to `await forEver` or `forTime(Infinity)`
12014
- await waitasecond.forTime(100000000);
12015
- // [1]
12016
- try {
12017
- await func();
12018
- }
12019
- finally {
12020
- // do nothing
12021
- }
12022
- })();
12238
+ * @private within the repository
12239
+ */
12240
+ function $preserve(...value) {
12241
+ _preserved.push(...value);
12023
12242
  }
12024
12243
  /**
12025
- * TODO: Probably remove in favour of `keepImported`
12026
- * TODO: [1] This maybe does memory leak
12244
+ * Note: [💞] Ignore a discrepancy between file name and entity name
12027
12245
  */
12028
12246
 
12029
12247
  // Note: [💎]
@@ -12051,25 +12269,25 @@
12051
12269
  // Note: [💎]
12052
12270
  // Note: Using direct eval, following variables are in same scope as eval call so they are accessible from inside the evaluated script:
12053
12271
  const spaceTrim = (_) => spaceTrim__default["default"](_);
12054
- preserve(spaceTrim);
12272
+ $preserve(spaceTrim);
12055
12273
  const removeQuotes$1 = removeQuotes;
12056
- preserve(removeQuotes$1);
12274
+ $preserve(removeQuotes$1);
12057
12275
  const unwrapResult$1 = unwrapResult;
12058
- preserve(unwrapResult$1);
12276
+ $preserve(unwrapResult$1);
12059
12277
  const trimEndOfCodeBlock$1 = trimEndOfCodeBlock;
12060
- preserve(trimEndOfCodeBlock$1);
12278
+ $preserve(trimEndOfCodeBlock$1);
12061
12279
  const trimCodeBlock$1 = trimCodeBlock;
12062
- preserve(trimCodeBlock$1);
12280
+ $preserve(trimCodeBlock$1);
12063
12281
  // TODO: DRY [🍯]
12064
12282
  const trim = (str) => str.trim();
12065
- preserve(trim);
12283
+ $preserve(trim);
12066
12284
  // TODO: DRY [🍯]
12067
12285
  const reverse = (str) => str.split('').reverse().join('');
12068
- preserve(reverse);
12286
+ $preserve(reverse);
12069
12287
  const removeEmojis$1 = removeEmojis;
12070
- preserve(removeEmojis$1);
12288
+ $preserve(removeEmojis$1);
12071
12289
  const prettifyMarkdown$1 = prettifyMarkdown;
12072
- preserve(prettifyMarkdown$1);
12290
+ $preserve(prettifyMarkdown$1);
12073
12291
  //-------[n12:]---
12074
12292
  const capitalize$1 = capitalize;
12075
12293
  const decapitalize$1 = decapitalize;
@@ -12085,18 +12303,18 @@
12085
12303
  // TODO: DRY [🍯]
12086
12304
  Array.from(parseKeywordsFromString(input)).join(', '); /* <- TODO: [🧠] What is the best format comma list, bullet list,...? */
12087
12305
  const normalizeTo_SCREAMING_CASE$1 = normalizeTo_SCREAMING_CASE;
12088
- preserve(capitalize$1);
12089
- preserve(decapitalize$1);
12090
- preserve(nameToUriPart$1);
12091
- preserve(nameToUriParts$1);
12092
- preserve(removeDiacritics$1);
12093
- preserve(normalizeWhitespaces$1);
12094
- preserve(normalizeToKebabCase$1);
12095
- preserve(normalizeTo_camelCase$1);
12096
- preserve(normalizeTo_snake_case$1);
12097
- preserve(normalizeTo_PascalCase$1);
12098
- preserve(parseKeywords);
12099
- preserve(normalizeTo_SCREAMING_CASE$1);
12306
+ $preserve(capitalize$1);
12307
+ $preserve(decapitalize$1);
12308
+ $preserve(nameToUriPart$1);
12309
+ $preserve(nameToUriParts$1);
12310
+ $preserve(removeDiacritics$1);
12311
+ $preserve(normalizeWhitespaces$1);
12312
+ $preserve(normalizeToKebabCase$1);
12313
+ $preserve(normalizeTo_camelCase$1);
12314
+ $preserve(normalizeTo_snake_case$1);
12315
+ $preserve(normalizeTo_PascalCase$1);
12316
+ $preserve(parseKeywords);
12317
+ $preserve(normalizeTo_SCREAMING_CASE$1);
12100
12318
  //-------[/n12]---
12101
12319
  if (!script.includes('return')) {
12102
12320
  script = `return ${script}`;
@@ -13597,7 +13815,7 @@
13597
13815
  previousConversationSummary: conversationSummary,
13598
13816
  userMessage,
13599
13817
  };
13600
- const result = await pipelineExecutor(inputParameters).asPromise();
13818
+ const result = await pipelineExecutor(inputParameters).asPromise({ isCrashedOnError: true });
13601
13819
  console.info(`\n`);
13602
13820
  console.info(spaceTrim__default["default"]((block) => `
13603
13821
 
@@ -14757,7 +14975,7 @@
14757
14975
  });
14758
14976
  function exportExecutionTask(executionTask, isFull) {
14759
14977
  // <- TODO: [🧠] This should be maybe method of `ExecutionTask` itself
14760
- const { taskType, promptbookVersion, taskId, title, status, errors, warnings, createdAt, updatedAt, currentValue, } = executionTask;
14978
+ const { taskType, promptbookVersion, taskId, title, status, errors, tldr, warnings, createdAt, updatedAt, currentValue, } = executionTask;
14761
14979
  if (isFull) {
14762
14980
  return {
14763
14981
  taskId,
@@ -14765,6 +14983,7 @@
14765
14983
  taskType,
14766
14984
  promptbookVersion,
14767
14985
  status,
14986
+ tldr,
14768
14987
  errors: errors.map(serializeError),
14769
14988
  warnings: warnings.map(serializeError),
14770
14989
  createdAt,
@@ -14779,6 +14998,7 @@
14779
14998
  taskType,
14780
14999
  promptbookVersion,
14781
15000
  status,
15001
+ tldr,
14782
15002
  createdAt,
14783
15003
  updatedAt,
14784
15004
  };
@@ -15345,7 +15565,7 @@
15345
15565
  /**
15346
15566
  * List of available Anthropic Claude models with pricing
15347
15567
  *
15348
- * Note: Done at 2025-05-06
15568
+ * Note: Synced with official API docs at 2025-08-20
15349
15569
  *
15350
15570
  * @see https://docs.anthropic.com/en/docs/models-overview
15351
15571
  * @public exported from `@promptbook/anthropic-claude`
@@ -15355,12 +15575,52 @@
15355
15575
  value: [
15356
15576
  {
15357
15577
  modelVariant: 'CHAT',
15358
- modelTitle: 'Claude 3.5 Sonnet',
15359
- modelName: 'claude-3-5-sonnet-20240620',
15360
- modelDescription: 'Latest Claude model with 200K token context window. Features state-of-the-art reasoning capabilities, sophisticated code generation, and enhanced multilingual understanding. Offers superior accuracy with 30% fewer hallucinations than Claude 3 Sonnet. Provides exceptional performance for complex enterprise applications while maintaining fast response times.',
15578
+ modelTitle: 'Claude Opus 4.1',
15579
+ modelName: 'claude-opus-4-1-20250805',
15580
+ modelDescription: 'Most powerful and capable Claude model with 200K token context window. Features superior reasoning capabilities, exceptional coding abilities, and advanced multimodal understanding. Sets new standards in complex reasoning and analytical tasks with enhanced safety measures. Ideal for the most demanding enterprise applications requiring maximum intelligence.',
15361
15581
  pricing: {
15362
- prompt: pricing(`$2.50 / 1M tokens`),
15363
- output: pricing(`$12.50 / 1M tokens`),
15582
+ prompt: pricing(`$15.00 / 1M tokens`),
15583
+ output: pricing(`$75.00 / 1M tokens`),
15584
+ },
15585
+ },
15586
+ {
15587
+ modelVariant: 'CHAT',
15588
+ modelTitle: 'Claude Opus 4',
15589
+ modelName: 'claude-opus-4-20250514',
15590
+ modelDescription: 'Previous flagship Claude model with 200K token context window. Features very high intelligence and capability with exceptional performance across reasoning, coding, and creative tasks. Maintains strong safety guardrails while delivering sophisticated outputs for complex professional applications.',
15591
+ pricing: {
15592
+ prompt: pricing(`$15.00 / 1M tokens`),
15593
+ output: pricing(`$75.00 / 1M tokens`),
15594
+ },
15595
+ },
15596
+ {
15597
+ modelVariant: 'CHAT',
15598
+ modelTitle: 'Claude Sonnet 4',
15599
+ modelName: 'claude-sonnet-4-20250514',
15600
+ modelDescription: 'High-performance Claude model with exceptional reasoning capabilities and 200K token context window (1M context beta available). Features balanced intelligence and efficiency with enhanced multimodal understanding. Offers optimal performance for most enterprise applications requiring sophisticated AI capabilities.',
15601
+ pricing: {
15602
+ prompt: pricing(`$3.00 / 1M tokens`),
15603
+ output: pricing(`$15.00 / 1M tokens`),
15604
+ },
15605
+ },
15606
+ {
15607
+ modelVariant: 'CHAT',
15608
+ modelTitle: 'Claude Sonnet 3.7',
15609
+ modelName: 'claude-3-7-sonnet-20250219',
15610
+ modelDescription: 'High-performance Claude model with early extended thinking capabilities and 200K token context window. Features enhanced reasoning chains, improved factual accuracy, and toggleable extended thinking for complex problem-solving. Ideal for applications requiring deep analytical capabilities.',
15611
+ pricing: {
15612
+ prompt: pricing(`$3.00 / 1M tokens`),
15613
+ output: pricing(`$15.00 / 1M tokens`),
15614
+ },
15615
+ },
15616
+ {
15617
+ modelVariant: 'CHAT',
15618
+ modelTitle: 'Claude Haiku 3.5',
15619
+ modelName: 'claude-3-5-haiku-20241022',
15620
+ modelDescription: 'Fastest Claude model with 200K token context window optimized for intelligence at blazing speeds. Features enhanced reasoning and contextual understanding while maintaining sub-second response times. Perfect for real-time applications, customer-facing deployments, and high-throughput services.',
15621
+ pricing: {
15622
+ prompt: pricing(`$0.80 / 1M tokens`),
15623
+ output: pricing(`$4.00 / 1M tokens`),
15364
15624
  },
15365
15625
  },
15366
15626
  {
@@ -15583,6 +15843,9 @@
15583
15843
  get description() {
15584
15844
  return 'Use all models provided by Anthropic Claude';
15585
15845
  }
15846
+ get profile() {
15847
+ return LLM_PROVIDER_PROFILES.ANTHROPIC;
15848
+ }
15586
15849
  async getClient() {
15587
15850
  if (this.client === null) {
15588
15851
  // Note: Passing only Anthropic Claude relevant options to Anthropic constructor
@@ -15623,8 +15886,7 @@
15623
15886
  const rawPromptContent = templateParameters(content, { ...parameters, modelName });
15624
15887
  const rawRequest = {
15625
15888
  model: modelRequirements.modelName || this.getDefaultChatModel().modelName,
15626
- max_tokens: modelRequirements.maxTokens || 4096,
15627
- // <- TODO: [🌾] Make some global max cap for maxTokens
15889
+ max_tokens: modelRequirements.maxTokens || 8192,
15628
15890
  temperature: modelRequirements.temperature,
15629
15891
  system: modelRequirements.systemMessage,
15630
15892
  messages: [
@@ -15683,59 +15945,6 @@
15683
15945
  },
15684
15946
  });
15685
15947
  }
15686
- /**
15687
- * Calls Anthropic Claude API to use a completion model.
15688
- */
15689
- async callCompletionModel(prompt) {
15690
- if (this.options.isVerbose) {
15691
- console.info('🖋 Anthropic Claude callCompletionModel call');
15692
- }
15693
- const { content, parameters, modelRequirements } = prompt;
15694
- if (modelRequirements.modelVariant !== 'COMPLETION') {
15695
- throw new PipelineExecutionError('Use callCompletionModel only for COMPLETION variant');
15696
- }
15697
- const client = await this.getClient();
15698
- const modelName = modelRequirements.modelName || this.getDefaultChatModel().modelName;
15699
- const rawPromptContent = templateParameters(content, { ...parameters, modelName });
15700
- const rawRequest = {
15701
- model: modelName,
15702
- max_tokens_to_sample: modelRequirements.maxTokens || 2000,
15703
- temperature: modelRequirements.temperature,
15704
- prompt: rawPromptContent,
15705
- };
15706
- const start = $getCurrentDate();
15707
- const rawResponse = await this.limiter
15708
- .schedule(() => client.completions.create(rawRequest))
15709
- .catch((error) => {
15710
- if (this.options.isVerbose) {
15711
- console.info(colors__default["default"].bgRed('error'), error);
15712
- }
15713
- throw error;
15714
- });
15715
- if (this.options.isVerbose) {
15716
- console.info(colors__default["default"].bgWhite('rawResponse'), JSON.stringify(rawResponse, null, 4));
15717
- }
15718
- if (!rawResponse.completion) {
15719
- throw new PipelineExecutionError('No completion from Anthropic Claude');
15720
- }
15721
- const resultContent = rawResponse.completion;
15722
- const complete = $getCurrentDate();
15723
- const usage = computeAnthropicClaudeUsage(rawPromptContent, resultContent, rawResponse);
15724
- return exportJson({
15725
- name: 'promptResult',
15726
- message: `Result of \`AnthropicClaudeExecutionTools.callCompletionModel\``,
15727
- order: [],
15728
- value: {
15729
- content: resultContent,
15730
- modelName: rawResponse.model || modelName,
15731
- timing: { start, complete },
15732
- usage,
15733
- rawPromptContent,
15734
- rawRequest,
15735
- rawResponse,
15736
- },
15737
- });
15738
- }
15739
15948
  // <- Note: [🤖] callXxxModel
15740
15949
  /**
15741
15950
  * Get the model that should be used as default
@@ -15757,7 +15966,7 @@
15757
15966
  * Default model for chat variant.
15758
15967
  */
15759
15968
  getDefaultChatModel() {
15760
- return this.getDefaultModel('claude-3-5-sonnet');
15969
+ return this.getDefaultModel('claude-sonnet-4-20250514');
15761
15970
  }
15762
15971
  }
15763
15972
  /**
@@ -15900,7 +16109,7 @@
15900
16109
  /**
15901
16110
  * List of available OpenAI models with pricing
15902
16111
  *
15903
- * Note: Done at 2025-05-06
16112
+ * Note: Synced with official API docs at 2025-08-20
15904
16113
  *
15905
16114
  * @see https://platform.openai.com/docs/models/
15906
16115
  * @see https://openai.com/api/pricing/
@@ -15909,6 +16118,138 @@
15909
16118
  const OPENAI_MODELS = exportJson({
15910
16119
  name: 'OPENAI_MODELS',
15911
16120
  value: [
16121
+ /**/
16122
+ {
16123
+ modelVariant: 'CHAT',
16124
+ modelTitle: 'gpt-5',
16125
+ modelName: 'gpt-5',
16126
+ modelDescription: "OpenAI's most advanced language model with unprecedented reasoning capabilities and 200K context window. Features revolutionary improvements in complex problem-solving, scientific reasoning, and creative tasks. Demonstrates human-level performance across diverse domains with enhanced safety measures and alignment. Represents the next generation of AI with superior understanding, nuanced responses, and advanced multimodal capabilities.",
16127
+ pricing: {
16128
+ prompt: pricing(`$1.25 / 1M tokens`),
16129
+ output: pricing(`$10.00 / 1M tokens`),
16130
+ },
16131
+ },
16132
+ /**/
16133
+ /**/
16134
+ {
16135
+ modelVariant: 'CHAT',
16136
+ modelTitle: 'gpt-5-mini',
16137
+ modelName: 'gpt-5-mini',
16138
+ modelDescription: "A faster, cost-efficient version of GPT-5 for well-defined tasks with 200K context window. Maintains core GPT-5 capabilities while offering 5x faster inference and significantly lower costs. Features enhanced instruction following and reduced latency for production applications requiring quick responses with high quality.",
16139
+ pricing: {
16140
+ prompt: pricing(`$0.25 / 1M tokens`),
16141
+ output: pricing(`$2.00 / 1M tokens`),
16142
+ },
16143
+ },
16144
+ /**/
16145
+ /**/
16146
+ {
16147
+ modelVariant: 'CHAT',
16148
+ modelTitle: 'gpt-5-nano',
16149
+ modelName: 'gpt-5-nano',
16150
+ modelDescription: "The fastest, most cost-efficient version of GPT-5 with 200K context window. Optimized for summarization, classification, and simple reasoning tasks. Features 10x faster inference than base GPT-5 while maintaining good quality for straightforward applications. Ideal for high-volume, cost-sensitive deployments.",
16151
+ pricing: {
16152
+ prompt: pricing(`$0.05 / 1M tokens`),
16153
+ output: pricing(`$0.40 / 1M tokens`),
16154
+ },
16155
+ },
16156
+ /**/
16157
+ /**/
16158
+ {
16159
+ modelVariant: 'CHAT',
16160
+ modelTitle: 'gpt-4.1',
16161
+ modelName: 'gpt-4.1',
16162
+ modelDescription: "Smartest non-reasoning model with 128K context window. Enhanced version of GPT-4 with improved instruction following, better factual accuracy, and reduced hallucinations. Features advanced function calling capabilities and superior performance on coding tasks. Ideal for applications requiring high intelligence without reasoning overhead.",
16163
+ pricing: {
16164
+ prompt: pricing(`$3.00 / 1M tokens`),
16165
+ output: pricing(`$12.00 / 1M tokens`),
16166
+ },
16167
+ },
16168
+ /**/
16169
+ /**/
16170
+ {
16171
+ modelVariant: 'CHAT',
16172
+ modelTitle: 'gpt-4.1-mini',
16173
+ modelName: 'gpt-4.1-mini',
16174
+ modelDescription: "Smaller, faster version of GPT-4.1 with 128K context window. Balances intelligence and efficiency with 3x faster inference than base GPT-4.1. Maintains strong capabilities across text generation, reasoning, and coding while offering better cost-performance ratio for most applications.",
16175
+ pricing: {
16176
+ prompt: pricing(`$0.80 / 1M tokens`),
16177
+ output: pricing(`$3.20 / 1M tokens`),
16178
+ },
16179
+ },
16180
+ /**/
16181
+ /**/
16182
+ {
16183
+ modelVariant: 'CHAT',
16184
+ modelTitle: 'gpt-4.1-nano',
16185
+ modelName: 'gpt-4.1-nano',
16186
+ modelDescription: "Fastest, most cost-efficient version of GPT-4.1 with 128K context window. Optimized for high-throughput applications requiring good quality at minimal cost. Features 5x faster inference than GPT-4.1 while maintaining adequate performance for most general-purpose tasks.",
16187
+ pricing: {
16188
+ prompt: pricing(`$0.20 / 1M tokens`),
16189
+ output: pricing(`$0.80 / 1M tokens`),
16190
+ },
16191
+ },
16192
+ /**/
16193
+ /**/
16194
+ {
16195
+ modelVariant: 'CHAT',
16196
+ modelTitle: 'o3',
16197
+ modelName: 'o3',
16198
+ modelDescription: "Advanced reasoning model with 128K context window specializing in complex logical, mathematical, and analytical tasks. Successor to o1 with enhanced step-by-step problem-solving capabilities and superior performance on STEM-focused problems. Ideal for professional applications requiring deep analytical thinking and precise reasoning.",
16199
+ pricing: {
16200
+ prompt: pricing(`$15.00 / 1M tokens`),
16201
+ output: pricing(`$60.00 / 1M tokens`),
16202
+ },
16203
+ },
16204
+ /**/
16205
+ /**/
16206
+ {
16207
+ modelVariant: 'CHAT',
16208
+ modelTitle: 'o3-pro',
16209
+ modelName: 'o3-pro',
16210
+ modelDescription: "Enhanced version of o3 with more compute allocated for better responses on the most challenging problems. Features extended reasoning time and improved accuracy on complex analytical tasks. Designed for applications where maximum reasoning quality is more important than response speed.",
16211
+ pricing: {
16212
+ prompt: pricing(`$30.00 / 1M tokens`),
16213
+ output: pricing(`$120.00 / 1M tokens`),
16214
+ },
16215
+ },
16216
+ /**/
16217
+ /**/
16218
+ {
16219
+ modelVariant: 'CHAT',
16220
+ modelTitle: 'o4-mini',
16221
+ modelName: 'o4-mini',
16222
+ modelDescription: "Fast, cost-efficient reasoning model with 128K context window. Successor to o1-mini with improved analytical capabilities while maintaining speed advantages. Features enhanced mathematical reasoning and logical problem-solving at significantly lower cost than full reasoning models.",
16223
+ pricing: {
16224
+ prompt: pricing(`$4.00 / 1M tokens`),
16225
+ output: pricing(`$16.00 / 1M tokens`),
16226
+ },
16227
+ },
16228
+ /**/
16229
+ /**/
16230
+ {
16231
+ modelVariant: 'CHAT',
16232
+ modelTitle: 'o3-deep-research',
16233
+ modelName: 'o3-deep-research',
16234
+ modelDescription: "Most powerful deep research model with 128K context window. Specialized for comprehensive research tasks, literature analysis, and complex information synthesis. Features advanced citation capabilities and enhanced factual accuracy for academic and professional research applications.",
16235
+ pricing: {
16236
+ prompt: pricing(`$25.00 / 1M tokens`),
16237
+ output: pricing(`$100.00 / 1M tokens`),
16238
+ },
16239
+ },
16240
+ /**/
16241
+ /**/
16242
+ {
16243
+ modelVariant: 'CHAT',
16244
+ modelTitle: 'o4-mini-deep-research',
16245
+ modelName: 'o4-mini-deep-research',
16246
+ modelDescription: "Faster, more affordable deep research model with 128K context window. Balances research capabilities with cost efficiency, offering good performance on literature review, fact-checking, and information synthesis tasks at a more accessible price point.",
16247
+ pricing: {
16248
+ prompt: pricing(`$12.00 / 1M tokens`),
16249
+ output: pricing(`$48.00 / 1M tokens`),
16250
+ },
16251
+ },
16252
+ /**/
15912
16253
  /*/
15913
16254
  {
15914
16255
  modelTitle: 'dall-e-3',
@@ -16429,7 +16770,6 @@
16429
16770
  const modelName = prompt.modelRequirements.modelName || this.options.deploymentName;
16430
16771
  const modelSettings = {
16431
16772
  maxTokens: modelRequirements.maxTokens,
16432
- // <- TODO: [🌾] Make some global max cap for maxTokens
16433
16773
  temperature: modelRequirements.temperature,
16434
16774
  user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
16435
16775
  // <- TODO: [🈁] Use `seed` here AND/OR use is `isDeterministic` for entire execution tools
@@ -16535,8 +16875,7 @@
16535
16875
  try {
16536
16876
  const modelName = prompt.modelRequirements.modelName || this.options.deploymentName;
16537
16877
  const modelSettings = {
16538
- maxTokens: modelRequirements.maxTokens || 2000,
16539
- // <- TODO: [🌾] Make some global max cap for maxTokens
16878
+ maxTokens: modelRequirements.maxTokens,
16540
16879
  temperature: modelRequirements.temperature,
16541
16880
  user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
16542
16881
  // <- TODO: [🈁] Use `seed` here AND/OR use is `isDeterministic` for entire execution tools
@@ -16902,7 +17241,7 @@
16902
17241
  /**
16903
17242
  * List of available Deepseek models with descriptions
16904
17243
  *
16905
- * Note: Done at 2025-05-06
17244
+ * Note: Synced with official API docs at 2025-08-20
16906
17245
  *
16907
17246
  * @see https://www.deepseek.com/models
16908
17247
  * @public exported from `@promptbook/deepseek`
@@ -16912,12 +17251,32 @@
16912
17251
  value: [
16913
17252
  {
16914
17253
  modelVariant: 'CHAT',
16915
- modelTitle: 'Deepseek Chat Pro',
16916
- modelName: 'deepseek-chat-pro',
16917
- modelDescription: 'Latest flagship general-purpose model with 256K context window. Enhanced from base Chat model with 40% improvement on complex reasoning tasks and specialized domain knowledge. Features advanced prompt optimization and improved contextual memory. Ideal for enterprise applications requiring highest quality responses.',
17254
+ modelTitle: 'DeepSeek V3',
17255
+ modelName: 'deepseek-chat',
17256
+ modelDescription: 'Latest flagship general-purpose model with 128K context window. Features exceptional reasoning capabilities, advanced code generation, and strong performance across diverse domains. Offers competitive performance with leading models while maintaining cost efficiency. Ideal for complex reasoning, coding, and knowledge-intensive tasks.',
16918
17257
  pricing: {
16919
- prompt: pricing(`$1.20 / 1M tokens`),
16920
- output: pricing(`$2.40 / 1M tokens`),
17258
+ prompt: pricing(`$0.14 / 1M tokens`),
17259
+ output: pricing(`$0.28 / 1M tokens`),
17260
+ },
17261
+ },
17262
+ {
17263
+ modelVariant: 'CHAT',
17264
+ modelTitle: 'DeepSeek R1',
17265
+ modelName: 'deepseek-reasoner',
17266
+ modelDescription: 'Advanced reasoning model with 128K context window specializing in complex problem-solving and analytical thinking. Features explicit reasoning chains, enhanced mathematical capabilities, and superior performance on STEM tasks. Designed for applications requiring deep analytical reasoning and step-by-step problem solving.',
17267
+ pricing: {
17268
+ prompt: pricing(`$0.55 / 1M tokens`),
17269
+ output: pricing(`$2.19 / 1M tokens`),
17270
+ },
17271
+ },
17272
+ {
17273
+ modelVariant: 'CHAT',
17274
+ modelTitle: 'DeepSeek Coder V2',
17275
+ modelName: 'deepseek-coder',
17276
+ modelDescription: 'Specialized coding model with 128K context window optimized for software development tasks. Features exceptional code generation, debugging, and refactoring capabilities across 40+ programming languages. Particularly strong in understanding complex codebases and implementing solutions based on natural language specifications.',
17277
+ pricing: {
17278
+ prompt: pricing(`$0.14 / 1M tokens`),
17279
+ output: pricing(`$0.28 / 1M tokens`),
16921
17280
  },
16922
17281
  },
16923
17282
  {
@@ -17151,7 +17510,7 @@
17151
17510
  /**
17152
17511
  * List of available Google models with descriptions
17153
17512
  *
17154
- * Note: Done at 2025-05-06
17513
+ * Note: Synced with official API docs at 2025-08-20
17155
17514
  *
17156
17515
  * @see https://ai.google.dev/models/gemini
17157
17516
  * @public exported from `@promptbook/google`
@@ -17162,11 +17521,51 @@
17162
17521
  {
17163
17522
  modelVariant: 'CHAT',
17164
17523
  modelTitle: 'Gemini 2.5 Pro',
17165
- modelName: 'gemini-2.5-pro-preview-03-25',
17166
- modelDescription: 'Latest advanced multimodal model with 1M token context window. Features exceptional reasoning across complex tasks, sophisticated function calling, and advanced image analysis (16MP resolution). Demonstrates superior performance in math, coding, and knowledge-intensive tasks with 30% improvement over Gemini 1.5 Pro. Ideal for enterprise applications requiring deep contextual understanding.',
17524
+ modelName: 'gemini-2.5-pro',
17525
+ modelDescription: 'State-of-the-art thinking model with 1M token context window capable of reasoning over complex problems in code, math, and STEM. Features enhanced thinking capabilities, advanced multimodal understanding, and superior performance on analytical tasks. Ideal for complex enterprise applications requiring maximum intelligence and reasoning.',
17167
17526
  pricing: {
17168
- prompt: pricing(`$8.00 / 1M tokens`),
17169
- output: pricing(`$24.00 / 1M tokens`),
17527
+ prompt: pricing(`$7.00 / 1M tokens`),
17528
+ output: pricing(`$21.00 / 1M tokens`),
17529
+ },
17530
+ },
17531
+ {
17532
+ modelVariant: 'CHAT',
17533
+ modelTitle: 'Gemini 2.5 Flash',
17534
+ modelName: 'gemini-2.5-flash',
17535
+ modelDescription: 'Best model in terms of price-performance with 1M token context window offering well-rounded capabilities. Features adaptive thinking, cost efficiency, and enhanced reasoning for large-scale processing. Ideal for low-latency, high-volume tasks that require thinking and agentic use cases.',
17536
+ pricing: {
17537
+ prompt: pricing(`$0.35 / 1M tokens`),
17538
+ output: pricing(`$1.05 / 1M tokens`),
17539
+ },
17540
+ },
17541
+ {
17542
+ modelVariant: 'CHAT',
17543
+ modelTitle: 'Gemini 2.5 Flash Lite',
17544
+ modelName: 'gemini-2.5-flash-lite',
17545
+ modelDescription: 'Cost-efficient Gemini 2.5 Flash model optimized for high throughput with 1M token context window. Features thinking capabilities while maintaining the most cost-efficient pricing. Perfect for real-time, low-latency use cases requiring good quality at scale.',
17546
+ pricing: {
17547
+ prompt: pricing(`$0.20 / 1M tokens`),
17548
+ output: pricing(`$0.60 / 1M tokens`),
17549
+ },
17550
+ },
17551
+ {
17552
+ modelVariant: 'CHAT',
17553
+ modelTitle: 'Gemini 2.0 Flash',
17554
+ modelName: 'gemini-2.0-flash',
17555
+ modelDescription: 'Next-generation model with 1M token context window delivering improved capabilities, superior speed, and realtime streaming. Features enhanced function calling, code execution, and search capabilities. Ideal for applications requiring cutting-edge AI capabilities with fast response times.',
17556
+ pricing: {
17557
+ prompt: pricing(`$0.25 / 1M tokens`),
17558
+ output: pricing(`$0.75 / 1M tokens`),
17559
+ },
17560
+ },
17561
+ {
17562
+ modelVariant: 'CHAT',
17563
+ modelTitle: 'Gemini 2.0 Flash Lite',
17564
+ modelName: 'gemini-2.0-flash-lite',
17565
+ modelDescription: 'Cost-efficient Gemini 2.0 Flash model optimized for low latency with 1M token context window. Balances performance and cost with enhanced efficiency for high-volume applications. Perfect for applications requiring good quality responses at minimal cost.',
17566
+ pricing: {
17567
+ prompt: pricing(`$0.15 / 1M tokens`),
17568
+ output: pricing(`$0.45 / 1M tokens`),
17170
17569
  },
17171
17570
  },
17172
17571
  {
@@ -17514,7 +17913,18 @@
17514
17913
  const openAiOptions = { ...this.options };
17515
17914
  delete openAiOptions.isVerbose;
17516
17915
  delete openAiOptions.userId;
17517
- this.client = new OpenAI__default["default"](openAiOptions);
17916
+ // Enhanced configuration for better ECONNRESET handling
17917
+ const enhancedOptions = {
17918
+ ...openAiOptions,
17919
+ timeout: API_REQUEST_TIMEOUT,
17920
+ maxRetries: CONNECTION_RETRIES_LIMIT,
17921
+ defaultHeaders: {
17922
+ Connection: 'keep-alive',
17923
+ 'Keep-Alive': 'timeout=30, max=100',
17924
+ ...openAiOptions.defaultHeaders,
17925
+ },
17926
+ };
17927
+ this.client = new OpenAI__default["default"](enhancedOptions);
17518
17928
  }
17519
17929
  return this.client;
17520
17930
  }
@@ -17567,7 +17977,6 @@
17567
17977
  const modelSettings = {
17568
17978
  model: modelName,
17569
17979
  max_tokens: modelRequirements.maxTokens,
17570
- // <- TODO: [🌾] Make some global max cap for maxTokens
17571
17980
  temperature: modelRequirements.temperature,
17572
17981
  // <- TODO: [🈁] Use `seed` here AND/OR use is `isDeterministic` for entire execution tools
17573
17982
  // <- Note: [🧆]
@@ -17603,7 +18012,7 @@
17603
18012
  console.info(colors__default["default"].bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
17604
18013
  }
17605
18014
  const rawResponse = await this.limiter
17606
- .schedule(() => client.chat.completions.create(rawRequest))
18015
+ .schedule(() => this.makeRequestWithRetry(() => client.chat.completions.create(rawRequest)))
17607
18016
  .catch((error) => {
17608
18017
  assertsError(error);
17609
18018
  if (this.options.isVerbose) {
@@ -17663,8 +18072,7 @@
17663
18072
  const modelName = modelRequirements.modelName || this.getDefaultCompletionModel().modelName;
17664
18073
  const modelSettings = {
17665
18074
  model: modelName,
17666
- max_tokens: modelRequirements.maxTokens || 2000,
17667
- // <- TODO: [🌾] Make some global max cap for maxTokens
18075
+ max_tokens: modelRequirements.maxTokens,
17668
18076
  temperature: modelRequirements.temperature,
17669
18077
  // <- TODO: [🈁] Use `seed` here AND/OR use is `isDeterministic` for entire execution tools
17670
18078
  // <- Note: [🧆]
@@ -17680,7 +18088,7 @@
17680
18088
  console.info(colors__default["default"].bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
17681
18089
  }
17682
18090
  const rawResponse = await this.limiter
17683
- .schedule(() => client.completions.create(rawRequest))
18091
+ .schedule(() => this.makeRequestWithRetry(() => client.completions.create(rawRequest)))
17684
18092
  .catch((error) => {
17685
18093
  assertsError(error);
17686
18094
  if (this.options.isVerbose) {
@@ -17744,7 +18152,7 @@
17744
18152
  console.info(colors__default["default"].bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
17745
18153
  }
17746
18154
  const rawResponse = await this.limiter
17747
- .schedule(() => client.embeddings.create(rawRequest))
18155
+ .schedule(() => this.makeRequestWithRetry(() => client.embeddings.create(rawRequest)))
17748
18156
  .catch((error) => {
17749
18157
  assertsError(error);
17750
18158
  if (this.options.isVerbose) {
@@ -17802,6 +18210,76 @@
17802
18210
  }
17803
18211
  return model;
17804
18212
  }
18213
+ // <- Note: [🤖] getDefaultXxxModel
18214
+ /**
18215
+ * Makes a request with retry logic for network errors like ECONNRESET
18216
+ */
18217
+ async makeRequestWithRetry(requestFn) {
18218
+ let lastError;
18219
+ for (let attempt = 1; attempt <= CONNECTION_RETRIES_LIMIT; attempt++) {
18220
+ try {
18221
+ return await requestFn();
18222
+ }
18223
+ catch (error) {
18224
+ assertsError(error);
18225
+ lastError = error;
18226
+ // Check if this is a retryable network error
18227
+ const isRetryableError = this.isRetryableNetworkError(error);
18228
+ if (!isRetryableError || attempt === CONNECTION_RETRIES_LIMIT) {
18229
+ if (this.options.isVerbose) {
18230
+ console.info(colors__default["default"].bgRed('Final error after retries'), `Attempt ${attempt}/${CONNECTION_RETRIES_LIMIT}:`, error);
18231
+ }
18232
+ throw error;
18233
+ }
18234
+ // Calculate exponential backoff delay
18235
+ const baseDelay = 1000; // 1 second
18236
+ const backoffDelay = baseDelay * Math.pow(2, attempt - 1);
18237
+ const jitterDelay = Math.random() * 500; // Add some randomness
18238
+ const totalDelay = backoffDelay + jitterDelay;
18239
+ if (this.options.isVerbose) {
18240
+ console.info(colors__default["default"].bgYellow('Retrying request'), `Attempt ${attempt}/${CONNECTION_RETRIES_LIMIT}, waiting ${Math.round(totalDelay)}ms:`, error.message);
18241
+ }
18242
+ // Wait before retrying
18243
+ await new Promise((resolve) => setTimeout(resolve, totalDelay));
18244
+ }
18245
+ }
18246
+ throw lastError;
18247
+ }
18248
+ /**
18249
+ * Determines if an error is retryable (network-related errors)
18250
+ */
18251
+ isRetryableNetworkError(error) {
18252
+ const errorMessage = error.message.toLowerCase();
18253
+ const errorCode = error.code;
18254
+ // Network connection errors that should be retried
18255
+ const retryableErrors = [
18256
+ 'econnreset',
18257
+ 'enotfound',
18258
+ 'econnrefused',
18259
+ 'etimedout',
18260
+ 'socket hang up',
18261
+ 'network error',
18262
+ 'fetch failed',
18263
+ 'connection reset',
18264
+ 'connection refused',
18265
+ 'timeout',
18266
+ ];
18267
+ // Check error message
18268
+ if (retryableErrors.some((retryableError) => errorMessage.includes(retryableError))) {
18269
+ return true;
18270
+ }
18271
+ // Check error code
18272
+ if (errorCode && retryableErrors.includes(errorCode.toLowerCase())) {
18273
+ return true;
18274
+ }
18275
+ // Check for specific HTTP status codes that are retryable
18276
+ const errorWithStatus = error;
18277
+ const httpStatus = errorWithStatus.status || errorWithStatus.statusCode;
18278
+ if (httpStatus && [429, 500, 502, 503, 504].includes(httpStatus)) {
18279
+ return true;
18280
+ }
18281
+ return false;
18282
+ }
17805
18283
  }
17806
18284
  /**
17807
18285
  * TODO: [🛄] Some way how to re-wrap the errors from `OpenAiCompatibleExecutionTools`
@@ -17813,7 +18291,7 @@
17813
18291
  /**
17814
18292
  * List of available models in Ollama library
17815
18293
  *
17816
- * Note: Done at 2025-05-19
18294
+ * Note: Synced with official API docs at 2025-08-20
17817
18295
  *
17818
18296
  * @see https://ollama.com/library
17819
18297
  * @public exported from `@promptbook/ollama`
@@ -17821,6 +18299,24 @@
17821
18299
  const OLLAMA_MODELS = exportJson({
17822
18300
  name: 'OLLAMA_MODELS',
17823
18301
  value: [
18302
+ {
18303
+ modelVariant: 'CHAT',
18304
+ modelTitle: 'llama3.3',
18305
+ modelName: 'llama3.3',
18306
+ modelDescription: 'Meta Llama 3.3 (70B parameters) with 128K context window. Latest generation foundation model with significantly enhanced reasoning, instruction following, and multilingual capabilities. Features improved performance on complex tasks and better factual accuracy compared to Llama 3.1.',
18307
+ },
18308
+ {
18309
+ modelVariant: 'CHAT',
18310
+ modelTitle: 'llama3.2',
18311
+ modelName: 'llama3.2',
18312
+ modelDescription: 'Meta Llama 3.2 (1B-90B parameters) with 128K context window. Enhanced model with improved reasoning capabilities, better instruction following, and multimodal support in larger variants. Features significant performance improvements over Llama 3.1 across diverse tasks.',
18313
+ },
18314
+ {
18315
+ modelVariant: 'CHAT',
18316
+ modelTitle: 'llama3.1',
18317
+ modelName: 'llama3.1',
18318
+ modelDescription: 'Meta Llama 3.1 (8B-405B parameters) with 128K context window. Advanced foundation model with enhanced reasoning, improved multilingual capabilities, and better performance on complex tasks. Features significant improvements in code generation and mathematical reasoning.',
18319
+ },
17824
18320
  {
17825
18321
  modelVariant: 'CHAT',
17826
18322
  modelTitle: 'llama3',
@@ -18291,6 +18787,9 @@
18291
18787
  get description() {
18292
18788
  return 'Use all models provided by OpenAI';
18293
18789
  }
18790
+ get profile() {
18791
+ return LLM_PROVIDER_PROFILES.OPENAI;
18792
+ }
18294
18793
  /*
18295
18794
  Note: Commenting this out to avoid circular dependency
18296
18795
  /**
@@ -18315,7 +18814,7 @@
18315
18814
  * Default model for chat variant.
18316
18815
  */
18317
18816
  getDefaultChatModel() {
18318
- return this.getDefaultModel('gpt-4-turbo');
18817
+ return this.getDefaultModel('gpt-5');
18319
18818
  }
18320
18819
  /**
18321
18820
  * Default model for completion variant.
@@ -18383,8 +18882,6 @@
18383
18882
  const modelName = modelRequirements.modelName || this.getDefaultChatModel().modelName;
18384
18883
  const modelSettings = {
18385
18884
  model: modelName,
18386
- max_tokens: modelRequirements.maxTokens,
18387
- // <- TODO: [🌾] Make some global max cap for maxTokens
18388
18885
 
18389
18886
  temperature: modelRequirements.temperature,
18390
18887
 
@@ -18838,7 +19335,9 @@
18838
19335
  },
18839
19336
  });
18840
19337
  const knowledgeContent = await source.asText();
18841
- const result = await prepareKnowledgeFromMarkdownExecutor({ knowledgeContent }).asPromise();
19338
+ const result = await prepareKnowledgeFromMarkdownExecutor({ knowledgeContent }).asPromise({
19339
+ isCrashedOnError: true,
19340
+ });
18842
19341
  const { outputParameters } = result;
18843
19342
  const { knowledgePieces: knowledgePiecesRaw } = outputParameters;
18844
19343
  const knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
@@ -18862,12 +19361,16 @@
18862
19361
  ];
18863
19362
  */
18864
19363
  try {
18865
- const titleResult = await prepareTitleExecutor({ knowledgePieceContent }).asPromise();
19364
+ const titleResult = await prepareTitleExecutor({ knowledgePieceContent }).asPromise({
19365
+ isCrashedOnError: true,
19366
+ });
18866
19367
  const { title: titleRaw = 'Untitled' } = titleResult.outputParameters;
18867
19368
  title = spaceTrim__default["default"](titleRaw) /* <- TODO: Maybe do in pipeline */;
18868
19369
  name = titleToName(title);
18869
19370
  // --- Keywords
18870
- const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise();
19371
+ const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise({
19372
+ isCrashedOnError: true,
19373
+ });
18871
19374
  const { keywords: keywordsRaw = '' } = keywordsResult.outputParameters;
18872
19375
  keywords = (keywordsRaw || '')
18873
19376
  .split(',')