@promptbook/components 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
@@ -35,7 +35,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
35
35
  * @generated
36
36
  * @see https://github.com/webgptorg/promptbook
37
37
  */
38
- const PROMPTBOOK_ENGINE_VERSION = '0.104.0-18';
38
+ const PROMPTBOOK_ENGINE_VERSION = '0.104.0-19';
39
39
  /**
40
40
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
41
41
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -1898,9 +1898,10 @@ function isValidFilePath(filename) {
1898
1898
  *
1899
1899
  * Note: [🔂] This function is idempotent.
1900
1900
  * Note: Dataurl are considered perfectly valid.
1901
- * Note: There are two similar functions:
1902
- * - `isValidUrl` which tests any URL
1903
- * - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
1901
+ * Note: There are few similar functions:
1902
+ * - `isValidUrl` *(this one)* which tests any URL
1903
+ * - `isValidAgentUrl` which tests just agent URL
1904
+ * - `isValidPipelineUrl` which tests just pipeline URL
1904
1905
  *
1905
1906
  * @public exported from `@promptbook/utils`
1906
1907
  */
@@ -3510,11 +3511,45 @@ function isValidPromptbookVersion(version) {
3510
3511
  return true;
3511
3512
  }
3512
3513
 
3514
+ /**
3515
+ * Tests if given string is valid agent URL
3516
+ *
3517
+ * Note: There are few similar functions:
3518
+ * - `isValidUrl` which tests any URL
3519
+ * - `isValidAgentUrl` *(this one)* which tests just agent URL
3520
+ * - `isValidPipelineUrl` which tests just pipeline URL
3521
+ *
3522
+ * @public exported from `@promptbook/utils`
3523
+ */
3524
+ function isValidAgentUrl(url) {
3525
+ if (!isValidUrl(url)) {
3526
+ return false;
3527
+ }
3528
+ if (!url.startsWith('https://') && !url.startsWith('http://') /* <- Note: [👣] */) {
3529
+ return false;
3530
+ }
3531
+ if (url.includes('#')) {
3532
+ // TODO: [🐠]
3533
+ return false;
3534
+ }
3535
+ /*
3536
+ Note: [👣][🧠] Is it secure to allow pipeline URLs on private and unsecured networks?
3537
+ if (isUrlOnPrivateNetwork(url)) {
3538
+ return false;
3539
+ }
3540
+ */
3541
+ return true;
3542
+ }
3543
+ /**
3544
+ * TODO: [🐠] Maybe more info why the URL is invalid
3545
+ */
3546
+
3513
3547
  /**
3514
3548
  * Tests if given string is valid pipeline URL URL.
3515
3549
  *
3516
- * Note: There are two similar functions:
3550
+ * Note: There are few similar functions:
3517
3551
  * - `isValidUrl` which tests any URL
3552
+ * - `isValidAgentUrl` which tests just agent URL
3518
3553
  * - `isValidPipelineUrl` *(this one)* which tests just pipeline URL
3519
3554
  *
3520
3555
  * @public exported from `@promptbook/utils`
@@ -4275,21 +4310,36 @@ class FromCommitmentDefinition extends BaseCommitmentDefinition {
4275
4310
  applyToAgentModelRequirements(requirements, content) {
4276
4311
  const trimmedContent = content.trim();
4277
4312
  if (!trimmedContent) {
4278
- return requirements;
4313
+ return {
4314
+ ...requirements,
4315
+ parentAgentUrl: undefined,
4316
+ };
4279
4317
  }
4280
- // Validate URL
4281
- try {
4282
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
4283
- const url = new URL(trimmedContent);
4284
- // TODO: Add more validation if needed (e.g. check for valid protocol)
4318
+ if (trimmedContent.toUpperCase() === 'VOID' ||
4319
+ trimmedContent.toUpperCase() === 'NULL' ||
4320
+ trimmedContent.toUpperCase() === 'NONE' ||
4321
+ trimmedContent.toUpperCase() === 'NIL') {
4322
+ return {
4323
+ ...requirements,
4324
+ parentAgentUrl: null,
4325
+ };
4285
4326
  }
4286
- catch (error) {
4287
- console.warn(`Invalid URL in FROM commitment: ${trimmedContent}`);
4288
- return requirements;
4327
+ if (!isValidAgentUrl(trimmedContent)) {
4328
+ throw new Error(spaceTrim$1((block) => `
4329
+ Invalid agent URL in FROM commitment: "${trimmedContent}"
4330
+
4331
+ \`\`\`book
4332
+ ${block(content)}
4333
+ \`\`\`
4334
+
4335
+
4336
+ `));
4289
4337
  }
4338
+ const parentAgentUrl = trimmedContent;
4339
+ console.log('!!!! parentAgentUrl', parentAgentUrl);
4290
4340
  return {
4291
4341
  ...requirements,
4292
- parentAgentUrl: trimmedContent,
4342
+ parentAgentUrl,
4293
4343
  };
4294
4344
  }
4295
4345
  }
@@ -7963,12 +8013,7 @@ const CORE_AGENTS_SERVER = {
7963
8013
  owner: PROMPTBOOK_LEGAL_ENTITY,
7964
8014
  url: 'https://core.ptbk.io/',
7965
8015
  };
7966
- /**
7967
- * @@@@
7968
- *
7969
- * @public exported from `@promptbook/core`
7970
- */
7971
- // !!!! export const CORE_AGENTS_SERVER_ADAM_AGENT_NAME: string_agent_name = 'adam';
8016
+ // <- TODO: [🆎] Allow to override (set) well-known agent names via Metadata
7972
8017
  /**
7973
8018
  * Available agents servers for the Promptbook
7974
8019
  *