@promptbook/cli 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.
package/esm/index.es.js CHANGED
@@ -57,7 +57,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
57
57
  * @generated
58
58
  * @see https://github.com/webgptorg/promptbook
59
59
  */
60
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-29';
60
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-31';
61
61
  /**
62
62
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
63
63
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -21904,7 +21904,11 @@ class UseCommitmentDefinition extends BaseCommitmentDefinition {
21904
21904
  *
21905
21905
  * @private internal constant for `aggregateUseCommitmentSystemMessages`
21906
21906
  */
21907
- const AGGREGATED_USE_COMMITMENT_TYPES = ['USE BROWSER', 'USE SEARCH ENGINE', 'USE TIME'];
21907
+ const AGGREGATED_USE_COMMITMENT_TYPES = [
21908
+ 'USE BROWSER',
21909
+ 'USE SEARCH ENGINE',
21910
+ 'USE TIME',
21911
+ ];
21908
21912
  /**
21909
21913
  * Prefix used for temporary in-system-message placeholders that preserve the first-occurrence position of aggregated `USE` sections.
21910
21914
  *
@@ -47745,6 +47749,7 @@ class SelfLearningManager {
47745
47749
 
47746
47750
  - Decide what the agent should learn from this interaction.
47747
47751
  - Append new commitments at the end of the agent source.
47752
+ - Return only newly learned commitments, never repeat commitments that are already present.
47748
47753
  - Do not modify the current agent source, just return new commitments (KNOWLEDGE, RULE, etc.).
47749
47754
  - If there is nothing new to learn, return empty book code block
47750
47755
  - Wrap the commitments in a book code block.
@@ -47797,10 +47802,42 @@ class SelfLearningManager {
47797
47802
  */
47798
47803
  appendToAgentSource(section) {
47799
47804
  const currentSource = this.options.getAgentSource();
47800
- const newSource = padBook(validateBook(spaceTrim$1(currentSource) + section));
47805
+ const normalizedSection = normalizeBookSection(section);
47806
+ if (!normalizedSection) {
47807
+ return;
47808
+ }
47809
+ if (containsNormalizedBookSection(currentSource, normalizedSection)) {
47810
+ return;
47811
+ }
47812
+ const newSource = padBook(validateBook(`${normalizeBookSection(currentSource)}\n\n${normalizedSection}`));
47801
47813
  this.options.updateAgentSource(newSource);
47802
47814
  }
47803
47815
  }
47816
+ /**
47817
+ * Normalizes one book fragment for deduplication and append composition.
47818
+ *
47819
+ * @param section Raw fragment from self-learning workflow.
47820
+ * @returns Trimmed fragment, or empty string when nothing remains.
47821
+ * @private function of Agent
47822
+ */
47823
+ function normalizeBookSection(section) {
47824
+ return spaceTrim$1(section).replace(/\r\n/g, '\n');
47825
+ }
47826
+ /**
47827
+ * Checks whether one normalized fragment already exists inside the current source.
47828
+ *
47829
+ * @param agentSource Current source.
47830
+ * @param normalizedSection Candidate fragment expected to be normalized first.
47831
+ * @returns True when appending would duplicate an existing fragment.
47832
+ * @private function of Agent
47833
+ */
47834
+ function containsNormalizedBookSection(agentSource, normalizedSection) {
47835
+ if (!normalizedSection) {
47836
+ return true;
47837
+ }
47838
+ const normalizedSource = normalizeBookSection(agentSource);
47839
+ return normalizedSource.includes(normalizedSection);
47840
+ }
47804
47841
  /**
47805
47842
  * Determines whether the interaction runs in OpenAI-compatible JSON schema mode.
47806
47843
  *