@promptbook/remote-server 0.80.0 → 0.81.0-5

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 (26) hide show
  1. package/README.md +6 -0
  2. package/esm/index.es.js +1 -1
  3. package/esm/typings/src/_packages/core.index.d.ts +0 -6
  4. package/esm/typings/src/_packages/editable.index.d.ts +10 -0
  5. package/esm/typings/src/_packages/templates.index.d.ts +4 -0
  6. package/esm/typings/src/_packages/types.index.d.ts +4 -0
  7. package/esm/typings/src/_packages/utils.index.d.ts +2 -2
  8. package/esm/typings/src/execution/ExecutionTools.d.ts +7 -0
  9. package/esm/typings/src/execution/PromptbookFetch.d.ts +5 -0
  10. package/esm/typings/src/execution/PromptbookFetch.test-type.d.ts +5 -0
  11. package/esm/typings/src/expectations/drafts/isDomainNameFree.d.ts +2 -1
  12. package/esm/typings/src/expectations/drafts/isGithubNameFree.d.ts +2 -1
  13. package/esm/typings/src/scrapers/_common/utils/makeKnowledgeSourceHandler.d.ts +1 -1
  14. package/esm/typings/src/scrapers/_common/utils/scraperFetch.d.ts +7 -0
  15. package/esm/typings/src/utils/editable/types/PipelineEditableSerialized.d.ts +42 -0
  16. package/esm/typings/src/{conversion → utils/editable}/utils/removePipelineCommand.d.ts +3 -3
  17. package/esm/typings/src/{conversion → utils/editable}/utils/renamePipelineParameter.d.ts +3 -3
  18. package/esm/typings/src/{conversion → utils/editable}/utils/stringifyPipelineJson.d.ts +2 -2
  19. package/esm/typings/src/utils/getBookTemplate.d.ts +12 -0
  20. package/esm/typings/src/utils/parameters/{replaceParameters.d.ts → templateParameters.d.ts} +1 -1
  21. package/package.json +2 -2
  22. package/umd/index.umd.js +1 -1
  23. /package/esm/typings/src/{conversion → utils/editable}/utils/removePipelineCommand.test.d.ts +0 -0
  24. /package/esm/typings/src/{conversion → utils/editable}/utils/renamePipelineParameter.test.d.ts +0 -0
  25. /package/esm/typings/src/{conversion → utils/editable}/utils/stringifyPipelineJson.test.d.ts +0 -0
  26. /package/esm/typings/src/utils/parameters/{replaceParameters.test.d.ts → templateParameters.test.d.ts} +0 -0
package/README.md CHANGED
@@ -23,6 +23,10 @@
23
23
 
24
24
 
25
25
 
26
+ <blockquote style="color: #ff8811">
27
+ <b>⚠ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>.
28
+ </blockquote>
29
+
26
30
  ## 📦 Package `@promptbook/remote-server`
27
31
 
28
32
  - Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
@@ -247,6 +251,8 @@ Or you can install them separately:
247
251
  - **[@promptbook/documents](https://www.npmjs.com/package/@promptbook/documents)** - Read knowledge from documents like `.docx`, `.odt`,…
248
252
  - **[@promptbook/legacy-documents](https://www.npmjs.com/package/@promptbook/legacy-documents)** - Read knowledge from legacy documents like `.doc`, `.rtf`,…
249
253
  - **[@promptbook/website-crawler](https://www.npmjs.com/package/@promptbook/website-crawler)** - Crawl knowledge from the web
254
+ - **[@promptbook/editable](https://www.npmjs.com/package/@promptbook/editable)** - Editable book as native javascript object with imperative object API
255
+ - **[@promptbook/templates](https://www.npmjs.com/package/@promptbook/templates)** - Usefull templates and examples of books which can be used as a starting point
250
256
  - **[@promptbook/types](https://www.npmjs.com/package/@promptbook/types)** - Just typescript types used in the library
251
257
  - **[@promptbook/cli](https://www.npmjs.com/package/@promptbook/cli)** - Command line interface utilities for promptbooks
252
258
 
package/esm/index.es.js CHANGED
@@ -15,7 +15,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
15
15
  *
16
16
  * @see https://github.com/webgptorg/promptbook
17
17
  */
18
- var PROMPTBOOK_ENGINE_VERSION = '0.80.0-1';
18
+ var PROMPTBOOK_ENGINE_VERSION = '0.81.0-4';
19
19
  /**
20
20
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
21
21
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -34,9 +34,6 @@ import { pipelineJsonToString } from '../conversion/pipelineJsonToString';
34
34
  import { precompilePipeline } from '../conversion/precompilePipeline';
35
35
  import { prettifyPipelineString } from '../conversion/prettify/prettifyPipelineString';
36
36
  import { extractParameterNamesFromTask } from '../conversion/utils/extractParameterNamesFromTask';
37
- import { removePipelineCommand } from '../conversion/utils/removePipelineCommand';
38
- import { renamePipelineParameter } from '../conversion/utils/renamePipelineParameter';
39
- import { stringifyPipelineJson } from '../conversion/utils/stringifyPipelineJson';
40
37
  import { validatePipeline } from '../conversion/validation/validatePipeline';
41
38
  import { CallbackInterfaceTools } from '../dialogs/callback/CallbackInterfaceTools';
42
39
  import type { CallbackInterfaceToolsOptions } from '../dialogs/callback/CallbackInterfaceToolsOptions';
@@ -155,9 +152,6 @@ export { pipelineJsonToString };
155
152
  export { precompilePipeline };
156
153
  export { prettifyPipelineString };
157
154
  export { extractParameterNamesFromTask };
158
- export { removePipelineCommand };
159
- export { renamePipelineParameter };
160
- export { stringifyPipelineJson };
161
155
  export { validatePipeline };
162
156
  export { CallbackInterfaceTools };
163
157
  export type { CallbackInterfaceToolsOptions };
@@ -0,0 +1,10 @@
1
+ import { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION } from '../version';
2
+ import type { PipelineEditableSerialized } from '../utils/editable/types/PipelineEditableSerialized';
3
+ import { removePipelineCommand } from '../utils/editable/utils/removePipelineCommand';
4
+ import { renamePipelineParameter } from '../utils/editable/utils/renamePipelineParameter';
5
+ import { stringifyPipelineJson } from '../utils/editable/utils/stringifyPipelineJson';
6
+ export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION };
7
+ export type { PipelineEditableSerialized };
8
+ export { removePipelineCommand };
9
+ export { renamePipelineParameter };
10
+ export { stringifyPipelineJson };
@@ -0,0 +1,4 @@
1
+ import { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION } from '../version';
2
+ import { getBookTemplate } from '../utils/getBookTemplate';
3
+ export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION };
4
+ export { getBookTemplate };
@@ -30,6 +30,7 @@ import type { LlmExecutionTools } from '../execution/LlmExecutionTools';
30
30
  import type { LlmExecutionToolsConstructor } from '../execution/LlmExecutionToolsConstructor';
31
31
  import type { PipelineExecutor } from '../execution/PipelineExecutor';
32
32
  import type { PipelineExecutorResult } from '../execution/PipelineExecutorResult';
33
+ import type { PromptbookFetch } from '../execution/PromptbookFetch';
33
34
  import type { PromptResult } from '../execution/PromptResult';
34
35
  import type { CompletionPromptResult } from '../execution/PromptResult';
35
36
  import type { ChatPromptResult } from '../execution/PromptResult';
@@ -241,6 +242,7 @@ import type { number_gigabytes } from '../types/typeAliases';
241
242
  import type { number_terabytes } from '../types/typeAliases';
242
243
  import type { Registered } from '../utils/$Register';
243
244
  import type { Registration } from '../utils/$Register';
245
+ import type { PipelineEditableSerialized } from '../utils/editable/types/PipelineEditableSerialized';
244
246
  import type { ExecCommandOptions } from '../utils/execCommand/ExecCommandOptions';
245
247
  import type { ExecCommandOptionsAdvanced } from '../utils/execCommand/ExecCommandOptions';
246
248
  import type { FromtoItems } from '../utils/FromtoItems';
@@ -292,6 +294,7 @@ export type { LlmExecutionTools };
292
294
  export type { LlmExecutionToolsConstructor };
293
295
  export type { PipelineExecutor };
294
296
  export type { PipelineExecutorResult };
297
+ export type { PromptbookFetch };
295
298
  export type { PromptResult };
296
299
  export type { CompletionPromptResult };
297
300
  export type { ChatPromptResult };
@@ -503,6 +506,7 @@ export type { number_gigabytes };
503
506
  export type { number_terabytes };
504
507
  export type { Registered };
505
508
  export type { Registration };
509
+ export type { PipelineEditableSerialized };
506
510
  export type { ExecCommandOptions };
507
511
  export type { ExecCommandOptionsAdvanced };
508
512
  export type { FromtoItems };
@@ -46,7 +46,7 @@ import { searchKeywords } from '../utils/normalization/searchKeywords';
46
46
  import { titleToName } from '../utils/normalization/titleToName';
47
47
  import { spaceTrim } from '../utils/organization/spaceTrim';
48
48
  import { extractParameterNames } from '../utils/parameters/extractParameterNames';
49
- import { replaceParameters } from '../utils/parameters/replaceParameters';
49
+ import { templateParameters } from '../utils/parameters/templateParameters';
50
50
  import { parseNumber } from '../utils/parseNumber';
51
51
  import { $randomSeed } from '../utils/random/$randomSeed';
52
52
  import { removeEmojis } from '../utils/removeEmojis';
@@ -121,7 +121,7 @@ export { searchKeywords };
121
121
  export { titleToName };
122
122
  export { spaceTrim };
123
123
  export { extractParameterNames };
124
- export { replaceParameters };
124
+ export { templateParameters };
125
125
  export { parseNumber };
126
126
  export { $randomSeed };
127
127
  export { removeEmojis };
@@ -3,6 +3,7 @@ import type { Arrayable } from '../types/Arrayable';
3
3
  import type { Executables } from './Executables';
4
4
  import type { FilesystemTools } from './FilesystemTools';
5
5
  import type { LlmExecutionTools } from './LlmExecutionTools';
6
+ import type { PromptbookFetch } from './PromptbookFetch';
6
7
  import type { ScriptExecutionTools } from './ScriptExecutionTools';
7
8
  import type { UserInterfaceTools } from './UserInterfaceTools';
8
9
  /**
@@ -27,6 +28,12 @@ export type ExecutionTools = {
27
28
  * @default undefined - If not provided, no filesystem operations will be possible
28
29
  */
29
30
  readonly fs?: FilesystemTools;
31
+ /**
32
+ * Fetch function for fetching resources
33
+ *
34
+ * @default `fetch` - If not provided, the built-in `fetch' function is used with a lightweight error handling wrapper.
35
+ */
36
+ readonly fetch?: PromptbookFetch;
30
37
  /**
31
38
  * Scrapers for extracting knowledge from external sources
32
39
  *
@@ -0,0 +1,5 @@
1
+ import type { string_url } from '../types/typeAliases';
2
+ /**
3
+ * Fetch function for fetching data from the internet used in scraping
4
+ */
5
+ export type PromptbookFetch = (url: string_url, init?: RequestInit) => Promise<Response>;
@@ -0,0 +1,5 @@
1
+ export {};
2
+ /**
3
+ * Note: [⚪] This should never be in any released package
4
+ * TODO: Is this a good pattern to do type testing?
5
+ */
@@ -1,8 +1,9 @@
1
+ import type { PromptbookFetch } from '../../execution/PromptbookFetch';
1
2
  import type { string_name } from '../../types/typeAliases';
2
3
  /**
3
4
  * @private still in development
4
5
  */
5
- export declare function isDomainNameFree(name: string_name): Promise<boolean>;
6
+ export declare function isDomainNameFree(name: string_name, fetch: PromptbookFetch): Promise<boolean>;
6
7
  /**
7
8
  * TODO: [🍓][🧠] Test and implement `isDomainNameFree`
8
9
  * TODO: Export via some (and probably new) NPM package
@@ -1,8 +1,9 @@
1
+ import type { PromptbookFetch } from '../../execution/PromptbookFetch';
1
2
  import type { string_name } from '../../types/typeAliases';
2
3
  /**
3
4
  * @private still in development
4
5
  */
5
- export declare function isGithubNameFree(name: string_name): Promise<boolean>;
6
+ export declare function isGithubNameFree(name: string_name, fetch: PromptbookFetch): Promise<boolean>;
6
7
  /**
7
8
  * TODO: [🍓][🧠] Test and implement `isGithubNameFree`
8
9
  * TODO: Export via some (and probably new) NPM package
@@ -8,4 +8,4 @@ import type { ScraperSourceHandler } from '../Scraper';
8
8
  *
9
9
  * @public exported from `@promptbook/core`
10
10
  */
11
- export declare function makeKnowledgeSourceHandler(knowledgeSource: SetOptional<KnowledgeSourceJson, 'name'>, tools: Pick<ExecutionTools, 'fs'>, options?: Pick<PrepareAndScrapeOptions, 'rootDirname' | 'isVerbose'>): Promise<ScraperSourceHandler>;
11
+ export declare function makeKnowledgeSourceHandler(knowledgeSource: SetOptional<KnowledgeSourceJson, 'name'>, tools: Pick<ExecutionTools, 'fs' | 'fetch'>, options?: Pick<PrepareAndScrapeOptions, 'rootDirname' | 'isVerbose'>): Promise<ScraperSourceHandler>;
@@ -0,0 +1,7 @@
1
+ import type { PromptbookFetch } from '../../../execution/PromptbookFetch';
2
+ /**
3
+ * The built-in `fetch' function with a lightweight error handling wrapper as default fetch function used in Promptbook scrapers
4
+ *
5
+ * @private as default `fetch` function used in Promptbook scrapers
6
+ */
7
+ export declare const scraperFetch: PromptbookFetch;
@@ -0,0 +1,42 @@
1
+ import type { ErrorJson } from '../../../errors/utils/ErrorJson';
2
+ import type { PipelineJson } from '../../../pipeline/PipelineJson/PipelineJson';
3
+ import type { string_date_iso8601 } from '../../../types/typeAliases';
4
+ import type { string_pipeline_url } from '../../../types/typeAliases';
5
+ import type { PipelineString } from '../../../pipeline/PipelineString';
6
+ /**
7
+ * Represents a single pipeline in PromptbookStudio
8
+ *
9
+ * This is simple extension of PipelineJson with additional metadata
10
+ * Note: There are two similar entities:
11
+ * 1) Type (interface) `PipelineEditableSerialized` which represents just data in database
12
+ * 2) Class `PipelineEditable` which implements `PipelineEditableSerialized` and adds error handling and editing capabilities
13
+ *
14
+ * @public exported from `@promptbook/editable`
15
+ */
16
+ export type PipelineEditableSerialized = PipelineJson & {
17
+ /**
18
+ * When was the pipeline created
19
+ */
20
+ readonly createdAt: string_date_iso8601;
21
+ /**
22
+ * When was the pipeline last modified
23
+ */
24
+ readonly updatedAt: string_date_iso8601 | null;
25
+ /**
26
+ * Unique identifier of the pipeline
27
+ *
28
+ * Note: In PromptbookStudio it is required
29
+ */
30
+ readonly pipelineUrl: string_pipeline_url;
31
+ /**
32
+ * Backup of the pipeline string
33
+ *
34
+ * Note: This is present ONLY if pipelineString can not be automatically converted into json (i.e. compilePipeline throws an error)
35
+ * In other words, this is just a BACKUP of pipeline which will be deleted whener pipeline is valid again
36
+ */
37
+ readonly pipelineString: PipelineString | string | null;
38
+ /**
39
+ * Known errors to transfer to new PipelineEditable
40
+ */
41
+ readonly knownErrors: Array<ErrorJson>;
42
+ };
@@ -1,5 +1,5 @@
1
- import type { CommandType } from '../../commands/_common/types/CommandType';
2
- import type { PipelineString } from '../../pipeline/PipelineString';
1
+ import type { CommandType } from '../../../commands/_common/types/CommandType';
2
+ import type { PipelineString } from '../../../pipeline/PipelineString';
3
3
  /**
4
4
  * Options for `removePipelineCommand`
5
5
  */
@@ -16,7 +16,7 @@ type RemovePipelineCommandOptions = {
16
16
  /**
17
17
  * Function `removePipelineCommand` will remove one command from pipeline string
18
18
  *
19
- * @public exported from `@promptbook/core` <- Note: [👖] This utility is so tightly interconnected with the Promptbook that it is not exported as util but in core
19
+ * @public exported from `@promptbook/editable`
20
20
  */
21
21
  export declare function removePipelineCommand(options: RemovePipelineCommandOptions): PipelineString;
22
22
  export {};
@@ -1,5 +1,5 @@
1
- import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
2
- import type { string_name } from '../../types/typeAliases';
1
+ import type { PipelineJson } from '../../../pipeline/PipelineJson/PipelineJson';
2
+ import type { string_name } from '../../../types/typeAliases';
3
3
  type RenameParameterOptions = {
4
4
  /**
5
5
  * Pipeline to search and replace for parameters
@@ -20,7 +20,7 @@ type RenameParameterOptions = {
20
20
  * In other words, it will find all parameters that are not used in the task itseld and all its dependencies
21
21
  *
22
22
  * @throws {PipelineLogicError} If the new parameter name is already used in the pipeline
23
- * @public exported from `@promptbook/core` <- Note: [👖] This utility is so tightly interconnected with the Promptbook that it is not exported as util but in core
23
+ * @public exported from `@promptbook/editable`
24
24
  */
25
25
  export declare function renamePipelineParameter(options: RenameParameterOptions): PipelineJson;
26
26
  export {};
@@ -1,11 +1,11 @@
1
- import type { string_json } from '../../types/typeAliases';
1
+ import type { string_json } from '../../../types/typeAliases';
2
2
  /**
3
3
  * Stringify the PipelineJson with proper formatting
4
4
  *
5
5
  * Note: [0] It can be used for more JSON types like whole collection of pipelines, single knowledge piece, etc.
6
6
  * Note: In contrast to JSON.stringify, this function ensures that **embedding index** is on single line
7
7
  *
8
- * @public exported from `@promptbook/core`
8
+ * @public exported from `@promptbook/editable`
9
9
  */
10
10
  export declare function stringifyPipelineJson<TType>(pipeline: TType): string_json<TType>;
11
11
  /**
@@ -0,0 +1,12 @@
1
+ import type { PipelineJson } from '../pipeline/PipelineJson/PipelineJson';
2
+ import type { string_formfactor_name } from '../formfactors/_common/string_formfactor_name';
3
+ /**
4
+ * Get template for new book
5
+ *
6
+ * @public exported from `@promptbook/templates`
7
+ */
8
+ export declare function getBookTemplate(formfactorName: string_formfactor_name): PipelineJson | null;
9
+ /**
10
+ * TODO: [🧠] Which is the best place for this function
11
+ * TODO: `book string template notation
12
+ */
@@ -9,4 +9,4 @@ import type { string_template } from '../../types/typeAliases';
9
9
  * @throws {PipelineExecutionError} if parameter is not defined, not closed, or not opened
10
10
  * @public exported from `@promptbook/utils`
11
11
  */
12
- export declare function replaceParameters(template: string_template, parameters: Parameters): string;
12
+ export declare function templateParameters(template: string_template, parameters: Parameters): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/remote-server",
3
- "version": "0.80.0",
3
+ "version": "0.81.0-5",
4
4
  "description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
5
5
  "--note-0": " <- [🐊]",
6
6
  "private": false,
@@ -54,7 +54,7 @@
54
54
  "module": "./esm/index.es.js",
55
55
  "typings": "./esm/typings/src/_packages/remote-server.index.d.ts",
56
56
  "peerDependencies": {
57
- "@promptbook/core": "0.80.0"
57
+ "@promptbook/core": "0.81.0-5"
58
58
  },
59
59
  "dependencies": {
60
60
  "colors": "1.4.0",
package/umd/index.umd.js CHANGED
@@ -22,7 +22,7 @@
22
22
  *
23
23
  * @see https://github.com/webgptorg/promptbook
24
24
  */
25
- var PROMPTBOOK_ENGINE_VERSION = '0.80.0-1';
25
+ var PROMPTBOOK_ENGINE_VERSION = '0.81.0-4';
26
26
  /**
27
27
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
28
28
  * Note: [💞] Ignore a discrepancy between file name and entity name