@promptbook/core 0.112.0-29 → 0.112.0-31

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.
@@ -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.112.0-26`).
18
+ * It follows semantic versioning (e.g., `0.112.0-30`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/core",
3
- "version": "0.112.0-29",
3
+ "version": "0.112.0-31",
4
4
  "description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
5
5
  "private": false,
6
6
  "sideEffects": false,
package/umd/index.umd.js CHANGED
@@ -27,7 +27,7 @@
27
27
  * @generated
28
28
  * @see https://github.com/webgptorg/promptbook
29
29
  */
30
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-29';
30
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-31';
31
31
  /**
32
32
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
33
33
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -15463,7 +15463,11 @@
15463
15463
  *
15464
15464
  * @private internal constant for `aggregateUseCommitmentSystemMessages`
15465
15465
  */
15466
- const AGGREGATED_USE_COMMITMENT_TYPES = ['USE BROWSER', 'USE SEARCH ENGINE', 'USE TIME'];
15466
+ const AGGREGATED_USE_COMMITMENT_TYPES = [
15467
+ 'USE BROWSER',
15468
+ 'USE SEARCH ENGINE',
15469
+ 'USE TIME',
15470
+ ];
15467
15471
  /**
15468
15472
  * Prefix used for temporary in-system-message placeholders that preserve the first-occurrence position of aggregated `USE` sections.
15469
15473
  *
@@ -33696,6 +33700,7 @@
33696
33700
 
33697
33701
  - Decide what the agent should learn from this interaction.
33698
33702
  - Append new commitments at the end of the agent source.
33703
+ - Return only newly learned commitments, never repeat commitments that are already present.
33699
33704
  - Do not modify the current agent source, just return new commitments (KNOWLEDGE, RULE, etc.).
33700
33705
  - If there is nothing new to learn, return empty book code block
33701
33706
  - Wrap the commitments in a book code block.
@@ -33748,10 +33753,42 @@
33748
33753
  */
33749
33754
  appendToAgentSource(section) {
33750
33755
  const currentSource = this.options.getAgentSource();
33751
- const newSource = padBook(validateBook(spacetrim.spaceTrim(currentSource) + section));
33756
+ const normalizedSection = normalizeBookSection(section);
33757
+ if (!normalizedSection) {
33758
+ return;
33759
+ }
33760
+ if (containsNormalizedBookSection(currentSource, normalizedSection)) {
33761
+ return;
33762
+ }
33763
+ const newSource = padBook(validateBook(`${normalizeBookSection(currentSource)}\n\n${normalizedSection}`));
33752
33764
  this.options.updateAgentSource(newSource);
33753
33765
  }
33754
33766
  }
33767
+ /**
33768
+ * Normalizes one book fragment for deduplication and append composition.
33769
+ *
33770
+ * @param section Raw fragment from self-learning workflow.
33771
+ * @returns Trimmed fragment, or empty string when nothing remains.
33772
+ * @private function of Agent
33773
+ */
33774
+ function normalizeBookSection(section) {
33775
+ return spacetrim.spaceTrim(section).replace(/\r\n/g, '\n');
33776
+ }
33777
+ /**
33778
+ * Checks whether one normalized fragment already exists inside the current source.
33779
+ *
33780
+ * @param agentSource Current source.
33781
+ * @param normalizedSection Candidate fragment expected to be normalized first.
33782
+ * @returns True when appending would duplicate an existing fragment.
33783
+ * @private function of Agent
33784
+ */
33785
+ function containsNormalizedBookSection(agentSource, normalizedSection) {
33786
+ if (!normalizedSection) {
33787
+ return true;
33788
+ }
33789
+ const normalizedSource = normalizeBookSection(agentSource);
33790
+ return normalizedSource.includes(normalizedSection);
33791
+ }
33755
33792
  /**
33756
33793
  * Determines whether the interaction runs in OpenAI-compatible JSON schema mode.
33757
33794
  *