@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.
package/esm/index.es.js CHANGED
@@ -19,7 +19,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
19
19
  * @generated
20
20
  * @see https://github.com/webgptorg/promptbook
21
21
  */
22
- const PROMPTBOOK_ENGINE_VERSION = '0.104.0-18';
22
+ const PROMPTBOOK_ENGINE_VERSION = '0.104.0-19';
23
23
  /**
24
24
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
25
25
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -2208,9 +2208,10 @@ function isValidFilePath(filename) {
2208
2208
  *
2209
2209
  * Note: [🔂] This function is idempotent.
2210
2210
  * Note: Dataurl are considered perfectly valid.
2211
- * Note: There are two similar functions:
2212
- * - `isValidUrl` which tests any URL
2213
- * - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
2211
+ * Note: There are few similar functions:
2212
+ * - `isValidUrl` *(this one)* which tests any URL
2213
+ * - `isValidAgentUrl` which tests just agent URL
2214
+ * - `isValidPipelineUrl` which tests just pipeline URL
2214
2215
  *
2215
2216
  * @public exported from `@promptbook/utils`
2216
2217
  */
@@ -2620,6 +2621,39 @@ function titleToName(value) {
2620
2621
  * Note: [💞] Ignore a discrepancy between file name and entity name
2621
2622
  */
2622
2623
 
2624
+ /**
2625
+ * Tests if given string is valid agent URL
2626
+ *
2627
+ * Note: There are few similar functions:
2628
+ * - `isValidUrl` which tests any URL
2629
+ * - `isValidAgentUrl` *(this one)* which tests just agent URL
2630
+ * - `isValidPipelineUrl` which tests just pipeline URL
2631
+ *
2632
+ * @public exported from `@promptbook/utils`
2633
+ */
2634
+ function isValidAgentUrl(url) {
2635
+ if (!isValidUrl(url)) {
2636
+ return false;
2637
+ }
2638
+ if (!url.startsWith('https://') && !url.startsWith('http://') /* <- Note: [👣] */) {
2639
+ return false;
2640
+ }
2641
+ if (url.includes('#')) {
2642
+ // TODO: [🐠]
2643
+ return false;
2644
+ }
2645
+ /*
2646
+ Note: [👣][🧠] Is it secure to allow pipeline URLs on private and unsecured networks?
2647
+ if (isUrlOnPrivateNetwork(url)) {
2648
+ return false;
2649
+ }
2650
+ */
2651
+ return true;
2652
+ }
2653
+ /**
2654
+ * TODO: [🐠] Maybe more info why the URL is invalid
2655
+ */
2656
+
2623
2657
  /**
2624
2658
  * Normalizes agent name from arbitrary string to valid agent name
2625
2659
  *
@@ -3336,21 +3370,36 @@ class FromCommitmentDefinition extends BaseCommitmentDefinition {
3336
3370
  applyToAgentModelRequirements(requirements, content) {
3337
3371
  const trimmedContent = content.trim();
3338
3372
  if (!trimmedContent) {
3339
- return requirements;
3373
+ return {
3374
+ ...requirements,
3375
+ parentAgentUrl: undefined,
3376
+ };
3340
3377
  }
3341
- // Validate URL
3342
- try {
3343
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
3344
- const url = new URL(trimmedContent);
3345
- // TODO: Add more validation if needed (e.g. check for valid protocol)
3378
+ if (trimmedContent.toUpperCase() === 'VOID' ||
3379
+ trimmedContent.toUpperCase() === 'NULL' ||
3380
+ trimmedContent.toUpperCase() === 'NONE' ||
3381
+ trimmedContent.toUpperCase() === 'NIL') {
3382
+ return {
3383
+ ...requirements,
3384
+ parentAgentUrl: null,
3385
+ };
3346
3386
  }
3347
- catch (error) {
3348
- console.warn(`Invalid URL in FROM commitment: ${trimmedContent}`);
3349
- return requirements;
3387
+ if (!isValidAgentUrl(trimmedContent)) {
3388
+ throw new Error(spaceTrim$1((block) => `
3389
+ Invalid agent URL in FROM commitment: "${trimmedContent}"
3390
+
3391
+ \`\`\`book
3392
+ ${block(content)}
3393
+ \`\`\`
3394
+
3395
+
3396
+ `));
3350
3397
  }
3398
+ const parentAgentUrl = trimmedContent;
3399
+ console.log('!!!! parentAgentUrl', parentAgentUrl);
3351
3400
  return {
3352
3401
  ...requirements,
3353
- parentAgentUrl: trimmedContent,
3402
+ parentAgentUrl,
3354
3403
  };
3355
3404
  }
3356
3405
  }