@promptbook/browser 0.104.0-18 → 0.104.0-19

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.
@@ -3,8 +3,9 @@ import type { really_unknown } from '../../organization/really_unknown';
3
3
  /**
4
4
  * Tests if given string is valid pipeline URL URL.
5
5
  *
6
- * Note: There are two similar functions:
6
+ * Note: There are few similar functions:
7
7
  * - `isValidUrl` which tests any URL
8
+ * - `isValidAgentUrl` which tests just agent URL
8
9
  * - `isValidPipelineUrl` *(this one)* which tests just pipeline URL
9
10
  *
10
11
  * @public exported from `@promptbook/utils`
@@ -5,9 +5,10 @@ import type { really_unknown } from '../../organization/really_unknown';
5
5
  *
6
6
  * Note: [🔂] This function is idempotent.
7
7
  * Note: Dataurl are considered perfectly valid.
8
- * Note: There are two similar functions:
9
- * - `isValidUrl` which tests any URL
10
- * - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
8
+ * Note: There are few similar functions:
9
+ * - `isValidUrl` *(this one)* which tests any URL
10
+ * - `isValidAgentUrl` which tests just agent URL
11
+ * - `isValidPipelineUrl` which tests just pipeline URL
11
12
  *
12
13
  * @public exported from `@promptbook/utils`
13
14
  */
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
15
15
  export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
16
16
  /**
17
17
  * Represents the version string of the Promptbook engine.
18
- * It follows semantic versioning (e.g., `0.104.0-17`).
18
+ * It follows semantic versioning (e.g., `0.104.0-18`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/browser",
3
- "version": "0.104.0-18",
3
+ "version": "0.104.0-19",
4
4
  "description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -94,7 +94,7 @@
94
94
  "module": "./esm/index.es.js",
95
95
  "typings": "./esm/typings/src/_packages/browser.index.d.ts",
96
96
  "peerDependencies": {
97
- "@promptbook/core": "0.104.0-18"
97
+ "@promptbook/core": "0.104.0-19"
98
98
  },
99
99
  "dependencies": {
100
100
  "crypto": "1.0.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
- const PROMPTBOOK_ENGINE_VERSION = '0.104.0-18';
26
+ const PROMPTBOOK_ENGINE_VERSION = '0.104.0-19';
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
@@ -2212,9 +2212,10 @@
2212
2212
  *
2213
2213
  * Note: [🔂] This function is idempotent.
2214
2214
  * Note: Dataurl are considered perfectly valid.
2215
- * Note: There are two similar functions:
2216
- * - `isValidUrl` which tests any URL
2217
- * - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
2215
+ * Note: There are few similar functions:
2216
+ * - `isValidUrl` *(this one)* which tests any URL
2217
+ * - `isValidAgentUrl` which tests just agent URL
2218
+ * - `isValidPipelineUrl` which tests just pipeline URL
2218
2219
  *
2219
2220
  * @public exported from `@promptbook/utils`
2220
2221
  */
@@ -2624,6 +2625,39 @@
2624
2625
  * Note: [💞] Ignore a discrepancy between file name and entity name
2625
2626
  */
2626
2627
 
2628
+ /**
2629
+ * Tests if given string is valid agent URL
2630
+ *
2631
+ * Note: There are few similar functions:
2632
+ * - `isValidUrl` which tests any URL
2633
+ * - `isValidAgentUrl` *(this one)* which tests just agent URL
2634
+ * - `isValidPipelineUrl` which tests just pipeline URL
2635
+ *
2636
+ * @public exported from `@promptbook/utils`
2637
+ */
2638
+ function isValidAgentUrl(url) {
2639
+ if (!isValidUrl(url)) {
2640
+ return false;
2641
+ }
2642
+ if (!url.startsWith('https://') && !url.startsWith('http://') /* <- Note: [👣] */) {
2643
+ return false;
2644
+ }
2645
+ if (url.includes('#')) {
2646
+ // TODO: [🐠]
2647
+ return false;
2648
+ }
2649
+ /*
2650
+ Note: [👣][🧠] Is it secure to allow pipeline URLs on private and unsecured networks?
2651
+ if (isUrlOnPrivateNetwork(url)) {
2652
+ return false;
2653
+ }
2654
+ */
2655
+ return true;
2656
+ }
2657
+ /**
2658
+ * TODO: [🐠] Maybe more info why the URL is invalid
2659
+ */
2660
+
2627
2661
  /**
2628
2662
  * Normalizes agent name from arbitrary string to valid agent name
2629
2663
  *
@@ -3340,21 +3374,36 @@
3340
3374
  applyToAgentModelRequirements(requirements, content) {
3341
3375
  const trimmedContent = content.trim();
3342
3376
  if (!trimmedContent) {
3343
- return requirements;
3377
+ return {
3378
+ ...requirements,
3379
+ parentAgentUrl: undefined,
3380
+ };
3344
3381
  }
3345
- // Validate URL
3346
- try {
3347
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
3348
- const url = new URL(trimmedContent);
3349
- // TODO: Add more validation if needed (e.g. check for valid protocol)
3382
+ if (trimmedContent.toUpperCase() === 'VOID' ||
3383
+ trimmedContent.toUpperCase() === 'NULL' ||
3384
+ trimmedContent.toUpperCase() === 'NONE' ||
3385
+ trimmedContent.toUpperCase() === 'NIL') {
3386
+ return {
3387
+ ...requirements,
3388
+ parentAgentUrl: null,
3389
+ };
3350
3390
  }
3351
- catch (error) {
3352
- console.warn(`Invalid URL in FROM commitment: ${trimmedContent}`);
3353
- return requirements;
3391
+ if (!isValidAgentUrl(trimmedContent)) {
3392
+ throw new Error(spaceTrim$1.spaceTrim((block) => `
3393
+ Invalid agent URL in FROM commitment: "${trimmedContent}"
3394
+
3395
+ \`\`\`book
3396
+ ${block(content)}
3397
+ \`\`\`
3398
+
3399
+
3400
+ `));
3354
3401
  }
3402
+ const parentAgentUrl = trimmedContent;
3403
+ console.log('!!!! parentAgentUrl', parentAgentUrl);
3355
3404
  return {
3356
3405
  ...requirements,
3357
- parentAgentUrl: trimmedContent,
3406
+ parentAgentUrl,
3358
3407
  };
3359
3408
  }
3360
3409
  }