@promptbook/remote-server 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/remote-server",
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/remote-server.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
  "colors": "1.4.0",
package/umd/index.umd.js CHANGED
@@ -28,7 +28,7 @@
28
28
  * @generated
29
29
  * @see https://github.com/webgptorg/promptbook
30
30
  */
31
- const PROMPTBOOK_ENGINE_VERSION = '0.86.22';
31
+ const PROMPTBOOK_ENGINE_VERSION = '0.86.30';
32
32
  /**
33
33
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
34
34
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -3963,142 +3963,6 @@
3963
3963
  }
3964
3964
  }
3965
3965
 
3966
- /**
3967
- * Extract all used variable names from ginen JavaScript/TypeScript script
3968
- *
3969
- * @param script JavaScript/TypeScript script
3970
- * @returns Set of variable names
3971
- * @throws {ParseError} if the script is invalid
3972
- * @public exported from `@promptbook/utils` <- Note: [👖] This is usable elsewhere than in Promptbook, so keeping in utils
3973
- */
3974
- function extractVariablesFromScript(script) {
3975
- if (script.trim() === '') {
3976
- return new Set();
3977
- }
3978
- const variables = new Set();
3979
- // JS keywords and builtins to exclude
3980
- const exclude = new Set([
3981
- // Keywords
3982
- 'break',
3983
- 'case',
3984
- 'catch',
3985
- 'class',
3986
- 'const',
3987
- 'continue',
3988
- 'debugger',
3989
- 'default',
3990
- 'delete',
3991
- 'do',
3992
- 'else',
3993
- 'export',
3994
- 'extends',
3995
- 'false',
3996
- 'finally',
3997
- 'for',
3998
- 'function',
3999
- 'if',
4000
- 'import',
4001
- 'in',
4002
- 'instanceof',
4003
- 'let',
4004
- 'new',
4005
- 'null',
4006
- 'return',
4007
- 'super',
4008
- 'switch',
4009
- 'this',
4010
- 'throw',
4011
- 'true',
4012
- 'try',
4013
- 'typeof',
4014
- 'var',
4015
- 'void',
4016
- 'while',
4017
- 'with',
4018
- 'yield',
4019
- // Common globals
4020
- 'console',
4021
- 'JSON',
4022
- 'Error',
4023
- // Typescript types
4024
- 'string',
4025
- 'number',
4026
- 'boolean',
4027
- 'object',
4028
- 'symbol',
4029
- // Common methods on built-in objects
4030
- 'test',
4031
- 'match',
4032
- 'exec',
4033
- 'replace',
4034
- 'search',
4035
- 'split',
4036
- ]);
4037
- try {
4038
- // Note: Extract variables from template literals like ${variable}
4039
- const templateRegex = /\$\{([a-zA-Z_$][a-zA-Z0-9_$]*)\}/g;
4040
- let match;
4041
- while ((match = templateRegex.exec(script)) !== null) {
4042
- const varName = match[1];
4043
- if (!exclude.has(varName)) {
4044
- variables.add(varName);
4045
- }
4046
- }
4047
- // Note: Process the script to handle normal variable usage
4048
- const processedScript = script
4049
- .replace(/'(?:\\.|[^'\\])*'/g, "''") // <- Note: Remove string literals
4050
- .replace(/"(?:\\.|[^"\\])*"/g, '""')
4051
- .replace(/`(?:\\.|[^`\\])*`/g, '``')
4052
- .replace(/\/(?:\\.|[^/\\])*\/[gimsuy]*/g, '{}'); // <- Note: Remove regex literals
4053
- // Note: Find identifiers in function arguments
4054
- const funcArgRegex = /\b([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/g;
4055
- const funcNames = new Set();
4056
- while ((match = funcArgRegex.exec(processedScript)) !== null) {
4057
- funcNames.add(match[1]);
4058
- }
4059
- // Find variable declarations to exclude them
4060
- const declaredVars = new Set();
4061
- const declRegex = /\b(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\b/g;
4062
- while ((match = declRegex.exec(processedScript)) !== null) {
4063
- declaredVars.add(match[2]);
4064
- }
4065
- // Note: Find identifiers in the script
4066
- const identifierRegex = /\b([a-zA-Z_$][a-zA-Z0-9_$]*)\b/g;
4067
- while ((match = identifierRegex.exec(processedScript)) !== null) {
4068
- const name = match[1];
4069
- // Add if not excluded, not a function name, and not a declared variable
4070
- if (!exclude.has(name) && !funcNames.has(name) && !declaredVars.has(name)) {
4071
- variables.add(name);
4072
- }
4073
- }
4074
- }
4075
- catch (error) {
4076
- if (!(error instanceof Error)) {
4077
- throw error;
4078
- }
4079
- throw new ParseError(spaceTrim__default["default"]((block) => `
4080
- Can not extract variables from the script
4081
- ${block(error.stack || error.message)}
4082
-
4083
- Found variables:
4084
- ${Array.from(variables)
4085
- .map((variableName, i) => `${i + 1}) ${variableName}`)
4086
- .join('\n')}
4087
-
4088
-
4089
- The script:
4090
-
4091
- \`\`\`javascript
4092
- ${block(script)}
4093
- \`\`\`
4094
- `));
4095
- }
4096
- return variables;
4097
- }
4098
- /**
4099
- * TODO: [🔣] Support for multiple languages - python, java,...
4100
- */
4101
-
4102
3966
  /**
4103
3967
  * Parses the task and returns the set of all used parameters
4104
3968
  *
@@ -4108,7 +3972,7 @@
4108
3972
  * @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
4109
3973
  */
4110
3974
  function extractParameterNamesFromTask(task) {
4111
- const { title, description, taskType, content, preparedContent, jokerParameterNames, foreach } = task;
3975
+ const { title, description, /* [🙊] taskType,*/ content, preparedContent, jokerParameterNames, foreach } = task;
4112
3976
  const parameterNames = new Set();
4113
3977
  for (const parameterName of [
4114
3978
  ...extractParameterNames(title),
@@ -4118,11 +3982,14 @@
4118
3982
  ]) {
4119
3983
  parameterNames.add(parameterName);
4120
3984
  }
3985
+ /*/
3986
+ // TODO: [🙊] Fix `extractVariablesFromScript` or delete
4121
3987
  if (taskType === 'SCRIPT_TASK') {
4122
3988
  for (const parameterName of extractVariablesFromScript(content)) {
4123
3989
  parameterNames.add(parameterName);
4124
3990
  }
4125
3991
  }
3992
+ /**/
4126
3993
  for (const jokerName of jokerParameterNames || []) {
4127
3994
  parameterNames.add(jokerName);
4128
3995
  }