@promptbook/markdown-utils 0.89.0-15 โ†’ 0.89.0-16

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/markdown-utils",
3
- "version": "0.89.0-15",
3
+ "version": "0.89.0-16",
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,
package/umd/index.umd.js CHANGED
@@ -25,7 +25,7 @@
25
25
  * @generated
26
26
  * @see https://github.com/webgptorg/promptbook
27
27
  */
28
- const PROMPTBOOK_ENGINE_VERSION = '0.89.0-15';
28
+ const PROMPTBOOK_ENGINE_VERSION = '0.89.0-16';
29
29
  /**
30
30
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
31
31
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
@@ -218,6 +218,7 @@
218
218
  * @public exported from `@promptbook/core`
219
219
  */
220
220
  const ADMIN_GITHUB_NAME = 'hejny';
221
+ // <- TODO: [๐ŸŠ] Pick the best claim
221
222
  /**
222
223
  * When the title is not provided, the default title is used
223
224
  *
@@ -290,7 +291,7 @@
290
291
  */
291
292
  const DEFAULT_MAX_EXECUTION_ATTEMPTS = 10; // <- TODO: [๐Ÿคนโ€โ™‚๏ธ]
292
293
  // <- TODO: [๐Ÿ•] Make also `BOOKS_DIRNAME_ALTERNATIVES`
293
- // TODO: !!!!!! Just .promptbook dir, hardocode others
294
+ // TODO: Just `.promptbook` in config, hardcode subfolders like `download-cache` or `execution-cache`
294
295
  /**
295
296
  * Where to store the temporary downloads
296
297
  *
@@ -422,44 +423,42 @@
422
423
  constructor(whatWasThrown) {
423
424
  const tag = `[๐Ÿคฎ]`;
424
425
  console.error(tag, whatWasThrown);
425
- super(spaceTrim.spaceTrim((block) => `
426
- ${ /* Fixing tests !!! block(valueToString(whatWasThrown)) */block(`non-Error object was thrown`)}
427
-
428
- Note: Look for ${tag} in the console for more details
429
- !!! Note: \`WrappedError\` indicates that somewhere in the code non-Error object was thrown and it was wrapped
426
+ super(spaceTrim.spaceTrim(`
427
+ Non-Error object was thrown
430
428
 
431
- Please report issue on ${ADMIN_EMAIL}
432
-
433
- `));
429
+ Note: Look for ${tag} in the console for more details
430
+ Please report issue on ${ADMIN_EMAIL}
431
+ `));
434
432
  this.name = 'WrappedError';
435
433
  Object.setPrototypeOf(this, WrappedError.prototype);
436
434
  }
437
435
  }
438
436
 
439
437
  /**
440
- * !!!@@@
438
+ * Helper used in catch blocks to assert that the error is an instance of `Error`
441
439
  *
442
- * @param whatWasThrown !!!@@@
443
- * @returns !!!@@@
440
+ * @param whatWasThrown Any object that was thrown
441
+ * @returns Nothing if the error is an instance of `Error`
442
+ * @throws `WrappedError` or `UnexpectedError` if the error is not standard
444
443
  *
445
444
  * @private within the repository
446
445
  */
447
446
  function assertsError(whatWasThrown) {
448
- // Case 1: !!!@@@
447
+ // Case 1: Handle error which was rethrown as `WrappedError`
449
448
  if (whatWasThrown instanceof WrappedError) {
450
449
  const wrappedError = whatWasThrown;
451
450
  throw wrappedError;
452
451
  }
453
- // Case 2: !!!@@@
452
+ // Case 2: Handle unexpected errors
454
453
  if (whatWasThrown instanceof UnexpectedError) {
455
454
  const unexpectedError = whatWasThrown;
456
455
  throw unexpectedError;
457
456
  }
458
- // Case 3: !!!@@@
457
+ // Case 3: Handle standard errors - keep them up to consumer
459
458
  if (whatWasThrown instanceof Error) {
460
459
  return;
461
460
  }
462
- // Case 4: !!!@@@
461
+ // Case 4: Handle non-standard errors - wrap them into `WrappedError` and throw
463
462
  throw new WrappedError(whatWasThrown);
464
463
  }
465
464
 
@@ -1755,7 +1754,7 @@
1755
1754
  }
1756
1755
  }
1757
1756
  /**
1758
- * TODO: !!!!!! Add id to all errors
1757
+ * TODO: [๐Ÿง ][๐ŸŒ‚] Add id to all errors
1759
1758
  */
1760
1759
 
1761
1760
  /**
@@ -2134,8 +2133,8 @@
2134
2133
  updatedAt = new Date();
2135
2134
  errors.push(...executionResult.errors);
2136
2135
  warnings.push(...executionResult.warnings);
2137
- // <- TODO: !!! Only unique errors and warnings should be added (or filtered)
2138
- // TODO: [๐Ÿง ] !!! errors, warning, isSuccessful are redundant both in `ExecutionTask` and `ExecutionTask.currentValue`
2136
+ // <- TODO: [๐ŸŒ‚] Only unique errors and warnings should be added (or filtered)
2137
+ // TODO: [๐Ÿง ] !! errors, warning, isSuccessful are redundant both in `ExecutionTask` and `ExecutionTask.currentValue`
2139
2138
  // Also maybe move `ExecutionTask.currentValue.usage` -> `ExecutionTask.usage`
2140
2139
  // And delete `ExecutionTask.currentValue.preparedPipeline`
2141
2140
  assertsTaskSuccessful(executionResult);