@promptbook/browser 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/browser",
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,
@@ -97,7 +97,7 @@
97
97
  "module": "./esm/index.es.js",
98
98
  "typings": "./esm/typings/src/_packages/browser.index.d.ts",
99
99
  "peerDependencies": {
100
- "@promptbook/core": "0.112.0-29"
100
+ "@promptbook/core": "0.112.0-31"
101
101
  },
102
102
  "dependencies": {
103
103
  "@openai/agents": "0.4.12",
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
@@ -10689,7 +10689,11 @@
10689
10689
  *
10690
10690
  * @private internal constant for `aggregateUseCommitmentSystemMessages`
10691
10691
  */
10692
- const AGGREGATED_USE_COMMITMENT_TYPES = ['USE BROWSER', 'USE SEARCH ENGINE', 'USE TIME'];
10692
+ const AGGREGATED_USE_COMMITMENT_TYPES = [
10693
+ 'USE BROWSER',
10694
+ 'USE SEARCH ENGINE',
10695
+ 'USE TIME',
10696
+ ];
10693
10697
  /**
10694
10698
  * Prefix used for temporary in-system-message placeholders that preserve the first-occurrence position of aggregated `USE` sections.
10695
10699
  *
@@ -28657,6 +28661,7 @@
28657
28661
 
28658
28662
  - Decide what the agent should learn from this interaction.
28659
28663
  - Append new commitments at the end of the agent source.
28664
+ - Return only newly learned commitments, never repeat commitments that are already present.
28660
28665
  - Do not modify the current agent source, just return new commitments (KNOWLEDGE, RULE, etc.).
28661
28666
  - If there is nothing new to learn, return empty book code block
28662
28667
  - Wrap the commitments in a book code block.
@@ -28709,10 +28714,42 @@
28709
28714
  */
28710
28715
  appendToAgentSource(section) {
28711
28716
  const currentSource = this.options.getAgentSource();
28712
- const newSource = padBook(validateBook(spacetrim.spaceTrim(currentSource) + section));
28717
+ const normalizedSection = normalizeBookSection(section);
28718
+ if (!normalizedSection) {
28719
+ return;
28720
+ }
28721
+ if (containsNormalizedBookSection(currentSource, normalizedSection)) {
28722
+ return;
28723
+ }
28724
+ const newSource = padBook(validateBook(`${normalizeBookSection(currentSource)}\n\n${normalizedSection}`));
28713
28725
  this.options.updateAgentSource(newSource);
28714
28726
  }
28715
28727
  }
28728
+ /**
28729
+ * Normalizes one book fragment for deduplication and append composition.
28730
+ *
28731
+ * @param section Raw fragment from self-learning workflow.
28732
+ * @returns Trimmed fragment, or empty string when nothing remains.
28733
+ * @private function of Agent
28734
+ */
28735
+ function normalizeBookSection(section) {
28736
+ return spacetrim.spaceTrim(section).replace(/\r\n/g, '\n');
28737
+ }
28738
+ /**
28739
+ * Checks whether one normalized fragment already exists inside the current source.
28740
+ *
28741
+ * @param agentSource Current source.
28742
+ * @param normalizedSection Candidate fragment expected to be normalized first.
28743
+ * @returns True when appending would duplicate an existing fragment.
28744
+ * @private function of Agent
28745
+ */
28746
+ function containsNormalizedBookSection(agentSource, normalizedSection) {
28747
+ if (!normalizedSection) {
28748
+ return true;
28749
+ }
28750
+ const normalizedSource = normalizeBookSection(agentSource);
28751
+ return normalizedSource.includes(normalizedSection);
28752
+ }
28716
28753
  /**
28717
28754
  * Determines whether the interaction runs in OpenAI-compatible JSON schema mode.
28718
28755
  *