@promptbook/remote-server 0.89.0-15 โ†’ 0.89.0-17

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.
@@ -8,8 +8,6 @@ import { NAME } from '../config';
8
8
  import { ADMIN_EMAIL } from '../config';
9
9
  import { ADMIN_GITHUB_NAME } from '../config';
10
10
  import { CLAIM } from '../config';
11
- import { LOGO_LIGHT_SRC } from '../config';
12
- import { LOGO_DARK_SRC } from '../config';
13
11
  import { DEFAULT_BOOK_TITLE } from '../config';
14
12
  import { DEFAULT_TASK_TITLE } from '../config';
15
13
  import { DEFAULT_PROMPT_TASK_TITLE } from '../config';
@@ -28,6 +26,7 @@ import { DEFAULT_SCRAPE_CACHE_DIRNAME } from '../config';
28
26
  import { CLI_APP_ID } from '../config';
29
27
  import { PLAYGROUND_APP_ID } from '../config';
30
28
  import { DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME } from '../config';
29
+ import { REMOTE_SERVER_URLS } from '../config';
31
30
  import { DEFAULT_REMOTE_SERVER_URL } from '../config';
32
31
  import { DEFAULT_CSV_SETTINGS } from '../config';
33
32
  import { DEFAULT_IS_VERBOSE } from '../config';
@@ -116,6 +115,8 @@ import { isPipelinePrepared } from '../prepare/isPipelinePrepared';
116
115
  import { preparePipeline } from '../prepare/preparePipeline';
117
116
  import { prepareTasks } from '../prepare/prepareTasks';
118
117
  import { unpreparePipeline } from '../prepare/unpreparePipeline';
118
+ import { identificationToPromptbookToken } from '../remote-server/socket-types/_subtypes/identificationToPromptbookToken';
119
+ import { promptbookTokenToIdentification } from '../remote-server/socket-types/_subtypes/promptbookTokenToIdentification';
119
120
  import { _BoilerplateScraperMetadataRegistration } from '../scrapers/_boilerplate/register-metadata';
120
121
  import { prepareKnowledgePieces } from '../scrapers/_common/prepareKnowledgePieces';
121
122
  import { $scrapersMetadataRegister } from '../scrapers/_common/register/$scrapersMetadataRegister';
@@ -145,8 +146,6 @@ export { NAME };
145
146
  export { ADMIN_EMAIL };
146
147
  export { ADMIN_GITHUB_NAME };
147
148
  export { CLAIM };
148
- export { LOGO_LIGHT_SRC };
149
- export { LOGO_DARK_SRC };
150
149
  export { DEFAULT_BOOK_TITLE };
151
150
  export { DEFAULT_TASK_TITLE };
152
151
  export { DEFAULT_PROMPT_TASK_TITLE };
@@ -165,6 +164,7 @@ export { DEFAULT_SCRAPE_CACHE_DIRNAME };
165
164
  export { CLI_APP_ID };
166
165
  export { PLAYGROUND_APP_ID };
167
166
  export { DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME };
167
+ export { REMOTE_SERVER_URLS };
168
168
  export { DEFAULT_REMOTE_SERVER_URL };
169
169
  export { DEFAULT_CSV_SETTINGS };
170
170
  export { DEFAULT_IS_VERBOSE };
@@ -253,6 +253,8 @@ export { isPipelinePrepared };
253
253
  export { preparePipeline };
254
254
  export { prepareTasks };
255
255
  export { unpreparePipeline };
256
+ export { identificationToPromptbookToken };
257
+ export { promptbookTokenToIdentification };
256
258
  export { _BoilerplateScraperMetadataRegistration };
257
259
  export { prepareKnowledgePieces };
258
260
  export { $scrapersMetadataRegister };
@@ -190,6 +190,7 @@ import type { string_css_property } from '../types/typeAliases';
190
190
  import type { string_css_value } from '../types/typeAliases';
191
191
  import type { string_css_selector } from '../types/typeAliases';
192
192
  import type { string_url } from '../types/typeAliases';
193
+ import type { string_promptbook_server_url } from '../types/typeAliases';
193
194
  import type { string_base_url } from '../types/typeAliases';
194
195
  import type { string_pipeline_root_url } from '../types/typeAliases';
195
196
  import type { string_pipeline_url } from '../types/typeAliases';
@@ -233,6 +234,7 @@ import type { string_postprocessing_function_name } from '../types/typeAliases';
233
234
  import type { id } from '../types/typeAliases';
234
235
  import type { task_id } from '../types/typeAliases';
235
236
  import type { string_token } from '../types/typeAliases';
237
+ import type { string_promptbook_token } from '../types/typeAliases';
236
238
  import type { string_license_token } from '../types/typeAliases';
237
239
  import type { string_password } from '../types/typeAliases';
238
240
  import type { string_ssh_key } from '../types/typeAliases';
@@ -477,6 +479,7 @@ export type { string_css_property };
477
479
  export type { string_css_value };
478
480
  export type { string_css_selector };
479
481
  export type { string_url };
482
+ export type { string_promptbook_server_url };
480
483
  export type { string_base_url };
481
484
  export type { string_pipeline_root_url };
482
485
  export type { string_pipeline_url };
@@ -520,6 +523,7 @@ export type { string_postprocessing_function_name };
520
523
  export type { id };
521
524
  export type { task_id };
522
525
  export type { string_token };
526
+ export type { string_promptbook_token };
523
527
  export type { string_license_token };
524
528
  export type { string_password };
525
529
  export type { string_ssh_key };
@@ -8,7 +8,6 @@ import type { Command as Program } from 'commander';
8
8
  */
9
9
  export declare function $initializeLoginCommand(program: Program): void;
10
10
  /**
11
- * TODO: Pass remote server URL (and path)
12
11
  * TODO: Implement non-interactive login
13
12
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
14
13
  * Note: [๐ŸŸก] Code in this file should never be published outside of `@promptbook/cli`
@@ -1,15 +1,28 @@
1
+ import type { LlmExecutionToolsWithTotalUsage } from '../../llm-providers/_common/utils/count-total-usage/LlmExecutionToolsWithTotalUsage';
1
2
  import type { CacheLlmToolsOptions } from '../../llm-providers/_common/utils/cache/CacheLlmToolsOptions';
2
- import type { string_url } from '../../types/typeAliases';
3
+ import type { string_promptbook_server_url } from '../../types/typeAliases';
3
4
  type ProvideLlmToolsForCliOptions = Pick<CacheLlmToolsOptions, 'isCacheReloaded'> & {
5
+ /**
6
+ * If true, user will be always prompted for login
7
+ *
8
+ * Note: This is used in `ptbk login` command
9
+ */
10
+ isLoginloaded?: true;
11
+ /**
12
+ * CLI options
13
+ */
4
14
  cliOptions: {
5
15
  verbose: boolean;
6
16
  interactive: boolean;
7
17
  provider: 'BYOK' | 'BRING_YOUR_OWN_KEYS' | 'REMOTE_SERVER' | 'RS' | string;
8
- remoteServerUrl: string_url;
18
+ remoteServerUrl: string_promptbook_server_url;
9
19
  };
10
20
  };
11
21
  /**
12
22
  * @private utility of CLI
13
23
  */
14
- export declare function $provideLlmToolsForCli(options: ProvideLlmToolsForCliOptions): Promise<import("../../_packages/types.index").LlmExecutionToolsWithTotalUsage>;
24
+ export declare function $provideLlmToolsForCli(options: ProvideLlmToolsForCliOptions): Promise<{
25
+ strategy: 'BRING_YOUR_OWN_KEYS' | 'REMOTE_SERVER';
26
+ llm: LlmExecutionToolsWithTotalUsage;
27
+ }>;
15
28
  export {};
@@ -3,7 +3,7 @@ import type { IntermediateFilesStrategy } from './types/IntermediateFilesStrateg
3
3
  import type { string_app_id } from './types/typeAliases';
4
4
  import type { string_email } from './types/typeAliases';
5
5
  import type { string_name } from './types/typeAliases';
6
- import type { string_url_image } from './types/typeAliases';
6
+ import type { string_promptbook_server_url } from './types/typeAliases';
7
7
  /**
8
8
  * Warning message for the generated sections and files files
9
9
  *
@@ -38,22 +38,6 @@ export declare const ADMIN_GITHUB_NAME: string_name;
38
38
  * @public exported from `@promptbook/core`
39
39
  */
40
40
  export declare const CLAIM = "It's time for a paradigm shift. The future of software in plain English, French or Latin";
41
- /**
42
- * Logo for the light theme
43
- *
44
- * TODO: [๐Ÿ—ฝ] Unite branding and make single place for it
45
- *
46
- * @public exported from `@promptbook/core`
47
- */
48
- export declare const LOGO_LIGHT_SRC: string_url_image;
49
- /**
50
- * Logo for the dark theme
51
- *
52
- * TODO: [๐Ÿ—ฝ] Unite branding and make single place for it
53
- *
54
- * @public exported from `@promptbook/core`
55
- */
56
- export declare const LOGO_DARK_SRC: string_url_image;
57
41
  /**
58
42
  * When the title is not provided, the default title is used
59
43
  *
@@ -90,6 +74,12 @@ export declare const DEFAULT_MAX_FILE_SIZE: number;
90
74
  * @private within the repository
91
75
  */
92
76
  export declare const GENERATOR_WARNING_BY_PROMPTBOOK_CLI = "\u26A0\uFE0F WARNING: This code has been generated by `@promptbook/cli` so that any manual changes will be overwritten";
77
+ /**
78
+ * Warning message for the automatically generated sections of `.env` files
79
+ *
80
+ * @private within the repository
81
+ */
82
+ export declare const GENERATOR_WARNING_IN_ENV = "Note: Added by Promptbook";
93
83
  /**
94
84
  * The maximum number of iterations for a loops
95
85
  *
@@ -238,11 +228,17 @@ export declare const MOMENT_ARG_THRESHOLDS: {
238
228
  readonly ss: 3;
239
229
  };
240
230
  /**
241
- * @@@
231
+ * Available remote servers for the Promptbook
232
+ *
233
+ * @public exported from `@promptbook/core`
234
+ */
235
+ export declare const REMOTE_SERVER_URLS: Array<string_promptbook_server_url>;
236
+ /**
237
+ * Default remote server URL for the Promptbook
242
238
  *
243
239
  * @public exported from `@promptbook/core`
244
240
  */
245
- export declare const DEFAULT_REMOTE_SERVER_URL = "https://api.pavolhejny.com/promptbook";
241
+ export declare const DEFAULT_REMOTE_SERVER_URL: string_promptbook_server_url;
246
242
  /**
247
243
  * @@@
248
244
  *
@@ -10,5 +10,5 @@ export declare class PipelineExecutionError extends Error {
10
10
  constructor(message: string);
11
11
  }
12
12
  /**
13
- * TODO: !!!!!! Add id to all errors
13
+ * TODO: [๐Ÿง ][๐ŸŒ‚] Add id to all errors
14
14
  */
@@ -1,9 +1,10 @@
1
1
  import type { really_unknown } from '../utils/organization/really_unknown';
2
2
  /**
3
- * !!!@@@
3
+ * Helper used in catch blocks to assert that the error is an instance of `Error`
4
4
  *
5
- * @param whatWasThrown !!!@@@
6
- * @returns !!!@@@
5
+ * @param whatWasThrown Any object that was thrown
6
+ * @returns Nothing if the error is an instance of `Error`
7
+ * @throws `WrappedError` or `UnexpectedError` if the error is not standard
7
8
  *
8
9
  * @private within the repository
9
10
  */
@@ -5,7 +5,14 @@ import type { string_url } from '../../../types/typeAliases';
5
5
  import type { really_any } from '../../../utils/organization/really_any';
6
6
  import type { CacheLlmToolsOptions } from '../utils/cache/CacheLlmToolsOptions';
7
7
  import type { LlmExecutionToolsWithTotalUsage } from '../utils/count-total-usage/LlmExecutionToolsWithTotalUsage';
8
- type ProvideLlmToolsForWizzardOrCliOptions = Pick<CacheLlmToolsOptions, 'isCacheReloaded'> & ({
8
+ type ProvideLlmToolsForWizzardOrCliOptions = {
9
+ /**
10
+ * If true, user will be always prompted for login
11
+ *
12
+ * Note: This is used in `ptbk login` command
13
+ */
14
+ isLoginloaded?: true;
15
+ } & Pick<CacheLlmToolsOptions, 'isCacheReloaded'> & ({
9
16
  /**
10
17
  * Use local keys and execute LLMs directly
11
18
  */
@@ -29,6 +36,8 @@ type ProvideLlmToolsForWizzardOrCliOptions = Pick<CacheLlmToolsOptions, 'isCache
29
36
  readonly appId: string_app_id;
30
37
  /**
31
38
  *
39
+ *
40
+ * Note: When login prompt fails, `process.exit(1)` is called
32
41
  */
33
42
  loginPrompt(): Promisable<Identification<really_any>>;
34
43
  });
@@ -0,0 +1,11 @@
1
+ import type { string_promptbook_token } from '../../../types/typeAliases';
2
+ import type { really_unknown } from '../../../utils/organization/really_unknown';
3
+ import type { ApplicationModeIdentification } from './Identification';
4
+ /**
5
+ * Convert identification to Promptbook token
6
+ *
7
+ * @param identification
8
+ *
9
+ * @public exported from `@promptbook/core`
10
+ */
11
+ export declare function identificationToPromptbookToken(identification: ApplicationModeIdentification<really_unknown>): string_promptbook_token;
@@ -0,0 +1,10 @@
1
+ import type { string_promptbook_token } from '../../../types/typeAliases';
2
+ import type { ApplicationModeIdentification } from './Identification';
3
+ /**
4
+ * Convert Promptbook token to identification
5
+ *
6
+ * @param promptbookToken
7
+ *
8
+ * @public exported from `@promptbook/core`
9
+ */
10
+ export declare function promptbookTokenToIdentification(promptbookToken: string_promptbook_token): ApplicationModeIdentification<undefined>;
@@ -1,6 +1,6 @@
1
1
  import type { PromptbookStorage } from '../_common/PromptbookStorage';
2
2
  /**
3
- * Stores data in .env variables (Remove !!! nonce 1)
3
+ * Stores data in .env variables
4
4
  *
5
5
  * Note: `$` is used to indicate that this function is not a pure function - it uses filesystem to access `.env` file and also writes to `process.env`
6
6
  *
@@ -35,3 +35,6 @@ export declare class $EnvStorage<TItem> implements PromptbookStorage<TItem> {
35
35
  */
36
36
  removeItem(key: string): void;
37
37
  }
38
+ /**
39
+ * TODO: Write file more securely - ensure that there can be no accidental overwriting of existing variables and other content
40
+ */
@@ -325,6 +325,12 @@ export type string_css_selector = string;
325
325
  * For example `"https://collboard.com/9SeSQTupmQHwuSrLi"`
326
326
  */
327
327
  export type string_url = string;
328
+ /**
329
+ * Semantic helper
330
+ *
331
+ * For example `"https://s1.ptbk.io/promptbook"`
332
+ */
333
+ export type string_promptbook_server_url = string;
328
334
  /**
329
335
  * Semantic helper
330
336
  *
@@ -570,6 +576,12 @@ export type string_postprocessing_function_name = string;
570
576
  export type id = string | number;
571
577
  export type task_id = string;
572
578
  export type string_token = string;
579
+ /**
580
+ * Semantic helper
581
+ *
582
+ * Made by `identificationToPromptbookToken` exported from `@promptbook/core`
583
+ */
584
+ export type string_promptbook_token = string_token;
573
585
  export type string_license_token = string_token;
574
586
  export type string_password = string;
575
587
  export type string_ssh_key = string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/remote-server",
3
- "version": "0.89.0-15",
3
+ "version": "0.89.0-17",
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,
@@ -51,7 +51,7 @@
51
51
  "module": "./esm/index.es.js",
52
52
  "typings": "./esm/typings/src/_packages/remote-server.index.d.ts",
53
53
  "peerDependencies": {
54
- "@promptbook/core": "0.89.0-15"
54
+ "@promptbook/core": "0.89.0-17"
55
55
  },
56
56
  "dependencies": {
57
57
  "colors": "1.4.0",
package/umd/index.umd.js CHANGED
@@ -30,7 +30,7 @@
30
30
  * @generated
31
31
  * @see https://github.com/webgptorg/promptbook
32
32
  */
33
- const PROMPTBOOK_ENGINE_VERSION = '0.89.0-15';
33
+ const PROMPTBOOK_ENGINE_VERSION = '0.89.0-17';
34
34
  /**
35
35
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
36
36
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
@@ -97,6 +97,7 @@
97
97
  * @public exported from `@promptbook/core`
98
98
  */
99
99
  const CLAIM = `It's time for a paradigm shift. The future of software in plain English, French or Latin`;
100
+ // <- TODO: [๐ŸŠ] Pick the best claim
100
101
  /**
101
102
  * When the title is not provided, the default title is used
102
103
  *
@@ -169,7 +170,7 @@
169
170
  */
170
171
  const DEFAULT_MAX_EXECUTION_ATTEMPTS = 10; // <- TODO: [๐Ÿคนโ€โ™‚๏ธ]
171
172
  // <- TODO: [๐Ÿ•] Make also `BOOKS_DIRNAME_ALTERNATIVES`
172
- // TODO: !!!!!! Just .promptbook dir, hardocode others
173
+ // TODO: Just `.promptbook` in config, hardcode subfolders like `download-cache` or `execution-cache`
173
174
  /**
174
175
  * Where to store the temporary downloads
175
176
  *
@@ -301,44 +302,42 @@
301
302
  constructor(whatWasThrown) {
302
303
  const tag = `[๐Ÿคฎ]`;
303
304
  console.error(tag, whatWasThrown);
304
- super(spaceTrim.spaceTrim((block) => `
305
- ${ /* Fixing tests !!! block(valueToString(whatWasThrown)) */block(`non-Error object was thrown`)}
306
-
307
- Note: Look for ${tag} in the console for more details
308
- !!! Note: \`WrappedError\` indicates that somewhere in the code non-Error object was thrown and it was wrapped
305
+ super(spaceTrim.spaceTrim(`
306
+ Non-Error object was thrown
309
307
 
310
- Please report issue on ${ADMIN_EMAIL}
311
-
312
- `));
308
+ Note: Look for ${tag} in the console for more details
309
+ Please report issue on ${ADMIN_EMAIL}
310
+ `));
313
311
  this.name = 'WrappedError';
314
312
  Object.setPrototypeOf(this, WrappedError.prototype);
315
313
  }
316
314
  }
317
315
 
318
316
  /**
319
- * !!!@@@
317
+ * Helper used in catch blocks to assert that the error is an instance of `Error`
320
318
  *
321
- * @param whatWasThrown !!!@@@
322
- * @returns !!!@@@
319
+ * @param whatWasThrown Any object that was thrown
320
+ * @returns Nothing if the error is an instance of `Error`
321
+ * @throws `WrappedError` or `UnexpectedError` if the error is not standard
323
322
  *
324
323
  * @private within the repository
325
324
  */
326
325
  function assertsError(whatWasThrown) {
327
- // Case 1: !!!@@@
326
+ // Case 1: Handle error which was rethrown as `WrappedError`
328
327
  if (whatWasThrown instanceof WrappedError) {
329
328
  const wrappedError = whatWasThrown;
330
329
  throw wrappedError;
331
330
  }
332
- // Case 2: !!!@@@
331
+ // Case 2: Handle unexpected errors
333
332
  if (whatWasThrown instanceof UnexpectedError) {
334
333
  const unexpectedError = whatWasThrown;
335
334
  throw unexpectedError;
336
335
  }
337
- // Case 3: !!!@@@
336
+ // Case 3: Handle standard errors - keep them up to consumer
338
337
  if (whatWasThrown instanceof Error) {
339
338
  return;
340
339
  }
341
- // Case 4: !!!@@@
340
+ // Case 4: Handle non-standard errors - wrap them into `WrappedError` and throw
342
341
  throw new WrappedError(whatWasThrown);
343
342
  }
344
343
 
@@ -417,7 +416,7 @@
417
416
  }
418
417
  }
419
418
  /**
420
- * TODO: !!!!!! Add id to all errors
419
+ * TODO: [๐Ÿง ][๐ŸŒ‚] Add id to all errors
421
420
  */
422
421
 
423
422
  /**
@@ -1989,8 +1988,8 @@
1989
1988
  updatedAt = new Date();
1990
1989
  errors.push(...executionResult.errors);
1991
1990
  warnings.push(...executionResult.warnings);
1992
- // <- TODO: !!! Only unique errors and warnings should be added (or filtered)
1993
- // TODO: [๐Ÿง ] !!! errors, warning, isSuccessful are redundant both in `ExecutionTask` and `ExecutionTask.currentValue`
1991
+ // <- TODO: [๐ŸŒ‚] Only unique errors and warnings should be added (or filtered)
1992
+ // TODO: [๐Ÿง ] !! errors, warning, isSuccessful are redundant both in `ExecutionTask` and `ExecutionTask.currentValue`
1994
1993
  // Also maybe move `ExecutionTask.currentValue.usage` -> `ExecutionTask.usage`
1995
1994
  // And delete `ExecutionTask.currentValue.preparedPipeline`
1996
1995
  assertsTaskSuccessful(executionResult);