@promptbook/browser 0.72.0-9 → 0.73.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 (146) hide show
  1. package/README.md +36 -252
  2. package/esm/index.es.js +227 -30
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/core.index.d.ts +24 -18
  5. package/esm/typings/src/_packages/node.index.d.ts +2 -0
  6. package/esm/typings/src/_packages/types.index.d.ts +18 -12
  7. package/esm/typings/src/_packages/utils.index.d.ts +2 -2
  8. package/esm/typings/src/collection/PipelineCollection.d.ts +1 -1
  9. package/esm/typings/src/collection/SimplePipelineCollection.d.ts +2 -2
  10. package/esm/typings/src/collection/collectionToJson.d.ts +1 -1
  11. package/esm/typings/src/collection/constructors/createCollectionFromJson.d.ts +1 -1
  12. package/esm/typings/src/collection/constructors/createCollectionFromPromise.d.ts +1 -1
  13. package/esm/typings/src/commands/TEMPLATE/TemplateTypes.d.ts +1 -1
  14. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +5 -5
  15. package/esm/typings/src/config.d.ts +22 -15
  16. package/esm/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +3 -3
  17. package/esm/typings/src/conversion/utils/stringifyPipelineJson.d.ts +1 -1
  18. package/esm/typings/src/conversion/validation/_importPipeline.d.ts +1 -1
  19. package/esm/typings/src/conversion/validation/validatePipeline.d.ts +2 -2
  20. package/esm/typings/src/executables/$provideExecutablesForNode.d.ts +12 -0
  21. package/esm/typings/src/executables/apps/locateLibreoffice.d.ts +11 -0
  22. package/esm/typings/src/executables/apps/locatePandoc.d.ts +11 -0
  23. package/esm/typings/src/executables/locateApp.d.ts +33 -0
  24. package/esm/typings/src/executables/locateApp.test.d.ts +1 -0
  25. package/esm/typings/src/executables/platforms/locateAppOnLinux.d.ts +12 -0
  26. package/esm/typings/src/executables/platforms/locateAppOnMacOs.d.ts +12 -0
  27. package/esm/typings/src/executables/platforms/locateAppOnWindows.d.ts +12 -0
  28. package/esm/typings/src/execution/EmbeddingVector.d.ts +1 -1
  29. package/esm/typings/src/execution/Executables.d.ts +18 -0
  30. package/esm/typings/src/execution/ExecutionTools.d.ts +9 -3
  31. package/esm/typings/src/execution/FilesystemTools.d.ts +1 -1
  32. package/esm/typings/src/execution/LlmExecutionTools.d.ts +2 -2
  33. package/esm/typings/src/execution/PipelineExecutorResult.d.ts +2 -2
  34. package/esm/typings/src/execution/assertsExecutionSuccessful.d.ts +3 -2
  35. package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorOptions.d.ts +29 -6
  36. package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +2 -11
  37. package/esm/typings/src/execution/createPipelineExecutor/20-executeTemplate.d.ts +4 -13
  38. package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +9 -14
  39. package/esm/typings/src/execution/createPipelineExecutor/{getSamplesForTemplate.d.ts → getExamplesForTemplate.d.ts} +1 -1
  40. package/esm/typings/src/execution/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +11 -3
  41. package/esm/typings/src/execution/utils/addUsage.d.ts +1 -1
  42. package/esm/typings/src/execution/utils/forEachAsync.d.ts +1 -1
  43. package/esm/typings/src/formats/_common/FormatDefinition.d.ts +4 -4
  44. package/esm/typings/src/formats/_common/FormatSubvalueDefinition.d.ts +3 -3
  45. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForCli.d.ts +2 -2
  46. package/esm/typings/src/llm-providers/_common/register/LlmToolsConfiguration.d.ts +1 -1
  47. package/esm/typings/src/llm-providers/_common/register/createLlmToolsFromConfiguration.d.ts +7 -0
  48. package/esm/typings/src/llm-providers/_common/utils/cache/CacheLlmToolsOptions.d.ts +4 -1
  49. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +1 -1
  50. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +2 -2
  51. package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
  52. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +1 -1
  53. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +2 -1
  54. package/esm/typings/src/llm-providers/langtail/LangtailExecutionTools.d.ts +1 -1
  55. package/esm/typings/src/llm-providers/mocked/$fakeTextToExpectations.d.ts +1 -1
  56. package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +1 -1
  57. package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +1 -1
  58. package/esm/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +4 -5
  59. package/esm/typings/src/llm-providers/multiple/joinLlmExecutionTools.d.ts +1 -1
  60. package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +0 -1
  61. package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +2 -2
  62. package/esm/typings/src/llm-providers/openai/OpenAiExecutionToolsOptions.d.ts +2 -2
  63. package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
  64. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +4 -4
  65. package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_ListModels_Request.d.ts +15 -6
  66. package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_ListModels_Response.d.ts +4 -4
  67. package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_Prompt_Request.d.ts +6 -12
  68. package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_Prompt_Response.d.ts +3 -3
  69. package/esm/typings/src/llm-providers/remote/interfaces/RemoteLlmExecutionToolsOptions.d.ts +9 -14
  70. package/esm/typings/src/llm-providers/remote/interfaces/RemoteServerOptions.d.ts +23 -8
  71. package/esm/typings/src/llm-providers/remote/startRemoteServer.d.ts +1 -1
  72. package/esm/typings/src/personas/preparePersona.d.ts +1 -1
  73. package/esm/typings/src/prepare/PrepareAndScrapeOptions.d.ts +4 -23
  74. package/esm/typings/src/prepare/isPipelinePrepared.d.ts +2 -2
  75. package/esm/typings/src/prepare/prepareTemplates.d.ts +2 -2
  76. package/esm/typings/src/scrapers/_common/Scraper.d.ts +2 -9
  77. package/esm/typings/src/scrapers/_common/prepareKnowledgePieces.d.ts +1 -1
  78. package/esm/typings/src/scrapers/_common/register/$provideScrapersForBrowser.d.ts +2 -2
  79. package/esm/typings/src/scrapers/_common/register/$provideScrapersForNode.d.ts +2 -2
  80. package/esm/typings/src/scrapers/_common/register/ScraperAndConverterMetadata.d.ts +2 -2
  81. package/esm/typings/src/scrapers/_common/utils/getScraperIntermediateSource.d.ts +2 -2
  82. package/esm/typings/src/scrapers/_common/utils/makeKnowledgeSourceHandler.d.ts +1 -1
  83. package/esm/typings/src/scrapers/document/DocumentScraper.d.ts +2 -2
  84. package/esm/typings/src/scrapers/document/DocumentScraper.test.d.ts +1 -1
  85. package/esm/typings/src/scrapers/document/createDocumentScraper.d.ts +1 -1
  86. package/esm/typings/src/scrapers/document/register-metadata.d.ts +1 -1
  87. package/esm/typings/src/scrapers/document-legacy/LegacyDocumentScraper.d.ts +3 -3
  88. package/esm/typings/src/scrapers/document-legacy/LegacyDocumentScraper.test.d.ts +1 -1
  89. package/esm/typings/src/scrapers/document-legacy/createLegacyDocumentScraper.d.ts +1 -1
  90. package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +1 -1
  91. package/esm/typings/src/scrapers/markdown/MarkdownScraper.d.ts +1 -1
  92. package/esm/typings/src/scrapers/markdown/MarkdownScraper.test.d.ts +1 -1
  93. package/esm/typings/src/scrapers/markdown/createMarkdownScraper.d.ts +1 -1
  94. package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +1 -1
  95. package/esm/typings/src/scrapers/pdf/PdfScraper.d.ts +2 -2
  96. package/esm/typings/src/scrapers/pdf/createPdfScraper.d.ts +1 -1
  97. package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +1 -1
  98. package/esm/typings/src/scrapers/website/WebsiteScraper.d.ts +6 -3
  99. package/esm/typings/src/scrapers/website/createWebsiteScraper.d.ts +1 -1
  100. package/esm/typings/src/scrapers/website/register-metadata.d.ts +1 -1
  101. package/esm/typings/src/scrapers/website/utils/createShowdownConverter.d.ts +7 -0
  102. package/esm/typings/src/scrapers/website/utils/createShowdownConverter.test.d.ts +1 -0
  103. package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +1 -1
  104. package/esm/typings/src/storage/file-cache-storage/utils/nameToSubfolderPath.d.ts +1 -1
  105. package/esm/typings/src/types/Arrayable.d.ts +1 -1
  106. package/esm/typings/src/types/IntermediateFilesStrategy.d.ts +7 -0
  107. package/esm/typings/src/types/PipelineJson/KnowledgePieceJson.d.ts +4 -4
  108. package/esm/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +1 -1
  109. package/esm/typings/src/types/PipelineJson/ParameterJson.d.ts +2 -2
  110. package/esm/typings/src/types/PipelineJson/PersonaJson.d.ts +1 -1
  111. package/esm/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -1
  112. package/esm/typings/src/types/PipelineJson/TemplateJsonCommon.d.ts +2 -2
  113. package/esm/typings/src/types/Prompt.d.ts +2 -1
  114. package/esm/typings/src/types/execution-report/ExecutionReportJson.d.ts +1 -1
  115. package/esm/typings/src/types/typeAliases.d.ts +11 -8
  116. package/esm/typings/src/utils/$Register.d.ts +1 -1
  117. package/esm/typings/src/utils/FromtoItems.d.ts +1 -1
  118. package/esm/typings/src/utils/arrayableToArray.d.ts +1 -1
  119. package/esm/typings/src/utils/emojis.d.ts +1 -1
  120. package/esm/typings/src/utils/execCommand/$execCommand.d.ts +4 -2
  121. package/esm/typings/src/utils/execCommand/$execCommandNormalizeOptions.d.ts +12 -0
  122. package/esm/typings/src/utils/execCommand/$execCommands.d.ts +1 -0
  123. package/esm/typings/src/utils/execCommand/ExecCommandOptions.d.ts +45 -0
  124. package/esm/typings/src/utils/expectation-counters/countSentences.d.ts +1 -1
  125. package/esm/typings/src/utils/files/isExecutable.d.ts +11 -0
  126. package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +1 -1
  127. package/esm/typings/src/utils/markdown/splitMarkdownIntoSections.d.ts +1 -1
  128. package/esm/typings/src/utils/normalization/IKeywords.d.ts +2 -2
  129. package/esm/typings/src/utils/normalization/parseKeywords.d.ts +2 -2
  130. package/esm/typings/src/utils/normalization/parseKeywordsFromString.d.ts +2 -2
  131. package/esm/typings/src/utils/normalization/searchKeywords.d.ts +2 -2
  132. package/esm/typings/src/utils/organization/TODO_USE.d.ts +1 -1
  133. package/esm/typings/src/utils/organization/keepUnused.d.ts +1 -1
  134. package/esm/typings/src/utils/random/$randomSeed.d.ts +1 -1
  135. package/esm/typings/src/utils/sets/intersection.d.ts +1 -1
  136. package/esm/typings/src/utils/sets/union.d.ts +1 -1
  137. package/esm/typings/src/utils/unwrapResult.d.ts +4 -4
  138. package/package.json +6 -4
  139. package/umd/index.umd.js +227 -30
  140. package/umd/index.umd.js.map +1 -1
  141. package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorSettings.d.ts +0 -29
  142. package/esm/typings/src/scrapers/website/utils/markdownConverter.d.ts +0 -12
  143. package/esm/typings/src/utils/execCommand/IExecCommandOptions.d.ts +0 -23
  144. package/esm/typings/src/utils/execCommand/execCommandNormalizeOptions.d.ts +0 -10
  145. /package/esm/typings/src/{scrapers/website/WebsiteScraper.test.d.ts → executables/apps/locateLibreoffice.test.d.ts} +0 -0
  146. /package/esm/typings/src/{scrapers/website/utils/markdownConverter.test.d.ts → executables/apps/locatePandoc.test.d.ts} +0 -0
@@ -1,14 +1,16 @@
1
- import type { IExecCommandOptions } from './IExecCommandOptions';
1
+ import type { ExecCommandOptions } from './ExecCommandOptions';
2
2
  /**
3
3
  * Run one command in a shell
4
4
  *
5
+ *
5
6
  * Note: There are 2 similar functions in the codebase:
6
7
  * - `$execCommand` which runs a single command
7
8
  * - `$execCommands` which runs multiple commands
9
+ * Note: `$` is used to indicate that this function is not a pure function - it runs a command in a shell
8
10
  *
9
11
  * @public exported from `@promptbook/node`
10
12
  */
11
- export declare function $execCommand(options: IExecCommandOptions): Promise<string>;
13
+ export declare function $execCommand(options: ExecCommandOptions): Promise<string>;
12
14
  /**
13
15
  * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
14
16
  */
@@ -0,0 +1,12 @@
1
+ import type { ExecCommandOptions } from './ExecCommandOptions';
2
+ import type { ExecCommandOptionsAdvanced } from './ExecCommandOptions';
3
+ /**
4
+ * Normalize options for `execCommand` and `execCommands`
5
+ *
6
+ * Note: `$` is used to indicate that this function behaves differently according to `process.platform`
7
+ *
8
+ * @private internal utility of `execCommand` and `execCommands`
9
+ */
10
+ export declare function $execCommandNormalizeOptions(options: ExecCommandOptions): Pick<ExecCommandOptionsAdvanced, 'command' | 'args' | 'cwd' | 'crashOnError' | 'timeout' | 'isVerbose'> & {
11
+ humanReadableCommand: string;
12
+ };
@@ -4,6 +4,7 @@
4
4
  * Note: There are 2 similar functions in the codebase:
5
5
  * - `$execCommand` which runs a single command
6
6
  * - `$execCommands` which runs multiple commands
7
+ * Note: `$` is used to indicate that this function is not a pure function - it runs a commands in a shell
7
8
  *
8
9
  * @public exported from `@promptbook/node`
9
10
  */
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @deprecated Use sth from type-fest or move this to type helpers
3
+ */
4
+ type RequiredAndOptional<TBase, TRequired extends keyof TBase, TOptional extends keyof TBase> = Pick<TBase, TRequired> & Partial<Pick<TBase, TOptional>>;
5
+ /**
6
+ * Simple options for `execCommand`
7
+ */
8
+ export type ExecCommandOptions = string | RequiredAndOptional<ExecCommandOptionsAdvanced, 'command', 'args' | 'cwd' | 'crashOnError' | 'timeout' | 'isVerbose'>;
9
+ /**
10
+ * Advanced options for `execCommand`
11
+ */
12
+ export type ExecCommandOptionsAdvanced = {
13
+ /**
14
+ * Command to run
15
+ */
16
+ readonly command: string;
17
+ /**
18
+ * Arguments for the command
19
+ */
20
+ readonly args: string[];
21
+ /**
22
+ * Current working directory
23
+ *
24
+ * @default process.cwd()
25
+ */
26
+ readonly cwd: string;
27
+ /**
28
+ * If `true` then the command will throw an error if the return code is not `0`
29
+ */
30
+ readonly crashOnError: boolean;
31
+ /**
32
+ * Timeout in milliseconds
33
+ */
34
+ readonly timeout: number;
35
+ /**
36
+ * If `true` then the command and entire CLI output will be logged to the console
37
+ *
38
+ * @default false
39
+ */
40
+ readonly isVerbose?: boolean;
41
+ };
42
+ export {};
43
+ /**
44
+ * TODO: [⏳] Make DEFAULT_TIMEOUT_MS as global constant
45
+ */
@@ -4,7 +4,7 @@ import type { ExpectationAmount } from '../../types/PipelineJson/Expectations';
4
4
  *
5
5
  * @public exported from `@promptbook/utils`
6
6
  */
7
- export declare function splitIntoSentences(text: string): Array<string>;
7
+ export declare function splitIntoSentences(text: string): ReadonlyArray<string>;
8
8
  /**
9
9
  * Counts number of sentences in the text
10
10
  *
@@ -0,0 +1,11 @@
1
+ import type { FilesystemTools } from '../../execution/FilesystemTools';
2
+ /**
3
+ * Checks if the file is executable
4
+ *
5
+ * @private within the repository
6
+ */
7
+ export declare function isExecutable(path: string, fs: FilesystemTools): Promise<boolean>;
8
+ /**
9
+ * Note: Not [~🟢~] because it is not directly dependent on `fs
10
+ * TODO: [🖇] What about symlinks?
11
+ */
@@ -30,7 +30,7 @@ export type CodeBlock = {
30
30
  * @throws {ParseError} if block is not closed properly
31
31
  * @public exported from `@promptbook/markdown-utils`
32
32
  */
33
- export declare function extractAllBlocksFromMarkdown(markdown: string_markdown): Array<CodeBlock>;
33
+ export declare function extractAllBlocksFromMarkdown(markdown: string_markdown): ReadonlyArray<CodeBlock>;
34
34
  /**
35
35
  * TODO: Maybe name for `blockNotation` instead of '```' and '>'
36
36
  */
@@ -5,7 +5,7 @@ import type { string_markdown_section } from '../../types/typeAliases';
5
5
  *
6
6
  * @public exported from `@promptbook/markdown-utils`
7
7
  */
8
- export declare function splitMarkdownIntoSections(markdown: string_markdown): Array<string_markdown_section>;
8
+ export declare function splitMarkdownIntoSections(markdown: string_markdown): ReadonlyArray<string_markdown_section>;
9
9
  /**
10
10
  * TODO: [🏛] This can be part of markdown builder
11
11
  * Note: [🕞] In past (commit 42086e1603cbed506482997c00a8ee979af0a247) there was much more
@@ -2,7 +2,7 @@
2
2
  * Semantic helper
3
3
  *
4
4
  * Keyword is string without diacritics in lowercase [a-z1-9]
5
- * Words are splitted between multiple keywords @see IKeywords
5
+ * Words are splitted between multiple keywords @see Keywords
6
6
  *
7
7
  * For example `"keyword"`
8
8
  *
@@ -15,7 +15,7 @@ export type string_keyword = string;
15
15
  *
16
16
  * @public exported from `@promptbook/utils`
17
17
  */
18
- export type IKeywords = Set<string_keyword>;
18
+ export type Keywords = Set<string_keyword>;
19
19
  /**
20
20
  * TODO: [🌮] Keywords with weight
21
21
  */
@@ -1,5 +1,5 @@
1
1
  import type { really_unknown } from '../organization/really_unknown';
2
- import type { IKeywords } from './IKeywords';
2
+ import type { Keywords } from './IKeywords';
3
3
  /**
4
4
  * Parses keywords from any object and recursively walks through
5
5
  *
@@ -9,7 +9,7 @@ import type { IKeywords } from './IKeywords';
9
9
  * @returns {Set} of keywords without diacritics in lowercase
10
10
  * @public exported from `@promptbook/utils`
11
11
  */
12
- export declare function parseKeywords(input: really_unknown): IKeywords;
12
+ export declare function parseKeywords(input: really_unknown): Keywords;
13
13
  /**
14
14
  * Note: Not using spread in input param because of keeping second parameter for options
15
15
  * TODO: [🌺] Use some intermediate util splitWords
@@ -1,4 +1,4 @@
1
- import type { IKeywords } from './IKeywords';
1
+ import type { Keywords } from './IKeywords';
2
2
  /**
3
3
  * Parses keywords from a string
4
4
  *
@@ -6,4 +6,4 @@ import type { IKeywords } from './IKeywords';
6
6
  * @returns {Set} of keywords without diacritics in lowercase
7
7
  * @public exported from `@promptbook/utils`
8
8
  */
9
- export declare function parseKeywordsFromString(input: string): IKeywords;
9
+ export declare function parseKeywordsFromString(input: string): Keywords;
@@ -1,4 +1,4 @@
1
- import type { IKeywords } from './IKeywords';
1
+ import type { Keywords } from './IKeywords';
2
2
  /**
3
3
  * @@@
4
4
  *
@@ -7,4 +7,4 @@ import type { IKeywords } from './IKeywords';
7
7
  * @returns
8
8
  * @public exported from `@promptbook/utils`
9
9
  */
10
- export declare function searchKeywords(haystack: IKeywords, needle: IKeywords): boolean;
10
+ export declare function searchKeywords(haystack: Keywords, needle: Keywords): boolean;
@@ -9,4 +9,4 @@ import type { really_any } from './really_any';
9
9
  * @returns void
10
10
  * @private within the repository
11
11
  */
12
- export declare function TODO_USE(...value: Array<really_any>): void;
12
+ export declare function TODO_USE(...value: ReadonlyArray<really_any>): void;
@@ -13,4 +13,4 @@ import type { really_any } from './really_any';
13
13
  * @returns void
14
14
  * @private within the repository
15
15
  */
16
- export declare function keepUnused<TTypeToKeep1 = really_any, TTypeToKeep2 = really_any, TTypeToKeep3 = really_any>(...valuesToKeep: Array<really_any>): void;
16
+ export declare function keepUnused<TTypeToKeep1 = really_any, TTypeToKeep2 = really_any, TTypeToKeep3 = really_any>(...valuesToKeep: ReadonlyArray<really_any>): void;
@@ -3,7 +3,7 @@ import type { number_seed } from '../../types/typeAliases';
3
3
  * Generates random seed
4
4
  *
5
5
  * Note: `$` is used to indicate that this function is not a pure function - it is not deterministic
6
- * Warning: This function is not cryptographically secure (it uses Math.random internally)
6
+ * Warning: This function is NOT cryptographically secure (it uses Math.random internally)
7
7
  * @public exported from `@promptbook/utils`
8
8
  */
9
9
  export declare function $randomSeed(): number_seed;
@@ -4,4 +4,4 @@
4
4
  * @deprecated use new javascript set methods instead @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
5
5
  * @public exported from `@promptbook/utils`
6
6
  */
7
- export declare function intersection<TItem>(...sets: Array<Set<TItem>>): Set<TItem>;
7
+ export declare function intersection<TItem>(...sets: ReadonlyArray<Set<TItem>>): Set<TItem>;
@@ -4,4 +4,4 @@
4
4
  * @deprecated use new javascript set methods instead @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
5
5
  * @public exported from `@promptbook/utils`
6
6
  */
7
- export declare function union<TItem>(...sets: Array<Set<TItem>>): Set<TItem>;
7
+ export declare function union<TItem>(...sets: ReadonlyArray<Set<TItem>>): Set<TItem>;
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * Additional options for `unwrapResult`
3
3
  */
4
- interface UnwrapResultOptions {
4
+ type UnwrapResultOptions = {
5
5
  /**
6
6
  * If true, the text is trimmed before processing
7
7
  */
8
- isTrimmed?: boolean;
8
+ readonly isTrimmed?: boolean;
9
9
  /**
10
10
  * If true, the introduce sentence is removed
11
11
  *
@@ -15,8 +15,8 @@ interface UnwrapResultOptions {
15
15
  *
16
16
  * @default true
17
17
  */
18
- isIntroduceSentenceRemoved?: boolean;
19
- }
18
+ readonly isIntroduceSentenceRemoved?: boolean;
19
+ };
20
20
  /**
21
21
  * Removes quotes and optional introduce text from a string
22
22
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/browser",
3
- "version": "0.72.0-9",
3
+ "version": "0.73.0",
4
4
  "description": "Supercharge your use of large language models",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -11,6 +11,7 @@
11
11
  "contributors": [
12
12
  "Pavol Hejný <me@pavolhejny.com> (https://www.pavolhejny.com/)"
13
13
  ],
14
+ "todo-0": "TODO: [❇️] Make better list of keywords",
14
15
  "keywords": [
15
16
  "ai",
16
17
  "llm",
@@ -30,7 +31,8 @@
30
31
  "o1",
31
32
  "o1-mini",
32
33
  "o1-preview",
33
- "anthropic"
34
+ "anthropic",
35
+ "LLMOps"
34
36
  ],
35
37
  "license": "CC-BY-4.0",
36
38
  "bugs": {
@@ -51,9 +53,9 @@
51
53
  "module": "./esm/index.es.js",
52
54
  "typings": "./esm/typings/src/_packages/browser.index.d.ts",
53
55
  "peerDependencies": {
54
- "@promptbook/core": "0.72.0-9"
56
+ "@promptbook/core": "0.73.0"
55
57
  },
56
58
  "dependencies": {
57
- "spacetrim": "0.11.39"
59
+ "spacetrim": "0.11.59"
58
60
  }
59
61
  }
package/umd/index.umd.js CHANGED
@@ -12,7 +12,7 @@
12
12
  /**
13
13
  * The version of the Promptbook library
14
14
  */
15
- var PROMPTBOOK_VERSION = '0.72.0-8';
15
+ var PROMPTBOOK_VERSION = '0.72.0';
16
16
  // TODO: [main] !!!! List here all the versions and annotate + put into script
17
17
 
18
18
  /*! *****************************************************************************
@@ -200,32 +200,6 @@
200
200
  */
201
201
  var $isRunningInWebWorker = new Function("\n try {\n if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {\n return true;\n } else {\n return false;\n }\n } catch (e) {\n return false;\n }\n");
202
202
 
203
- /**
204
- * @@@!!!!!!
205
- *
206
- * 1) @@@
207
- * 2) @@@
208
- *
209
- * @public exported from `@promptbook/browser`
210
- */
211
- function $provideScrapersForBrowser(tools, options) {
212
- return __awaiter(this, void 0, void 0, function () {
213
- var isAutoInstalled /* Note: [0] Intentionally not assigning a default value = IS_AUTO_INSTALLED */;
214
- return __generator(this, function (_a) {
215
- if (!$isRunningInBrowser() || $isRunningInWebWorker()) {
216
- throw new EnvironmentMismatchError('Function `$provideScrapersForBrowser` works only in browser environment');
217
- }
218
- isAutoInstalled = (options || {}).isAutoInstalled;
219
- if (isAutoInstalled === true /* <- Note: [0] Ignoring undefined, just checking EXPLICIT requirement for install */) {
220
- throw new EnvironmentMismatchError('Auto-installing is not supported in browser environment');
221
- }
222
- return [2 /*return*/, [
223
- // TODO: !!!!!!! Implement
224
- ]];
225
- });
226
- });
227
- }
228
-
229
203
  /**
230
204
  * @@@
231
205
  *
@@ -441,10 +415,10 @@
441
415
  'content',
442
416
  'context',
443
417
  'knowledge',
444
- 'samples',
418
+ 'examples',
445
419
  'modelName',
446
420
  'currentDate',
447
- // <- TODO: !!!!! list here all command names
421
+ // <- TODO: list here all command names
448
422
  // <- TODO: Add more like 'date', 'modelName',...
449
423
  // <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
450
424
  ]);
@@ -464,6 +438,229 @@
464
438
  * TODO: [🧠][🧜‍♂️] Maybe join remoteUrl and path into single value
465
439
  */
466
440
 
441
+ /**
442
+ * This error type indicates that some part of the code is not implemented yet
443
+ *
444
+ * @public exported from `@promptbook/core`
445
+ */
446
+ var NotYetImplementedError = /** @class */ (function (_super) {
447
+ __extends(NotYetImplementedError, _super);
448
+ function NotYetImplementedError(message) {
449
+ var _this = _super.call(this, spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This feature is not implemented yet but it will be soon.\n\n If you want speed up the implementation or just read more, look here:\n https://github.com/webgptorg/promptbook\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
450
+ _this.name = 'NotYetImplementedError';
451
+ Object.setPrototypeOf(_this, NotYetImplementedError.prototype);
452
+ return _this;
453
+ }
454
+ return NotYetImplementedError;
455
+ }(Error));
456
+
457
+ /**
458
+ * @@@
459
+ *
460
+ * Note: `$` is used to indicate that this function is not a pure function - it access global scope
461
+ *
462
+ * @private internal function of `$Register`
463
+ */
464
+ function $getGlobalScope() {
465
+ return Function('return this')();
466
+ }
467
+
468
+ /**
469
+ * @@@
470
+ *
471
+ * @param text @@@
472
+ * @returns @@@
473
+ * @example 'HELLO_WORLD'
474
+ * @example 'I_LOVE_PROMPTBOOK'
475
+ * @public exported from `@promptbook/utils`
476
+ */
477
+ function normalizeTo_SCREAMING_CASE(text) {
478
+ var e_1, _a;
479
+ var charType;
480
+ var lastCharType = 'OTHER';
481
+ var normalizedName = '';
482
+ try {
483
+ for (var text_1 = __values(text), text_1_1 = text_1.next(); !text_1_1.done; text_1_1 = text_1.next()) {
484
+ var char = text_1_1.value;
485
+ var normalizedChar = void 0;
486
+ if (/^[a-z]$/.test(char)) {
487
+ charType = 'LOWERCASE';
488
+ normalizedChar = char.toUpperCase();
489
+ }
490
+ else if (/^[A-Z]$/.test(char)) {
491
+ charType = 'UPPERCASE';
492
+ normalizedChar = char;
493
+ }
494
+ else if (/^[0-9]$/.test(char)) {
495
+ charType = 'NUMBER';
496
+ normalizedChar = char;
497
+ }
498
+ else {
499
+ charType = 'OTHER';
500
+ normalizedChar = '_';
501
+ }
502
+ if (charType !== lastCharType &&
503
+ !(lastCharType === 'UPPERCASE' && charType === 'LOWERCASE') &&
504
+ !(lastCharType === 'NUMBER') &&
505
+ !(charType === 'NUMBER')) {
506
+ normalizedName += '_';
507
+ }
508
+ normalizedName += normalizedChar;
509
+ lastCharType = charType;
510
+ }
511
+ }
512
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
513
+ finally {
514
+ try {
515
+ if (text_1_1 && !text_1_1.done && (_a = text_1.return)) _a.call(text_1);
516
+ }
517
+ finally { if (e_1) throw e_1.error; }
518
+ }
519
+ normalizedName = normalizedName.replace(/_+/g, '_');
520
+ normalizedName = normalizedName.replace(/_?\/_?/g, '/');
521
+ normalizedName = normalizedName.replace(/^_/, '');
522
+ normalizedName = normalizedName.replace(/_$/, '');
523
+ return normalizedName;
524
+ }
525
+ /**
526
+ * TODO: Tests
527
+ * > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: 'Moje tabule' })).toEqual('/VtG7sR9rRJqwNEdM2/Moje tabule');
528
+ * > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: 'ěščřžžýáíúů' })).toEqual('/VtG7sR9rRJqwNEdM2/escrzyaieuu');
529
+ * > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: ' ahoj ' })).toEqual('/VtG7sR9rRJqwNEdM2/ahoj');
530
+ * > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: ' ahoj_ahojAhoj ahoj ' })).toEqual('/VtG7sR9rRJqwNEdM2/ahoj-ahoj-ahoj-ahoj');
531
+ * TODO: [🌺] Use some intermediate util splitWords
532
+ */
533
+
534
+ /**
535
+ * @@@
536
+ *
537
+ * @param text @@@
538
+ * @returns @@@
539
+ * @example 'hello_world'
540
+ * @example 'i_love_promptbook'
541
+ * @public exported from `@promptbook/utils`
542
+ */
543
+ function normalizeTo_snake_case(text) {
544
+ return normalizeTo_SCREAMING_CASE(text).toLowerCase();
545
+ }
546
+
547
+ /**
548
+ * Register is @@@
549
+ *
550
+ * Note: `$` is used to indicate that this function is not a pure function - it accesses and adds variables in global scope.
551
+ *
552
+ * @private internal utility, exported are only signleton instances of this class
553
+ */
554
+ var $Register = /** @class */ (function () {
555
+ function $Register(registerName) {
556
+ this.registerName = registerName;
557
+ var storageName = "_promptbook_".concat(normalizeTo_snake_case(registerName));
558
+ var globalScope = $getGlobalScope();
559
+ if (globalScope[storageName] === undefined) {
560
+ globalScope[storageName] = [];
561
+ }
562
+ else if (!Array.isArray(globalScope[storageName])) {
563
+ throw new UnexpectedError("Expected (global) ".concat(storageName, " to be an array, but got ").concat(typeof globalScope[storageName]));
564
+ }
565
+ this.storage = globalScope[storageName];
566
+ }
567
+ $Register.prototype.list = function () {
568
+ // <- TODO: ReadonlyDeep<ReadonlyArray<TRegistered>>
569
+ return this.storage;
570
+ };
571
+ $Register.prototype.register = function (registered) {
572
+ var packageName = registered.packageName, className = registered.className;
573
+ var existingRegistrationIndex = this.storage.findIndex(function (item) { return item.packageName === packageName && item.className === className; });
574
+ var existingRegistration = this.storage[existingRegistrationIndex];
575
+ if (!existingRegistration) {
576
+ this.storage.push(registered);
577
+ }
578
+ else {
579
+ this.storage[existingRegistrationIndex] = registered;
580
+ }
581
+ return {
582
+ registerName: this.registerName,
583
+ packageName: packageName,
584
+ className: className,
585
+ get isDestroyed() {
586
+ return false;
587
+ },
588
+ destroy: function () {
589
+ throw new NotYetImplementedError("Registration to ".concat(this.registerName, " is permanent in this version of Promptbook"));
590
+ },
591
+ };
592
+ };
593
+ return $Register;
594
+ }());
595
+
596
+ /**
597
+ * @@@
598
+ *
599
+ * Note: `$` is used to indicate that this interacts with the global scope
600
+ * @singleton Only one instance of each register is created per build, but thare can be more @@@
601
+ * @public exported from `@promptbook/core`
602
+ */
603
+ var $scrapersRegister = new $Register('scraper_constructors');
604
+ /**
605
+ * TODO: [®] DRY Register logic
606
+ */
607
+
608
+ /**
609
+ * @@@
610
+ *
611
+ * 1) @@@
612
+ * 2) @@@
613
+ *
614
+ * @public exported from `@promptbook/browser`
615
+ */
616
+ function $provideScrapersForBrowser(tools, options) {
617
+ return __awaiter(this, void 0, void 0, function () {
618
+ var isAutoInstalled /* Note: [0] Intentionally not assigning a default value = IS_AUTO_INSTALLED */, scrapers, _a, _b, scraperFactory, scraper, e_1_1;
619
+ var e_1, _c;
620
+ return __generator(this, function (_d) {
621
+ switch (_d.label) {
622
+ case 0:
623
+ if (!$isRunningInBrowser() || $isRunningInWebWorker()) {
624
+ throw new EnvironmentMismatchError('Function `$provideScrapersForBrowser` works only in browser environment');
625
+ }
626
+ isAutoInstalled = (options || {}).isAutoInstalled;
627
+ if (isAutoInstalled === true /* <- Note: [0] Ignoring undefined, just checking EXPLICIT requirement for install */) {
628
+ throw new EnvironmentMismatchError('Auto-installing is not supported in browser environment');
629
+ }
630
+ scrapers = [];
631
+ _d.label = 1;
632
+ case 1:
633
+ _d.trys.push([1, 6, 7, 8]);
634
+ _a = __values($scrapersRegister.list()), _b = _a.next();
635
+ _d.label = 2;
636
+ case 2:
637
+ if (!!_b.done) return [3 /*break*/, 5];
638
+ scraperFactory = _b.value;
639
+ return [4 /*yield*/, scraperFactory(tools, options || {})];
640
+ case 3:
641
+ scraper = _d.sent();
642
+ scrapers.push(scraper);
643
+ _d.label = 4;
644
+ case 4:
645
+ _b = _a.next();
646
+ return [3 /*break*/, 2];
647
+ case 5: return [3 /*break*/, 8];
648
+ case 6:
649
+ e_1_1 = _d.sent();
650
+ e_1 = { error: e_1_1 };
651
+ return [3 /*break*/, 8];
652
+ case 7:
653
+ try {
654
+ if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
655
+ }
656
+ finally { if (e_1) throw e_1.error; }
657
+ return [7 /*endfinally*/];
658
+ case 8: return [2 /*return*/, scrapers];
659
+ }
660
+ });
661
+ });
662
+ }
663
+
467
664
  /**
468
665
  * Tests if the value is [🚉] serializable as JSON
469
666
  *
@@ -518,7 +715,7 @@
518
715
  return pipelineJsonStringified;
519
716
  }
520
717
  /**
521
- * TODO: [🐝] Not Working propperly @see https://promptbook.studio/samples/mixed-knowledge.ptbk.md
718
+ * TODO: [🐝] Not Working propperly @see https://promptbook.studio/examples/mixed-knowledge.ptbk.md
522
719
  * TODO: [🧠][0] Maybe rename to `stringifyPipelineJson`, `stringifyIndexedJson`,...
523
720
  * TODO: [🧠] Maybe more elegant solution than replacing via regex
524
721
  * TODO: [🍙] Make some standard order of json properties