@promptbook/core 0.100.4-0 → 0.101.0-1

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 (82) hide show
  1. package/README.md +240 -3
  2. package/esm/index.es.js +167 -152
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/components.index.d.ts +4 -0
  5. package/esm/typings/src/_packages/core.index.d.ts +4 -2
  6. package/esm/typings/src/_packages/markdown-utils.index.d.ts +14 -0
  7. package/esm/typings/src/_packages/types.index.d.ts +4 -6
  8. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +21 -0
  9. package/esm/typings/src/book-2.0/{commitments/_misc → agent-source}/AgentModelRequirements.d.ts +1 -1
  10. package/esm/typings/src/book-2.0/{commitments/_misc → agent-source}/AgentSourceParseResult.d.ts +3 -1
  11. package/esm/typings/src/book-2.0/{commitments/_misc → agent-source}/createAgentModelRequirements.d.ts +2 -2
  12. package/esm/typings/src/book-2.0/{commitments/_misc → agent-source}/createAgentModelRequirementsWithCommitments.d.ts +3 -3
  13. package/esm/typings/src/book-2.0/{commitments/_misc → agent-source}/createCommitmentRegex.d.ts +2 -2
  14. package/esm/typings/src/book-2.0/agent-source/extractMetaLinks.d.ts +8 -0
  15. package/esm/typings/src/book-2.0/agent-source/parseAgentSource.d.ts +4 -19
  16. package/esm/typings/src/book-2.0/agent-source/parseAgentSourceWithCommitments.d.ts +9 -0
  17. package/esm/typings/src/book-2.0/commitments/ACTION/ACTION.d.ts +1 -1
  18. package/esm/typings/src/book-2.0/commitments/FORMAT/FORMAT.d.ts +1 -1
  19. package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/KNOWLEDGE.d.ts +1 -1
  20. package/esm/typings/src/book-2.0/commitments/META_IMAGE/META_IMAGE.d.ts +1 -1
  21. package/esm/typings/src/book-2.0/commitments/META_LINK/META_LINK.d.ts +1 -1
  22. package/esm/typings/src/book-2.0/commitments/MODEL/MODEL.d.ts +1 -1
  23. package/esm/typings/src/book-2.0/commitments/NOTE/NOTE.d.ts +1 -1
  24. package/esm/typings/src/book-2.0/commitments/PERSONA/PERSONA.d.ts +1 -1
  25. package/esm/typings/src/book-2.0/commitments/RULE/RULE.d.ts +1 -1
  26. package/esm/typings/src/book-2.0/commitments/SAMPLE/SAMPLE.d.ts +1 -1
  27. package/esm/typings/src/book-2.0/commitments/STYLE/STYLE.d.ts +1 -1
  28. package/esm/typings/src/book-2.0/commitments/_base/BaseCommitmentDefinition.d.ts +1 -1
  29. package/esm/typings/src/book-2.0/commitments/_base/CommitmentDefinition.d.ts +1 -1
  30. package/esm/typings/src/book-2.0/commitments/_base/NotYetImplementedCommitmentDefinition.d.ts +1 -1
  31. package/esm/typings/src/book-2.0/commitments/{_misc → _base}/ParsedCommitment.d.ts +1 -1
  32. package/esm/typings/src/book-2.0/commitments/_base/createEmptyAgentModelRequirements.d.ts +1 -1
  33. package/esm/typings/src/book-2.0/utils/extractAgentMetadata.d.ts +17 -0
  34. package/esm/typings/src/book-2.0/utils/extractProfileImageFromSystemMessage.d.ts +12 -0
  35. package/esm/typings/src/book-2.0/utils/generateGravatarUrl.d.ts +10 -0
  36. package/esm/typings/src/book-2.0/utils/generatePlaceholderAgentProfileImageUrl.d.ts +10 -0
  37. package/esm/typings/src/book-components/AvatarProfile/AvatarChip/AvatarChip.d.ts +1 -1
  38. package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.d.ts +2 -8
  39. package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +6 -0
  40. package/esm/typings/src/book-components/Chat/examples/ChatMarkdownDemo.d.ts +16 -0
  41. package/esm/typings/src/book-components/Chat/types/ChatParticipant.d.ts +1 -1
  42. package/esm/typings/src/book-components/Chat/utils/renderMarkdown.d.ts +21 -0
  43. package/esm/typings/src/book-components/Chat/utils/renderMarkdown.test.d.ts +1 -0
  44. package/esm/typings/src/llm-providers/_common/profiles/llmProviderProfiles.d.ts +1 -1
  45. package/esm/typings/src/utils/expectation-counters/countCharacters.d.ts +2 -1
  46. package/esm/typings/src/utils/expectation-counters/countLines.d.ts +2 -1
  47. package/esm/typings/src/utils/expectation-counters/countPages.d.ts +2 -1
  48. package/esm/typings/src/utils/expectation-counters/countParagraphs.d.ts +2 -1
  49. package/esm/typings/src/utils/expectation-counters/countSentences.d.ts +1 -0
  50. package/esm/typings/src/utils/expectation-counters/countWords.d.ts +3 -1
  51. package/esm/typings/src/utils/markdown/escapeMarkdownBlock.d.ts +2 -0
  52. package/esm/typings/src/utils/markdown/humanizeAiText.d.ts +13 -0
  53. package/esm/typings/src/utils/markdown/humanizeAiText.test.d.ts +1 -0
  54. package/esm/typings/src/utils/markdown/humanizeAiTextEllipsis.d.ts +13 -0
  55. package/esm/typings/src/utils/markdown/humanizeAiTextEmdashed.d.ts +13 -0
  56. package/esm/typings/src/utils/markdown/humanizeAiTextQuotes.d.ts +13 -0
  57. package/esm/typings/src/utils/markdown/humanizeAiTextWhitespace.d.ts +13 -0
  58. package/esm/typings/src/utils/markdown/prettifyMarkdown.d.ts +8 -0
  59. package/esm/typings/src/utils/markdown/promptbookifyAiText.d.ts +12 -0
  60. package/esm/typings/src/utils/markdown/promptbookifyAiText.test.d.ts +1 -0
  61. package/esm/typings/src/utils/markdown/removeMarkdownLinks.d.ts +11 -0
  62. package/esm/typings/src/utils/markdown/removeMarkdownLinks.test.d.ts +4 -0
  63. package/esm/typings/src/utils/normalization/capitalize.d.ts +2 -0
  64. package/esm/typings/src/utils/normalization/decapitalize.d.ts +3 -1
  65. package/esm/typings/src/utils/normalization/normalizeTo_SCREAMING_CASE.d.ts +2 -0
  66. package/esm/typings/src/utils/normalization/normalizeTo_snake_case.d.ts +2 -0
  67. package/esm/typings/src/utils/normalization/normalizeWhitespaces.d.ts +2 -0
  68. package/esm/typings/src/utils/normalization/removeDiacritics.d.ts +2 -0
  69. package/esm/typings/src/utils/parseNumber.d.ts +1 -0
  70. package/esm/typings/src/utils/removeEmojis.d.ts +2 -0
  71. package/esm/typings/src/utils/removeQuotes.d.ts +1 -0
  72. package/esm/typings/src/utils/serialization/deepClone.d.ts +1 -0
  73. package/esm/typings/src/utils/trimCodeBlock.d.ts +1 -0
  74. package/esm/typings/src/utils/validators/url/isValidUrl.d.ts +1 -0
  75. package/esm/typings/src/utils/validators/uuid/isValidUuid.d.ts +2 -0
  76. package/esm/typings/src/version.d.ts +1 -1
  77. package/package.json +1 -1
  78. package/umd/index.umd.js +172 -155
  79. package/umd/index.umd.js.map +1 -1
  80. package/esm/typings/src/book-2.0/commitments/_misc/parseAgentSourceWithCommitments.d.ts +0 -24
  81. package/esm/typings/src/book-2.0/utils/profileImageUtils.d.ts +0 -39
  82. /package/esm/typings/src/book-2.0/{commitments/_misc → agent-source}/removeCommentsFromSystemMessage.d.ts +0 -0
package/README.md CHANGED
@@ -48,9 +48,246 @@ npm i ptbk
48
48
  npm install @promptbook/core
49
49
  ```
50
50
 
51
- Core of the library, it contains the main logic for promptbooks.
52
-
53
-
51
+ The core package contains the fundamental logic and infrastructure for Promptbook. It provides the essential building blocks for creating, parsing, validating, and executing promptbooks, along with comprehensive error handling, LLM provider integrations, and execution utilities.
52
+
53
+ ## 🎯 Purpose and Motivation
54
+
55
+ The core package serves as the foundation of the Promptbook ecosystem. It abstracts away the complexity of working with different LLM providers, provides a unified interface for prompt execution, and handles all the intricate details of pipeline management, parameter validation, and result processing.
56
+
57
+ ## 🔧 High-Level Functionality
58
+
59
+ This package orchestrates the entire promptbook execution lifecycle:
60
+ - **Pipeline Management**: Parse, validate, and compile promptbook definitions
61
+ - **Execution Engine**: Create and manage pipeline executors with comprehensive error handling
62
+ - **LLM Integration**: Unified interface for multiple LLM providers (OpenAI, Anthropic, Google, etc.)
63
+ - **Parameter Processing**: Template parameter substitution and validation
64
+ - **Knowledge Management**: Handle knowledge sources and scraping
65
+ - **Storage Abstraction**: Flexible storage backends for caching and persistence
66
+ - **Format Support**: Parse and validate various data formats (JSON, CSV, XML)
67
+
68
+ ## ✨ Key Features
69
+
70
+ - 🚀 **Universal Pipeline Executor** - Execute promptbooks with any supported LLM provider
71
+ - 🔄 **Multi-Provider Support** - Seamlessly switch between OpenAI, Anthropic, Google, and other providers
72
+ - 📊 **Comprehensive Validation** - Validate promptbooks, parameters, and execution results
73
+ - 🎯 **Expectation Checking** - Built-in validation for output format, length, and content expectations
74
+ - 🧠 **Knowledge Integration** - Scrape and process knowledge from various sources
75
+ - 💾 **Flexible Storage** - Memory, filesystem, and custom storage backends
76
+ - 🔧 **Error Handling** - Detailed error types for debugging and monitoring
77
+ - 📈 **Usage Tracking** - Monitor token usage, costs, and performance metrics
78
+ - 🎨 **Format Parsers** - Support for JSON, CSV, XML, and text formats
79
+ - 🔀 **Pipeline Migration** - Upgrade and migrate pipeline definitions
80
+
81
+ ## 📦 Exported Entities
82
+
83
+ ### Version Information
84
+ - `BOOK_LANGUAGE_VERSION` - Current book language version
85
+ - `PROMPTBOOK_ENGINE_VERSION` - Current engine version
86
+
87
+ ### Agent and Book Management
88
+ - `createAgentModelRequirements` - Create model requirements for agents
89
+ - `parseAgentSource` - Parse agent source code
90
+ - `isValidBook` - Validate book format
91
+ - `validateBook` - Comprehensive book validation
92
+ - `DEFAULT_BOOK` - Default book template
93
+
94
+ ### Commitment System
95
+ - `createEmptyAgentModelRequirements` - Create empty model requirements
96
+ - `createBasicAgentModelRequirements` - Create basic model requirements
97
+ - `NotYetImplementedCommitmentDefinition` - Placeholder for future commitments
98
+ - `getCommitmentDefinition` - Get specific commitment definition
99
+ - `getAllCommitmentDefinitions` - Get all available commitment definitions
100
+ - `getAllCommitmentTypes` - Get all commitment types
101
+ - `isCommitmentSupported` - Check if commitment is supported
102
+
103
+ ### Collection Management
104
+ - `collectionToJson` - Convert collection to JSON
105
+ - `createCollectionFromJson` - Create collection from JSON data
106
+ - `createCollectionFromPromise` - Create collection from async source
107
+ - `createCollectionFromUrl` - Create collection from URL
108
+ - `createSubcollection` - Create filtered subcollection
109
+
110
+ ### Configuration Constants
111
+ - `NAME` - Project name
112
+ - `ADMIN_EMAIL` - Administrator email
113
+ - `ADMIN_GITHUB_NAME` - GitHub username
114
+ - `CLAIM` - Project claim/tagline
115
+ - `DEFAULT_BOOK_TITLE` - Default book title
116
+ - `DEFAULT_TASK_TITLE` - Default task title
117
+ - `DEFAULT_PROMPT_TASK_TITLE` - Default prompt task title
118
+ - `DEFAULT_BOOK_OUTPUT_PARAMETER_NAME` - Default output parameter name
119
+ - `DEFAULT_MAX_FILE_SIZE` - Maximum file size limit
120
+ - `BIG_DATASET_TRESHOLD` - Threshold for large datasets
121
+ - `FAILED_VALUE_PLACEHOLDER` - Placeholder for failed values
122
+ - `PENDING_VALUE_PLACEHOLDER` - Placeholder for pending values
123
+ - `MAX_FILENAME_LENGTH` - Maximum filename length
124
+ - `DEFAULT_INTERMEDIATE_FILES_STRATEGY` - Strategy for intermediate files
125
+ - `DEFAULT_MAX_PARALLEL_COUNT` - Maximum parallel executions
126
+ - `DEFAULT_MAX_EXECUTION_ATTEMPTS` - Maximum execution attempts
127
+ - `DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH` - Knowledge scraping depth limit
128
+ - `DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL` - Knowledge scraping total limit
129
+ - `DEFAULT_BOOKS_DIRNAME` - Default books directory name
130
+ - `DEFAULT_DOWNLOAD_CACHE_DIRNAME` - Default download cache directory
131
+ - `DEFAULT_EXECUTION_CACHE_DIRNAME` - Default execution cache directory
132
+ - `DEFAULT_SCRAPE_CACHE_DIRNAME` - Default scrape cache directory
133
+ - `CLI_APP_ID` - CLI application identifier
134
+ - `PLAYGROUND_APP_ID` - Playground application identifier
135
+ - `DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME` - Default collection filename
136
+ - `DEFAULT_REMOTE_SERVER_URL` - Default remote server URL
137
+ - `DEFAULT_CSV_SETTINGS` - Default CSV parsing settings
138
+ - `DEFAULT_IS_VERBOSE` - Default verbosity setting
139
+ - `SET_IS_VERBOSE` - Verbosity setter
140
+ - `DEFAULT_IS_AUTO_INSTALLED` - Default auto-install setting
141
+ - `DEFAULT_TASK_SIMULATED_DURATION_MS` - Default task simulation duration
142
+ - `DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME` - Default collection function name
143
+ - `DEFAULT_MAX_REQUESTS_PER_MINUTE` - Rate limiting configuration
144
+ - `API_REQUEST_TIMEOUT` - API request timeout
145
+ - `PROMPTBOOK_LOGO_URL` - Official logo URL
146
+
147
+ ### Model and Provider Constants
148
+ - `MODEL_TRUST_LEVELS` - Trust levels for different models
149
+ - `MODEL_ORDERS` - Ordering preferences for models
150
+ - `ORDER_OF_PIPELINE_JSON` - JSON property ordering
151
+ - `RESERVED_PARAMETER_NAMES` - Reserved parameter names
152
+
153
+ ### Pipeline Processing
154
+ - `compilePipeline` - Compile pipeline from source
155
+ - `parsePipeline` - Parse pipeline definition
156
+ - `pipelineJsonToString` - Convert pipeline JSON to string
157
+ - `prettifyPipelineString` - Format pipeline string
158
+ - `extractParameterNamesFromTask` - Extract parameter names
159
+ - `validatePipeline` - Validate pipeline structure
160
+
161
+ ### Dialog and Interface Tools
162
+ - `CallbackInterfaceTools` - Callback-based interface tools
163
+ - `CallbackInterfaceToolsOptions` - Options for callback tools (type)
164
+
165
+ ### Error Handling
166
+ - `BoilerplateError` - Base error class
167
+ - `PROMPTBOOK_ERRORS` - All error types registry
168
+ - `AbstractFormatError` - Abstract format validation error
169
+ - `AuthenticationError` - Authentication failure error
170
+ - `CollectionError` - Collection-related error
171
+ - `EnvironmentMismatchError` - Environment compatibility error
172
+ - `ExpectError` - Expectation validation error
173
+ - `KnowledgeScrapeError` - Knowledge scraping error
174
+ - `LimitReachedError` - Resource limit error
175
+ - `MissingToolsError` - Missing tools error
176
+ - `NotFoundError` - Resource not found error
177
+ - `NotYetImplementedError` - Feature not implemented error
178
+ - `ParseError` - Parsing error
179
+ - `PipelineExecutionError` - Pipeline execution error
180
+ - `PipelineLogicError` - Pipeline logic error
181
+ - `PipelineUrlError` - Pipeline URL error
182
+ - `PromptbookFetchError` - Fetch operation error
183
+ - `UnexpectedError` - Unexpected error
184
+ - `WrappedError` - Wrapped error container
185
+
186
+ ### Execution Engine
187
+ - `createPipelineExecutor` - Create pipeline executor
188
+ - `computeCosineSimilarity` - Compute cosine similarity for embeddings
189
+ - `embeddingVectorToString` - Convert embedding vector to string
190
+ - `executionReportJsonToString` - Convert execution report to string
191
+ - `ExecutionReportStringOptions` - Report formatting options (type)
192
+ - `ExecutionReportStringOptionsDefaults` - Default report options
193
+
194
+ ### Usage and Metrics
195
+ - `addUsage` - Add usage metrics
196
+ - `isPassingExpectations` - Check if expectations are met
197
+ - `ZERO_VALUE` - Zero usage value constant
198
+ - `UNCERTAIN_ZERO_VALUE` - Uncertain zero value constant
199
+ - `ZERO_USAGE` - Zero usage object
200
+ - `UNCERTAIN_USAGE` - Uncertain usage object
201
+ - `usageToHuman` - Convert usage to human-readable format
202
+ - `usageToWorktime` - Convert usage to work time estimate
203
+
204
+ ### Format Parsers
205
+ - `CsvFormatError` - CSV format error
206
+ - `CsvFormatParser` - CSV format parser
207
+ - `MANDATORY_CSV_SETTINGS` - Required CSV settings
208
+ - `TextFormatParser` - Text format parser
209
+
210
+ ### Form Factor Definitions
211
+ - `BoilerplateFormfactorDefinition` - Boilerplate form factor
212
+ - `ChatbotFormfactorDefinition` - Chatbot form factor
213
+ - `CompletionFormfactorDefinition` - Completion form factor
214
+ - `GeneratorFormfactorDefinition` - Generator form factor
215
+ - `GenericFormfactorDefinition` - Generic form factor
216
+ - `ImageGeneratorFormfactorDefinition` - Image generator form factor
217
+ - `FORMFACTOR_DEFINITIONS` - All form factor definitions
218
+ - `MatcherFormfactorDefinition` - Matcher form factor
219
+ - `SheetsFormfactorDefinition` - Sheets form factor
220
+ - `TranslatorFormfactorDefinition` - Translator form factor
221
+
222
+ ### LLM Provider Integration
223
+ - `filterModels` - Filter available models
224
+ - `$llmToolsMetadataRegister` - LLM tools metadata registry
225
+ - `$llmToolsRegister` - LLM tools registry
226
+ - `createLlmToolsFromConfiguration` - Create tools from config
227
+ - `cacheLlmTools` - Cache LLM tools
228
+ - `countUsage` - Count total usage
229
+ - `limitTotalUsage` - Limit total usage
230
+ - `joinLlmExecutionTools` - Join multiple LLM tools
231
+ - `MultipleLlmExecutionTools` - Multiple LLM tools container
232
+
233
+ ### Provider Registrations
234
+ - `_AnthropicClaudeMetadataRegistration` - Anthropic Claude registration
235
+ - `_AzureOpenAiMetadataRegistration` - Azure OpenAI registration
236
+ - `_DeepseekMetadataRegistration` - Deepseek registration
237
+ - `_GoogleMetadataRegistration` - Google registration
238
+ - `_OllamaMetadataRegistration` - Ollama registration
239
+ - `_OpenAiMetadataRegistration` - OpenAI registration
240
+ - `_OpenAiAssistantMetadataRegistration` - OpenAI Assistant registration
241
+ - `_OpenAiCompatibleMetadataRegistration` - OpenAI Compatible registration
242
+
243
+ ### Pipeline Management
244
+ - `migratePipeline` - Migrate pipeline to newer version
245
+ - `preparePersona` - Prepare persona for execution
246
+ - `book` - Book notation utilities
247
+ - `isValidPipelineString` - Validate pipeline string
248
+ - `GENERIC_PIPELINE_INTERFACE` - Generic pipeline interface
249
+ - `getPipelineInterface` - Get pipeline interface
250
+ - `isPipelineImplementingInterface` - Check interface implementation
251
+ - `isPipelineInterfacesEqual` - Compare pipeline interfaces
252
+ - `EXPECTATION_UNITS` - Units for expectations
253
+ - `validatePipelineString` - Validate pipeline string format
254
+
255
+ ### Pipeline Preparation
256
+ - `isPipelinePrepared` - Check if pipeline is prepared
257
+ - `preparePipeline` - Prepare pipeline for execution
258
+ - `unpreparePipeline` - Unprepare pipeline
259
+
260
+ ### Remote Server Integration
261
+ - `identificationToPromptbookToken` - Convert ID to token
262
+ - `promptbookTokenToIdentification` - Convert token to ID
263
+
264
+ ### Knowledge Scraping
265
+ - `_BoilerplateScraperMetadataRegistration` - Boilerplate scraper registration
266
+ - `prepareKnowledgePieces` - Prepare knowledge pieces
267
+ - `$scrapersMetadataRegister` - Scrapers metadata registry
268
+ - `$scrapersRegister` - Scrapers registry
269
+ - `makeKnowledgeSourceHandler` - Create knowledge source handler
270
+ - `promptbookFetch` - Fetch with promptbook context
271
+ - `_LegacyDocumentScraperMetadataRegistration` - Legacy document scraper
272
+ - `_DocumentScraperMetadataRegistration` - Document scraper registration
273
+ - `_MarkdownScraperMetadataRegistration` - Markdown scraper registration
274
+ - `_MarkitdownScraperMetadataRegistration` - Markitdown scraper registration
275
+ - `_PdfScraperMetadataRegistration` - PDF scraper registration
276
+ - `_WebsiteScraperMetadataRegistration` - Website scraper registration
277
+
278
+ ### Storage Backends
279
+ - `BlackholeStorage` - Blackhole storage (discards data)
280
+ - `MemoryStorage` - In-memory storage
281
+ - `PrefixStorage` - Prefixed storage wrapper
282
+
283
+ ### Type Definitions
284
+ - `MODEL_VARIANTS` - Available model variants
285
+ - `NonTaskSectionTypes` - Non-task section types
286
+ - `SectionTypes` - All section types
287
+ - `TaskTypes` - Task types
288
+
289
+ ### Server Configuration
290
+ - `REMOTE_SERVER_URLS` - Remote server URLs
54
291
 
55
292
  > 💡 This package does not make sense on its own, look at [all promptbook packages](#-packages) or just install all by `npm i ptbk`
56
293