@promptbook/editable 0.84.0-9 → 0.84.0

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 (43) hide show
  1. package/README.md +21 -9
  2. package/esm/index.es.js +56 -6
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/cli.index.d.ts +4 -0
  5. package/esm/typings/src/_packages/core.index.d.ts +12 -2
  6. package/esm/typings/src/_packages/deepseek.index.d.ts +8 -0
  7. package/esm/typings/src/_packages/types.index.d.ts +2 -0
  8. package/esm/typings/src/_packages/utils.index.d.ts +2 -0
  9. package/esm/typings/src/_packages/wizzard.index.d.ts +4 -0
  10. package/esm/typings/src/cli/cli-commands/about.d.ts +4 -1
  11. package/esm/typings/src/cli/cli-commands/hello.d.ts +3 -1
  12. package/esm/typings/src/cli/cli-commands/list-models.d.ts +3 -1
  13. package/esm/typings/src/cli/cli-commands/list-scrapers.d.ts +13 -0
  14. package/esm/typings/src/cli/cli-commands/make.d.ts +3 -1
  15. package/esm/typings/src/cli/cli-commands/prettify.d.ts +3 -1
  16. package/esm/typings/src/cli/cli-commands/run.d.ts +3 -1
  17. package/esm/typings/src/cli/cli-commands/runInteractiveChatbot.d.ts +1 -1
  18. package/esm/typings/src/cli/cli-commands/test-command.d.ts +3 -1
  19. package/esm/typings/src/config.d.ts +27 -1
  20. package/esm/typings/src/conversion/compilePipelineOnRemoteServer.d.ts +1 -1
  21. package/esm/typings/src/execution/FilesystemTools.d.ts +1 -1
  22. package/esm/typings/src/execution/assertsExecutionSuccessful.d.ts +3 -1
  23. package/esm/typings/src/llm-providers/_common/register/$registeredLlmToolsMessage.d.ts +9 -0
  24. package/esm/typings/src/llm-providers/deepseek/DeepseekExecutionToolsOptions.d.ts +9 -0
  25. package/esm/typings/src/llm-providers/deepseek/createDeepseekExecutionTools.d.ts +14 -0
  26. package/esm/typings/src/llm-providers/deepseek/register-configuration.d.ts +14 -0
  27. package/esm/typings/src/llm-providers/deepseek/register-constructor.d.ts +15 -0
  28. package/esm/typings/src/pipeline/book-notation.d.ts +3 -2
  29. package/esm/typings/src/pipeline/prompt-notation.d.ts +18 -5
  30. package/esm/typings/src/prepare/preparePipelineOnRemoteServer.d.ts +1 -1
  31. package/esm/typings/src/remote-server/socket-types/_subtypes/PromptbookServer_Identification.d.ts +5 -2
  32. package/esm/typings/src/utils/editable/edit-pipeline-string/deflatePipeline.test.d.ts +1 -0
  33. package/esm/typings/src/utils/editable/utils/isFlatPipeline.test.d.ts +1 -0
  34. package/esm/typings/src/utils/environment/$isRunningInBrowser.d.ts +3 -0
  35. package/esm/typings/src/utils/environment/$isRunningInJest.d.ts +3 -0
  36. package/esm/typings/src/utils/environment/$isRunningInNode.d.ts +3 -0
  37. package/esm/typings/src/utils/environment/$isRunningInWebWorker.d.ts +3 -0
  38. package/esm/typings/src/utils/files/mimeTypeToExtension.d.ts +10 -0
  39. package/esm/typings/src/utils/files/mimeTypeToExtension.test.d.ts +1 -0
  40. package/esm/typings/src/wizzard/wizzard.d.ts +7 -1
  41. package/package.json +9 -16
  42. package/umd/index.umd.js +56 -6
  43. package/umd/index.umd.js.map +1 -1
package/umd/index.umd.js CHANGED
@@ -23,7 +23,7 @@
23
23
  * @generated
24
24
  * @see https://github.com/webgptorg/promptbook
25
25
  */
26
- var PROMPTBOOK_ENGINE_VERSION = '0.84.0-8';
26
+ var PROMPTBOOK_ENGINE_VERSION = '0.84.0-21';
27
27
  /**
28
28
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
29
29
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -194,6 +194,12 @@
194
194
  * @public exported from `@promptbook/core`
195
195
  */
196
196
  var DEFAULT_BOOK_TITLE = "\u2728 Untitled Book";
197
+ /**
198
+ * When the pipeline is flat and no name of return parameter is provided, this name is used
199
+ *
200
+ * @public exported from `@promptbook/core`
201
+ */
202
+ var DEFAULT_BOOK_OUTPUT_PARAMETER_NAME = 'result';
197
203
  // <- TODO: [🧠] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
198
204
  /**
199
205
  * The maximum number of iterations for a loops
@@ -3874,6 +3880,21 @@
3874
3880
  return null;
3875
3881
  }
3876
3882
 
3883
+ /**
3884
+ * Checks if value is valid email
3885
+ *
3886
+ * @public exported from `@promptbook/utils`
3887
+ */
3888
+ function isValidEmail(email) {
3889
+ if (typeof email !== 'string') {
3890
+ return false;
3891
+ }
3892
+ if (email.split('\n').length > 1) {
3893
+ return false;
3894
+ }
3895
+ return /^.+@.+\..+$/.test(email);
3896
+ }
3897
+
3877
3898
  /**
3878
3899
  * Function `validatePipelineString` will validate the if the string is a valid pipeline string
3879
3900
  * It does not check if the string is fully logically correct, but if it is a string that can be a pipeline string or the string looks completely different.
@@ -3887,6 +3908,15 @@
3887
3908
  if (isValidJsonString(pipelineString)) {
3888
3909
  throw new ParseError('Expected a book, but got a JSON string');
3889
3910
  }
3911
+ else if (isValidUrl(pipelineString)) {
3912
+ throw new ParseError("Expected a book, but got just the URL \"".concat(pipelineString, "\""));
3913
+ }
3914
+ else if (isValidFilePath(pipelineString)) {
3915
+ throw new ParseError("Expected a book, but got just the file path \"".concat(pipelineString, "\""));
3916
+ }
3917
+ else if (isValidEmail(pipelineString)) {
3918
+ throw new ParseError("Expected a book, but got just the email \"".concat(pipelineString, "\""));
3919
+ }
3890
3920
  // <- TODO: Implement the validation + add tests when the pipeline logic considered as invalid
3891
3921
  return pipelineString;
3892
3922
  }
@@ -3914,12 +3944,15 @@
3914
3944
  pipelineString = removeMarkdownComments(pipelineString);
3915
3945
  pipelineString = spaceTrim__default["default"](pipelineString);
3916
3946
  var isMarkdownBeginningWithHeadline = pipelineString.startsWith('# ');
3917
- var isLastLineReturnStatement = pipelineString.split('\n').pop().split('`').join('').startsWith('->');
3918
- // TODO: Also (double)check
3947
+ //const isLastLineReturnStatement = pipelineString.split('\n').pop()!.split('`').join('').startsWith('->');
3948
+ var isBacktickBlockUsed = pipelineString.includes('```');
3949
+ var isQuoteBlocksUsed = /^>\s+/m.test(pipelineString);
3950
+ var isBlocksUsed = isBacktickBlockUsed || isQuoteBlocksUsed;
3951
+ // TODO: [🧉] Also (double)check
3919
3952
  // > const usedCommands
3920
3953
  // > const isBlocksUsed
3921
3954
  // > const returnStatementCount
3922
- var isFlat = !isMarkdownBeginningWithHeadline && isLastLineReturnStatement;
3955
+ var isFlat = !isMarkdownBeginningWithHeadline && !isBlocksUsed; /* && isLastLineReturnStatement */
3923
3956
  return isFlat;
3924
3957
  }
3925
3958
 
@@ -3933,9 +3966,26 @@
3933
3966
  return pipelineString;
3934
3967
  }
3935
3968
  var pipelineStringLines = pipelineString.split('\n');
3936
- var returnStatement = pipelineStringLines.pop();
3969
+ var potentialReturnStatement = pipelineStringLines.pop();
3970
+ var returnStatement;
3971
+ if (/(-|=)>\s*\{.*\}/.test(potentialReturnStatement)) {
3972
+ // Note: Last line is return statement
3973
+ returnStatement = potentialReturnStatement;
3974
+ }
3975
+ else {
3976
+ // Note: Last line is not a return statement
3977
+ returnStatement = "-> {".concat(DEFAULT_BOOK_OUTPUT_PARAMETER_NAME, "}");
3978
+ pipelineStringLines.push(potentialReturnStatement);
3979
+ }
3937
3980
  var prompt = spaceTrim__default["default"](pipelineStringLines.join('\n'));
3938
- pipelineString = validatePipelineString(spaceTrim__default["default"](function (block) { return "\n # ".concat(DEFAULT_BOOK_TITLE, "\n\n ## Prompt\n\n ```\n ").concat(block(prompt), "\n ```\n\n ").concat(returnStatement, "\n "); }));
3981
+ var quotedPrompt;
3982
+ if (prompt.split('\n').length <= 1) {
3983
+ quotedPrompt = "> ".concat(prompt);
3984
+ }
3985
+ else {
3986
+ quotedPrompt = spaceTrim__default["default"](function (block) { return "\n ```\n ".concat(block(prompt.split('`').join('\\`')), "\n ```\n "); });
3987
+ }
3988
+ pipelineString = validatePipelineString(spaceTrim__default["default"](function (block) { return "\n # ".concat(DEFAULT_BOOK_TITLE, "\n\n ## Prompt\n\n ").concat(block(quotedPrompt), "\n\n ").concat(returnStatement, "\n "); }));
3939
3989
  // <- TODO: Maybe use book` notation
3940
3990
  return pipelineString;
3941
3991
  }