@promptbook/markitdown 0.86.22 → 0.86.30

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.
@@ -2,7 +2,6 @@ import { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION } from '../version';
2
2
  import { VALUE_STRINGS } from '../config';
3
3
  import { SMALL_NUMBER } from '../config';
4
4
  import { renderPromptbookMermaid } from '../conversion/prettify/renderPipelineMermaidOptions';
5
- import { extractVariablesFromScript } from '../conversion/utils/extractVariablesFromScript';
6
5
  import { deserializeError } from '../errors/utils/deserializeError';
7
6
  import { serializeError } from '../errors/utils/serializeError';
8
7
  import { forEachAsync } from '../execution/utils/forEachAsync';
@@ -84,7 +83,6 @@ export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION };
84
83
  export { VALUE_STRINGS };
85
84
  export { SMALL_NUMBER };
86
85
  export { renderPromptbookMermaid };
87
- export { extractVariablesFromScript };
88
86
  export { deserializeError };
89
87
  export { serializeError };
90
88
  export { forEachAsync };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/markitdown",
3
- "version": "0.86.22",
3
+ "version": "0.86.30",
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,7 +47,7 @@
47
47
  "module": "./esm/index.es.js",
48
48
  "typings": "./esm/typings/src/_packages/markitdown.index.d.ts",
49
49
  "peerDependencies": {
50
- "@promptbook/core": "0.86.22"
50
+ "@promptbook/core": "0.86.30"
51
51
  },
52
52
  "dependencies": {
53
53
  "crypto": "^1.0.1",
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.86.22';
28
+ const PROMPTBOOK_ENGINE_VERSION = '0.86.30';
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
@@ -3634,142 +3634,6 @@
3634
3634
  }
3635
3635
  }
3636
3636
 
3637
- /**
3638
- * Extract all used variable names from ginen JavaScript/TypeScript script
3639
- *
3640
- * @param script JavaScript/TypeScript script
3641
- * @returns Set of variable names
3642
- * @throws {ParseError} if the script is invalid
3643
- * @public exported from `@promptbook/utils` <- Note: [👖] This is usable elsewhere than in Promptbook, so keeping in utils
3644
- */
3645
- function extractVariablesFromScript(script) {
3646
- if (script.trim() === '') {
3647
- return new Set();
3648
- }
3649
- const variables = new Set();
3650
- // JS keywords and builtins to exclude
3651
- const exclude = new Set([
3652
- // Keywords
3653
- 'break',
3654
- 'case',
3655
- 'catch',
3656
- 'class',
3657
- 'const',
3658
- 'continue',
3659
- 'debugger',
3660
- 'default',
3661
- 'delete',
3662
- 'do',
3663
- 'else',
3664
- 'export',
3665
- 'extends',
3666
- 'false',
3667
- 'finally',
3668
- 'for',
3669
- 'function',
3670
- 'if',
3671
- 'import',
3672
- 'in',
3673
- 'instanceof',
3674
- 'let',
3675
- 'new',
3676
- 'null',
3677
- 'return',
3678
- 'super',
3679
- 'switch',
3680
- 'this',
3681
- 'throw',
3682
- 'true',
3683
- 'try',
3684
- 'typeof',
3685
- 'var',
3686
- 'void',
3687
- 'while',
3688
- 'with',
3689
- 'yield',
3690
- // Common globals
3691
- 'console',
3692
- 'JSON',
3693
- 'Error',
3694
- // Typescript types
3695
- 'string',
3696
- 'number',
3697
- 'boolean',
3698
- 'object',
3699
- 'symbol',
3700
- // Common methods on built-in objects
3701
- 'test',
3702
- 'match',
3703
- 'exec',
3704
- 'replace',
3705
- 'search',
3706
- 'split',
3707
- ]);
3708
- try {
3709
- // Note: Extract variables from template literals like ${variable}
3710
- const templateRegex = /\$\{([a-zA-Z_$][a-zA-Z0-9_$]*)\}/g;
3711
- let match;
3712
- while ((match = templateRegex.exec(script)) !== null) {
3713
- const varName = match[1];
3714
- if (!exclude.has(varName)) {
3715
- variables.add(varName);
3716
- }
3717
- }
3718
- // Note: Process the script to handle normal variable usage
3719
- const processedScript = script
3720
- .replace(/'(?:\\.|[^'\\])*'/g, "''") // <- Note: Remove string literals
3721
- .replace(/"(?:\\.|[^"\\])*"/g, '""')
3722
- .replace(/`(?:\\.|[^`\\])*`/g, '``')
3723
- .replace(/\/(?:\\.|[^/\\])*\/[gimsuy]*/g, '{}'); // <- Note: Remove regex literals
3724
- // Note: Find identifiers in function arguments
3725
- const funcArgRegex = /\b([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/g;
3726
- const funcNames = new Set();
3727
- while ((match = funcArgRegex.exec(processedScript)) !== null) {
3728
- funcNames.add(match[1]);
3729
- }
3730
- // Find variable declarations to exclude them
3731
- const declaredVars = new Set();
3732
- const declRegex = /\b(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\b/g;
3733
- while ((match = declRegex.exec(processedScript)) !== null) {
3734
- declaredVars.add(match[2]);
3735
- }
3736
- // Note: Find identifiers in the script
3737
- const identifierRegex = /\b([a-zA-Z_$][a-zA-Z0-9_$]*)\b/g;
3738
- while ((match = identifierRegex.exec(processedScript)) !== null) {
3739
- const name = match[1];
3740
- // Add if not excluded, not a function name, and not a declared variable
3741
- if (!exclude.has(name) && !funcNames.has(name) && !declaredVars.has(name)) {
3742
- variables.add(name);
3743
- }
3744
- }
3745
- }
3746
- catch (error) {
3747
- if (!(error instanceof Error)) {
3748
- throw error;
3749
- }
3750
- throw new ParseError(spaceTrim__default["default"]((block) => `
3751
- Can not extract variables from the script
3752
- ${block(error.stack || error.message)}
3753
-
3754
- Found variables:
3755
- ${Array.from(variables)
3756
- .map((variableName, i) => `${i + 1}) ${variableName}`)
3757
- .join('\n')}
3758
-
3759
-
3760
- The script:
3761
-
3762
- \`\`\`javascript
3763
- ${block(script)}
3764
- \`\`\`
3765
- `));
3766
- }
3767
- return variables;
3768
- }
3769
- /**
3770
- * TODO: [🔣] Support for multiple languages - python, java,...
3771
- */
3772
-
3773
3637
  /**
3774
3638
  * Parses the task and returns the set of all used parameters
3775
3639
  *
@@ -3779,7 +3643,7 @@
3779
3643
  * @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
3780
3644
  */
3781
3645
  function extractParameterNamesFromTask(task) {
3782
- const { title, description, taskType, content, preparedContent, jokerParameterNames, foreach } = task;
3646
+ const { title, description, /* [🙊] taskType,*/ content, preparedContent, jokerParameterNames, foreach } = task;
3783
3647
  const parameterNames = new Set();
3784
3648
  for (const parameterName of [
3785
3649
  ...extractParameterNames(title),
@@ -3789,11 +3653,14 @@
3789
3653
  ]) {
3790
3654
  parameterNames.add(parameterName);
3791
3655
  }
3656
+ /*/
3657
+ // TODO: [🙊] Fix `extractVariablesFromScript` or delete
3792
3658
  if (taskType === 'SCRIPT_TASK') {
3793
3659
  for (const parameterName of extractVariablesFromScript(content)) {
3794
3660
  parameterNames.add(parameterName);
3795
3661
  }
3796
3662
  }
3663
+ /**/
3797
3664
  for (const jokerName of jokerParameterNames || []) {
3798
3665
  parameterNames.add(jokerName);
3799
3666
  }