@promptbook/remote-client 0.100.1 → 0.100.2

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.
package/esm/index.es.js CHANGED
@@ -20,7 +20,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
20
20
  * @generated
21
21
  * @see https://github.com/webgptorg/promptbook
22
22
  */
23
- const PROMPTBOOK_ENGINE_VERSION = '0.100.1';
23
+ const PROMPTBOOK_ENGINE_VERSION = '0.100.2';
24
24
  /**
25
25
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
26
26
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -707,7 +707,7 @@ const SectionTypes = [
707
707
  ];
708
708
 
709
709
  /**
710
- * Tests if given string is valid URL.
710
+ * Tests if given string is valid file path.
711
711
  *
712
712
  * Note: This does not check if the file exists only if the path is valid
713
713
  * @public exported from `@promptbook/utils`
@@ -719,18 +719,25 @@ function isValidFilePath(filename) {
719
719
  if (filename.split('\n').length > 1) {
720
720
  return false;
721
721
  }
722
- if (filename.split(' ').length >
723
- 5 /* <- TODO: [🧠][🈷] Make some better non-arbitrary way how to distinct filenames from informational texts */) {
722
+ // Normalize slashes early so heuristics can detect path-like inputs
723
+ const filenameSlashes = filename.replace(/\\/g, '/');
724
+ // Reject strings that look like sentences (informational text)
725
+ // Heuristic: contains multiple spaces and ends with a period, or contains typical sentence punctuation
726
+ // But skip this heuristic if the string looks like a path (contains '/' or starts with a drive letter)
727
+ if (filename.trim().length > 60 && // long enough to be a sentence
728
+ /[.!?]/.test(filename) && // contains sentence punctuation
729
+ filename.split(' ').length > 8 && // has many words
730
+ !/\/|^[A-Z]:/i.test(filenameSlashes) // do NOT treat as sentence if looks like a path
731
+ ) {
724
732
  return false;
725
733
  }
726
- const filenameSlashes = filename.split('\\').join('/');
727
734
  // Absolute Unix path: /hello.txt
728
735
  if (/^(\/)/i.test(filenameSlashes)) {
729
736
  // console.log(filename, 'Absolute Unix path: /hello.txt');
730
737
  return true;
731
738
  }
732
- // Absolute Windows path: /hello.txt
733
- if (/^([A-Z]{1,2}:\/?)\//i.test(filenameSlashes)) {
739
+ // Absolute Windows path: C:/ or C:\ (allow spaces and multiple dots in filename)
740
+ if (/^[A-Z]:\/.+$/i.test(filenameSlashes)) {
734
741
  // console.log(filename, 'Absolute Windows path: /hello.txt');
735
742
  return true;
736
743
  }