@promptbook/remote-server 0.84.0 → 0.85.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 (35) hide show
  1. package/README.md +4 -0
  2. package/esm/index.es.js +4646 -4469
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/core.index.d.ts +0 -2
  5. package/esm/typings/src/_packages/types.index.d.ts +14 -2
  6. package/esm/typings/src/_packages/utils.index.d.ts +0 -2
  7. package/esm/typings/src/cli/cli-commands/_boilerplate.d.ts +13 -0
  8. package/esm/typings/src/cli/cli-commands/start-server.d.ts +13 -0
  9. package/esm/typings/src/conversion/compilePipelineOnRemoteServer.d.ts +1 -1
  10. package/esm/typings/src/execution/AbstractTaskResult.d.ts +25 -0
  11. package/esm/typings/src/execution/ExecutionTask.d.ts +71 -0
  12. package/esm/typings/src/execution/FilesystemTools.d.ts +1 -1
  13. package/esm/typings/src/execution/PipelineExecutor.d.ts +2 -5
  14. package/esm/typings/src/execution/PipelineExecutorResult.d.ts +2 -15
  15. package/esm/typings/src/execution/PromptbookFetch.d.ts +8 -1
  16. package/esm/typings/src/execution/{assertsExecutionSuccessful.d.ts → assertsTaskSuccessful.d.ts} +2 -3
  17. package/esm/typings/src/execution/createPipelineExecutor/00-createPipelineExecutor.d.ts +0 -3
  18. package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +2 -6
  19. package/esm/typings/src/execution/createPipelineExecutor/20-executeTask.d.ts +3 -6
  20. package/esm/typings/src/prepare/preparePipelineOnRemoteServer.d.ts +1 -1
  21. package/esm/typings/src/remote-server/startRemoteServer.d.ts +3 -0
  22. package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +6 -4
  23. package/esm/typings/src/types/typeAliases.d.ts +2 -0
  24. package/esm/typings/src/utils/environment/$isRunningInBrowser.d.ts +2 -2
  25. package/esm/typings/src/utils/environment/$isRunningInJest.d.ts +2 -2
  26. package/esm/typings/src/utils/environment/$isRunningInNode.d.ts +2 -2
  27. package/esm/typings/src/utils/environment/$isRunningInWebWorker.d.ts +1 -1
  28. package/esm/typings/src/utils/random/$randomSeed.d.ts +2 -1
  29. package/esm/typings/src/utils/random/$randomToken.d.ts +13 -0
  30. package/esm/typings/src/wizzard/wizzard.d.ts +2 -3
  31. package/package.json +5 -2
  32. package/umd/index.umd.js +4656 -4481
  33. package/umd/index.umd.js.map +1 -1
  34. package/esm/typings/src/remote-server/socket-types/_common/PromptbookServer_Progress.d.ts +0 -10
  35. package/esm/typings/src/types/TaskProgress.d.ts +0 -43
@@ -59,7 +59,6 @@ import { PipelineExecutionError } from '../errors/PipelineExecutionError';
59
59
  import { PipelineLogicError } from '../errors/PipelineLogicError';
60
60
  import { PipelineUrlError } from '../errors/PipelineUrlError';
61
61
  import { UnexpectedError } from '../errors/UnexpectedError';
62
- import { assertsExecutionSuccessful } from '../execution/assertsExecutionSuccessful';
63
62
  import { createPipelineExecutor } from '../execution/createPipelineExecutor/00-createPipelineExecutor';
64
63
  import { embeddingVectorToString } from '../execution/embeddingVectorToString';
65
64
  import { executionReportJsonToString } from '../execution/execution-report/executionReportJsonToString';
@@ -190,7 +189,6 @@ export { PipelineExecutionError };
190
189
  export { PipelineLogicError };
191
190
  export { PipelineUrlError };
192
191
  export { UnexpectedError };
193
- export { assertsExecutionSuccessful };
194
192
  export { createPipelineExecutor };
195
193
  export { embeddingVectorToString };
196
194
  export { executionReportJsonToString };
@@ -28,6 +28,7 @@ import type { renderPipelineMermaidOptions } from '../conversion/prettify/render
28
28
  import type { CallbackInterfaceToolsOptions } from '../dialogs/callback/CallbackInterfaceToolsOptions';
29
29
  import type { ErrorJson } from '../errors/utils/ErrorJson';
30
30
  import type { LocateAppOptions } from '../executables/locateApp';
31
+ import type { AbstractTaskResult } from '../execution/AbstractTaskResult';
31
32
  import type { AvailableModel } from '../execution/AvailableModel';
32
33
  import type { CommonToolsOptions } from '../execution/CommonToolsOptions';
33
34
  import type { CreatePipelineExecutorOptions } from '../execution/createPipelineExecutor/00-CreatePipelineExecutorOptions';
@@ -37,6 +38,10 @@ import type { ExecutionPromptReportJson } from '../execution/execution-report/Ex
37
38
  import type { ExecutionReportJson } from '../execution/execution-report/ExecutionReportJson';
38
39
  import type { ExecutionReportString } from '../execution/execution-report/ExecutionReportString';
39
40
  import type { ExecutionReportStringOptions } from '../execution/execution-report/ExecutionReportStringOptions';
41
+ import type { ExecutionTask } from '../execution/ExecutionTask';
42
+ import type { PreparationTask } from '../execution/ExecutionTask';
43
+ import type { AbstractTask } from '../execution/ExecutionTask';
44
+ import type { Task } from '../execution/ExecutionTask';
40
45
  import type { ExecutionTools } from '../execution/ExecutionTools';
41
46
  import type { FilesystemTools } from '../execution/FilesystemTools';
42
47
  import type { LlmExecutionTools } from '../execution/LlmExecutionTools';
@@ -133,7 +138,6 @@ import type { ChatPrompt } from '../types/Prompt';
133
138
  import type { EmbeddingPrompt } from '../types/Prompt';
134
139
  import type { ScriptLanguage } from '../types/ScriptLanguage';
135
140
  import type { SectionType } from '../types/SectionType';
136
- import type { TaskProgress } from '../types/TaskProgress';
137
141
  import type { TaskType } from '../types/TaskType';
138
142
  import type { string_char_emoji } from '../types/typeAliasEmoji';
139
143
  import type { string_business_category_name } from '../types/typeAliases';
@@ -221,6 +225,7 @@ import type { string_translate_language } from '../types/typeAliases';
221
225
  import type { string_javascript_name } from '../types/typeAliases';
222
226
  import type { string_postprocessing_function_name } from '../types/typeAliases';
223
227
  import type { id } from '../types/typeAliases';
228
+ import type { task_id } from '../types/typeAliases';
224
229
  import type { string_token } from '../types/typeAliases';
225
230
  import type { string_license_token } from '../types/typeAliases';
226
231
  import type { string_password } from '../types/typeAliases';
@@ -234,6 +239,7 @@ import type { number_tokens } from '../types/typeAliases';
234
239
  import type { number_positive } from '../types/typeAliases';
235
240
  import type { number_negative } from '../types/typeAliases';
236
241
  import type { number_integer } from '../types/typeAliases';
242
+ import type { number_port } from '../types/typeAliases';
237
243
  import type { number_percent } from '../types/typeAliases';
238
244
  import type { number_model_temperature } from '../types/typeAliases';
239
245
  import type { number_seed } from '../types/typeAliases';
@@ -303,6 +309,7 @@ export type { renderPipelineMermaidOptions };
303
309
  export type { CallbackInterfaceToolsOptions };
304
310
  export type { ErrorJson };
305
311
  export type { LocateAppOptions };
312
+ export type { AbstractTaskResult };
306
313
  export type { AvailableModel };
307
314
  export type { CommonToolsOptions };
308
315
  export type { CreatePipelineExecutorOptions };
@@ -312,6 +319,10 @@ export type { ExecutionPromptReportJson };
312
319
  export type { ExecutionReportJson };
313
320
  export type { ExecutionReportString };
314
321
  export type { ExecutionReportStringOptions };
322
+ export type { ExecutionTask };
323
+ export type { PreparationTask };
324
+ export type { AbstractTask };
325
+ export type { Task };
315
326
  export type { ExecutionTools };
316
327
  export type { FilesystemTools };
317
328
  export type { LlmExecutionTools };
@@ -408,7 +419,6 @@ export type { ChatPrompt };
408
419
  export type { EmbeddingPrompt };
409
420
  export type { ScriptLanguage };
410
421
  export type { SectionType };
411
- export type { TaskProgress };
412
422
  export type { TaskType };
413
423
  export type { string_char_emoji };
414
424
  export type { string_business_category_name };
@@ -496,6 +506,7 @@ export type { string_translate_language };
496
506
  export type { string_javascript_name };
497
507
  export type { string_postprocessing_function_name };
498
508
  export type { id };
509
+ export type { task_id };
499
510
  export type { string_token };
500
511
  export type { string_license_token };
501
512
  export type { string_password };
@@ -509,6 +520,7 @@ export type { number_tokens };
509
520
  export type { number_positive };
510
521
  export type { number_negative };
511
522
  export type { number_integer };
523
+ export type { number_port };
512
524
  export type { number_percent };
513
525
  export type { number_model_temperature };
514
526
  export type { number_seed };
@@ -54,7 +54,6 @@ import { numberToString } from '../utils/parameters/numberToString';
54
54
  import { templateParameters } from '../utils/parameters/templateParameters';
55
55
  import { valueToString } from '../utils/parameters/valueToString';
56
56
  import { parseNumber } from '../utils/parseNumber';
57
- import { $randomSeed } from '../utils/random/$randomSeed';
58
57
  import { removeEmojis } from '../utils/removeEmojis';
59
58
  import { removeQuotes } from '../utils/removeQuotes';
60
59
  import { $deepFreeze } from '../utils/serialization/$deepFreeze';
@@ -136,7 +135,6 @@ export { numberToString };
136
135
  export { templateParameters };
137
136
  export { valueToString };
138
137
  export { parseNumber };
139
- export { $randomSeed };
140
138
  export { removeEmojis };
141
139
  export { removeQuotes };
142
140
  export { $deepFreeze };
@@ -0,0 +1,13 @@
1
+ import type { Command as Program } from 'commander';
2
+ /**
3
+ * Initializes `boilerplate` command for Promptbook CLI utilities
4
+ *
5
+ * Note: `$` is used to indicate that this function is not a pure function - it registers a command in the CLI
6
+ *
7
+ * @private internal function of `promptbookCli`
8
+ */
9
+ export declare function $initializeBoilerplateCommand(program: Program): void;
10
+ /**
11
+ * Note: [💞] Ignore a discrepancy between file name and entity name
12
+ * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
13
+ */
@@ -0,0 +1,13 @@
1
+ import type { Command as Program } from 'commander';
2
+ /**
3
+ * Initializes `start-server` command for Promptbook CLI utilities
4
+ *
5
+ * Note: `$` is used to indicate that this function is not a pure function - it registers a command in the CLI
6
+ *
7
+ * @private internal function of `promptbookCli`
8
+ */
9
+ export declare function $initializeStartServerCommand(program: Program): void;
10
+ /**
11
+ * Note: [💞] Ignore a discrepancy between file name and entity name
12
+ * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
13
+ */
@@ -17,5 +17,5 @@ import type { RemoteClientOptions } from '../remote-server/types/RemoteClientOpt
17
17
  */
18
18
  export declare function compilePipelineOnRemoteServer<TCustomOptions = undefined>(pipelineString: PipelineString, options: RemoteClientOptions<TCustomOptions>): Promise<PipelineJson>;
19
19
  /**
20
- * TODO: [🐚] Do not return Promise<PipelineJson> But PreparePipelineTask
20
+ * TODO: [🐚] Do not return `Promise<PipelineJson>` But `PreparationTask`
21
21
  */
@@ -0,0 +1,25 @@
1
+ import { ReadonlyDeep } from 'type-fest';
2
+ import type { ErrorJson } from '../errors/utils/ErrorJson';
3
+ /**
4
+ * @@@
5
+ *
6
+ * Note: [🚉] This is fully serializable as JSON
7
+ */
8
+ export type AbstractTaskResult = {
9
+ /**
10
+ * Whether the execution was successful, details are aviable in `executionReport`
11
+ */
12
+ readonly isSuccessful: boolean;
13
+ /**
14
+ * Errors that occured during the execution, details are aviable in `executionReport`
15
+ */
16
+ readonly errors: ReadonlyDeep<ReadonlyArray<ErrorJson>>;
17
+ /**
18
+ * Warnings that occured during the execution, details are aviable in `executionReport`
19
+ */
20
+ readonly warnings: ReadonlyDeep<ReadonlyArray<ErrorJson>>;
21
+ };
22
+ /**
23
+ * TODO: [🧠] Should this file be in /execution or /types folder?
24
+ * TODO: [🧠] Maybe constrain `ErrorJson` -> `ErrorJson & { name: 'PipelineExecutionError' | 'Error' }`
25
+ */
@@ -0,0 +1,71 @@
1
+ import type { Observable } from 'rxjs';
2
+ import { PartialDeep } from 'type-fest';
3
+ import type { string_SCREAMING_CASE } from '../utils/normalization/normalizeTo_SCREAMING_CASE';
4
+ import type { task_id } from '../types/typeAliases';
5
+ import type { AbstractTaskResult } from './AbstractTaskResult';
6
+ import type { PipelineExecutorResult } from './PipelineExecutorResult';
7
+ /**
8
+ * Options for creating a new task
9
+ */
10
+ type CreateTaskOptions<TTaskResult extends AbstractTaskResult> = {
11
+ /**
12
+ * The type of task to create
13
+ */
14
+ readonly taskType: AbstractTask<TTaskResult>['taskType'];
15
+ /**
16
+ * Callback that processes the task and updates the ongoing result
17
+ * @param ongoingResult The partial result of the task processing
18
+ * @returns The final task result
19
+ */
20
+ taskProcessCallback(updateOngoingResult: (newOngoingResult: PartialDeep<TTaskResult>) => void): Promise<TTaskResult>;
21
+ };
22
+ /**
23
+ * Helper to create a new task
24
+ *
25
+ * @private internal helper function
26
+ */
27
+ export declare function createTask<TTaskResult extends AbstractTaskResult>(options: CreateTaskOptions<TTaskResult>): AbstractTask<TTaskResult>;
28
+ /**
29
+ * Represents a task that executes a pipeline
30
+ */
31
+ export type ExecutionTask = AbstractTask<PipelineExecutorResult> & {
32
+ readonly taskType: 'EXECUTION';
33
+ readonly taskId: `execution-${task_id}`;
34
+ };
35
+ /**
36
+ * Represents a task that prepares a pipeline
37
+ * @deprecated TODO: [🐚] Currently unused - use
38
+ */
39
+ export type PreparationTask = AbstractTask<PipelineExecutorResult> & {
40
+ readonly taskType: 'PREPARATION';
41
+ readonly taskId: `preparation-${task_id}`;
42
+ };
43
+ /**
44
+ * Base interface for all task types
45
+ */
46
+ export type AbstractTask<TTaskResult extends AbstractTaskResult> = {
47
+ /**
48
+ * Type of the task
49
+ */
50
+ readonly taskType: string_SCREAMING_CASE;
51
+ /**
52
+ * Unique identifier for the task
53
+ */
54
+ readonly taskId: task_id;
55
+ /**
56
+ * Gets a promise that resolves with the task result
57
+ */
58
+ asPromise(options?: {
59
+ readonly isCrashedOnError?: boolean;
60
+ }): Promise<TTaskResult>;
61
+ /**
62
+ * Gets an observable stream of partial task results
63
+ */
64
+ asObservable(): Observable<PartialDeep<TTaskResult>>;
65
+ };
66
+ export type Task = ExecutionTask | PreparationTask;
67
+ export {};
68
+ /**
69
+ * TODO: Maybe allow to terminate the task and add getter `isFinished` or `status`
70
+ * TODO: [🐚] Split into more files and make `PrepareTask` & `RemoteTask` + split the function
71
+ */
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import type fs from 'fs/promises';
2
+ import type fs from 'node:fs/promises';
3
3
  /**
4
4
  * Container for all the tools needed to manipulate with filesystem
5
5
  */
@@ -1,7 +1,5 @@
1
- import type { Promisable } from 'type-fest';
2
- import type { TaskProgress } from '../types/TaskProgress';
3
1
  import type { InputParameters } from '../types/typeAliases';
4
- import type { PipelineExecutorResult } from './PipelineExecutorResult';
2
+ import type { ExecutionTask } from './ExecutionTask';
5
3
  /**
6
4
  * Executor is a simple async function that takes INPUT PARAMETERs and returns result parameters _(along with all intermediate parameters and INPUT PARAMETERs = it extends input object)_.
7
5
  * Executor is made by combining execution tools and pipeline collection.
@@ -11,9 +9,8 @@ import type { PipelineExecutorResult } from './PipelineExecutorResult';
11
9
  * @see https://github.com/webgptorg/promptbook#executor
12
10
  */
13
11
  export type PipelineExecutor = {
14
- (inputParameters: InputParameters, onProgress?: (taskProgress: TaskProgress) => Promisable<void>): Promise<PipelineExecutorResult>;
12
+ (inputParameters: InputParameters): ExecutionTask;
15
13
  };
16
14
  /**
17
- * TODO: [🐚] Change onProgress to object that represents the running execution, can be subscribed via RxJS to and also awaited
18
15
  * TODO: [🧠] Should this file be in /execution or /types folder?
19
16
  */
@@ -1,7 +1,7 @@
1
1
  import { ReadonlyDeep } from 'type-fest';
2
- import type { ErrorJson } from '../errors/utils/ErrorJson';
3
2
  import type { PipelineJson } from '../pipeline/PipelineJson/PipelineJson';
4
3
  import type { Parameters } from '../types/typeAliases';
4
+ import type { AbstractTaskResult } from './AbstractTaskResult';
5
5
  import type { ExecutionReportJson } from './execution-report/ExecutionReportJson';
6
6
  import type { PromptResultUsage } from './PromptResultUsage';
7
7
  /**
@@ -9,29 +9,17 @@ import type { PromptResultUsage } from './PromptResultUsage';
9
9
  *
10
10
  * Note: [🚉] This is fully serializable as JSON
11
11
  */
12
- export type PipelineExecutorResult = {
12
+ export type PipelineExecutorResult = AbstractTaskResult & {
13
13
  /**
14
14
  * Result parameters of the execution
15
15
  *
16
16
  * Note: If the execution was not successful, there are only some of the result parameters
17
17
  */
18
18
  readonly outputParameters: Readonly<Parameters>;
19
- /**
20
- * Whether the execution was successful, details are aviable in `executionReport`
21
- */
22
- readonly isSuccessful: boolean;
23
19
  /**
24
20
  * Added usage of whole execution, detailed usage is aviable in `executionReport`
25
21
  */
26
22
  readonly usage: ReadonlyDeep<PromptResultUsage>;
27
- /**
28
- * Errors that occured during the execution, details are aviable in `executionReport`
29
- */
30
- readonly errors: ReadonlyDeep<ReadonlyArray<ErrorJson>>;
31
- /**
32
- * Warnings that occured during the execution, details are aviable in `executionReport`
33
- */
34
- readonly warnings: ReadonlyDeep<ReadonlyArray<ErrorJson>>;
35
23
  /**
36
24
  * The report of the execution with all details
37
25
  */
@@ -46,5 +34,4 @@ export type PipelineExecutorResult = {
46
34
  };
47
35
  /**
48
36
  * TODO: [🧠] Should this file be in /execution or /types folder?
49
- * TODO: [🧠] Maybe constrain `ErrorJson` -> `ErrorJson & { name: 'PipelineExecutionError' | 'Error' }`
50
37
  */
@@ -1,5 +1,12 @@
1
1
  import type { string_url } from '../types/typeAliases';
2
2
  /**
3
- * Fetch function for fetching data from the internet used in scraping
3
+ * Fetch function used in Promptbook engine
4
+ *
5
+ * In most cases it is just native `fetch` function with a lightweight error handling wrapper
6
+ * But it can be replaced with any other fetch function, polyfill, custom implementation, security layer, etc.
7
+ *
8
+ * It is used in theese places:
9
+ * - Fetching knowledge sources
10
+ * - Callbacks from remote server ([👩🏾‍🤝‍🧑🏾] Not yet implemented)
4
11
  */
5
12
  export type PromptbookFetch = (url: string_url, init?: RequestInit) => Promise<Response>;
@@ -6,10 +6,9 @@ import type { PipelineExecutorResult } from './PipelineExecutorResult';
6
6
  *
7
7
  * @param executionResult - The partial result of the Promptbook execution
8
8
  * @throws {PipelineExecutionError} If the execution is not successful or if multiple errors occurred
9
- * @public exported from `@promptbook/core`
9
+ * @private internal helper function of `asPromise` method of `ExecutionTask`
10
10
  */
11
- export declare function assertsExecutionSuccessful(executionResult: Pick<PipelineExecutorResult, 'isSuccessful' | 'errors' | 'warnings'>): void;
11
+ export declare function assertsTaskSuccessful(executionResult: Pick<PipelineExecutorResult, 'isSuccessful' | 'errors' | 'warnings'>): void;
12
12
  /**
13
- * TODO: [🐚] This function should be removed OR changed OR be completely rewritten
14
13
  * TODO: [🧠] Can this return type be better typed than void
15
14
  */
@@ -8,6 +8,3 @@ import type { CreatePipelineExecutorOptions } from './00-CreatePipelineExecutorO
8
8
  * @public exported from `@promptbook/core`
9
9
  */
10
10
  export declare function createPipelineExecutor(options: CreatePipelineExecutorOptions): PipelineExecutor;
11
- /**
12
- * TODO: [🐚] Change onProgress to object that represents the running execution, can be subscribed via RxJS to and also awaited
13
- */
@@ -1,6 +1,5 @@
1
- import type { Promisable, ReadonlyDeep } from 'type-fest';
1
+ import type { PartialDeep, Promisable, ReadonlyDeep } from 'type-fest';
2
2
  import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
3
- import type { TaskProgress } from '../../types/TaskProgress';
4
3
  import type { InputParameters } from '../../types/typeAliases';
5
4
  import type { PipelineExecutorResult } from '../PipelineExecutorResult';
6
5
  import type { CreatePipelineExecutorOptions } from './00-CreatePipelineExecutorOptions';
@@ -17,7 +16,7 @@ type ExecutePipelineOptions = Required<CreatePipelineExecutorOptions> & {
17
16
  /**
18
17
  * @@@
19
18
  */
20
- onProgress?(taskProgress: TaskProgress): Promisable<void>;
19
+ onProgress?(newOngoingResult: PartialDeep<PipelineExecutorResult>): Promisable<void>;
21
20
  /**
22
21
  * @@@
23
22
  */
@@ -44,6 +43,3 @@ type ExecutePipelineOptions = Required<CreatePipelineExecutorOptions> & {
44
43
  */
45
44
  export declare function executePipeline(options: ExecutePipelineOptions): Promise<PipelineExecutorResult>;
46
45
  export {};
47
- /**
48
- * TODO: [🐚] Change onProgress to object that represents the running execution, can be subscribed via RxJS to and also awaited
49
- */
@@ -1,9 +1,9 @@
1
- import type { Promisable, ReadonlyDeep, WritableDeep } from 'type-fest';
1
+ import type { PartialDeep, Promisable, ReadonlyDeep, WritableDeep } from 'type-fest';
2
2
  import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
3
3
  import type { TaskJson } from '../../pipeline/PipelineJson/TaskJson';
4
- import type { TaskProgress } from '../../types/TaskProgress';
5
4
  import type { Parameters } from '../../types/typeAliases';
6
5
  import type { ExecutionReportJson } from '../execution-report/ExecutionReportJson';
6
+ import type { PipelineExecutorResult } from '../PipelineExecutorResult';
7
7
  import type { CreatePipelineExecutorOptions } from './00-CreatePipelineExecutorOptions';
8
8
  /**
9
9
  * @@@
@@ -26,7 +26,7 @@ type executeSingleTaskOptions = Required<CreatePipelineExecutorOptions> & {
26
26
  /**
27
27
  * @@@
28
28
  */
29
- readonly onProgress: (taskProgress: TaskProgress) => Promisable<void>;
29
+ readonly onProgress: (newOngoingResult: PartialDeep<PipelineExecutorResult>) => Promisable<void>;
30
30
  /**
31
31
  * @@@
32
32
  */
@@ -46,6 +46,3 @@ export {};
46
46
  /**
47
47
  * TODO: [🤹‍♂️]
48
48
  */
49
- /**
50
- * TODO: [🐚] Change onProgress to object that represents the running execution, can be subscribed via RxJS to and also awaited
51
- */
@@ -13,5 +13,5 @@ import type { RemoteClientOptions } from '../remote-server/types/RemoteClientOpt
13
13
  */
14
14
  export declare function preparePipelineOnRemoteServer<TCustomOptions = undefined>(pipeline: PipelineJson, options: RemoteClientOptions<TCustomOptions>): Promise<PipelineJson>;
15
15
  /**
16
- * TODO: [🐚] Do not return Promise<PipelineJson> But PreparePipelineTask
16
+ * TODO: [🐚] Do not return `Promise<PipelineJson>` But `PreparationTask`
17
17
  */
@@ -11,6 +11,9 @@ import type { RemoteServerOptions } from './types/RemoteServerOptions';
11
11
  */
12
12
  export declare function startRemoteServer<TCustomOptions = undefined>(options: RemoteServerOptions<TCustomOptions>): IDestroyable;
13
13
  /**
14
+ * TODO: !!!!!!! CORS and security
15
+ * TODO: !!!!!!! Allow to pass tokem here
16
+ * TODO: [👩🏾‍🤝‍🧑🏾] Allow to pass custom fetch function here - PromptbookFetch
14
17
  * TODO: Split this file into multiple functions - handler for each request
15
18
  * TODO: Maybe use `$exportJson`
16
19
  * TODO: [🧠][🛍] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'`
@@ -25,12 +25,14 @@ export type RemoteServerOptions<TCustomOptions> = CommonToolsOptions & {
25
25
  */
26
26
  readonly port: number;
27
27
  /**
28
- * Path for the Socket.io server to listen
28
+ * Root path of the server
29
29
  *
30
- * @default '/socket.io'
31
- * @example '/promptbook/socket.io'
30
+ * Note: This is useful when you reverse proxy the server without changing the path
31
+ *
32
+ * @default '/'
33
+ * @example '/api/promptbook/'
32
34
  */
33
- readonly path: string_uri;
35
+ readonly rootPath: string_uri;
34
36
  } & (AnonymousRemoteServerOptions | ApplicationRemoteServerOptions<TCustomOptions> | (AnonymousRemoteServerOptions & ApplicationRemoteServerOptions<TCustomOptions>));
35
37
  export type AnonymousRemoteServerOptions = {
36
38
  /**
@@ -556,6 +556,7 @@ export type string_javascript_name = string;
556
556
  */
557
557
  export type string_postprocessing_function_name = string;
558
558
  export type id = string | number;
559
+ export type task_id = string;
559
560
  export type string_token = string;
560
561
  export type string_license_token = string_token;
561
562
  export type string_password = string;
@@ -588,6 +589,7 @@ export type number_tokens = number_integer & (number_positive | 0);
588
589
  export type number_positive = number;
589
590
  export type number_negative = number;
590
591
  export type number_integer = number;
592
+ export type number_port = number_positive & number_integer;
591
593
  /**
592
594
  * Semantic helper;
593
595
  * Percentage from 0 to 1 (100%) (and bellow and above)
@@ -7,5 +7,5 @@
7
7
  */
8
8
  export declare const $isRunningInBrowser: Function;
9
9
  /**
10
- * TODO: []
11
- */
10
+ * TODO: [🎺]
11
+ */
@@ -7,5 +7,5 @@
7
7
  */
8
8
  export declare const $isRunningInJest: Function;
9
9
  /**
10
- * TODO: []
11
- */
10
+ * TODO: [🎺]
11
+ */
@@ -7,5 +7,5 @@
7
7
  */
8
8
  export declare const $isRunningInNode: Function;
9
9
  /**
10
- * TODO: []
11
- */
10
+ * TODO: [🎺]
11
+ */
@@ -7,5 +7,5 @@
7
7
  */
8
8
  export declare const $isRunningInWebWorker: Function;
9
9
  /**
10
- * TODO: []
10
+ * TODO: [🎺]
11
11
  */
@@ -4,6 +4,7 @@ import type { number_seed } from '../../types/typeAliases';
4
4
  *
5
5
  * Note: `$` is used to indicate that this function is not a pure function - it is not deterministic
6
6
  * Warning: This function is NOT cryptographically secure (it uses Math.random internally)
7
- * @public exported from `@promptbook/utils`
7
+ *
8
+ * @private internal helper function
8
9
  */
9
10
  export declare function $randomSeed(): number_seed;
@@ -0,0 +1,13 @@
1
+ import type { string_token } from '../../types/typeAliases';
2
+ /**
3
+ * Generates random token
4
+ *
5
+ * Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
6
+ *
7
+ * @private internal helper function
8
+ * @returns secure random token
9
+ */
10
+ export declare function $randomToken(randomness: number): string_token;
11
+ /**
12
+ * TODO: Maybe use nanoid instead https://github.com/ai/nanoid
13
+ */
@@ -1,9 +1,7 @@
1
- import { Promisable } from 'type-fest';
2
1
  import type { ExecutionTools } from '../execution/ExecutionTools';
3
2
  import type { PipelineExecutorResult } from '../execution/PipelineExecutorResult';
4
3
  import type { PipelineJson } from '../pipeline/PipelineJson/PipelineJson';
5
4
  import type { PipelineString } from '../pipeline/PipelineString';
6
- import type { TaskProgress } from '../types/TaskProgress';
7
5
  import type { InputParameters } from '../types/typeAliases';
8
6
  import type { string_filename } from '../types/typeAliases';
9
7
  import type { string_parameter_value } from '../types/typeAliases';
@@ -28,7 +26,7 @@ declare class Wizzard {
28
26
  *
29
27
  * Note: This works simmilar to the `ptbk run` command
30
28
  */
31
- execute(book: string_pipeline_url | string_filename | PipelineString, inputParameters: InputParameters, onProgress?: (taskProgress: TaskProgress) => Promisable<void>): Promise<{
29
+ execute(book: string_pipeline_url | string_filename | PipelineString, inputParameters: InputParameters): Promise<{
32
30
  /**
33
31
  * Simple result of the execution
34
32
  */
@@ -65,5 +63,6 @@ declare class Wizzard {
65
63
  export declare const wizzard: Wizzard;
66
64
  export {};
67
65
  /**
66
+ * TODO: [🧠] Maybe some way how to handle the progress and streaming?
68
67
  * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
69
68
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/remote-server",
3
- "version": "0.84.0",
3
+ "version": "0.85.0-1",
4
4
  "description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -47,13 +47,16 @@
47
47
  "module": "./esm/index.es.js",
48
48
  "typings": "./esm/typings/src/_packages/remote-server.index.d.ts",
49
49
  "peerDependencies": {
50
- "@promptbook/core": "0.84.0"
50
+ "@promptbook/core": "0.85.0-1"
51
51
  },
52
52
  "dependencies": {
53
53
  "colors": "1.4.0",
54
+ "crypto": "^1.0.1",
54
55
  "crypto-js": "4.2.0",
56
+ "express": "^4.21.2",
55
57
  "papaparse": "5.4.1",
56
58
  "prettier": "2.8.1",
59
+ "rxjs": "^7.8.1",
57
60
  "socket.io": "4.8.1",
58
61
  "spacetrim": "0.11.59",
59
62
  "userhome": "1.0.1",