@promptbook/wizard 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
@@ -38,7 +38,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
38
38
  * @generated
39
39
  * @see https://github.com/webgptorg/promptbook
40
40
  */
41
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-29';
41
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-31';
42
42
  /**
43
43
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
44
44
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -23143,7 +23143,11 @@ class UseCommitmentDefinition extends BaseCommitmentDefinition {
23143
23143
  *
23144
23144
  * @private internal constant for `aggregateUseCommitmentSystemMessages`
23145
23145
  */
23146
- const AGGREGATED_USE_COMMITMENT_TYPES = ['USE BROWSER', 'USE SEARCH ENGINE', 'USE TIME'];
23146
+ const AGGREGATED_USE_COMMITMENT_TYPES = [
23147
+ 'USE BROWSER',
23148
+ 'USE SEARCH ENGINE',
23149
+ 'USE TIME',
23150
+ ];
23147
23151
  /**
23148
23152
  * Prefix used for temporary in-system-message placeholders that preserve the first-occurrence position of aggregated `USE` sections.
23149
23153
  *
@@ -38972,6 +38976,7 @@ class SelfLearningManager {
38972
38976
 
38973
38977
  - Decide what the agent should learn from this interaction.
38974
38978
  - Append new commitments at the end of the agent source.
38979
+ - Return only newly learned commitments, never repeat commitments that are already present.
38975
38980
  - Do not modify the current agent source, just return new commitments (KNOWLEDGE, RULE, etc.).
38976
38981
  - If there is nothing new to learn, return empty book code block
38977
38982
  - Wrap the commitments in a book code block.
@@ -39024,10 +39029,42 @@ class SelfLearningManager {
39024
39029
  */
39025
39030
  appendToAgentSource(section) {
39026
39031
  const currentSource = this.options.getAgentSource();
39027
- const newSource = padBook(validateBook(spaceTrim$1(currentSource) + section));
39032
+ const normalizedSection = normalizeBookSection(section);
39033
+ if (!normalizedSection) {
39034
+ return;
39035
+ }
39036
+ if (containsNormalizedBookSection(currentSource, normalizedSection)) {
39037
+ return;
39038
+ }
39039
+ const newSource = padBook(validateBook(`${normalizeBookSection(currentSource)}\n\n${normalizedSection}`));
39028
39040
  this.options.updateAgentSource(newSource);
39029
39041
  }
39030
39042
  }
39043
+ /**
39044
+ * Normalizes one book fragment for deduplication and append composition.
39045
+ *
39046
+ * @param section Raw fragment from self-learning workflow.
39047
+ * @returns Trimmed fragment, or empty string when nothing remains.
39048
+ * @private function of Agent
39049
+ */
39050
+ function normalizeBookSection(section) {
39051
+ return spaceTrim$1(section).replace(/\r\n/g, '\n');
39052
+ }
39053
+ /**
39054
+ * Checks whether one normalized fragment already exists inside the current source.
39055
+ *
39056
+ * @param agentSource Current source.
39057
+ * @param normalizedSection Candidate fragment expected to be normalized first.
39058
+ * @returns True when appending would duplicate an existing fragment.
39059
+ * @private function of Agent
39060
+ */
39061
+ function containsNormalizedBookSection(agentSource, normalizedSection) {
39062
+ if (!normalizedSection) {
39063
+ return true;
39064
+ }
39065
+ const normalizedSource = normalizeBookSection(agentSource);
39066
+ return normalizedSource.includes(normalizedSection);
39067
+ }
39031
39068
  /**
39032
39069
  * Determines whether the interaction runs in OpenAI-compatible JSON schema mode.
39033
39070
  *